Commit 556e58cc authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1668492: institution/account setting theme not set in view table

Allow to set the theme in view table on the DB only when
  we have userscanchooseviewthemes = true and
  the theme is set when we are editing page

behatnotneeded

Change-Id: I16ef25e8efa6060aa7e5a30a44ed2f4698f6d625
parent 6957a254
......@@ -4943,5 +4943,16 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2017030200) {
log_debug('Clean institution theme in view table');
if (!get_config('userscanchooseviewthemes')) {
execute_sql("
UPDATE {view}
SET theme = NULL
WHERE theme IS NOT NULL
");
}
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2017022700;
$config->version = 2017030200;
$config->series = '17.04';
$config->release = '17.04dev';
$config->minupgradefrom = 2012080604;
......
......@@ -560,36 +560,6 @@ class View {
if (isset($viewdata['type']) && $viewdata['type'] != 'portfolio' && get_record('view', 'owner', $viewdata['owner'], 'type', $viewdata['type'])) {
$viewdata['type'] = 'portfolio';
}
// Try to create the view with the owner's default theme if that theme is set by an
// institution (i.e. if it's different from the site theme)
//
// This needs to be modified if users are ever allowed to change their own theme
// preference. Currently it's okay because users' themes are forced on them by
// the site or institution default, but if some users are allowed to change their
// own theme pref, we should create those users' views without a theme.
if (!get_config('userscanchooseviewthemes') && !isset($viewdata['theme'])
&& (!isset($viewdata['type']) || $viewdata['type'] != 'dashboard')) {
global $USER;
if ($viewdata['owner'] == $USER->get('id')) {
$owner = $USER;
}
else {
$owner = new User();
$owner->find_by_id($viewdata['owner']);
}
$ownerthemedata = $owner->get('institutiontheme');
$themeoptions = get_all_themes();
$ownertheme = (isset($ownerthemedata->basename) && array_key_exists($ownerthemedata->basename, $themeoptions)) ? $ownerthemedata->basename : null;
if ($accounttheme = $owner->get_account_preference('theme')) {
$accountthemeparts = explode('/', $accounttheme);
$ownertheme = $accountthemeparts[0];
}
if ($ownertheme && $ownertheme != get_config('theme') && $ownertheme != 'custom') {
$viewdata['theme'] = $ownertheme;
}
}
}
if (isset($viewdata['group'])) {
......
......@@ -236,10 +236,16 @@ $commentoptions->view = $view;
$feedback = ArtefactTypeComment::get_comments($commentoptions);
// Set up theme
// if the view theme is set in view table
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($view);
}
// if it's another users view, it should be displayed with the other users institution theme
else if ($owner && $owner != $USER->get('id')) {
$THEME = new Theme($owner);
}
$headers = array();
$headers[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/smoothness/jquery-ui.min.css') . '">';
$headers = array_merge($headers, $view->get_all_blocktype_css());
......
......@@ -82,7 +82,8 @@ Feature: Mahara users can allow their tagged blogs tags to be copied
# allow the ajax to load
And I wait "1" seconds
And I follow "Page 01"
And I scroll to the base of id "copyview-button"
And I follow "Copy"
And I press "Save"
Then I should see "Journal entries with tags \"blog\", \"one\" but not tag \"two\""
And I should see "userB entry"
\ No newline at end of file
And I should see "userB entry"
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