function user_admin_perm_submit in Drupal 4
Same name and namespace in other branches
- 5 modules/user/user.module \user_admin_perm_submit()
- 6 modules/user/user.admin.inc \user_admin_perm_submit()
File
- modules/
user.module, line 1844 - Enables the user registration and login system.
Code
function user_admin_perm_submit($form_id, $edit) {
// Save permissions:
$result = db_query('SELECT * FROM {role}');
while ($role = db_fetch_object($result)) {
if (isset($edit[$role->rid])) {
// 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);
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])));
}
}
}
drupal_set_message(t('The changes have been saved.'));
// Clear the cached pages and menus:
menu_rebuild();
}