Commit 34d45ce0 authored by Hugh Davenport's avatar Hugh Davenport
Browse files

Allow institutions to select "None" online users



Before it checked if the value was empty, which is true when
the value is 0. If this was the case, set it as default to 2

This patch checks instead if it is set, and only then sets the
default of 2. This allows you to select the option 0 (None)

Also makes sure that the online users block is not shown when
there are no users to display (ie, all institutions that the user
is in have None selected)

Change-Id: Ib168d9796484dacbb8d58d111127c9bf21069a59
Signed-off-by: default avatarHugh Davenport <hugh@catalyst.net.nz>
parent 921930ee
......@@ -548,7 +548,7 @@ function institution_submit(Pieform $form, $values) {
$newinstitution->displayname = $values['displayname'];
$newinstitution->authplugin = empty($values['authplugin']) ? null : $values['authplugin'];
$newinstitution->showonlineusers = empty($values['showonlineusers']) ? 2 : $values['showonlineusers'];
$newinstitution->showonlineusers = !isset($values['showonlineusers']) ? 2 : $values['showonlineusers'];
if (get_config('usersuniquebyusername')) {
// Registering absolutely not allowed when this setting is on, it's a
// security risk. See the documentation for the usersuniquebyusername
......
......@@ -483,7 +483,21 @@ EOF;
'weight' => -20,
'data' => profile_sideblock()
);
if (get_config('showonlineuserssideblock')) {
$showusers = 2;
$institutions = $USER->institutions;
if (!empty($institutions)) {
$showusers = 0;
foreach ($institutions as $i) {
if ($i->showonlineusers == 2) {
$showusers = 2;
break;
}
if ($i->showonlineusers == 1) {
$showusers = 1;
}
}
}
if (get_config('showonlineuserssideblock') && $showusers > 0) {
$SIDEBLOCKS[] = array(
'name' => 'onlineusers',
'id' => 'sb-onlineusers',
......
Supports Markdown
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