ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADNDismiss.php
Go to the documentation of this file.
1<?php
2
25{
26 public const TABLE_NAME = 'il_adn_dismiss';
27
28 #[\Override]
29 public function getConnectorContainerName(): string
30 {
31 return self::TABLE_NAME;
32 }
33
37 public static function returnDbTableName(): string
38 {
39 return self::TABLE_NAME;
40 }
41
42 protected static array $request_cache = [];
43
44 public static function hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification): bool
45 {
46 $not_id = $ilADNNotification->getId();
47 $usr_id = $ilObjUser->getId();
48 if (!isset(self::$request_cache[$usr_id][$not_id])) {
49 self::$request_cache[$usr_id][$not_id] = self::where([
50 'usr_id' => $usr_id,
51 'notification_id' => $not_id,
52 ])->hasSets();
53 }
54
55 return (bool) self::$request_cache[$usr_id][$not_id];
56 }
57
58 public static function dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification): void
59 {
60 if (!self::hasDimissed($ilObjUser, $ilADNNotification) && $ilADNNotification->isUserAllowedToDismiss($ilObjUser)) {
61 $obj = new self();
62 $obj->setNotificationId($ilADNNotification->getId());
63 $obj->setUsrId($ilObjUser->getId());
64 $obj->create();
65 }
66 }
67
68 public static function reactivateAll(ilADNNotification $ilADNNotification): void
69 {
73 foreach (self::where(['notification_id' => $ilADNNotification->getId()]) as $dismiss) {
74 $dismiss->delete();
75 }
76 }
77
86 protected ?int $id = null;
92 protected int $usr_id = 0;
98 protected int $notification_id = 0;
99
100 public function getId(): ?int
101 {
102 return $this->id;
103 }
104
105 public function setId(int $id): void
106 {
107 $this->id = $id;
108 }
109
110 public function getUsrId(): int
111 {
112 return $this->usr_id;
113 }
114
115 public function setUsrId(int $usr_id): void
116 {
117 $this->usr_id = $usr_id;
118 }
119
120 public function getNotificationId(): int
121 {
123 }
124
125 public function setNotificationId(int $notification_id): void
126 {
127 $this->notification_id = $notification_id;
128 }
129}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
int $usr_id
@con_has_field true @con_fieldtype integer @con_length 8
int $notification_id
@con_has_field true @con_fieldtype integer @con_length 8
getConnectorContainerName()
@description Return the Name of your Connector Table
static dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
static array $request_cache
setUsrId(int $usr_id)
static returnDbTableName()
static hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
int $id
@con_is_primary true @con_is_unique true @con_has_field true @con_fieldtype integer @con_length 8 @co...
setNotificationId(int $notification_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isUserAllowedToDismiss(ilObjUser $user)
User class.