Commit 60f4478f authored by Nathan Lewis's avatar Nathan Lewis Committed by Ghada El-Zoghbi
Browse files

Generate page content before initialising smarty (Bug #1337626)



Change-Id: I4b5fb0da8567e95fd9c0e57806baca835b50764e
Signed-off-by: default avatarNathan Lewis <nathan.lewis@totaralms.com>
parent 4f715dc2
......@@ -65,7 +65,7 @@ if ($USER->is_logged_in()) {
$editwindow = group_format_editwindow($group);
$view = group_get_homepage_view($group->id);
$viewcontent = $view->build_rows();
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$headers = array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">');
if ($group->public) {
......
......@@ -46,6 +46,7 @@ if ($USER->is_logged_in()) {
));
}
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$smarty = smarty(
$javascript,
$stylesheets,
......@@ -80,7 +81,7 @@ JAVASCRIPT;
}
$smarty->assign('dashboardview', true);
$smarty->assign('viewcontent', $view->build_rows());
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('viewid', $view->get('id'));
}
else {
......
......@@ -24,6 +24,8 @@ function smarty_core() {
* This function creates a Smarty object and sets it up for use within our
* podclass app, setting up some variables.
*
* WARNING: If you are using pieforms, set them up BEFORE calling this function.
*
* The variables that it sets up are:
*
* - WWWROOT: The base url for the Mahara system
......
......@@ -90,7 +90,7 @@ if ($restrictedview && !$USER->is_logged_in()) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
if (!$restrictedview) {
$viewcontent = $view->build_rows();
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
}
$javascript = array('paginator', 'lib/pieforms/static/core/pieforms.js', 'expandable');
......
......@@ -173,6 +173,15 @@ $addform = pieform(array(
),
));
$blockid = $view->get_blockinstance_currently_being_configured();
if (!$blockid) {
$blockid = param_integer('block', 0);
if (!$blockid) {
// Build content before initialising smarty in case pieform elements define headers.
$viewcontent = $view->build_rows(true);
}
}
$smarty = smarty($javascript, $stylesheets, array(
'view' => array(
'addblock',
......@@ -257,10 +266,6 @@ if (get_config('userscanchooseviewthemes') && $view->is_themeable() && $view->ge
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewtitle', $viewtitle);
$blockid = $view->get_blockinstance_currently_being_configured();
if (!$blockid) {
$blockid = param_integer('block', 0);
}
if ($blockid) {
// Configuring a single block
$bi = new BlockInstance($blockid);
......@@ -268,7 +273,7 @@ if ($blockid) {
}
else {
// The HTML for the columns in the view
$columns = $view->build_rows(true);
$columns = $viewcontent;
$smarty->assign('columns', $columns);
}
$smarty->assign('issiteview', isset($institution) && ($institution == 'mahara'));
......
......@@ -227,6 +227,8 @@ if ($owner && $owner == $USER->get('id')) {
}
}
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$smarty = smarty(
$javascript,
$headers,
......@@ -343,7 +345,7 @@ if ($mnetviewlist = $SESSION->get('mnetviewaccess')) {
}
$smarty->assign('viewdescription', $view->get('description'));
$smarty->assign('viewcontent', $view->build_rows());
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('releaseform', $releaseform);
if (isset($addfeedbackform)) {
$smarty->assign('enablecomments', 1);
......
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