/[drupal]/contributions/modules/adminrole/adminrole.module
ViewVC logotype

Contents of /contributions/modules/adminrole/adminrole.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Fri May 4 17:33:17 2007 UTC (2 years, 6 months ago) by jacobsingh
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, HEAD
Changes since 1.2: +36 -37 lines
File MIME type: text/x-php
A few small tweaks re: patch from douggreen
1 <?php
2 // $Id$
3
4 /** @file
5 * adminrole:
6 * This module simply gives a designated role all permissions every time the
7 * modules page is submitted.
8 */
9
10 /**
11 * Implementation of hook_help().
12 */
13 function adminrole_help($section) {
14 switch ($section) {
15 case 'admin/settings/adminrole':
16 return t('Change which role is a "admin" Role with full perms');
17 }
18 }
19
20 /**
21 * Implementation of hook_menu().
22 */
23 function adminrole_menu($may_cache) {
24 $items = array();
25
26 if ($may_cache) {
27 $items[] = array(
28 'path' => 'admin/settings/adminrole',
29 'title' => t('adminrole'),
30 'callback' => 'drupal_get_form',
31 'callback arguments' => array('adminrole_admin_settings'),
32 'access' => user_access('administer site configuration'),
33 'type' => MENU_NORMAL_ITEM
34 );
35 $items[] = array(
36 'path' => 'admin/adminrole/update',
37 'title' => t('adminrole'),
38 'callback' => 'adminrole_update_perms',
39 'access' => user_access('administer site configuration'),
40 'type' => MENU_SUGGESTED_ITEM
41 );
42 }
43 return $items;
44 }
45
46 function adminrole_update_perms() {
47 if ($admin_role = variable_get('adminrole_adminrole', 0)) {
48 $perms = array();
49 foreach (module_list(FALSE, FALSE, TRUE) as $module) {
50 if ($permissions = module_invoke($module, 'perm')) {
51 $perms = array_merge($perms, $permissions);
52 }
53 }
54 db_query('DELETE FROM {permission} WHERE rid = %d', $admin_role);
55 if (count($perms)) {
56 db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $admin_role, implode(', ', $perms));
57 }
58 drupal_set_message(t('Admin Permissions Set'));
59 }
60 }
61
62 function adminrole_admin_settings() {
63 $form = array();
64 $form['adminrole_adminrole'] = array(
65 '#type' => 'select',
66 '#title' => t('Admin Roles'),
67 '#default_value' => variable_get('adminrole_adminrole', 0),
68 '#description' => t("Which Role is Admin?"),
69 '#options' => array_merge(array(0 => t('-- Please Select One --')), user_roles()),
70 );
71 return system_settings_form($form);
72 }
73
74 function adminrole_form_alter($form_id, &$form) {
75 if ($form_id == 'system_modules') {
76 $form['#submit']["adminrole_update_perms"] = array();
77 }
78 }
79
80
81
82
83

  ViewVC Help
Powered by ViewVC 1.1.2