#119 Add ability to delete issued certificates
This commit is contained in:
parent
6e55519b81
commit
a9fdf770d0
5 changed files with 90 additions and 1 deletions
|
@ -265,7 +265,7 @@ class certificate {
|
|||
|
||||
// Return the issues.
|
||||
$ufields = \user_picture::fields('u');
|
||||
$sql = "SELECT $ufields, ci.code, ci.timecreated
|
||||
$sql = "SELECT $ufields, ci.id as issueid, ci.code, ci.timecreated
|
||||
FROM {user} u
|
||||
INNER JOIN {customcert_issues} ci
|
||||
ON u.id = ci.userid
|
||||
|
|
|
@ -86,6 +86,11 @@ class report_table extends \table_sql {
|
|||
$headers[] = get_string('file');
|
||||
}
|
||||
|
||||
if (has_capability('mod/customcert:manage', \context_module::instance($cm->id))) {
|
||||
$columns[] = 'actions';
|
||||
$headers[] = '';
|
||||
}
|
||||
|
||||
$this->define_columns($columns);
|
||||
$this->define_headers($headers);
|
||||
$this->collapsible(false);
|
||||
|
@ -149,6 +154,27 @@ class report_table extends \table_sql {
|
|||
return $OUTPUT->action_link($link, '', null, null, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the actions column.
|
||||
*
|
||||
* @param \stdClass $user
|
||||
* @return string
|
||||
*/
|
||||
public function col_actions($user) {
|
||||
global $OUTPUT;
|
||||
|
||||
$icon = new \pix_icon('i/delete', get_string('delete'));
|
||||
$link = new \moodle_url('/mod/customcert/report.php',
|
||||
[
|
||||
'id' => $this->cm->id,
|
||||
'deleteissue' => $user->issueid,
|
||||
'sesskey' => sesskey()
|
||||
]
|
||||
);
|
||||
|
||||
return $OUTPUT->action_icon($link, $icon, null, ['class' => 'action-icon delete-icon']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the reader.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue