When defining a form, you can define custom report access callbacks instead of just using a global user permission. It would be nice if you could do something similar for the bypass access. An example use-case is that I would like to allow OG administrators to bypass mollom access when editing their group content.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jojonaloha’s picture

Status: Active » Needs review
FileSize
1.59 KB

Attached patch adds a check for a 'bypass access callbacks' key in the form info. You can see an example of how I would use this in a sandbox module I'm made to add OG integration: https://drupal.org/node/2283955

Here is the array structure:

$form_info['bypass access callbacks'] = array(
  array(
    'callback' => 'my_function_name', // required
    'args' => array($param1, $param2), // optional, but must be an array of any length
  ),
);

The callback function would look like this:

function my_function_name($form, $param1, $param2) {
  // do stuff
}
eshta’s picture

Status: Needs review » Needs work
+++ b/mollom.module
@@ -808,6 +808,22 @@ function mollom_form_alter(&$form, &$form_state, $form_id) {
+              return;

By returning here the users who would bypass mollom form protection are also missing on the delete/feedback integration that follows after the user_access if block. I don't believe you can equate those two. Looks like Mollom currently does this right below there in the bypass_access permission check and this also seems wrong. Maybe we can fix both at the same time?

I do wonder, however, if the scenario you describe can't be handled with the existing bypass_access permissions array. The idea is interesting though and I can see how it would make things more flexible. We'd need to add documentation to the mollom.api.php file as well a tests to ensure that callbacks are called.