Skip to content

Commit b3c1b99

Browse files
committed
add deletelocalcopy to the actions column
1 parent 8ecc09a commit b3c1b99

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

classes/report_table.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,42 @@ public function col_download($user) {
177177
public function col_actions($user) {
178178
global $OUTPUT;
179179

180-
$icon = new \pix_icon('i/delete', get_string('delete'));
181-
$link = new \moodle_url('/mod/customcert/view.php',
180+
$actions = [
182181
[
183-
'id' => $this->cm->id,
184-
'deleteissue' => $user->issueid,
185-
'sesskey' => sesskey()
182+
'icon' => new \pix_icon('i/delete', get_string('delete')),
183+
'link' => new \moodle_url(
184+
'/mod/customcert/view.php',
185+
[
186+
'id' => $this->cm->id,
187+
'deleteissue' => $user->issueid,
188+
'sesskey' => sesskey()
189+
]
190+
),
191+
'attributes' => ['class' => 'action-icon delete-icon'],
186192
]
187-
);
193+
];
194+
195+
if (has_capability('mod/customcert:deletelocalcopy', \context_module::instance($this->cm->id)) && localfile::existsPDF($this->cm, $user->id)) {
196+
$actions[] = [
197+
'icon' => new \pix_icon('deletelocalcopy', get_string('deletelocalcopy', 'customcert'), 'customcert'),
198+
'link' => new \moodle_url(
199+
'/mod/customcert/view.php',
200+
[
201+
'id' => $this->cm->id,
202+
'deleteissue' => $user->issueid,
203+
'deletelocalcopy' => 1,
204+
'sesskey' => sesskey()
205+
]
206+
),
207+
'attributes' => ['class' => 'action-icon deletelocalcopy-icon'],
208+
];
209+
}
188210

189-
return $OUTPUT->action_icon($link, $icon, null, ['class' => 'action-icon delete-icon']);
211+
return implode(" ", array_map(
212+
fn ($action) =>
213+
$OUTPUT->action_icon($action['link'], $action['icon'], null, $action['attributes'] ?? []),
214+
$actions
215+
));
190216
}
191217

192218
/**

0 commit comments

Comments
 (0)