You are here

function shib_auth_list_rules in Shibboleth Authentication 5.3

List the added rule(s)

Return value

Rule list in a HTML table

1 string reference to 'shib_auth_list_rules'
shib_auth_menu in ./shib_auth.module
Generate the menu element to access the Shibboleth authentication module's administration page @returns HTML text of the administer menu element

File

./shib_auth_admin.inc, line 110
Generate the administration form of the Shibboleth authentication module

Code

function shib_auth_list_rules() {
  $header = array(
    array(
      'data' => t('Attribute'),
      'field' => 'field',
    ),
    array(
      'data' => t('RegExp'),
      'field' => 'regexpression',
    ),
    array(
      'data' => t('Role(s)'),
      'field' => 'role',
    ),
    array(
      'data' => t('Actions'),
    ),
  );
  $tablesort_sql = 'SELECT * FROM {shib_auth}' . tablesort_sql($header);
  $rules = db_query($tablesort_sql);
  if (!$rules) {
    return t('There is no rule in the database');
  }
  $row = array();
  while ($rule = db_fetch_array($rules)) {
    $user_roles = user_roles(TRUE);
    $roles = unserialize($rule['role']);
    $roles_list = '';
    if (!empty($roles)) {
      $roles_list = implode(', ', $roles);
    }
    $links = l(t('Clone') . ' ', 'admin/user/shib_auth/rules/Clone/' . $rule['id']);
    $links .= l(t('Edit') . ' ', 'admin/user/shib_auth/rules/Edit/' . $rule['id']);
    $links .= l(t('Delete') . ' ', 'admin/user/shib_auth/rules/Delete/' . $rule['id']);
    $row[] = array(
      $rule['field'],
      $rule['regexpression'],
      $roles_list,
      $links,
    );
  }
  return theme_table($header, $row);
}