You are here

function theme_simple_access_form in Simple Access 6.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \theme_simple_access_form()
  2. 5 simple_access.module \theme_simple_access_form()
  3. 7.2 simple_access.theme.inc \theme_simple_access_form()

@file Provide themes for simple access administration

4 theme calls to theme_simple_access_form()
simple_access_form in ./simple_access.module
simple_access_group_grant_form in ./simple_access.module
Configure grant group permissions
simple_access_group_revoke_form in ./simple_access.module
Configure revoke group permissions
simple_access_profile_form in ./simple_access.admin.inc

File

./simple_access.theme.inc, line 7
Provide themes for simple access administration

Code

function theme_simple_access_form($form) {
  drupal_add_css(drupal_get_path('module', 'simple_access') . '/simple_access.css');
  $output = '';
  if (isset($form['#admin'])) {
    $variable = array(
      'view' => 1,
      'update' => 1,
      'delete' => 1,
    );
  }
  else {
    $variable = variable_get('sa_display', array(
      'view' => 1,
    ));
  }
  $head = array(
    t('Access Group'),
  );
  if (isset($variable['view']) && $variable['view'] || isset($form['#admin'])) {
    $head[] = t('View');
  }
  if (isset($variable['update']) && $variable['update'] || isset($form['#admin'])) {
    $head[] = t('Update');
  }
  if (isset($variable['delete']) && $variable['delete'] || isset($form['#admin'])) {
    $head[] = t('Delete');
  }
  foreach (element_children($form) as $gid) {
    if (!isset($form['#access']) || $form['#access']) {
      $row = array(
        array(
          'data' => drupal_render($form[$gid]['name']),
        ),
      );
      if (isset($variable['view']) && $variable['view'] || isset($form['#admin'])) {
        $row[] = array(
          'data' => drupal_render($form[$gid]['sa_view']),
        );
      }
      if (isset($variable['update']) && $variable['update'] || isset($form['#admin'])) {
        $row[] = array(
          'data' => drupal_render($form[$gid]['sa_update']),
        );
      }
      if (isset($variable['delete']) && $variable['delete'] || isset($form['#admin'])) {
        $row[] = array(
          'data' => drupal_render($form[$gid]['sa_delete']),
        );
      }
      $rows[] = $row;
    }
  }
  if (!empty($rows)) {
    $output .= theme('table', $head, $rows);
    $output .= drupal_render($form);
    return $output;
  }
}