19 declare(strict_types=1);
48 $this->
logger->debug(sprintf(
'START - Fetching all active certificates for user: "%s"', $userId));
52 il_cert_user_cert.obj_type, 53 il_cert_user_cert.thumbnail_image_path, 54 il_cert_user_cert.acquired_timestamp, 57 il_cert_user_cert.obj_id, 59 WHEN (trans.title IS NOT NULL AND LENGTH(trans.title) > 0) THEN trans.title 60 WHEN (object_data.title IS NOT NULL AND LENGTH(object_data.title) > 0) THEN object_data.title 61 WHEN (object_data_del.title IS NOT NULL AND LENGTH(object_data_del.title) > 0) THEN object_data_del.title 62 ELSE ' . $this->database->quote($this->defaultTitle,
'text') .
' 66 WHEN (trans.description IS NOT NULL AND LENGTH(trans.description) > 0) THEN trans.description 67 WHEN (object_data.description IS NOT NULL AND LENGTH(object_data.description) > 0) THEN object_data.description 68 WHEN (object_data_del.description IS NOT NULL AND LENGTH(object_data_del.description) > 0) THEN object_data_del.description 72 FROM il_cert_user_cert 73 LEFT JOIN object_data ON object_data.obj_id = il_cert_user_cert.obj_id 74 LEFT JOIN object_translation trans ON trans.obj_id = object_data.obj_id 75 AND trans.lang_code = ' . $this->database->quote($params[
'language'],
'text') .
' 76 LEFT JOIN object_data_del ON object_data_del.obj_id = il_cert_user_cert.obj_id 77 LEFT JOIN usr_data ON usr_data.usr_id = il_cert_user_cert.usr_id 78 WHERE il_cert_user_cert.usr_id = ' . $this->database->quote($userId,
'integer') .
' AND currently_active = 1';
84 if (isset($params[
'limit'])) {
85 if (!is_numeric($params[
'limit'])) {
89 if (!isset($params[
'offset'])) {
90 $params[
'offset'] = 0;
91 } elseif (!is_numeric($params[
'offset'])) {
95 $this->database->setLimit($params[
'limit'], $params[
'offset']);
98 $query = $this->database->query($sql);
104 while ($row = $this->database->fetchAssoc(
$query)) {
105 $title = $row[
'title'];
108 'id' => (
int) $row[
'id'],
110 'obj_id' => (
int) $row[
'obj_id'],
111 'obj_type' => $row[
'obj_type'],
112 'date' => (
int) $row[
'acquired_timestamp'],
113 'thumbnail_image_path' => $row[
'thumbnail_image_path'],
114 'description' => $row[
'description'],
115 'firstname' => $row[
'firstname'],
116 'lastname' => $row[
'lastname'],
120 if (isset($params[
'limit'])) {
123 FROM il_cert_user_cert 124 WHERE usr_id = ' . $this->database->quote($userId,
'integer') .
' AND currently_active = 1';
126 $row_cnt = $this->database->fetchAssoc($this->database->query($cnt_sql));
128 $data[
'cnt'] = (
int) $row_cnt[
'cnt'];
130 $this->
logger->debug(sprintf(
131 'All active certificates for user: "%s" total: "%s"',
139 $this->
logger->debug(sprintf(
'END - Actual results: "%s"', json_encode(
$data, JSON_THROW_ON_ERROR)));
146 if (isset($params[
'order_field'])) {
147 if (!is_string($params[
'order_field'])) {
151 if (!in_array($params[
'order_field'], [
'date',
'id',
'title'])) {
155 if ($params[
'order_field'] ===
'date') {
156 $params[
'order_field'] =
'acquired_timestamp';
159 if (!isset($params[
'order_direction'])) {
160 $params[
'order_direction'] =
'ASC';
161 } elseif (!in_array(strtolower($params[
'order_direction']), [
'asc',
'desc'])) {
165 return ' ORDER BY ' . $params[
'order_field'] .
' ' . $params[
'order_direction'];
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
getOrderByPart(array $params, array $filter)
fetchDataSet(int $userId, array $params, array $filter)
__construct(ilDBInterface $database, ilLogger $logger, string $defaultTitle)