Index: adminrole.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/Attic/adminrole.install,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 adminrole.install
--- adminrole.install	7 Jan 2010 16:22:53 -0000	1.1.2.4
+++ adminrole.install	27 Jul 2010 20:31:10 -0000
@@ -33,6 +33,7 @@ function adminrole_enable() {
 function adminrole_uninstall() {
   variable_del('adminrole_adminrole');
   variable_del('user_admin_role');
+  variable_del('adminrole_perm_exlusions');
 }
 
 /**
Index: adminrole.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adminrole/adminrole.module,v
retrieving revision 1.2.2.8.2.9
diff -u -p -r1.2.2.8.2.9 adminrole.module
--- adminrole.module	25 Nov 2009 20:44:54 -0000	1.2.2.8.2.9
+++ adminrole.module	27 Jul 2010 20:31:11 -0000
@@ -8,6 +8,37 @@
  */
 
 /**
+ * Implementation of hook_menu().
+ */
+function adminrole_menu() {
+  $items = array();
+
+  $items['admin/settings/adminrole'] = array(
+    'title' => 'Admin role',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('adminrole_perm_exclusions_form'),
+    'access arguments' => array('administer permissions'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'adminrole.settings.inc',
+    // @TODO description
+  );
+
+  return $items;
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function adminrole_theme() {
+  return array(
+    'adminrole_perm_exlusions' => array(
+      'arguments' => array('element' => NULL),
+      'file' => 'adminrole.settings.inc',
+    ),
+  );
+}
+
+/**
  * Implement hook_form_FORM_ID_alter().
  */
 function adminrole_form_user_admin_settings_alter(&$form, $form_state) {
@@ -29,6 +60,7 @@ function adminrole_form_user_admin_setti
     '#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.'),
+    // @TODO Modify this description. Explain the exclusions and link to admin/settings/adminrole
   );
 
   // Ensure the save/reset buttons have a lower weight than our fieldset.
@@ -49,7 +81,10 @@ function adminrole_form_alter(&$form, $f
  */
 function adminrole_update_permissions() {
   if ($rid = variable_get('user_admin_role', 0)) {
-    $perms = module_invoke_all('perm');
+    $perms = array_diff(
+      module_invoke_all('perm'),
+      array_keys(variable_get('adminrole_perm_exlusions', array()), TRUE)
+    );
     db_query('DELETE FROM {permission} WHERE rid = %d', $rid);
     if ($perms) {
       db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $rid, implode(', ', $perms));
Index: adminrole.settings.inc
===================================================================
RCS file: adminrole.settings.inc
diff -N adminrole.settings.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ adminrole.settings.inc	27 Jul 2010 20:31:11 -0000
@@ -0,0 +1,70 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Administration functions
+ */
+
+/**
+ * FAPI form builder
+ */
+function adminrole_perm_exclusions_form($form_state) {
+  $form = array();
+
+  $exlusions = array_keys(variable_get('adminrole_perm_exlusions', array()), TRUE);
+
+  $form['adminrole_perm_exlusions'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Exclusions'),
+    '#options' => array(),
+    '#default_value' => array(),
+    '#theme' => 'adminrole_perm_exlusions',
+    '#modules' => array(),
+  );
+
+  foreach (module_list(FALSE, FALSE, TRUE) as $module) {
+    $permissions = module_invoke($module, 'perm');
+
+    if (!$permissions) {
+      continue;
+    }
+
+    $default_value = array_intersect($exlusions, $permissions);
+    $form['adminrole_perm_exlusions']['#options'] += drupal_map_assoc($permissions, 't');
+    $form['adminrole_perm_exlusions']['#default_value'] += $default_value;
+
+    $form['adminrole_perm_exlusions']['#modules'][$module] = array(
+      'module' => $module,
+      'permissions' => $permissions,
+      'excluded' => count($default_value),
+    );
+  }
+
+  return system_settings_form($form);
+}
+
+/**
+ * Theme exlusions checkboxes
+ */
+function theme_adminrole_perm_exlusions($element) {
+  $return = '';
+  
+  foreach ($element['#modules'] as $info) {
+    $fs = array(
+      '#type' => 'fieldset',
+      '#title' => $info['module'],
+      '#collapsible' => TRUE,
+      '#collapsed' => !$info['excluded'],
+      '#value' => '',
+    );
+
+    foreach ($info['permissions'] as $perm) {
+      $fs['#value'] .= drupal_render($element[$perm]);
+    }
+
+    $return .= theme('fieldset', $fs);
+  }
+  
+  return $return . drupal_render($element);
+}
