? .svn ? 221124.patch Index: adminrole.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/adminrole.info,v retrieving revision 1.3 diff -u -p -r1.3 adminrole.info --- adminrole.info 18 Jun 2007 22:53:28 -0000 1.3 +++ adminrole.info 14 Feb 2008 21:00:49 -0000 @@ -1,3 +1,3 @@ name = Admin Role -description = Create a role to be "admin" and automatically assign all perms to that role. +description = "Automatically assign all permissions to an admin role." package = User Access \ No newline at end of file Index: adminrole.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/adminrole.module,v retrieving revision 1.3 diff -u -p -r1.3 adminrole.module --- adminrole.module 4 May 2007 17:33:17 -0000 1.3 +++ adminrole.module 14 Feb 2008 21:00:49 -0000 @@ -26,7 +26,8 @@ function adminrole_menu($may_cache) { if ($may_cache) { $items[] = array( 'path' => 'admin/settings/adminrole', - 'title' => t('adminrole'), + 'title' => t('Admin Role'), + 'description' => t('Change which role is a "admin" Role with full perms'), 'callback' => 'drupal_get_form', 'callback arguments' => array('adminrole_admin_settings'), 'access' => user_access('administer site configuration'), @@ -40,44 +41,54 @@ function adminrole_menu($may_cache) { 'type' => MENU_SUGGESTED_ITEM ); } + return $items; } +/** + * Sets permissions + */ function adminrole_update_perms() { if ($admin_role = variable_get('adminrole_adminrole', 0)) { $perms = array(); + foreach (module_list(FALSE, FALSE, TRUE) as $module) { if ($permissions = module_invoke($module, 'perm')) { $perms = array_merge($perms, $permissions); } } + db_query('DELETE FROM {permission} WHERE rid = %d', $admin_role); if (count($perms)) { db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $admin_role, implode(', ', $perms)); } + drupal_set_message(t('Admin Permissions Set')); } } +/** + * Settings form + */ function adminrole_admin_settings() { $form = array(); + $form['adminrole_adminrole'] = array( '#type' => 'select', '#title' => t('Admin Roles'), '#default_value' => variable_get('adminrole_adminrole', 0), - '#description' => t("Which Role is Admin?"), + '#description' => t('Which Role is Admin?'), '#options' => array_merge(array(0 => t('-- Please Select One --')), user_roles()), ); + return system_settings_form($form); } +/** + * Sets a callback on forms to invoke adminrole_update_perms() + */ function adminrole_form_alter($form_id, &$form) { - if ($form_id == 'system_modules') { - $form['#submit']["adminrole_update_perms"] = array(); + if (in_array($form_id, array('system_modules', 'adminrole_admin_settings'))) { + $form['#submit']['adminrole_update_perms'] = array(); } -} - - - - - +}