ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADNDismiss.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
11  const TABLE_NAME = 'il_adn_dismiss';
12 
16  public function getConnectorContainerName()
17  {
18  return self::TABLE_NAME;
19  }
20 
25  public static function returnDbTableName()
26  {
27  return self::TABLE_NAME;
28  }
29 
33  protected static $request_cache = array();
34 
40  public static function hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification) : bool
41  {
42  $not_id = $ilADNNotification->getId();
43  $usr_id = $ilObjUser->getId();
44  if (!isset(self::$request_cache[$usr_id][$not_id])) {
45  self::$request_cache[$usr_id][$not_id] = self::where(array(
46  'usr_id' => $usr_id,
47  'notification_id' => $not_id,
48  ))->hasSets();
49  }
50 
51  return (bool) self::$request_cache[$usr_id][$not_id];
52  }
53 
58  public static function dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification) : void
59  {
60  if (!self::hasDimissed($ilObjUser, $ilADNNotification) and $ilADNNotification->isUserAllowedToDismiss($ilObjUser)) {
61  $obj = new self();
62  $obj->setNotificationId($ilADNNotification->getId());
63  $obj->setUsrId($ilObjUser->getId());
64  $obj->create();
65  }
66  }
67 
71  public static function reactivateAll(ilADNNotification $ilADNNotification) : void
72  {
76  foreach (self::where(array('notification_id' => $ilADNNotification->getId())) as $dismiss) {
77  $dismiss->delete();
78  }
79  }
80 
90  protected $id = 0;
97  protected $usr_id = 0;
104  protected $notification_id = 0;
105 
109  public function getId()
110  {
111  return $this->id;
112  }
113 
117  public function setId($id)
118  {
119  $this->id = $id;
120  }
121 
125  public function getUsrId()
126  {
127  return $this->usr_id;
128  }
129 
133  public function setUsrId($usr_id)
134  {
135  $this->usr_id = $usr_id;
136  }
137 
141  public function getNotificationId()
142  {
143  return $this->notification_id;
144  }
145 
150  {
151  $this->notification_id = $notification_id;
152  }
153 }
static returnDbTableName()
static hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
static dismiss(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
setNotificationId($notification_id)
Class ilADNDismiss.
getId()
get object id public
isUserAllowedToDismiss(ilObjUser $ilUser)