Commit 95e28613 authored by Robert Lyon's avatar Robert Lyon

Bug 1824731: Allow stats column options to be enabled / disabled

If the site's config has enabled a setting or not

behatnotneeded

Change-Id: Ie526dd7dfe9506702b5676e13c459866f3f675be
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 297d3275)
parent eb02217a
......@@ -230,13 +230,13 @@ $string['reportdescuserdetails'] = '<ul>
<li>First name</li>
<li>Last name</li>
<li>Email address</li>
<li>Display name</li>
<li>ID number</li>
<li>Display name</li>
<li>Username</li>
<li>Remote username</li>
<li>Quota used</li>
<li>Last login</li>
<li>Number of probation points</li>
<li>Number of probation points (if enabled)</li>
</ul><p>People whose user accounts were created during the selected time period are displayed.</p>';
$string['reportuseractivity'] = 'User activity';
......
......@@ -559,6 +559,13 @@ function userdetails_statistics_headers($extra, $urllink) {
'class' => format_class($extra, 'lastlogin'),
'link' => format_goto($urllink . '&sort=lastlogin', $extra, array('sort'), 'lastlogin')
),
array(
'id' => 'probation',
'name' => get_string('probationreportcolumn', 'admin'),
'class' => format_class($extra, 'probation'),
'link' => format_goto($urllink . '&sort=probation', $extra, array('sort'), 'probation'),
'disabled' => empty(get_config('probationenabled'))
),
);
}
......@@ -642,6 +649,7 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
case "remotename":
case "quotapercent":
case "studentid":
case "probation":
$orderby = " " . $sorttype . " " . (!empty($extra['sortdesc']) ? 'DESC' : 'ASC') . ", CONCAT (u.firstname, ' ', u.lastname)";
break;
case "lastname":
......@@ -655,7 +663,7 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
$sql = "SELECT u.id, u.firstname, u.lastname, u.username, u.preferredname AS displayname,
u.lastlogin, u.email, u.studentid, u.ctime,
(SELECT remoteusername FROM {auth_remote_user} aru WHERE aru.localusr = u.id LIMIT 1) AS remotename,
((u.quotaused * 1.0)/ u.quota) AS quotapercent, u.quota, u.quotaused
((u.quotaused * 1.0)/ u.quota) AS quotapercent, u.quota, u.quotaused, u.probation
" . $fromsql . $wheresql . "
ORDER BY " . $orderby;
if (empty($extra['csvdownload'])) {
......@@ -677,7 +685,7 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
}
if (!empty($extra['csvdownload'])) {
$csvfields = array('firstname', 'lastname', 'email', 'studentid',
'preferredname', 'username', 'remoteuser', 'quotapercent_format', 'lastlogin');
'preferredname', 'username', 'remoteuser', 'quotapercent_format', 'lastlogin', 'probation');
$USER->set_download_file(generate_csv($data, $csvfields), $institution . 'userdetailsstatistics.csv', 'text/csv');
}
$result['csv'] = true;
......@@ -4444,10 +4452,12 @@ function report_config_form($extra, $institutionelement) {
$activeheadings = get_active_columns($data, $extra->extra);
$headerelements = array();
foreach ($data['tableheadings'] as $heading) {
$disabled = isset($heading['disabled']) && !empty($heading['disabled']) ? true : false;
$disabled = $disabled ? true : (!empty($heading['required']) ? true : false);
$headerelements['report_column_' . $heading['id']] = array(
'type' => 'checkbox',
'title' => $heading['name'],
'readonly' => (!empty($heading['required']) ? true : false),
'readonly' => $disabled,
'defaultvalue' => (!empty($heading['required']) || !empty($heading['selected']) ? $heading['id'] : null),
);
}
......
{foreach from=$data item=item}
<tr class="{cycle values='r0,r1'}">
{if $columns.rownum}<td>{$offset + $dwoo.foreach.default.iteration}</td>{/if}
{if $columns.firstname}<td><a href="{$item->profileurl}">{$item->firstname}</a></td>{/if}
{if $columns.firstname}<td><a href="{$item->profileurl}">{$item->firstname}</a></td>{/if}
{if $columns.lastname}<td><a href="{$item->profileurl}">{$item->lastname}</a></td>{/if}
{if $columns.email}<td>{$item->email}</td>{/if}
{if $columns.studentid}<td>{$item->studentid}</td>{/if}
......@@ -10,5 +10,6 @@
{if $columns.remotename}<td>{$item->remotename}</td>{/if}
{if $columns.quotapercent}<td>{$item->quotapercent_format}% <span class="text-small text-midtone">({$item->quotaused_format}/{$item->quota_format})</span></td>{/if}
{if $columns.lastlogin}<td>{$item->lastlogin}</td>{/if}
{if $columns.probation}<td>{$item->probation}</td>{/if}
</tr>
{/foreach}
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