Commit 9aabde37 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1791544: missing checks when adding sideblocks

    We need to check if the site is intalled or the user is logged in
    before trying to get information from the database
    to make the sideblocks

    behatnotneeded

Change-Id: I45e6db018199166af9eb4d1aff3f12ff7661ded0
parent 24fa5f97
......@@ -3771,6 +3771,11 @@ function display_size($size) {
*/
function profile_sideblock() {
global $USER, $SESSION;
if (!$USER->is_logged_in() || in_admin_section()) {
return null;
}
safe_require('notification', 'internal');
require_once('group.php');
require_once('institution.php');
......@@ -3900,6 +3905,9 @@ function profile_sideblock() {
function onlineusers_sideblock() {
global $USER;
if (!$USER->is_logged_in() || in_admin_section()) {
return null;
}
// Determine what level of users to show
// 0 = none, 1 = institution/s only, 2 = all users
$showusers = 2;
......@@ -4073,6 +4081,14 @@ function progressbar_artefact_link($pluginname, $artefacttype) {
function progressbar_sideblock($preview=false) {
global $USER;
if (!$USER->is_logged_in()) {
return null;
}
if (in_admin_section() && (!defined('SECTION_PAGE') || SECTION_PAGE != 'progressbar')) {
return null;
}
if (!get_config('showprogressbar')) {
return null;
}
......
......@@ -170,43 +170,45 @@ function smarty($javascript = array(), $headers = array(), $pagestrings = array(
$langselectform = language_select_form();
}
$sideblock_menu = array();
// Fetch all the core side blocks now to avoid any 'set headdata' before smarty_core() problems
$authgenerateloginform = auth_generate_login_form();
$isloginblockvisible = !$USER->is_logged_in() && !get_config('siteclosedforupgrade') && get_config('showloginsideblock');
$loginsideblock = array(
'name' => 'login',
'weight' => -10,
'id' => 'sb-loginbox',
'data' => array('loginform' => $authgenerateloginform),
'visible' => $isloginblockvisible,
'template' => 'sideblocks/login.tpl',
'smarty' => array('SHOWLOGINBLOCK' => $isloginblockvisible),
);
sideblock_template($loginsideblock, $sideblock_menu);
sideblock_template(site_menu(), $sideblock_menu);
sideblock_template(tags_sideblock(), $sideblock_menu);
sideblock_template(selfsearch_sideblock(), $sideblock_menu);
sideblock_template(profile_sideblock(), $sideblock_menu);
sideblock_template(onlineusers_sideblock(), $sideblock_menu);
sideblock_template(progressbar_sideblock(), $sideblock_menu);
sideblock_template(ssopeer_sideblock(), $sideblock_menu);
sideblock_template(quota_sideblock(), $sideblock_menu);
if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
foreach ($extraconfig['sideblocks'] as $sideblock) {
sideblock_template($sideblock, $sideblock_menu);
if (get_config('installed')) {
// Fetch all the core side blocks now to avoid any 'set headdata' before smarty_core() problems
$authgenerateloginform = auth_generate_login_form();
$isloginblockvisible = !$USER->is_logged_in() && !get_config('siteclosedforupgrade') && get_config('showloginsideblock');
$loginsideblock = array(
'name' => 'login',
'weight' => -10,
'id' => 'sb-loginbox',
'data' => array('loginform' => $authgenerateloginform),
'visible' => $isloginblockvisible,
'template' => 'sideblocks/login.tpl',
'smarty' => array('SHOWLOGINBLOCK' => $isloginblockvisible),
);
sideblock_template($loginsideblock, $sideblock_menu);
sideblock_template(site_menu(), $sideblock_menu);
sideblock_template(tags_sideblock(), $sideblock_menu);
sideblock_template(selfsearch_sideblock(), $sideblock_menu);
sideblock_template(profile_sideblock(), $sideblock_menu);
sideblock_template(onlineusers_sideblock(), $sideblock_menu);
sideblock_template(progressbar_sideblock(), $sideblock_menu);
sideblock_template(ssopeer_sideblock(), $sideblock_menu);
sideblock_template(quota_sideblock(), $sideblock_menu);
if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
foreach ($extraconfig['sideblocks'] as $sideblock) {
sideblock_template($sideblock, $sideblock_menu);
}
}
}
// local_sideblocks_update allows sites to customise the sideblocks by munging the $sideblock_menu array.
if (function_exists('local_sideblocks_update')) {
local_sideblocks_update($sideblock_menu);
}
// Remove those that are not visible before displaying
foreach ($sideblock_menu as $sbk => $sbv) {
if (empty($sbv['visible'])) {
unset($sideblock_menu[$sbk]);
// local_sideblocks_update allows sites to customise the sideblocks by munging the $sideblock_menu array.
if (function_exists('local_sideblocks_update')) {
local_sideblocks_update($sideblock_menu);
}
// Remove those that are not visible before displaying
foreach ($sideblock_menu as $sbk => $sbv) {
if (empty($sbv['visible'])) {
unset($sideblock_menu[$sbk]);
}
}
usort($sideblock_menu, "sort_menu_by_weight");
}
usort($sideblock_menu, "sort_menu_by_weight");
$smarty = smarty_core();
......@@ -3380,6 +3382,10 @@ function ssopeer_sideblock() {
*/
function site_menu() {
global $USER;
if (!get_config('installed') || in_admin_section()) {
return null;
}
$menu = array();
$public = $loggedin = false;
if ($menuitems = get_records_array('site_menu','public',(int) !$USER->is_logged_in(), 'displayorder')) {
......
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