/** * Return a list of themes available to this user * If the user is a member of any institutions, only themes available to * those institutions are returned; or * If a user is not a member of any institution, all themes not marked as * institution specific are returned. * @return array subdir => name */ function get_user_accessible_themes() { global $USER; $themes = array(); if ($institutions = $USER->get('institutions')) { // Get themes for all of this users institutions foreach ($institutions as $i) { $themes = array_merge($themes, get_institution_themes($i->institution)); } } else { $themelist = get_all_theme_objects(); foreach ($themelist as $subdir => $theme) { if (!isset($theme->institutions) || !is_array($theme->institutions)) { $themes[$subdir] = isset($theme->displayname) ? $theme->displayname : $subdir; } } } $themes = array_merge(array('sitedefault' => get_string('nothemeselected', 'view')), $themes); unset($themes['custom']); return $themes; }
/** * Checks if theme still exists and if not resets it to default option * * @param $theme string Name of theme * @param $institution string Name of Institution * * @return bool True if theme exists */ function validate_theme($theme, $institution = null) { global $SESSION; if ($institution) { $themeoptions = get_institution_themes($institution); } else { $themeoptions = get_all_themes(); } if (!array_key_exists($theme, $themeoptions)) { if ($institution) { set_config_institution($institution, 'theme', null); } else { set_config('theme', 'default'); } $SESSION->add_info_msg(get_string('thememissing', 'admin', $theme)); return false; } return true; }
$inuse = implode(',', $inuserecords); } $authtypes = auth_get_available_auth_types($institution); } else { $data = new StdClass(); $data->displayname = ''; $data->expiry = null; if (!get_config('usersuniquebyusername')) { $data->registerallowed = 1; } $data->theme = 'sitedefault'; $data->defaultmembershipperiod = null; $lockedprofilefields = array(); $authtypes = auth_get_available_auth_types(); } $themeoptions = get_institution_themes($institution); $themeoptions['sitedefault'] = '- ' . get_string('sitedefault', 'admin') . ' (' . $themeoptions[get_config('theme')] . ') -'; uksort($themeoptions, 'theme_sort'); $sitename = get_config('sitename'); safe_require('artefact', 'internal'); $elements = array('name' => array('type' => 'text', 'title' => get_string('institutionname', 'admin'), 'rules' => array('required' => true, 'maxlength' => 255, 'regex' => '/^[a-zA-Z]+$/'), 'ignore' => !$add, 'help' => true), 'add' => array('type' => 'hidden', 'value' => true, 'ignore' => !$add), 'inuse' => array('type' => 'hidden', 'value' => $inuse, 'id' => 'inuse', 'ignore' => $add), 'i' => array('type' => 'hidden', 'value' => $institution, 'ignore' => $add), 'displayname' => array('type' => 'text', 'title' => get_string('institutiondisplayname', 'admin'), 'defaultvalue' => $data->displayname, 'rules' => array('required' => true, 'maxlength' => 255), 'help' => true)); if ($USER->get('admin') && $institution != 'mahara') { $elements['expiry'] = array('type' => 'date', 'title' => get_string('institutionexpiry', 'admin'), 'description' => get_string('institutionexpirydescription', 'admin', hsc($sitename)), 'defaultvalue' => is_null($data->expiry) ? null : strtotime($data->expiry), 'help' => true, 'minyear' => date('Y') - 2, 'maxyear' => date('Y') + 10); } if ($USER->get('admin')) { $elements['authplugin'] = array('type' => 'authlist', 'title' => get_string('authplugin', 'admin'), 'options' => $authinstances, 'authtypes' => $authtypes, 'instancearray' => $instancearray, 'instancestring' => $instancestring, 'institution' => $institution, 'help' => true, 'ignore' => count($authtypes) == 0 || $institution == ''); } if (!$add && empty($authinstances)) { if ($USER->get('admin')) { $SESSION->add_error_msg(get_string('adminnoauthpluginforinstitution', 'admin')); } else {
/** * Return a list of themes available to this user * If the user is a member of any institutions, only themes available to * those institutions are returned; or * If a user is not a member of any institution, all themes not marked as * institution specific are returned. * @return array subdir => name */ function get_user_accessible_themes() { global $USER; $themes = array(); if ($institutions = $USER->get('institutions')) { // Get themes for all of this users institutions foreach ($institutions as $i) { $themes = array_merge($themes, get_institution_themes($i->institution)); } } else { $themelist = get_all_theme_objects(); foreach ($themelist as $subdir => $theme) { if (!isset($theme->institutions) || !is_array($theme->institutions)) { $themes[$subdir] = isset($theme->displayname) ? $theme->displayname : $subdir; } } } return $themes; }