@@ -244,6 +244,16 @@ public static function list_issues_parameters() {
244
244
'Timestamp. Returns items created after this date (included). ' ,
245
245
VALUE_OPTIONAL
246
246
),
247
+ 'userid ' => new external_value (
248
+ PARAM_INT ,
249
+ 'User id. Returns items for this user. ' ,
250
+ VALUE_OPTIONAL
251
+ ),
252
+ 'customcertid ' => new external_value (
253
+ PARAM_INT ,
254
+ 'Customcert id. Returns items for this customcert. ' ,
255
+ VALUE_OPTIONAL
256
+ ),
247
257
]
248
258
);
249
259
}
@@ -252,9 +262,11 @@ public static function list_issues_parameters() {
252
262
* Returns array of issued certificates.
253
263
*
254
264
* @param ?int $timecreatedfrom Timestamp. Returns items created after this date (included).
265
+ * @param ?int $userid User id. Returns items for this user.
266
+ * @param ?int $customcertid Customcert id. Returns items for this customcert.
255
267
* @return array
256
268
*/
257
- public static function list_issues ($ timecreatedfrom = null ) {
269
+ public static function list_issues ($ timecreatedfrom = null , $ userid = null , $ customcertid = null ) {
258
270
global $ DB ;
259
271
260
272
$ params = [
@@ -273,10 +285,22 @@ public static function list_issues($timecreatedfrom = null) {
273
285
ON ci.customcertid = c.id
274
286
JOIN {customcert_templates} ct
275
287
ON c.templateid = ct.id " ;
288
+ $ conditions = [];
276
289
if ($ timecreatedfrom ) {
277
- $ sql . = " WHERE ci.timecreated >= :timecreatedfrom " ;
290
+ $ conditions [] = "ci.timecreated >= :timecreatedfrom " ;
278
291
$ nameparams ['timecreatedfrom ' ] = $ timecreatedfrom ;
279
292
}
293
+ if ($ userid ) {
294
+ $ conditions [] = "ci.userid = :userid " ;
295
+ $ nameparams ['userid ' ] = $ userid ;
296
+ }
297
+ if ($ customcertid ) {
298
+ $ conditions [] = "ci.customcertid = :customcertid " ;
299
+ $ nameparams ['customcertid ' ] = $ customcertid ;
300
+ }
301
+ if ($ conditions ) {
302
+ $ sql .= " WHERE " . implode (" AND " , $ conditions );
303
+ }
280
304
281
305
if ($ issues = $ DB ->get_records_sql ($ sql , $ nameparams )) {
282
306
0 commit comments