19 declare(strict_types=1);
29 private readonly
string $defaultTitle
40 $this->
logger->debug(sprintf(
'START - Fetching all active certificates for user: "%s"', $userId));
44 il_cert_user_cert.obj_type, 45 il_cert_user_cert.thumbnail_image_path, 46 il_cert_user_cert.acquired_timestamp, 49 il_cert_user_cert.obj_id, 51 WHEN (trans.title IS NOT NULL AND LENGTH(trans.title) > 0) THEN trans.title 52 WHEN (object_data.title IS NOT NULL AND LENGTH(object_data.title) > 0) THEN object_data.title 53 WHEN (object_data_del.title IS NOT NULL AND LENGTH(object_data_del.title) > 0) THEN object_data_del.title 54 ELSE ' . $this->database->quote($this->defaultTitle,
'text') .
' 58 WHEN (trans.description IS NOT NULL AND LENGTH(trans.description) > 0) THEN trans.description 59 WHEN (object_data.description IS NOT NULL AND LENGTH(object_data.description) > 0) THEN object_data.description 60 WHEN (object_data_del.description IS NOT NULL AND LENGTH(object_data_del.description) > 0) THEN object_data_del.description 64 FROM il_cert_user_cert 65 LEFT JOIN object_data ON object_data.obj_id = il_cert_user_cert.obj_id 66 LEFT JOIN object_translation trans ON trans.obj_id = object_data.obj_id 67 AND trans.lang_code = ' . $this->database->quote($params[
'language'],
'text') .
' 68 LEFT JOIN object_data_del ON object_data_del.obj_id = il_cert_user_cert.obj_id 69 LEFT JOIN usr_data ON usr_data.usr_id = il_cert_user_cert.usr_id 70 WHERE il_cert_user_cert.usr_id = ' . $this->database->quote($userId,
'integer') .
' AND currently_active = 1';
76 if (isset($params[
'limit'])) {
77 if (!is_numeric($params[
'limit'])) {
81 if (!isset($params[
'offset'])) {
82 $params[
'offset'] = 0;
83 } elseif (!is_numeric($params[
'offset'])) {
87 $this->database->setLimit($params[
'limit'], $params[
'offset']);
90 $query = $this->database->query($sql);
96 while ($row = $this->database->fetchAssoc($query)) {
97 $title = $row[
'title'];
100 'id' => (
int) $row[
'id'],
102 'obj_id' => (
int) $row[
'obj_id'],
103 'obj_type' => $row[
'obj_type'],
104 'date' => (
int) $row[
'acquired_timestamp'],
105 'thumbnail_image_path' => $row[
'thumbnail_image_path'],
106 'description' => $row[
'description'],
107 'firstname' => $row[
'firstname'],
108 'lastname' => $row[
'lastname'],
112 if (isset($params[
'limit'])) {
115 FROM il_cert_user_cert 116 WHERE usr_id = ' . $this->database->quote($userId,
'integer') .
' AND currently_active = 1';
118 $row_cnt = $this->database->fetchAssoc($this->database->query($cnt_sql));
120 $data[
'cnt'] = (
int) $row_cnt[
'cnt'];
124 'All active certificates for user: "%s" total: "%s"',
133 $this->
logger->debug(sprintf(
'END - Actual results: "%s"', json_encode(
$data, JSON_THROW_ON_ERROR)));
140 if (isset($params[
'order_field'])) {
141 if (!is_string($params[
'order_field'])) {
145 if (!in_array($params[
'order_field'], [
'date',
'id',
'title'])) {
149 if ($params[
'order_field'] ===
'date') {
150 $params[
'order_field'] =
'acquired_timestamp';
153 if (!isset($params[
'order_direction'])) {
154 $params[
'order_direction'] =
'ASC';
155 } elseif (!in_array(strtolower($params[
'order_direction']), [
'asc',
'desc'])) {
159 return ' ORDER BY ' . $params[
'order_field'] .
' ' . $params[
'order_direction'];
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
getOrderByPart(array $params, array $filter)
__construct(private readonly ilDBInterface $database, private readonly ilLogger $logger, private readonly string $defaultTitle)
fetchDataSet(int $userId, array $params, array $filter)