You are here

function theme_simple_access_form in Simple Access 7.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. 6.2 simple_access.theme.inc \theme_simple_access_form()

Theme simple access form.

4 theme calls to theme_simple_access_form()
simple_access_form in ./simple_access.module
Simple Access form.
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
Simple Access profile form.

File

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

Code

function theme_simple_access_form($variables) {
  $form =& $variables['form'];
  $options = array();
  $output = '';
  if (isset($form['#admin'])) {
    $variable = array(
      'view' => 1,
      'update' => 1,
      'delete' => 1,
    );
  }
  else {
    $variable = variable_get('simple_access_display', array(
      'view' => 1,
    ));
  }
  $options['header'] = array(
    t('Access Group'),
  );
  if (isset($variable['view']) && $variable['view'] || isset($form['#admin'])) {
    $options['header'][] = t('View');
  }
  if (isset($variable['update']) && $variable['update'] || isset($form['#admin'])) {
    $options['header'][] = t('Update');
  }
  if (isset($variable['delete']) && $variable['delete'] || isset($form['#admin'])) {
    $options['header'][] = 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']),
        );
      }
      $options['rows'][] = $row;
    }
  }
  if (!empty($options['rows'])) {
    $output .= theme('table', $options);
    return $output;
  }
}