67 {
68 $this->logger->info(sprintf('START - Fetching all active certificates for user: "%s"', $userId));
69
70 $sql = 'SELECT
71 il_cert_user_cert.id,
72 il_cert_user_cert.obj_type,
73 il_cert_user_cert.thumbnail_image_path,
74 il_cert_user_cert.acquired_timestamp,
75 usr_data.firstname,
76 usr_data.lastname,
77 il_cert_user_cert.obj_id,
78 (CASE WHEN (object_data.title IS NULL OR LENGTH(object_data.title) = 0)
79 THEN
80 CASE WHEN (object_data_del.title IS NULL OR LENGTH(object_data_del.title) = 0)
81 THEN ' . $this->database->quote($this->defaultTitle, 'text') . '
82 ELSE object_data_del.title
83 END
84 ELSE object_data.title
85 END
86 ) as title,
87 (CASE WHEN (object_data.description IS NULL OR LENGTH(object_data.description) = 0)
88 THEN
89 CASE WHEN (object_data_del.description IS NULL OR LENGTH(object_data_del.description) = 0)
90 THEN ""
91 ELSE object_data_del.description
92 END
93 ELSE object_data.description
94 END
95 ) as description
96FROM il_cert_user_cert
97LEFT JOIN object_data ON object_data.obj_id = il_cert_user_cert.obj_id
98LEFT JOIN object_data_del ON object_data_del.obj_id = il_cert_user_cert.obj_id
99LEFT JOIN usr_data ON usr_data.usr_id = il_cert_user_cert.user_id
100WHERE user_id = ' . $this->database->quote($userId, 'integer') . ' AND currently_active = 1';
101
102
105 }
106
108 if (!is_numeric(
$params[
'limit'])) {
109 throw new InvalidArgumentException('Please provide a valid numerical limit.');
110 }
111
112 if (!isset(
$params[
'offset'])) {
114 } else {
115 if (!is_numeric(
$params[
'offset'])) {
116 throw new InvalidArgumentException('Please provide a valid numerical offset.');
117 }
118 }
119
121 }
122
123 $query = $this->database->query($sql);
124
126 'items' => [],
127 'cnt' => 0,
128 ];
129
130 while (
$row = $this->database->fetchAssoc(
$query)) {
132
133 $data[
'items'][] = array(
136 'obj_id' =>
$row[
'obj_id'],
137 'obj_type' =>
$row[
'obj_type'],
138 'date' =>
$row[
'acquired_timestamp'],
139 'thumbnail_image_path' =>
$row[
'thumbnail_image_path'],
140 'description' =>
$row[
'description'],
141 'firstname' =>
$row[
'firstname'],
142 'lastname' =>
$row[
'lastname'],
143 );
144 }
145
147 $cnt_sql = '
148 SELECT COUNT(*) cnt
149 FROM il_cert_user_cert
150 WHERE user_id = ' . $this->database->quote($userId, 'integer') . ' AND currently_active = 1';
151
152 $row_cnt = $this->database->fetchAssoc($this->database->query($cnt_sql));
153
154 $data[
'cnt'] = $row_cnt[
'cnt'];
155
156 $this->logger->info(sprintf(
157 'All active certificates for user: "%s" total: "%s"',
158 $userId,
160 ));
161 } else {
163 }
164
165 $this->logger->debug(sprintf(
'END - Actual results:', json_encode(
$data)));
166
168 }
getOrderByPart(array $params, array $filter)