diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-09-17 22:07:17 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-09-17 22:07:17 +0000 |
commit | 30b69380afe3db9e37754ecacc34faed27a543d1 (patch) | |
tree | 6f6ee17f4a5e5a81f5bc16a05bf81de05ee83140 | |
parent | 4b9926263c4dc2ab7533ab57859e00989173dcc4 (diff) | |
download | brdo-30b69380afe3db9e37754ecacc34faed27a543d1.tar.gz brdo-30b69380afe3db9e37754ecacc34faed27a543d1.tar.bz2 |
- #10689: Group permissions by module in UI + minor code cleanups.
- Adding a drupal_goto to the block admin.
-rw-r--r-- | misc/drupal.css | 6 | ||||
-rw-r--r-- | modules/block.module | 1 | ||||
-rw-r--r-- | modules/block/block.module | 1 | ||||
-rw-r--r-- | modules/user.module | 38 | ||||
-rw-r--r-- | modules/user/user.module | 38 |
5 files changed, 54 insertions, 30 deletions
diff --git a/misc/drupal.css b/misc/drupal.css index bcc8b1156..2edc97ccc 100644 --- a/misc/drupal.css +++ b/misc/drupal.css @@ -333,6 +333,12 @@ tr.light .form-item, tr.dark .form-item { #forum td.posts, #forum td.topics, #forum td.replies, #forum td.pager { text-align: center; } +#permissions td.module { + font-weight: bold; +} +#permissions td.permission { + padding-left: 2em; +} .poll .bar { height: 1em; margin: 1px 0; diff --git a/modules/block.module b/modules/block.module index faa21eeb3..605de85ab 100644 --- a/modules/block.module +++ b/modules/block.module @@ -282,6 +282,7 @@ function block_admin() { if ($op == t('Save blocks')) { drupal_set_message(block_admin_save($edit)); cache_clear_all(); + drupal_goto($_GET['q']); } print theme('page', block_admin_display()); } diff --git a/modules/block/block.module b/modules/block/block.module index faa21eeb3..605de85ab 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -282,6 +282,7 @@ function block_admin() { if ($op == t('Save blocks')) { drupal_set_message(block_admin_save($edit)); cache_clear_all(); + drupal_goto($_GET['q']); } print theme('page', block_admin_display()); } diff --git a/modules/user.module b/modules/user.module index 628a49210..c691c6cfa 100644 --- a/modules/user.module +++ b/modules/user.module @@ -1379,9 +1379,13 @@ function user_admin_perm($edit = array()) { // Delete, so if we clear every checkbox we reset that role; // otherwise permissions are active and denied everywhere. db_query('DELETE FROM {permission} WHERE rid = %d', $role->rid); - $perm = $edit[$role->rid] ? implode(', ', array_keys($edit[$role->rid])) : ''; - if ($perm) { - db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, $perm); + foreach ($edit[$role->rid] as $key => $value) { + if (!$value) { + unset($edit[$role->rid][$key]); + } + } + if (count($edit[$role->rid])) { + db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, implode(', ', array_keys($edit[$role->rid]))); } } @@ -1389,11 +1393,9 @@ function user_admin_perm($edit = array()) { // permissions. cache_clear_all(); menu_rebuild(); - } - // Compile permission array: - $perms = module_invoke_all('perm'); - asort($perms); + drupal_goto($_GET['q']); + } // Compile role array: $result = db_query('SELECT r.rid, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY name'); @@ -1409,18 +1411,24 @@ function user_admin_perm($edit = array()) { } // Render role/permission overview: - $header = array_merge(array(' '), $role_names); + $header = array_merge(array('permission'), $role_names); - foreach ($perms as $perm) { - $row[] = t($perm); - foreach ($role_names as $rid => $name) { - $row[] = "<input type=\"checkbox\" name=\"edit[$rid][$perm]\"". (strstr($role_perms[$rid], $perm) ? ' checked="checked"' : '') .' />'; + foreach (module_list() as $module) { + if ($perms = module_invoke($module, 'perm')) { + $rows[] = array(array('data' => t('%module module', array('%module' => $module)), 'class' => 'module', 'colspan' => count($role_names) + 1)); + asort($perms); + foreach ($perms as $perm) { + $row[] = array('data' => t($perm), 'class' => 'permission'); + foreach ($role_names as $rid => $name) { + $row[] = form_checkbox('', "$rid][$perm", 1, strstr($role_perms[$rid], $perm)); + } + $rows[] = $row; + unset($row); + } } - $rows[] = $row; - unset($row); } - $output = theme('table', $header, $rows); + $output = theme('table', $header, $rows, array('id' => 'permissions')); $output .= form_submit(t('Save permissions')); return form($output); diff --git a/modules/user/user.module b/modules/user/user.module index 628a49210..c691c6cfa 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1379,9 +1379,13 @@ function user_admin_perm($edit = array()) { // Delete, so if we clear every checkbox we reset that role; // otherwise permissions are active and denied everywhere. db_query('DELETE FROM {permission} WHERE rid = %d', $role->rid); - $perm = $edit[$role->rid] ? implode(', ', array_keys($edit[$role->rid])) : ''; - if ($perm) { - db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, $perm); + foreach ($edit[$role->rid] as $key => $value) { + if (!$value) { + unset($edit[$role->rid][$key]); + } + } + if (count($edit[$role->rid])) { + db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, implode(', ', array_keys($edit[$role->rid]))); } } @@ -1389,11 +1393,9 @@ function user_admin_perm($edit = array()) { // permissions. cache_clear_all(); menu_rebuild(); - } - // Compile permission array: - $perms = module_invoke_all('perm'); - asort($perms); + drupal_goto($_GET['q']); + } // Compile role array: $result = db_query('SELECT r.rid, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY name'); @@ -1409,18 +1411,24 @@ function user_admin_perm($edit = array()) { } // Render role/permission overview: - $header = array_merge(array(' '), $role_names); + $header = array_merge(array('permission'), $role_names); - foreach ($perms as $perm) { - $row[] = t($perm); - foreach ($role_names as $rid => $name) { - $row[] = "<input type=\"checkbox\" name=\"edit[$rid][$perm]\"". (strstr($role_perms[$rid], $perm) ? ' checked="checked"' : '') .' />'; + foreach (module_list() as $module) { + if ($perms = module_invoke($module, 'perm')) { + $rows[] = array(array('data' => t('%module module', array('%module' => $module)), 'class' => 'module', 'colspan' => count($role_names) + 1)); + asort($perms); + foreach ($perms as $perm) { + $row[] = array('data' => t($perm), 'class' => 'permission'); + foreach ($role_names as $rid => $name) { + $row[] = form_checkbox('', "$rid][$perm", 1, strstr($role_perms[$rid], $perm)); + } + $rows[] = $row; + unset($row); + } } - $rows[] = $row; - unset($row); } - $output = theme('table', $header, $rows); + $output = theme('table', $header, $rows, array('id' => 'permissions')); $output .= form_submit(t('Save permissions')); return form($output); |