Wray Bowling
Wray Bowling

Reputation: 2506

Drupal module's list of permissions are stuck

From what I understand, my problem is that I am (rather, my client is) running an older version of Drupal, specifically Core 6.26 If you're curious about any additional specs, I'll be happy to divulge.

With that out of the way, I made a new module with the following menu hook.

function checkin_menu(){
    $items = array();
    $items['checkin'] = array(
        'title' => 'Checkin'
        ,'type' => MENU_CALLBACK
        ,'access arguments' => array('checkin')
        ,'page callback' => 'checkin'
    );
}

The permissions listed out exactly what I expected. There was a section called "Checkin" the same as the module's name as specified in the .info file, and one item to give permissions to "checkin"

Later on I expanded the module to have two different paths. The second one is supposed to be for admins only.

function checkin_menu(){
    $items = array();
    $items['checkin'] = array(
        'title' => 'Checkin'
        ,'type' => MENU_CALLBACK
        ,'access arguments' => array('create a checkin')
        ,'page callback' => 'checkin'
    );
    $items['checkin_admin'] = array(
        'title' => 'Checkin Admin'
        ,'type' => MENU_CALLBACK
        ,'access arguments' => array('view all checkins')
        ,'page callback' => 'device_checkin_page'
    );
    return $items;
}

Much to my surprise neither "create a checkin" or "view all checkins" is showing up. I still have the original "checkins" showing on the permissions page. I've been hunting for answers for a couple days now. Help a guy out?

Upvotes: 0

Views: 42

Answers (1)

Max
Max

Reputation: 6791

Permissions are defined by a different hook, which is hook_perm.

So you should be doing something like this:

/**
 * Implementation of the hook_perm()
 */
function checkin_perm() {
  return array (
    'create a checkin',
    'view all checkins',
  );
}

Upvotes: 3

Related Questions