ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  {
122  return $this->notification_id;
123  }
124 
125  public function setNotificationId(int $notification_id): void
126  {
127  $this->notification_id = $notification_id;
128  }
129 }
static returnDbTableName()
static hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
static array $request_cache
static dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isUserAllowedToDismiss(ilObjUser $user)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setUsrId(int $usr_id)
int $usr_id
true integer 8
int $id
true true true integer 8 true
int $notification_id
true integer 8
setNotificationId(int $notification_id)