@@ -177,16 +177,42 @@ public function col_download($user) {
177
177
public function col_actions ($ user ) {
178
178
global $ OUTPUT ;
179
179
180
- $ icon = new \pix_icon ('i/delete ' , get_string ('delete ' ));
181
- $ link = new \moodle_url ('/mod/customcert/view.php ' ,
180
+ $ actions = [
182
181
[
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 ' ],
186
192
]
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
+ }
188
210
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
+ ));
190
216
}
191
217
192
218
/**
0 commit comments