ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilNotification Class Reference

Class ilNotification. More...

+ Collaboration diagram for ilNotification:

Static Public Member Functions

static hasNotification ($type, $user_id, $id)
 Check notification status for object and user. More...
 
static hasOptOut ($obj_id)
 Is opt out (disable notification) allowed? More...
 
static getNotificationsForObject ($type, $id, $page_id=null, $ignore_threshold=false)
 Get all users for given object. More...
 
static setNotification ($type, $user_id, $id, $status=true)
 Set notification status for object and user. More...
 
static updateNotificationTime ($type, $id, array $user_ids, $page_id=false)
 Update the last mail timestamp for given object and users. More...
 
static removeForObject ($type, $id)
 Remove all notifications for given object. More...
 
static removeForUser ($user_id)
 Remove all notifications for given user. More...
 
static getActivatedNotifications (int $type, int $user_id)
 Get activated notifications of give type for user. More...
 

Data Fields

const TYPE_EXERCISE_SUBMISSION = 1
 
const TYPE_WIKI = 2
 
const TYPE_WIKI_PAGE = 3
 
const TYPE_BLOG = 4
 
const TYPE_DATA_COLLECTION = 5
 
const TYPE_POLL = 6
 
const TYPE_LM_BLOCKED_USERS = 7
 
const TYPE_BOOK = 8
 
const TYPE_LM = 9
 
const TYPE_LM_PAGE = 10
 
const THRESHOLD = 180
 

Detailed Description

Class ilNotification.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Id
class.ilObjExerciseGUI.php 24003 2010-05-26 14:35:42Z akill

@ilCtrl_Calls ilNotification:

Definition at line 15 of file class.ilNotification.php.

Member Function Documentation

◆ getActivatedNotifications()

static ilNotification::getActivatedNotifications ( int  $type,
int  $user_id 
)
static

Get activated notifications of give type for user.

Parameters
int$type
int$user_id
Returns
int[]

Definition at line 309 of file class.ilNotification.php.

309 : array
310 {
311 global $DIC;
312
313 $db = $DIC->database();
314
315 $set = $db->queryF(
316 "SELECT id FROM notification " .
317 " WHERE type = %s " .
318 " AND user_id = %s " .
319 " AND activated = %s ",
320 array("integer", "integer", "integer"),
321 array($type, $user_id, 1)
322 );
323 $ids = [];
324 while ($rec = $db->fetchAssoc($set)) {
325 $ids[] = $rec["id"];
326 }
327
328 return $ids;
329 }
$type
$DIC
Definition: xapitoken.php:46

References $DIC, and $type.

Referenced by ilExcTutorRepository\getExerciseIdsBeingTutor().

+ Here is the caller graph for this function:

◆ getNotificationsForObject()

static ilNotification::getNotificationsForObject (   $type,
  $id,
  $page_id = null,
  $ignore_threshold = false 
)
static

Get all users for given object.

Parameters
int$type
int$id
int$page_id
bool$ignore_threshold
Returns
array

Definition at line 122 of file class.ilNotification.php.

