function user_admin_perm_submit

You are here

4.7 user.module user_admin_perm_submit($form_id, $edit)
5 user.module user_admin_perm_submit($form_id, $form_values)
6 user.admin.inc user_admin_perm_submit($form, &$form_state)

File

modules/user/user.module, line 1907
Enables the user registration and login system.

Code

function user_admin_perm_submit($form_id, $form_values) {
  // Save permissions:
  $result = db_query('SELECT * FROM {role}');
  while ($role = db_fetch_object($result)) {
    if (isset($form_values[$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);
      $form_values[$role->rid] = array_filter($form_values[$role->rid]);
      if (count($form_values[$role->rid])) {
        db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, implode(', ', array_keys($form_values[$role->rid])));
      }
    }
  }

  drupal_set_message(t('The changes have been saved.'));

  // Clear the cached pages and menus:
  menu_rebuild();

}