Commit f100a316 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Bug#1086569 Fixed the statistics display message"

parents b8c570a5 fb128a98
......@@ -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