summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module102
1 files changed, 28 insertions, 74 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module b/kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module
index 02a7534..9b19372 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/permission_select/permission_select.module
@@ -1,5 +1,4 @@
<?php
-// $Id: permission_select.module,v 1.1.4.2 2009/05/18 00:29:20 himerus Exp $
/**
* @file
* Module will add select all/deselect all options through out the
@@ -9,7 +8,7 @@
/**
* Implementation of hook_perm().
*/
-function permission_select_perm() {
+function permission_select_permission() {
return array(
'use permission select' => array(
'title' => t('Use permission select'),
@@ -22,7 +21,7 @@ function permission_select_perm() {
*/
function permission_select_init() {
if (user_access('use permission select') &&
-substr($_GET['q'], 0, 22) == 'admin/user/permissions') {
+substr($_GET['q'], 0, 24) == 'admin/people/permissions' ) {
$path = drupal_get_path('module', 'permission_select');
drupal_add_css($path .'/permission_select.css', array('type' => 'module', 'media' => 'all', 'preprocess' => TRUE,));
drupal_add_js($path .'/permission_select.js');
@@ -33,92 +32,47 @@ substr($_GET['q'], 0, 22) == 'admin/user/permissions') {
* telling the system we want to use out custom function to render this form
*/
function permission_select_theme_registry_alter(&$theme_registry) {
- if (!empty($theme_registry['user_admin_perm'])) {
- $theme_registry['user_admin_perm']['function'] = 'permission_select_theme_user_admin_perm';
+ if (!empty($theme_registry['user_admin_permissions'])) {
+ $theme_registry['user_admin_permissions']['function'] = 'permission_select_theme_user_admin_perm';
}
}
/**
* Theme the administer permissions page.
*/
-function permission_select_theme_user_admin_perm($form) {
+function permission_select_theme_user_admin_perm($variables) {
+ $form = $variables['form'];
$roles = user_roles();
+ $permission_select_header = '<div class="permission_select"><h5>Master Permission Select</h5><ul>';
foreach (element_children($form['permission']) as $key) {
- // Don't take form control structures
- if (is_array($form['permission'][$key])) {
- $row = array();
- // Module name
- if (is_numeric($key)) {
- $mod_name = t($form['permission'][$key]['#id']);
- $row[] = array('data' => t('@module module', array('@module' => drupal_render($form['permission'][$key]))), 'class' => 'module module_name', 'id' => 'module-'. $mod_name, 'colspan' => count($form['role_names']) + 1);
- }
- else {
- // Permission row.
- $row[] = array(
- 'data' => drupal_render($form['permission'][$key]),
- 'class' => 'permission',
- );
- foreach (element_children($form['checkboxes']) as $rid) {
- if (is_array($form['checkboxes'][$rid])) {
- $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => 'checkbox module-'. $mod_name, 'title' => $roles[$rid] . ' : ' . t($key));
- }
- }
- }
- $rows[] = array(
- 'data' => $row,
- 'class' => 'module-'. $mod_name,
- );
- }
- }
- $header[] = (t('Permission'));
- foreach (element_children($form['role_names']) as $rid) {
- if (is_array($form['role_names'][$rid])) {
- $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => 'checkbox');
+ $row = array();
+ // Module name
+ if (is_numeric($key)) {
+ $mod_name = t($form['permission'][$key]['#id']);
+ $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => array('module module_name'), 'id' => 'module-' . $mod_name, 'colspan' => count($form['role_names']['#value']) + 1);
}
- }
- $output = theme('system_compact_link');
- $output .= theme('table', $header, $rows, array('id' => 'permissions'));
- $output .= drupal_render_children($form);
- return $output;
-}
-
-
-
-
-
-
-function _____theme_user_admin_perm($form) {
- $roles = user_roles();
- foreach (element_children($form['permission']) as $key) {
- // Don't take form control structures
- if (is_array($form['permission'][$key])) {
- $row = array();
- // Module name
- if (is_numeric($key)) {
- $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => 'module', 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['role_names']) + 1);
- }
- else {
- // Permission row.
- $row[] = array(
- 'data' => drupal_render($form['permission'][$key]),
- 'class' => 'permission',
- );
- foreach (element_children($form['checkboxes']) as $rid) {
- if (is_array($form['checkboxes'][$rid])) {
- $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => 'checkbox', 'title' => $roles[$rid] . ' : ' . t($key));
- }
- }
+ 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 module-' . $mod_name .' rid-'.$rid));
}
- $rows[] = $row;
}
+ $rows[] = $row;
}
$header[] = (t('Permission'));
foreach (element_children($form['role_names']) as $rid) {
- if (is_array($form['role_names'][$rid])) {
- $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => 'checkbox');
- }
+ $permission_select_header .= '<li><a href="#" class="rcheck">check all</a>&nbsp;/&nbsp;<a href="#" class="runcheck">uncheck all</a><span id ="rid-'.$rid.'" class="role">' .$roles[$rid].'</span></li>';
+ $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox'));
}
+ $permission_select_header .= '</ul></div>';
$output = theme('system_compact_link');
- $output .= theme('table', $header, $rows, array('id' => 'permissions'));
+ $output .= $permission_select_header;
+ $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
$output .= drupal_render_children($form);
return $output;
}