123 {
124 global $DIC;
125
126 $ilDB = $DIC->database();
127 $tree = $DIC->repositoryTree();
128
129 include_once("./Services/Notification/classes/class.ilObjNotificationSettings.php");
130
131 // currently done for blog
132 $recipients = array();
133 $setting = new ilObjNotificationSettings($id);
135 foreach (ilObject::_getAllReferences($id) as $ref_id) {
136 $grp_ref_id = $tree->checkForParentType($ref_id, 'grp');
137 if ($grp_ref_id > 0) {
138 include_once("./Modules/Group/classes/class.ilGroupParticipants.php");
140 foreach ($p->getMembers() as $user_id) {
141 if (!in_array($user_id, $recipients)) {
142 $recipients[$user_id] = $user_id;
143 }
144 }
145 }
146 $crs_ref_id = $tree->checkForParentType($ref_id, 'crs');
147 if ($crs_ref_id > 0) {
148 include_once("./Modules/Course/classes/class.ilCourseParticipants.php");
150 foreach ($p->getMembers() as $user_id) {
151 if (!in_array($user_id, $recipients)) {
152 $recipients[$user_id] = $user_id;
153 }
154 }
155 }
156 }
157 }
158
159 // remove all users that deactivated the feature
160 if ($setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_OPT_OUT) {
161 $sql = "SELECT user_id FROM notification" .
162 " WHERE type = " . $ilDB->quote($type, "integer") .
163 " AND id = " . $ilDB->quote($id, "integer") .
164 " AND activated = " . $ilDB->quote(0, "integer") .
165 " AND " . $ilDB->in("user_id", $recipients, false, "integer");
166 $set = $ilDB->query($sql);
167 while ($rec = $ilDB->fetchAssoc($set)) {
168 unset($recipients[$rec["user_id"]]);
169 }
170 }
171
172 // remove all users that got a mail
173 if ($setting->getMode() != ilObjNotificationSettings::MODE_DEF_OFF_USER_ACTIVATION && !$ignore_threshold) {
174 $sql = "SELECT user_id FROM notification" .
175 " WHERE type = " . $ilDB->quote($type, "integer") .
176 " AND id = " . $ilDB->quote($id, "integer") .
177 " AND activated = " . $ilDB->quote(1, "integer") .
178 " AND " . $ilDB->in("user_id", $recipients, false, "integer");
179 $sql .= " AND (last_mail > " . $ilDB->quote(date(
180 "Y-m-d H:i:s",
181 strtotime("-" . self::THRESHOLD . "minutes")
182 ), "timestamp");
183 if ($page_id) {
184 $sql .= " AND page_id = " . $ilDB->quote($page_id, "integer");
185 }
186 $sql .= ")";
187
188 $set = $ilDB->query($sql);
189 while ($rec = $ilDB->fetchAssoc($set)) {
190 unset($recipients[$rec["user_id"]]);
191 }
192 }
193
194 // get single subscriptions
195 if ($setting->getMode() != ilObjNotificationSettings::MODE_DEF_ON_NO_OPT_OUT) {
196 $sql = "SELECT user_id FROM notification" .
197 " WHERE type = " . $ilDB->quote($type, "integer") .
198 " AND id = " . $ilDB->quote($id, "integer") .
199 " AND activated = " . $ilDB->quote(1, "integer");
200 if (!$ignore_threshold) {
201 $sql .= " AND (last_mail < " . $ilDB->quote(date(
202 "Y-m-d H:i:s",
203 strtotime("-" . self::THRESHOLD . "minutes")
204 ), "timestamp") .
205 " OR last_mail IS NULL";
206 if ($page_id) {
207 $sql .= " OR page_id <> " . $ilDB->quote($page_id, "integer");
208 }
209 $sql .= ")";
210 }
211 $set = $ilDB->query($sql);
212 while ($row = $ilDB->fetchAssoc($set)) {
213 $recipients[$row["user_id"]] = $row["user_id"];
214 }
215 }
216
217 return $recipients;
218 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Handles general object notification settings, see e.g.
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
global $ilDB

References $DIC, $ilDB, $type, ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilObject\_lookupObjectId(), ilObjNotificationSettings\MODE_DEF_OFF_USER_ACTIVATION, ilObjNotificationSettings\MODE_DEF_ON_NO_OPT_OUT, and ilObjNotificationSettings\MODE_DEF_ON_OPT_OUT.

Referenced by ilExSubmissionBaseGUI\handleNewUpload(), ilExAssTypeWikiTeam\handleNewUpload(), ilExAssignmentReminder\parseGradeReminders(), ilLMPageGUI\processAnswer(), ilLearningModuleNotification\send(), ilObjBlog\sendNotification(), ilWikiUtil\sendNotification(), ilBookCronNotification\sendNotifications(), and ilObjPollGUI\sendNotifications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasNotification()

static ilNotification::hasNotification (   $type,
  $user_id,
  $id 
)
static

Check notification status for object and user.

Parameters
int$type
int$user_id
int$id
Returns
bool

Definition at line 38 of file class.ilNotification.php.

