Get all the permissions granted by this module via hook_permission ()

How do I list all the permissions allowed by a given module?

+3


source to share


1 answer


I could simplify the solution, but to get module permissions you only need to execute hook_permissions modules. for example a call to views_permission ()

If you are looking for all the permissions on the system, you can try calling user_permission_get_modules (), which is part of the custom module in the kernel.



/**
 * Determine the modules that permissions belong to.
 *
 * @return
 *   An associative array in the format $permission => $module.
 */
function user_permission_get_modules() {
  $permissions = array();
  foreach (module_implements('permission') as $module) {
    $perms = module_invoke($module, 'permission');
    foreach ($perms as $key => $value) {
      $permissions[$key] = $module;
    }
  }
  return $permissions;
}

      

+3


source







All Articles