You are here

function simple_access_page_overview in Simple Access 5.2

Same name and namespace in other branches
  1. 5 simple_access.module \simple_access_page_overview()
  2. 6.2 simple_access.admin.inc \simple_access_page_overview()
  3. 7.2 simple_access.admin.inc \simple_access_page_overview()
1 string reference to 'simple_access_page_overview'
simple_access_menu in ./simple_access.module
Implementation of hook_menu().

File

./simple_access.module, line 512
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_page_overview() {
  if (count($groups = simple_access_get_groups())) {
    drupal_set_title(t('Access groups'));
    $roles = user_roles();
    $form['groups'] = array(
      '#tree' => TRUE,
    );
    foreach ($groups as $group) {
      $gid = $group['gid'];
      $form['groups'][$gid]['name'] = array(
        '#value' => $group['name'],
      );
      $r = array();
      foreach ($group['roles'] as $rid) {
        $r[] = $roles[$rid];
      }
      $form['groups'][$gid]['roles'] = array(
        '#value' => implode(', ', $r),
      );
      $form['groups'][$gid]['weight'] = array(
        '#type' => 'weight',
        '#default_value' => $group['weight'],
        '#attributes' => array(
          'class' => 'sa-group-weight',
        ),
      );
      $form['groups'][$gid]['ops'] = array(
        '#value' => l('edit', 'admin/user/simple_access/edit/' . $gid) . ' ' . l('delete', 'admin/user/simple_access/delete/' . $gid),
      );
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update'),
    );
    return $form;
  }
  else {
    drupal_set_message(t('You have not yet defined any access groups.'));
    drupal_goto('admin/user/simple_access/add');
  }
}