From b8ae0b32188231ce79c2945e78c26e909f4e25c2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 30 Nov 2005 11:09:38 +0000 Subject: [PATCH] - Patch #38981 by Robert: add permission to enable/disbale theme switching by users. --- modules/system.module | 49 ++++++++++++++++++++---------------- modules/system/system.module | 49 ++++++++++++++++++++---------------- modules/user.module | 2 +- modules/user/user.module | 2 +- 4 files changed, 56 insertions(+), 46 deletions(-) diff --git a/modules/system.module b/modules/system.module index 248ae68a42a..e22afafedbb 100644 --- a/modules/system.module +++ b/modules/system.module @@ -47,7 +47,7 @@ function system_help($section) { * Implementation of hook_perm(). */ function system_perm() { - return array('administer site configuration', 'access administration pages'); + return array('administer site configuration', 'access administration pages', 'select different theme'); } /** @@ -159,31 +159,36 @@ function system_test() { */ function system_user($type, $edit, &$user, $category = NULL) { if ($type == 'form' && $category == 'account') { - $themes = list_themes(); - ksort($themes); + if (user_access('select different theme')) { + $themes = list_themes(); - // Reset to follow site default theme if user selects the site default - if ($key == variable_get('theme_default', 'bluemarine')) { - $key = ''; - if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) { - $edit['theme'] = ''; + if (count($themes) > 1) { + ksort($themes); + + // Reset to follow site default theme if user selects the site default + if ($key == variable_get('theme_default', 'bluemarine')) { + $key = ''; + if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) { + $edit['theme'] = ''; + } + } + + $form['themes'] = array( + '#type' => 'fieldset', '#title' => t('Theme configuration'), '#description' => t('Selecting a different theme will change the look and feel of the site.'), '#weight' => 2, '#collapsible' => TRUE, '#theme' => 'system_user'); + + foreach ($themes as $info) { + $info->screenshot = dirname($info->filename) . '/screenshot.png'; + $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot'); + + $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot); + $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename)); + $options[$info->name] = ''; + } + + $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine')); } } - $form['themes'] = array( - '#type' => 'fieldset', '#title' => t('Theme configuration'), '#description' => t('Selecting a different theme will change the look and feel of the site.'), '#weight' => 2, '#collapsible' => TRUE, '#theme' => 'system_user'); - - foreach ($themes as $info) { - $info->screenshot = dirname($info->filename) . '/screenshot.png'; - $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot'); - - $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot); - $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename)); - $options[$info->name] = ''; - } - - $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine')); - if (variable_get('configurable_timezones', 1)) { $zones = _system_zonelist(); $form['locale'] = array('#type'=>'item', '#title' => t('Locale settings'), '#weight' => 6); diff --git a/modules/system/system.module b/modules/system/system.module index 248ae68a42a..e22afafedbb 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -47,7 +47,7 @@ function system_help($section) { * Implementation of hook_perm(). */ function system_perm() { - return array('administer site configuration', 'access administration pages'); + return array('administer site configuration', 'access administration pages', 'select different theme'); } /** @@ -159,31 +159,36 @@ function system_test() { */ function system_user($type, $edit, &$user, $category = NULL) { if ($type == 'form' && $category == 'account') { - $themes = list_themes(); - ksort($themes); + if (user_access('select different theme')) { + $themes = list_themes(); - // Reset to follow site default theme if user selects the site default - if ($key == variable_get('theme_default', 'bluemarine')) { - $key = ''; - if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) { - $edit['theme'] = ''; + if (count($themes) > 1) { + ksort($themes); + + // Reset to follow site default theme if user selects the site default + if ($key == variable_get('theme_default', 'bluemarine')) { + $key = ''; + if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) { + $edit['theme'] = ''; + } + } + + $form['themes'] = array( + '#type' => 'fieldset', '#title' => t('Theme configuration'), '#description' => t('Selecting a different theme will change the look and feel of the site.'), '#weight' => 2, '#collapsible' => TRUE, '#theme' => 'system_user'); + + foreach ($themes as $info) { + $info->screenshot = dirname($info->filename) . '/screenshot.png'; + $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot'); + + $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot); + $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename)); + $options[$info->name] = ''; + } + + $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine')); } } - $form['themes'] = array( - '#type' => 'fieldset', '#title' => t('Theme configuration'), '#description' => t('Selecting a different theme will change the look and feel of the site.'), '#weight' => 2, '#collapsible' => TRUE, '#theme' => 'system_user'); - - foreach ($themes as $info) { - $info->screenshot = dirname($info->filename) . '/screenshot.png'; - $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot'); - - $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot); - $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename)); - $options[$info->name] = ''; - } - - $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine')); - if (variable_get('configurable_timezones', 1)) { $zones = _system_zonelist(); $form['locale'] = array('#type'=>'item', '#title' => t('Locale settings'), '#weight' => 6); diff --git a/modules/user.module b/modules/user.module index baf2af02469..8b3f57889db 100644 --- a/modules/user.module +++ b/modules/user.module @@ -1820,7 +1820,7 @@ function user_help($section) { diff --git a/modules/user/user.module b/modules/user/user.module index baf2af02469..8b3f57889db 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1820,7 +1820,7 @@ function user_help($section) {