Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/Attic/README.txt,v
retrieving revision 1.1.2.1.2.1
diff -u -p -r1.1.2.1.2.1 README.txt
--- README.txt	7 Jan 2009 21:03:45 -0000	1.1.2.1.2.1
+++ README.txt	25 Nov 2009 03:23:52 -0000
@@ -6,8 +6,8 @@ This module is a little helper to mainta
 
    1. Enable the module
    2. Create your "Administrator" Role if it doesn't exist already
-   3. Go to Admin -> User -> Admin Role (http://example.com/admin/user/adminrole)
-   4. Select your role
+   3. Go to Admin -> User -> User settings (http://example.com/admin/user/settings)
+   4. Select your role in the 'Administrator role' fieldset
 
 == Usage ==
 
Index: adminrole.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/adminrole.module,v
retrieving revision 1.2.2.8.2.6
diff -u -p -r1.2.2.8.2.6 adminrole.module
--- adminrole.module	7 Jan 2009 21:12:03 -0000	1.2.2.8.2.6
+++ adminrole.module	25 Nov 2009 03:23:52 -0000
@@ -1,90 +1,56 @@
 <?php
 // $Id: adminrole.module,v 1.2.2.8.2.6 2009/01/07 21:12:03 bevan Exp $
 
-/** @file
- * adminrole:
+/**
+ * @file
  * This module simply gives a designated role all permissions every time the
  * modules page is submitted.
  */
 
 /**
- * Implementation of hook_help().
+ * Implement hook_form_alter().
  */
-function adminrole_help($section) {
-  switch ($section) {
-    case 'admin/user/adminrole':
-      return t('Change which role is an "administrator" role with full permissions');
+function adminrole_form_alter(&$form, $form_state, $form_id) {
+  if (in_array($form_id, array('system_modules', 'user_admin_settings'))) {
+    $form['#submit'][] = 'adminrole_update_perms';
   }
 }
 
 /**
- * Implementation of hook_menu().
+ * Implement hook_form_FORM_ID_alter().
  */
-function adminrole_menu() {
-  $items = array();
-
-  $items['admin/user/adminrole'] = array(
-    'title' => t('Admin Role'),
-    'description' => t('Change which role is an "administrator" role with full permissions'),
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('adminrole_admin_settings'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM,
+function adminrole_form_user_admin_settings_alter(&$form, $form_state) {
+  // Administrative role option.
+  $form['admin_role'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Administrator role'),
   );
 
-  $items['admin/adminrole/update'] = array(
-    'title' => t('Update Admin Role'),
-    'page callback' => 'adminrole_update_perms',
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_CALLBACK,
+  // Do not allow users to set the anonymous or authenticated user roles as the
+  // administrator role.
+  $roles = user_roles();
+  unset($roles[DRUPAL_ANONYMOUS_RID]);
+  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+
+  $form['admin_role']['user_admin_role'] = array(
+    '#type' => 'select',
+    '#title' => t('Administrator role'),
+    '#default_value' => variable_get('user_admin_role', 0),
+    '#options' => array(0 => t('Disabled')) + $roles,
+    '#description' => t('This role will be automatically assigned new permissions whenever a module is enabled. Changing this setting will not affect existing permissions.'),
   );
 
-  return $items;
+  // Ensure the save/reset buttons have a lower weight than our fieldset.
+  $form['buttons'] += array('#weight' => 100);
 }
 
-function adminrole_update_perms() {
-  if ($admin_role = variable_get('adminrole_adminrole', 0)) {
-    if ($admin_role == 0) {
-      return;
-    }
-    $perms = array();
-    foreach (module_list(TRUE, FALSE, TRUE) as $module) {
-      if ($permissions = module_invoke($module, 'perm')) {
-        $perms = array_merge($perms, $permissions);
-      }
-    }
+function adminrole_update_permissions() {
+  if ($admin_role = variable_get('user_admin_role', 0)) {
+    //module_implements('', FALSE, TRUE);
+    $perms = module_invoke_all('perm');
     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'));
-  }
-}
-
-function adminrole_admin_settings() {
-  $form = array();
-
-  $u_roles = user_roles();
-  // Removing Authenticated and anonymous roles
-  unset($u_roles[1]);
-  unset($u_roles[2]);
-
-  $u_roles[0] = t('-- Please Select One --');
-  ksort($u_roles);
-
-  $form['adminrole_adminrole'] = array(
-   '#type' => 'select',
-   '#title' => t('Admin Roles'),
-   '#default_value' => variable_get('adminrole_adminrole', 0),
-   '#description' => t("Which role should get all permissions?"),
-   '#options' => $u_roles,
-  );
-
-  return system_settings_form($form);
-}
-
-function adminrole_form_alter(&$form, $form_state, $form_id) {
-  if (in_array($form_id, array('system_modules', 'adminrole_admin_settings'))) {
-     $form['#submit'][] = 'adminrole_update_perms';
   }
 }
