ILIAS  release_8 Revision v8.24
class.ilADNDismiss.php
Go to the documentation of this file.
1<?php
2
25{
26 public const TABLE_NAME = 'il_adn_dismiss';
27
28 public function getConnectorContainerName(): string
29 {
30 return self::TABLE_NAME;
31 }
32
36 public static function returnDbTableName(): string
37 {
38 return self::TABLE_NAME;
39 }
40
41 protected static array $request_cache = array();
42
43 public static function hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification): bool
44 {
45 $not_id = $ilADNNotification->getId();
46 $usr_id = $ilObjUser->getId();
47 if (!isset(self::$request_cache[$usr_id][$not_id])) {
48 self::$request_cache[$usr_id][$not_id] = self::where(array(
49 'usr_id' => $usr_id,
50 'notification_id' => $not_id,
51 ))->hasSets();
52 }
53
54 return (bool) self::$request_cache[$usr_id][$not_id];
55 }
56
57 public static function dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification): void
58 {
59 if (!self::hasDimissed($ilObjUser, $ilADNNotification) && $ilADNNotification->isUserAllowedToDismiss($ilObjUser)) {
60 $obj = new self();
61 $obj->setNotificationId($ilADNNotification->getId());
62 $obj->setUsrId($ilObjUser->getId());
63 $obj->create();
64 }
65 }
66
67 public static function reactivateAll(ilADNNotification $ilADNNotification): void
68 {
72 foreach (self::where(array('notification_id' => $ilADNNotification->getId())) as $dismiss) {
73 $dismiss->delete();
74 }
75 }
76
85 protected ?int $id = null;
91 protected int $usr_id = 0;
97 protected int $notification_id = 0;
98
99 public function getId(): ?int
100 {
101 return $this->id;
102 }
103
104 public function setId(int $id): void
105 {
106 $this->id = $id;
107 }
108
109 public function getUsrId(): int
110 {
111 return $this->usr_id;
112 }
113
114 public function setUsrId(int $usr_id): void
115 {
116 $this->usr_id = $usr_id;
117 }
118
119 public function getNotificationId(): int
120 {
122 }
123
124 public function setNotificationId(int $notification_id): void
125 {
126 $this->notification_id = $notification_id;
127 }
128}
Class ActiveRecord.
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.