Commit 35a6a62a authored by Son Nguyen's avatar Son Nguyen

Enable 'No institution' users to use skins (Bug 1249123)

if it is activated in config.php

The skins setting is added to Site config page as well

Change-Id: I4464867db90dc9fd34220b1d865fb5b3527ef168
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 526a4e61
......@@ -107,6 +107,13 @@ $siteoptionform = array(
'defaultvalue' => get_config('homepageinfo'),
'disabled' => in_array('homepageinfo', $OVERRIDDEN),
),
'skins' => array(
'type' => 'checkbox',
'title' => get_string('skins', 'admin'),
'description' => get_string('skinssitedescription', 'admin'),
'defaultvalue' => get_config('skins'),
'disabled' => in_array('skins', $OVERRIDDEN),
),
'registration_sendweeklyupdates' => array(
'type' => 'checkbox',
'title' => get_string('sendweeklyupdates', 'admin'),
......@@ -681,7 +688,7 @@ function siteoptions_fail(Pieform $form, $field) {
function siteoptions_submit(Pieform $form, $values) {
$fields = array(
'sitename','lang','theme', 'dropdownmenu',
'sitename','lang','theme', 'dropdownmenu', 'skins',
'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'generatesitemap',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
......
......@@ -361,6 +361,7 @@ $string['siteoptionsset'] = 'Site options have been updated.';
$string['sitethemedescription'] = 'The default theme for the site. If your theme is not listed, check the error log.';
$string['skins'] = 'Page skins';
$string['skinsinstitutiondescription'] = 'Allow this institution\'s users to set "skins" on their pages.';
$string['skinssitedescription'] = 'Allow site\'s users to set "skins" on their pages.';
$string['smallviewheaders'] = 'Small page headers';
$string['smallviewheadersdescription'] = 'If checked, a small header and site navigation block will be displayed when viewing or editing portfolio pages created by users.';
$string['spamhaus'] = 'Enable Spamhaus URL blacklist';
......
......@@ -2090,7 +2090,7 @@ function admin_nav() {
);
// Add the menu items for skins, if that feature is enabled
if (get_config('skins')) {
if (can_use_skins()) {
$menu['configsite/siteskins'] = array(
'path' => 'configsite/siteskins',
'url' => 'admin/site/skins.php',
......@@ -3944,14 +3944,24 @@ function escape_css_string($string, $singlequote=true) {
* @return bool
*/
function can_use_skins($userid = null) {
global $USER;
if (!get_config('skins')) {
return false;
}
// Site admin can create site skins
if ($USER->get('admin')) {
return true;
}
// A user can belong to multiple institutions. If any of their institutions allow it, then
// let them use skins!
$results = get_config_user_institution('skins', $userid);
foreach ($results as $r) {
foreach ($results as $inst => $r) {
if (($inst == 'mahara') && get_config('skins')) {
return true;
}
if ($r) {
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment