| 1 |
<?php
|
| 2 |
// $Id: simple_access.theme.inc,v 1.4 2009/10/11 00:50:57 gordon Exp $
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Provide themes for simple access administration
|
| 6 |
*/
|
| 7 |
|
| 8 |
function theme_simple_access_form($form) {
|
| 9 |
drupal_add_css(drupal_get_path('module', 'simple_access') . '/simple_access.css');
|
| 10 |
|
| 11 |
$options = array();
|
| 12 |
$output = '';
|
| 13 |
if (isset($form['#admin'])) {
|
| 14 |
$variable = array('view' => 1, 'update' => 1, 'delete' => 1);
|
| 15 |
}
|
| 16 |
else {
|
| 17 |
$variable = variable_get('sa_display', array('view' => 1));
|
| 18 |
}
|
| 19 |
$options['header'] = array(t('Access Group'));
|
| 20 |
if ((isset($variable['view']) && $variable['view']) || isset($form['#admin'])) {
|
| 21 |
$options['header'][] = t('View');
|
| 22 |
}
|
| 23 |
if ((isset($variable['update']) && $variable['update']) || isset($form['#admin'])) {
|
| 24 |
$options['header'][] = t('Update');
|
| 25 |
}
|
| 26 |
if ((isset($variable['delete']) && $variable['delete']) || isset($form['#admin'])) {
|
| 27 |
$options['header'][] = t('Delete');
|
| 28 |
}
|
| 29 |
|
| 30 |
foreach (element_children($form['form']) as $gid) {
|
| 31 |
if (!isset($form['#access']) || $form['#access']) {
|
| 32 |
$row = array(
|
| 33 |
array('data' => drupal_render($form['form'][$gid]['name'])),
|
| 34 |
);
|
| 35 |
if ((isset($variable['view']) && $variable['view']) || isset($form['#admin'])) {
|
| 36 |
$row[] = array(
|
| 37 |
'data' => drupal_render($form['form'][$gid]['sa_view']),
|
| 38 |
);
|
| 39 |
}
|
| 40 |
if ((isset($variable['update']) && $variable['update']) || isset($form['#admin'])) {
|
| 41 |
$row[] = array(
|
| 42 |
'data' => drupal_render($form['form'][$gid]['sa_update']),
|
| 43 |
);
|
| 44 |
}
|
| 45 |
if ((isset($variable['delete']) && $variable['delete']) || isset($form['#admin'])) {
|
| 46 |
$row[] = array(
|
| 47 |
'data' => drupal_render($form['form'][$gid]['sa_delete']),
|
| 48 |
);
|
| 49 |
}
|
| 50 |
|
| 51 |
$options['rows'][] = $row;
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
if (!empty($options['rows'])) {
|
| 56 |
$output .= theme('table', $options);
|
| 57 |
return $output;
|
| 58 |
}
|
| 59 |
}
|
| 60 |
|
| 61 |
function theme_simple_access_page_overview_list(&$form) {
|
| 62 |
drupal_add_tabledrag('sa-group-list', 'order', 'sibling', 'sa-group-weight');
|
| 63 |
$output = '';
|
| 64 |
$options = array(
|
| 65 |
'header' => array(t('Group'), t('Roles'), t('Weight'), t('Operations')),
|
| 66 |
'rows' => array(),
|
| 67 |
'attributes' => array('id' => 'sa-group-list'),
|
| 68 |
);
|
| 69 |
foreach (element_children($form['form'], TRUE) as $gid) {
|
| 70 |
$options['rows'][] = array(
|
| 71 |
'data' => array(
|
| 72 |
drupal_render($form['form'][$gid]['name']),
|
| 73 |
array('data' => drupal_render($form['form'][$gid]['roles']), 'class' => 'sa-group-roles'),
|
| 74 |
drupal_render($form['form'][$gid]['weight']),
|
| 75 |
drupal_render($form['form'][$gid]['ops']),
|
| 76 |
),
|
| 77 |
'class' => array('draggable'),
|
| 78 |
);
|
| 79 |
}
|
| 80 |
|
| 81 |
$output .= theme('table', $options);
|
| 82 |
|
| 83 |
return $output;
|
| 84 |
}
|
| 85 |
|
| 86 |
function theme_simple_access_profile_list($form) {
|
| 87 |
drupal_add_tabledrag('sa-profile-list', 'order', 'sibling', 'sa-profile-weight');
|
| 88 |
$options = array(
|
| 89 |
'header' => array(t('Name'), t('Weight'), t('Operations')),
|
| 90 |
'rows' => array(),
|
| 91 |
'attributes' => array('id' => 'sa-profile-list'),
|
| 92 |
);
|
| 93 |
$output = '';
|
| 94 |
|
| 95 |
foreach (element_children($form['form']['profiles']) as $id) {
|
| 96 |
$options['rows'][] = array(
|
| 97 |
'data' => array(
|
| 98 |
array('data' => drupal_render($form['form']['profiles'][$id]['name'])),
|
| 99 |
array('data' => drupal_render($form['form']['profiles'][$id]['weight'])),
|
| 100 |
array('data' => drupal_render($form['form']['profiles'][$id]['operations'])),
|
| 101 |
),
|
| 102 |
'class' => array('draggable'),
|
| 103 |
);
|
| 104 |
}
|
| 105 |
|
| 106 |
if (empty($data['rows'])) {
|
| 107 |
$data['rows'][] = array(
|
| 108 |
array(
|
| 109 |
'data' => t('No profiles defined'),
|
| 110 |
'colspan' => 3,
|
| 111 |
'align' => 'center',
|
| 112 |
),
|
| 113 |
);
|
| 114 |
}
|
| 115 |
$output .= theme('table', $options);
|
| 116 |
|
| 117 |
return $output;
|
| 118 |
}
|
| 119 |
|
| 120 |
|