Commit fb128a98 authored by Christian Tuveve-Aiono's avatar Christian Tuveve-Aiono Committed by Robert Lyon
Browse files

Bug#1086569 Fixed the statistics display message



When the staff statistics access option has been
turned off,the institution statistics display message has been
made clearer letting the user know they have no access.

Also fixed problem where user is admin in one institution and staff
in another but can not see stats for the institution they are a staff
member in (when staff statistics are turned on)

Change-Id: I81f2cd7d37bc13106429369fbd9a8eb018d7fcdd
Signed-off-by: default avatarChristian Tuveve-Aiono <handlethesandal@gmail.com>
parent 5eb8a44f
......@@ -21,16 +21,26 @@ if (!is_logged_in()) {
throw new AccessDeniedException();
}
$institutionelement = get_institution_selector(true, false, true, get_config('staffstats'));
$institution = param_alphanum('institution', null);
$notallowed = false;
if (!empty($institution)) {
$staffstats = get_config('staffstats');
if (!$USER->get('admin') && !$USER->is_institutional_admin($institution) && (!$USER->is_institutional_staff($institution) || ($USER->is_institutional_staff($institution) && empty($staffstats)))) {
$notallowed = true;
}
}
if (empty($institutionelement)) {
if (!$notallowed) {
$institutionelement = get_institution_selector(true, false, true, get_config('staffstats'));
}
if (empty($institutionelement) || $notallowed) {
$smarty = smarty();
$smarty->assign('CANCREATEINST', $USER->get('admin'));
$smarty->display('admin/users/noinstitutionsstats.tpl');
exit;
}
$institution = param_alphanum('institution', null);
if (!$institution || !$USER->can_edit_institution($institution, true)) {
$institution = empty($institutionelement['value']) ? $institutionelement['defaultvalue'] : $institutionelement['value'];
}
......
......@@ -919,7 +919,8 @@ $string['Admins'] = 'Administrators';
$string['noinstitutions'] = 'No institutions';
$string['noinstitutionsdescription'] = 'If you would like to associate users with an institution, you should create the institution first.';
$string['noinstitutionsstatsdescription'] = 'Institution statistics are not available because there are no institutions available to your user.';
$string['noinstitutionsstats'] = 'Unable to view institution statistics';
$string['noinstitutionsstatsdescription1'] = 'Staff statistics access needs to be turned on for the site to allow staff to view their institution statistics. A site administrator can turn this setting on in "User settings" under <a href="%sadmin/site/options.php">Configure site</a>.';
$string['noinstitutiongeneralpages'] = 'You do not have permission to edit any institution general pages or no institutions have been created yet.';
$string['noinstitutiongeneralpagesadmin'] = 'If you are a site administrator, please edit the default general pages in <a href="%s">Configure site</a>.';
......
......@@ -831,7 +831,17 @@ function get_institution_selector($includedefault = true, $assumesiteadmin=false
else {
$institutions = get_records_select_array('institution', "name != 'mahara'", null, 'displayname');
}
} else if ($USER->is_institutional_admin()) {
}
else if ($USER->is_institutional_admin() && ($USER->is_institutional_staff() && $includeinstitutionstaff)) {
// if a user is both an admin for some institution and is a staff member for others
$institutions = get_records_select_array(
'institution',
'name IN (' . join(',', array_map('db_quote',$USER->get('admininstitutions'))) .
',' . join(',', array_map('db_quote',$USER->get('staffinstitutions'))) . ')',
null, 'displayname'
);
}
else if ($USER->is_institutional_admin()) {
$institutions = get_records_select_array(
'institution',
'name IN (' . join(',', array_map('db_quote',$USER->get('admininstitutions'))) . ')',
......@@ -844,7 +854,8 @@ function get_institution_selector($includedefault = true, $assumesiteadmin=false
'name IN (' . join(',', array_map('db_quote',$USER->get('staffinstitutions'))) . ')',
null, 'displayname'
);
} else {
}
else {
return null;
}
......
{include file="header.tpl"}
<h1>{str tag="noinstitutions" section="admin"}</h1>
<h1>{str tag="noinstitutionsstats" section="admin"}</h1>
<p>{str tag="noinstitutionsstatsdescription" section="admin"}</p>
<p>{str tag="noinstitutionsstatsdescription1" section="admin" arg1="`$WWWROOT`"}</p>
{if $CANCREATEINST}
<div class="institutioneditbuttons">
<form action="{$WWWROOT}admin/users/institutions.php" method="post">
......
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