From 1d27bece758b1506748095d19bb2bca57a817120 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Tue, 18 Dec 2018 09:43:43 +0800 Subject: [PATCH] Report now respects the setting 'Show user identity' (#224) --- classes/certificate.php | 3 ++- classes/report_table.php | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/classes/certificate.php b/classes/certificate.php index 01e2b86..0dd842e 100644 --- a/classes/certificate.php +++ b/classes/certificate.php @@ -260,7 +260,8 @@ class certificate { $allparams = $conditionsparams + array('customcertid' => $customcertid); // Return the issues. - $ufields = \user_picture::fields('u'); + $extrafields = get_extra_user_fields(\context_module::instance($cm->id)); + $ufields = \user_picture::fields('u', $extrafields); $sql = "SELECT $ufields, ci.id as issueid, ci.code, ci.timecreated FROM {user} u INNER JOIN {customcert_issues} ci diff --git a/classes/report_table.php b/classes/report_table.php index 978a6fe..a1db6bb 100644 --- a/classes/report_table.php +++ b/classes/report_table.php @@ -65,14 +65,22 @@ class report_table extends \table_sql { public function __construct($customcertid, $cm, $groupmode, $download = null) { parent::__construct('mod_customcert_report_table'); - $columns = array( - 'fullname', - 'timecreated' - ); - $headers = array( - get_string('fullname'), - get_string('receiveddate', 'customcert') - ); + $context = \context_module::instance($cm->id); + $extrafields = get_extra_user_fields($context); + + $columns = []; + $columns[] = 'fullname'; + foreach ($extrafields as $extrafield) { + $columns[] = $extrafield; + } + $columns[] = 'timecreated'; + + $headers = []; + $headers[] = get_string('fullname'); + foreach ($extrafields as $extrafield) { + $headers[] = get_user_field_name($extrafield); + } + $headers[] = get_string('receiveddate', 'customcert'); // Check if we were passed a filename, which means we want to download it. if ($download) { @@ -84,7 +92,7 @@ class report_table extends \table_sql { $headers[] = get_string('file'); } - if (!$this->is_downloading() && has_capability('mod/customcert:manage', \context_module::instance($cm->id))) { + if (!$this->is_downloading() && has_capability('mod/customcert:manage', $context)) { $columns[] = 'actions'; $headers[] = ''; }