From 95e286130cbbf81bbec76a9f398a21e01552e97d Mon Sep 17 00:00:00 2001 From: Robert Lyon Date: Mon, 15 Apr 2019 07:06:51 +1200 Subject: [PATCH] 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 (cherry picked from commit 297d3275704f7c58f76ee9f4b740ba1d141256c7) --- htdocs/lang/en.utf8/statistics.php | 4 ++-- htdocs/lib/statistics.php | 16 +++++++++++++--- .../templates/admin/users/userdetailsstats.tpl | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/lang/en.utf8/statistics.php b/htdocs/lang/en.utf8/statistics.php index 9d7836c67b..0805853890 100644 --- a/htdocs/lang/en.utf8/statistics.php +++ b/htdocs/lang/en.utf8/statistics.php @@ -230,13 +230,13 @@ $string['reportdescuserdetails'] = '

People whose user accounts were created during the selected time period are displayed.

'; $string['reportuseractivity'] = 'User activity'; diff --git a/htdocs/lib/statistics.php b/htdocs/lib/statistics.php index d1875afe43..355ed2b7a2 100644 --- a/htdocs/lib/statistics.php +++ b/htdocs/lib/statistics.php @@ -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), ); } diff --git a/htdocs/theme/raw/templates/admin/users/userdetailsstats.tpl b/htdocs/theme/raw/templates/admin/users/userdetailsstats.tpl index 92bd4e566a..f3f8e78051 100644 --- a/htdocs/theme/raw/templates/admin/users/userdetailsstats.tpl +++ b/htdocs/theme/raw/templates/admin/users/userdetailsstats.tpl @@ -1,7 +1,7 @@ {foreach from=$data item=item} {if $columns.rownum}{$offset + $dwoo.foreach.default.iteration}{/if} - {if $columns.firstname}{$item->firstname}{/if} + {if $columns.firstname}{$item->firstname}{/if} {if $columns.lastname}{$item->lastname}{/if} {if $columns.email}{$item->email}{/if} {if $columns.studentid}{$item->studentid}{/if} @@ -10,5 +10,6 @@ {if $columns.remotename}{$item->remotename}{/if} {if $columns.quotapercent}{$item->quotapercent_format}% ({$item->quotaused_format}/{$item->quota_format}){/if} {if $columns.lastlogin}{$item->lastlogin}{/if} + {if $columns.probation}{$item->probation}{/if} {/foreach} -- GitLab