You are here

function rb_misc_user_permissions_options_list in Rules Bonus Pack 7

Options list callback for user permissions.

1 string reference to 'rb_misc_user_permissions_options_list'
rb_misc_rules_condition_info in ./rb_misc.rules.inc
Implements hook_rules_condition_info().

File

./rb_misc.rules.inc, line 375
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_user_permissions_options_list($element) {

  // Get a list of all the modules implementing a hook_permission() and sort by
  // display name.
  $modules = $permissions = array();
  $module_info = system_get_info('module');
  foreach (module_implements('permission') as $module) {
    $modules[$module] = $module_info[$module]['name'];
  }
  asort($modules);
  foreach ($modules as $module => $display_name) {
    if ($perms = module_invoke($module, 'permission')) {
      foreach ($perms as $perm => $perm_item) {
        $permissions[$display_name][$perm] = strip_tags($perm_item['title']);
      }
    }
  }
  return $permissions;
}