39 {
40 global $DIC;
41
42 $ilDB = $DIC->database();
43 $tree = $DIC->repositoryTree();
44
45 $notification = false;
46
47 include_once("./Services/Notification/classes/class.ilObjNotificationSettings.php");
48 $setting = new ilObjNotificationSettings($id);
50 // check membership, members should be notidifed...
51 foreach (ilObject::_getAllReferences($id) as $ref_id) {
52 $grp_ref_id = $tree->checkForParentType($ref_id, 'grp');
53 if ($grp_ref_id > 0) {
54 include_once("./Modules/Group/classes/class.ilGroupParticipants.php");
55 if (ilGroupParticipants::_isParticipant($grp_ref_id, $user_id)) {
56 $notification = true;
57 }
58 }
59 $crs_ref_id = $tree->checkForParentType($ref_id, 'crs');
60 if ($crs_ref_id > 0) {
61 include_once("./Modules/Course/classes/class.ilCourseParticipants.php");
62 if (ilCourseParticipants::_isParticipant($crs_ref_id, $user_id)) {
63 $notification = true;
64 }
65 }
66 }
67
68 if ($notification && $setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_OPT_OUT) {
69 $set = $ilDB->query("SELECT user_id FROM notification" .
70 " WHERE type = " . $ilDB->quote($type, "integer") .
71 " AND user_id = " . $ilDB->quote($user_id, "integer") .
72 " AND id = " . $ilDB->quote($id, "integer") .
73 " AND activated = " . $ilDB->quote(0, "integer"));
74 $rec = $ilDB->fetchAssoc($set);
75 // ... except when the opted out
76 if ($rec["user_id"] == $user_id) {
77 return false;
78 }
79 return true;
80 }
81
82 if ($notification && $setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_NO_OPT_OUT) {
83 return true;
84 }
85 }
86
87
88 $set = $ilDB->query("SELECT user_id FROM notification" .
89 " WHERE type = " . $ilDB->quote($type, "integer") .
90 " AND user_id = " . $ilDB->quote($user_id, "integer") .
91 " AND id = " . $ilDB->quote($id, "integer") .
92 " AND activated = " . $ilDB->quote(1, "integer"));
93
94 return (bool) $ilDB->numRows($set);
95 }
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.

References $DIC, $ilDB, $type, ilObject\_getAllReferences(), ilGroupParticipants\_isParticipant(), ilParticipants\_isParticipant(), ilObjNotificationSettings\MODE_DEF_OFF_USER_ACTIVATION, ilObjNotificationSettings\MODE_DEF_ON_NO_OPT_OUT, and ilObjNotificationSettings\MODE_DEF_ON_OPT_OUT.

Referenced by ilObjDataCollectionGUI\addHeaderAction(), ilLMPresentationGUI\addHeaderAction(), ilWikiPageGUI\addHeaderAction(), ilObjExerciseGUI\getEditFormCustomValues(), ilPollBlockGUI\getHTML(), ilObjContentObjectGUI\getPropertiesFormValues(), ilObjBookingPoolGUI\initHeaderAction(), and ilObjBlogGUI\initHeaderAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasOptOut()

static ilNotification::hasOptOut (   $obj_id)
static

Is opt out (disable notification) allowed?

Parameters
int$obj_id
Returns
bool

Definition at line 103 of file class.ilNotification.php.

104 {
105 include_once("./Services/Notification/classes/class.ilObjNotificationSettings.php");
106 $setting = new ilObjNotificationSettings($obj_id);
107 if ($setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_NO_OPT_OUT) {
108 return false;
109 }
110 return true;
111 }

References ilObjNotificationSettings\MODE_DEF_ON_NO_OPT_OUT.

Referenced by ilLMPresentationGUI\addHeaderAction(), ilWikiPageGUI\addHeaderAction(), and ilObjBlogGUI\initHeaderAction().

+ Here is the caller graph for this function:

◆ removeForObject()

static ilNotification::removeForObject (   $type,
  $id 
)
static

Remove all notifications for given object.

Parameters
int$type
int$id

Definition at line 276 of file class.ilNotification.php.

277 {
278 global $DIC;
279
280 $ilDB = $DIC->database();
281
282 $ilDB->query("DELETE FROM notification" .
283 " WHERE type = " . $ilDB->quote($type, "integer") .
284 " AND id = " . $ilDB->quote($id, "integer"));
285 }

