summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-07-20 00:39:52 (GMT)
committerAlex Pott2013-07-20 00:39:52 (GMT)
commitc874593f07169505baaea5f70fe8709f088b6f1d (patch)
treef7a3cd0e88787bf792d20573ea36c98471b6995a
parented556d1923636c9ce4cfc41626dcdd4d9771b397 (diff)
Issue #1938938 by duellj, Risse: Convert theme_user_admin_permissions() to table #type.
-rw-r--r--core/modules/user/user.admin.inc114
-rw-r--r--core/modules/user/user.module4
2 files changed, 40 insertions, 78 deletions
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index bb486ff..58063e8 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -130,12 +130,33 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
}
asort($modules);
+ $form['system_compact_link'] = array(
+ '#theme' => 'system_compact_link',
+ );
+
+ $form['permissions'] = array(
+ '#type' => 'table',
+ '#header' => array(t('Permission')),
+ '#id' => 'permissions',
+ );
+ foreach ($role_names as $rid => $name) {
+ $form['permissions']['#header'][] = array(
+ 'data' => $name,
+ 'class' => array('checkbox'),
+ );
+ }
+
foreach ($modules as $module => $display_name) {
if ($permissions = module_invoke($module, 'permission')) {
- $form['permission'][] = array(
+ // Module name.
+ $form['permissions'][$module] = array(array(
+ '#wrapper_attributes' => array(
+ 'colspan' => count($role_names) + 1,
+ 'class' => array('module'),
+ 'id' => 'module-' . $module,
+ ),
'#markup' => $module_info[$module]['name'],
- '#id' => $module,
- );
+ ));
foreach ($permissions as $perm => $perm_item) {
// Fill in default values for the permission.
$perm_item += array(
@@ -149,32 +170,32 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
'#permission_item' => $perm_item,
'#hide' => $hide_descriptions,
);
- $form['permission'][$perm] = array(
+ $form['permissions'][$perm]['description'] = array(
+ '#wrapper_attributes' => array(
+ 'class' => array('permission'),
+ ),
'#type' => 'item',
'#markup' => $perm_item['title'],
'#description' => drupal_render($user_permission_description),
);
+ $options[$perm] = '';
foreach ($role_names as $rid => $name) {
- // Builds arrays for checked boxes for each role
- if (in_array($perm, $role_permissions[$rid])) {
- $status[$rid][] = $perm;
- }
+ $form['permissions'][$perm][$rid] = array(
+ '#title' => $name . ': ' . $perm_item['title'],
+ '#title_display' => 'invisible',
+ '#wrapper_attributes' => array(
+ 'class' => array('checkbox'),
+ ),
+ '#type' => 'checkbox',
+ '#default_value' => in_array($perm,$role_permissions[$rid]) ? 1 : 0,
+ '#attributes' => array('class' => array('rid-' . $rid)),
+ '#parents' => array($rid, $perm),
+ );
}
}
}
}
- // Have to build checkboxes here after checkbox arrays are built
- foreach ($role_names as $rid => $name) {
- $form['checkboxes'][$rid] = array(
- '#type' => 'checkboxes',
- '#options' => $options,
- '#default_value' => isset($status[$rid]) ? $status[$rid] : array(),
- '#attributes' => array('class' => array('rid-' . $rid)),
- );
- $form['role_names'][$rid] = array('#markup' => check_plain($name), '#tree' => TRUE);
- }
-
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
@@ -200,61 +221,6 @@ function user_admin_permissions_submit($form, &$form_state) {
}
/**
- * Returns HTML for the administer permissions page.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @ingroup themeable
- */
-function theme_user_admin_permissions($variables) {
- $form = $variables['form'];
-
- $roles = user_role_names();
- foreach (element_children($form['permission']) as $key) {
- $row = array();
- // Module name
- if (is_numeric($key)) {
- $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['role_names']['#value']) + 1);
- }
- else {
- // Permission row.
- $row[] = array(
- 'data' => drupal_render($form['permission'][$key]),
- 'class' => array('permission'),
- );
- foreach (element_children($form['checkboxes']) as $rid) {
- $form['checkboxes'][$rid][$key]['#title'] = $roles[$rid] . ': ' . $form['permission'][$key]['#markup'];
- $form['checkboxes'][$rid][$key]['#title_display'] = 'invisible';
- $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox'));
- }
- }
- $rows[] = $row;
- }
- $header[] = (t('Permission'));
- foreach (element_children($form['role_names']) as $rid) {
- $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox'));
- }
- $system_compact_link = array(
- '#theme' => 'system_compact_link',
- );
- $table = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#attributes' => array(
- 'id' => 'permissions',
- ),
- '#sticky' => TRUE,
- );
- $output = drupal_render($system_compact_link);
- $output .= drupal_render($table);
- $output .= drupal_render_children($form);
- return $output;
-}
-
-/**
* Returns HTML for an individual permission description.
*
* @param $variables
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 5127a4c..68cf77e 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -100,10 +100,6 @@ function user_theme() {
'file' => 'user.pages.inc',
'template' => 'user',
),
- 'user_admin_permissions' => array(
- 'render element' => 'form',
- 'file' => 'user.admin.inc',
- ),
'user_permission_description' => array(
'variables' => array('permission_item' => NULL, 'hide' => NULL),
'file' => 'user.admin.inc',