Commit 0c9532c1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Set theme based on institution

parent e602eb72
......@@ -82,6 +82,7 @@ class User {
'accountprefs' => array(),
'activityprefs' => array(),
'institutions' => array(),
'theme' => null,
'admininstitutions' => array(),
'sesskey' => ''
);
......@@ -398,6 +399,9 @@ class User {
if ($i->admin) {
$admininstitutions[$i->institution] = $i->institution;
}
if (empty($this->theme)) {
$this->theme = $i->theme;
}
}
$this->institutions = $institutions;
$this->admininstitutions = $admininstitutions;
......
......@@ -774,8 +774,10 @@ function load_user_institutions($userid) {
if (empty($userid)) {
throw new InvalidArgumentException("couldn't load institutions, no user id specified");
}
if ($institutions = get_records_assoc('usr_institution', 'usr', $userid, '',
'institution,ctime,expiry,studentid,staff,admin')) {
if ($institutions = get_records_sql_assoc('
SELECT u.institution,u.ctime,u.expiry,u.studentid,u.staff,u.admin,i.theme
FROM {usr_institution} u INNER JOIN {institution} i ON u.institution = i.name
WHERE u.usr = ?', array($userid))) {
return $institutions;
}
return array();
......
......@@ -531,7 +531,13 @@ function theme_setup() {
}
$theme = new StdClass;
$theme->theme = get_config('theme');
global $USER;
if (!empty($USER)) {
$theme->theme = $USER->get('theme');
}
if (empty($theme->theme)) {
$theme->theme = get_config('theme');
}
$theme->path = get_config('docroot') . 'theme/' . $theme->theme . '/';
$theme->template_dir = array($theme->path . 'templates/');
$theme->inheritance = array($theme->theme);
......
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