You are here

function _shib_auth_list_rules in Shibboleth Authentication 7.4

Same name and namespace in other branches
  1. 6.4 shib_auth_roles_forms.inc \_shib_auth_list_rules()
  2. 6.3 shib_auth.module \_shib_auth_list_rules()

Lists all rules, and let the admin to do certain actions with them.

@returns HTML table containing the number of rule, attribute, RegExp, role and the actions which can be done with each role.

1 string reference to '_shib_auth_list_rules'
shib_auth_menu in ./shib_auth.module
Implements hook_menu().

File

./shib_auth_roles_forms.inc, line 15
Roles manager forms.

Code

function _shib_auth_list_rules() {
  $rows = array();

  // If the admin is not logged in through shibboleth, role name cache has to be
  // generated.
  shib_auth_generate_rolenames(TRUE);

  // Create rows.
  $rules = db_select('shib_auth', 'role')
    ->fields('role')
    ->execute();
  while ($rule = $rules
    ->fetchAssoc()) {
    $roles = unserialize($rule['role']);
    $roles_list = array();
    foreach ($roles as $role) {
      if (!empty($role)) {
        $roles_list[] = shib_auth_get_rolename($role);
      }
    }
    $sticky = $rule['sticky'] == 1 ? 'Yes' : 'No';
    $rows[] = array(
      $rule['field'],
      urldecode($rule['regexpression']),
      implode(', ', $roles_list),
      $sticky,
      l(t('Clone'), 'admin/config/people/shib_auth/clone/' . $rule['id']) . ' | ' . l(t('Edit'), 'admin/config/people/shib_auth/edit/' . $rule['id']) . ' | ' . l(t('Delete'), 'admin/config/people/shib_auth/delete/' . $rule['id']),
    );
  }

  // Create the rule list in HTML table.
  $attributes = array(
    'class' => array(
      'shib_auth_role_table',
    ),
  );
  $header = array(
    t('Attribute'),
    t('RegExp'),
    t('Roles'),
    t('Sticky'),
    t('Actions'),
  );
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => $attributes,
    'empty' => t('There are no rules in the database.'),
    'sticky' => FALSE,
  ));
  $output .= l(t('Add new rule'), 'admin/config/people/shib_auth/new');
  return $output;
}