Closed (fixed)
Project:
Mollom
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2009 at 23:07 UTC
Updated:
24 Apr 2014 at 17:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gregglesSo, I was able to get this to work by adding a #process handler to the form to set the $form_state['mollom'] value.
I think it would be better to add a hook in mollom_expand_element that allows other modules to provide feedback on whether or not mollom should be used / and how.
Comment #2
gregglesFor anyone else who is in the same position, below is my solution. It prevents mollom from running either CAPTCHA or text analysis on comments on nodes of "api" type.
Comment #3
dries commented@greggles: I haven't tested your code but that is indeed the proper way to do this (thanks to the fact that the Mollom module implements a new form element). I'll keep this snippet in the issue for a while, but then I might migrate it to a documentation page.
Comment #4
sunFor this to happen, we need to implement hook_forms() for comment.module in Drupal core, so that we have a unique $form_id to configure Mollom for.
That would make totally sense. Unfortunately, it's late. Probably too late for D7... :-/
Comment #5
sunAlso taking into account #706180: Fire a hook before Mollom adds its stuff in hook_form_alter(), I think the proper way to do this would be to implement something along the lines of
for Mollom's form processing, and, a hook that allows modules to return whether this mode should be enabled.
If enabled, Mollom would operate as always under the hood, i.e. still communicating with the servers for textual analysis, but wouldn't ever trigger a form validation error.
Comment #6
sunre #4: Opened #757154: Base form_id via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter()
Comment #7
dave reidIf we just make this small change, all a module would need to do is this:
The only thing I can think of is if we start to store results of mollom_form_info() in cache, then this won't work.
The only other thing is you'd need to explicitly check that the user doesn't have the 'administer mollom' permission so this doesn't screw up editing form protections.
Comment #8
dries commentedThis looks good. Can we add your example snippet to mollom.api.php?
Comment #9
pwolanin commentedI've run into a similar problem - but I was thinking it should be something a the form building function can control.
For example, I might build the form differently for anonymous users (need you e-mail + captcha) versus registered users (never need a captcha) - or even more specific. I guess the patch above allows the same logic - but it has to live within this alter hook instead of inside the form building function itself.
Something like this (for Drupal 6):
Comment #10
pwolanin commenteddaviereid helpfully explained what's going on in addition to the context of the patch. Seems reasonable.
The patch applies cleanly with offset to the 6.x-1.13 version too.
Comment #11
pwolanin commentedLooking in more detail at the code - the 'mode' will always be overwritten with the value from the DB.
Comment #12
sun$mollom_form, resp., mollom_form_load() and mollom_form_info() are completely separate and detached operations. Hence, this 'mode' has no effect.
Powered by Dreditor.
Comment #13
dave reidYeah it doesn't work. It would make sense to support a form property of #mollom_mode or something that can be set manually.
Comment #14
sunTest-driven development.
Comment #15
sunIgnore :P
Comment #16
sunThat must have contained a typo somewhere? Or I'd like to know why.
Comment #18
sunThe original post precisely describes the current possibilities within Form API.
For now, there's little point in converting two $form_state properties into one other global property on $form or $form_state. What effectively counts is the module weight.
Comment #19
dries commentedsun's example is clean and elegant. It is more of an example but it doesn't hurt to have an example test as we can point other people to it. Marking this RTBC. Comments from anyone else?
Comment #20
dave reidWay cleaner. +1 from me.
Comment #21
dries commentedCommitted to CVS HEAD.
Comment #22
sunComment #23
sunComment #24
dries commentedLooks good. Same as HEAD. Committed to CVS HEAD. Thanks sun and Dave.
Comment #26
leksat commentedHere is how I disable mollom for comment form of particular content types:
True for D6.
Comment #27
jjesus commented+1 Thanks for this one.