- #10689: Group permissions by module in UI + minor code cleanups.

- Adding a drupal_goto to the block admin.
4.5.x
Steven Wittens 2004-09-17 22:07:17 +00:00
parent 4b9926263c
commit 30b69380af
5 changed files with 54 additions and 30 deletions

View File

@ -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;

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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);

View File

@ -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);