0

I am trying to insert a new event inside an already existing module. The module is Nodeaccess https://www.drupal.org/project/nodeaccess it's used to grant users edit/delete permissions to single nodes.

inside sites/all/modules/nodeaccess i have made the file nodeaccess.rules.inc which contains this code:

/**
 * @file
 * Rules integration.
 */

/**
 * Implementation of hook_rules_event_info().
 */
function nodeaccess_rules_event_info() {
    return array(
        'nodeaccess_grant_permissions' => array(
            'label' => t('Permissions are granted to a user'),
            'group'=>t("NodeAccess"),
            'variables' => array(
                'granter' => array('type' => 'user', 'label' => t('The user who granted the permissions.')),
                'granted' => array('type' => 'user', 'label' => t('The user who got the new permissions.')),
                'node' => array('type' => 'node', 'label' => t('The node on which the permission has been granted.')),
            ),
        ),
    );
}

Looking at different guides on the web it looks like this is all you have to do to get a new event but in the events list i can't find it. I have tried:

  • refreshing the cache

  • disabling/enabling nodeaccess module then refreshing the cache (and rebuilding permissions as it was requested)

  • disabling/enabling rules module then refreshing the cache

  • adding the rule entry in a *.rules.inc file i've seen it's being imported (namely the feeds.rules.inc file from the feeds module which already existed when i installed the rules module)

Nothing worked so far

EDIT: i have changed the function name and the entry name (both from "node_access" to "nodeaccess" ) but it's still not showing. I have discovered that if i add an entry on a file i know it's being imported and keep the prefix of the entry, then it shows up

1 Answer 1

0

The problem is the function name. Since the module name is nodeaccess (and not node_access), function name should be nodeaccess_rules_event_info

However, it is not recommended to add anything to a contributed module (unless you are going to contribute back to the module's issue queue).

If this rule is specific your project, you can add it in your own custom module.

4
  • I have changed both the function name and the rule rule name to nodeaccess but it's still not showing, shall i try to disable and enable the module?
    – valepu
    Commented Jul 9, 2014 at 12:21
  • Question just got chamelleoned and your answer is no longer applicable.
    – Mołot
    Commented Jul 9, 2014 at 12:23
  • When i changed the question i have added an edit at the end saying that i have changed the question because of this answer. In other words i have updated the question because of this answer to rule out one problem (since it's still not working)
    – valepu
    Commented Jul 9, 2014 at 12:42
  • Anyways disabling and enabling the module did the job. The answer is partially correct (i had to change both function name and rule name plus i had to toggle the module)
    – valepu
    Commented Jul 9, 2014 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.