From 652e4a8120971628df0e7cf350da00d6d3dbfca4 Mon Sep 17 00:00:00 2001 From: Eric Rasmussen <eric@unl.edu> Date: Thu, 8 Dec 2011 15:07:01 +0000 Subject: [PATCH] [gh-272] Merging test into staging -c1325 git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1348 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/unl/unl.module | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module index 55f17062..748c6371 100644 --- a/sites/all/modules/unl/unl.module +++ b/sites/all/modules/unl/unl.module @@ -267,6 +267,19 @@ function unl_permission() { ); } +/** + * Implements hook_preprocess_page(). + */ +function unl_preprocess_page(&$vars) { + switch (current_path()) { + case 'admin/modules': + if (!unl_user_is_administrator()) { + // Changed here rather than using hook_help because the later merely appends to the existing text. + $vars['page']['help']['system_help']['#markup'] = '<p>Not all modules can be turned on/off. If you have questions about modules on this page or modules not yet part of the UNL project contact an administrator.</p>'; + } + } +} + /** * Implementation of hook_menu(). */ @@ -473,6 +486,29 @@ function unl_form_field_ui_display_overview_form_alter(&$form, &$form_state, $fo } } +/** + * Implementation of hook_form_FORM_ID_alter() for system_modules. + */ +function unl_form_system_modules_alter(&$form, &$form_state, $form_id) { + // Whitelist of modules that Site Admin are allowed to turn on and off on admin/modules + $modules = array('aggregator', 'blog', 'book', 'comment', 'translation', 'dashboard', 'forum', 'help', 'list', 'locale', 'number', 'taxonomy', 'trigger', // Core on this line, Contrib below + 'action_email_role', 'context', 'context_layouts', 'context_ui', 'features', 'unl_news', 'imce', 'imce_mkdir', 'imce_rename', 'menu_block', 'menu_block_export', + 'form_builder', 'form_builder_webform_ui', 'webform', 'webform_alt_ui', + 'workbench', 'workbench_access', 'workbench_files', 'workbench_media', 'workbench_moderation'); + + if (!unl_user_is_administrator() && isset($form['modules'])) { + foreach ($form['modules'] as $category_name => $category) { + if (is_array($category)) { + foreach ($category as $module_name => $module) { + if (!in_array($module_name, $modules) && substr($module_name,0,1) !== '#') { + $form['modules'][$category_name][$module_name]['#disabled'] = true; + } + } + } + } + } +} + /** * Implementation of hook_form_alter(). */ -- GitLab