References $DIC, $ilDB, and $type.

Referenced by ilObjExercise\delete(), ilObjWiki\delete(), ilWikiPage\delete(), and ilObjBlog\doDelete().

+ Here is the caller graph for this function:

◆ removeForUser()

static ilNotification::removeForUser (   $user_id)
static

Remove all notifications for given user.

Parameters
int$user_id

Definition at line 292 of file class.ilNotification.php.

293 {
294 global $DIC;
295
296 $ilDB = $DIC->database();
297
298 $ilDB->query("DELETE FROM notification" .
299 " WHERE user_id = " . $ilDB->quote($user_id, "integer"));
300 }

References $DIC, and $ilDB.

Referenced by ilObjUser\delete().

+ Here is the caller graph for this function:

◆ setNotification()

static ilNotification::setNotification (   $type,
  $user_id,
  $id,
  $status = true 
)
static

Set notification status for object and user.

Parameters
int$type
int$user_id
int$id
bool$status

Definition at line 228 of file class.ilNotification.php.

229 {
230 global $DIC;
231
232 $ilDB = $DIC->database();
233
234 $fields = array(
235 "type" => array("integer", $type),
236 "user_id" => array("integer", $user_id),
237 "id" => array("integer", $id)
238 );
239 $ilDB->replace("notification", $fields, array("activated" => array("integer", (int) $status)));
240 }

References $DIC, $ilDB, and $type.

Referenced by ilLMPresentationGUI\executeCommand(), ilWikiPageGUI\executeCommand(), ilObjBookingPoolGUI\saveNotificationObject(), ilObjContentObjectGUI\saveProperties(), ilObjBlogGUI\setNotification(), ilObjPollGUI\subscribe(), ilObjBibliographicGUI\toggleNotification(), ilObjDataCollectionGUI\toggleNotification(), ilObjPollGUI\unsubscribe(), and ilObjExerciseGUI\updateCustom().

+ Here is the caller graph for this function:

◆ updateNotificationTime()

static ilNotification::updateNotificationTime (   $type,
  $id,
array  $user_ids,
  $page_id = false 
)
static

Update the last mail timestamp for given object and users.

Parameters
int$type
int$id
array$user_ids
int$page_id

Definition at line 250 of file class.ilNotification.php.

251 {
252 global $DIC;
253
254 $ilDB = $DIC->database();
255
256 $sql = "UPDATE notification" .
257 " SET last_mail = " . $ilDB->quote(date("Y-m-d H:i:s"), "timestamp");
258
259 if ($page_id) {
260 $sql .= ", page_id = " . $ilDB->quote($page_id, "integer");
261 }
262
263 $sql .= " WHERE type = " . $ilDB->quote($type, "integer") .
264 " AND id = " . $ilDB->quote($id, "integer") .
265 " AND " . $ilDB->in("user_id", $user_ids, false, "integer");
266
267 $ilDB->query($sql);
268 }

References $DIC, $ilDB, and $type.

Referenced by ilLearningModuleNotification\send(), ilObjBlog\sendNotification(), ilWikiUtil\sendNotification(), and ilObjPollGUI\sendNotifications().

+ Here is the caller graph for this function:

Field Documentation

◆ THRESHOLD

const ilNotification::THRESHOLD = 180

Definition at line 28 of file class.ilNotification.php.

◆ TYPE_BLOG

const ilNotification::TYPE_BLOG = 4

◆ TYPE_BOOK

◆ TYPE_DATA_COLLECTION

const ilNotification::TYPE_DATA_COLLECTION = 5

◆ TYPE_EXERCISE_SUBMISSION

◆ TYPE_LM

◆ TYPE_LM_BLOCKED_USERS

const ilNotification::TYPE_LM_BLOCKED_USERS = 7

◆ TYPE_LM_PAGE

◆ TYPE_POLL

const ilNotification::TYPE_POLL = 6

◆ TYPE_WIKI

◆ TYPE_WIKI_PAGE


The documentation for this class was generated from the following file: