summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc/drupal.css6
-rw-r--r--modules/block.module1
-rw-r--r--modules/block/block.module1
-rw-r--r--modules/user.module38
-rw-r--r--modules/user/user.module38
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('&nbsp;'), $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);