40 : array
41 {
42 $this->
logger->debug(sprintf(
'START - Fetching all active certificates for user: "%s"', $userId));
43 $additional_select = '';
44 if (
45 $this->
database->tableColumnExists(
'il_cert_user_cert',
'background_image_path') &&
46 $this->database->tableColumnExists('il_cert_user_cert', 'tile_image_path')
47 ) {
48 $additional_select =
49 self::TABLE_NAME . '.tile_image_path,
50 ' . self::TABLE_NAME . '.tile_image_ident,';
51 }
52
53 $sql = 'SELECT
54 ' . self::TABLE_NAME . '.id,
55 ' . self::TABLE_NAME . '.obj_type,
56 ' . self::TABLE_NAME . '.acquired_timestamp,
57 ' . self::TABLE_NAME . '.tile_image_ident,
58 ' . $additional_select . ' usr_data.firstname,
59 usr_data.lastname,
60 ' . self::TABLE_NAME . '.obj_id,
61 (CASE
62 WHEN (trans.title IS NOT NULL AND LENGTH(trans.title) > 0) THEN trans.title
63 WHEN (object_data.title IS NOT NULL AND LENGTH(object_data.title) > 0) THEN object_data.title
64 WHEN (object_data_del.title IS NOT NULL AND LENGTH(object_data_del.title) > 0) THEN object_data_del.title
65 ELSE ' . $this->
database->quote($this->defaultTitle,
'text') .
'
66 END
67 ) as title,
68 (CASE
69 WHEN (trans.description IS NOT NULL AND LENGTH(trans.description) > 0) THEN trans.description
70 WHEN (object_data.description IS NOT NULL AND LENGTH(object_data.description) > 0) THEN object_data.description
71 WHEN (object_data_del.description IS NOT NULL AND LENGTH(object_data_del.description) > 0) THEN object_data_del.description
72 ELSE ""
73 END
74 ) as description
75FROM ' . self::TABLE_NAME . '
76LEFT JOIN object_data ON object_data.obj_id = ' . self::TABLE_NAME . '.obj_id
77LEFT JOIN object_translation trans ON trans.obj_id = object_data.obj_id
78AND trans.lang_code = ' . $this->
database->quote(
$params[
'language'],
'text') .
'
79LEFT JOIN object_data_del ON object_data_del.obj_id = ' . self::TABLE_NAME . '.obj_id
80LEFT JOIN usr_data ON usr_data.usr_id = ' . self::TABLE_NAME . '.usr_id
81WHERE ' . self::TABLE_NAME .
'.usr_id = ' . $this->
database->quote($userId,
'integer') .
' AND currently_active = 1';
82
85 }
86
88 if (!is_numeric(
$params[
'limit'])) {
89 throw new InvalidArgumentException('Please provide a valid numerical limit.');
90 }
91
92 if (!isset(
$params[
'offset'])) {
94 } elseif (!is_numeric(
$params[
'offset'])) {
95 throw new InvalidArgumentException('Please provide a valid numerical offset.');
96 }
97
99 }
100
101 $query = $this->
database->query($sql);
102
104 'items' => [],
105 ];
106
107 while ($row = $this->
database->fetchAssoc($query)) {
108 $title = $row['title'];
109
111 'id' => (
int) $row[
'id'],
112 'title' => $title,
113 'obj_id' => (int) $row['obj_id'],
114 'obj_type' => $row['obj_type'],
115 'date' => (
int) $row[
'acquired_timestamp'],
116 'tile_image_path' => $row['tile_image_path'] ?? '',
117 'tile_image_ident' => $row['tile_image_ident'],
118 'description' => $row['description'],
119 'firstname' => $row['firstname'],
120 'lastname' => $row['lastname'],
121 ];
122 }
123
125 $cnt_sql = '
126 SELECT COUNT(*) cnt
127 FROM ' . self::TABLE_NAME . '
128 WHERE usr_id = ' . $this->
database->quote($userId,
'integer') .
' AND currently_active = 1';
129
131
132 $data[
'cnt'] = (
int) $row_cnt[
'cnt'];
133
135 sprintf(
136 'All active certificates for user: "%s" total: "%s"',
137 $userId,
139 )
140 );
141 } else {
143 }
144
145 $this->
logger->debug(sprintf(
'END - Actual results: "%s"', json_encode(
$data, JSON_THROW_ON_ERROR)));
146
148 }
getOrderByPart(array $params, array $filter)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params