Report now respects the setting 'Show user identity' (#224)

This commit is contained in:
Mark Nelson 2018-12-18 09:43:43 +08:00
parent d9576aac13
commit 1d27bece75
2 changed files with 19 additions and 10 deletions

View file

@ -260,7 +260,8 @@ class certificate {
$allparams = $conditionsparams + array('customcertid' => $customcertid); $allparams = $conditionsparams + array('customcertid' => $customcertid);
// Return the issues. // 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 $sql = "SELECT $ufields, ci.id as issueid, ci.code, ci.timecreated
FROM {user} u FROM {user} u
INNER JOIN {customcert_issues} ci INNER JOIN {customcert_issues} ci

View file

@ -65,14 +65,22 @@ class report_table extends \table_sql {
public function __construct($customcertid, $cm, $groupmode, $download = null) { public function __construct($customcertid, $cm, $groupmode, $download = null) {
parent::__construct('mod_customcert_report_table'); parent::__construct('mod_customcert_report_table');
$columns = array( $context = \context_module::instance($cm->id);
'fullname', $extrafields = get_extra_user_fields($context);
'timecreated'
); $columns = [];
$headers = array( $columns[] = 'fullname';
get_string('fullname'), foreach ($extrafields as $extrafield) {
get_string('receiveddate', 'customcert') $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. // Check if we were passed a filename, which means we want to download it.
if ($download) { if ($download) {
@ -84,7 +92,7 @@ class report_table extends \table_sql {
$headers[] = get_string('file'); $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'; $columns[] = 'actions';
$headers[] = ''; $headers[] = '';
} }