4

In Drupal 7, it appears that access administration pages is a VALID access argument. Is this the case?
How can I determine all the correct access arguments?

1 Answer 1

5

That permission is defined from system_permission().

The access arguments that an access callback uses can be any value, as any access callback can define its own access arguments in the implementation of hook_menu().
If you are referring to the access arguments accepted from user_access(), which is normally the access callback used from most of the menus defined from Drupal modules, then the access arguments are just the string for the permission the user needs to have to access that menu. The "access administration pages" string is just a possible value, and third-party modules can extend the permissions adding new ones to the ones already defined from Drupal core modules.

To get all the permissions defined from the installed modules, and assigned to one of the roles used in your site, you can use the following snippet (it requires the Devel module):

$cache = array();
$result = db_query("SELECT rid, permission FROM {role_permission}");

foreach ($result as $row) {
  $cache[] = $row->permission;
}

dsm(array_unique($cache));

To get any permission defined from the modules enabled in your site, you can use the following snippet:

$permissions = module_invoke_all('permission');
dsm($permissions);

The difference between the snippets is that the first one can return also the permissions defined from a module that you disabled, as long as the permission has been assigned to a role; the second only returns the permissions defined from currently enabled modules. If you have temporary disabled a module, the second snippet will not return its permissions.

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.