ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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 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

◆ 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 119 of file class.ilNotification.php.

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

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

Referenced by ilExSubmissionBaseGUI\handleNewUpload(), ilLMPageGUI\processAnswer(), ilObjBlog\sendNotification(), ilWikiUtil\sendNotification(), 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 35 of file class.ilNotification.php.

36 {
37 global $DIC;
38
39 $ilDB = $DIC->database();
40 $tree = $DIC->repositoryTree();
41
42 $notification = false;
43
44 include_once("./Services/Notification/classes/class.ilObjNotificationSettings.php");
45 $setting = new ilObjNotificationSettings($id);
47 // check membership, members should be notidifed...
48 foreach (ilObject::_getAllReferences($id) as $ref_id) {
49 $grp_ref_id = $tree->checkForParentType($ref_id, 'grp');
50 if ($grp_ref_id > 0) {
51 include_once("./Modules/Group/classes/class.ilGroupParticipants.php");
52 if (ilGroupParticipants::_isParticipant($grp_ref_id, $user_id)) {
53 $notification = true;
54 }
55 }
56 $crs_ref_id = $tree->checkForParentType($ref_id, 'crs');
57 if ($crs_ref_id > 0) {
58 include_once("./Modules/Course/classes/class.ilCourseParticipants.php");
59 if (ilCourseParticipants::_isParticipant($crs_ref_id, $user_id)) {
60 $notification = true;
61 }
62 }
63 }
64
65 if ($notification && $setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_OPT_OUT) {
66 $set = $ilDB->query("SELECT user_id FROM notification" .
67 " WHERE type = " . $ilDB->quote($type, "integer") .
68 " AND user_id = " . $ilDB->quote($user_id, "integer") .
69 " AND id = " . $ilDB->quote($id, "integer") .
70 " AND activated = " . $ilDB->quote(0, "integer"));
71 $rec = $ilDB->fetchAssoc($set);
72 // ... except when the opted out
73 if ($rec["user_id"] == $user_id) {
74 return false;
75 }
76 return true;
77 }
78
79 if ($notification && $setting->getMode() == ilObjNotificationSettings::MODE_DEF_ON_NO_OPT_OUT) {
80 return true;
81 }
82 }
83
84
85 $set = $ilDB->query("SELECT user_id FROM notification" .
86 " WHERE type = " . $ilDB->quote($type, "integer") .
87 " AND user_id = " . $ilDB->quote($user_id, "integer") .
88 " AND id = " . $ilDB->quote($id, "integer") .
89 " AND activated = " . $ilDB->quote(1, "integer"));
90
91 return (bool) $ilDB->numRows($set);
92 }
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, $id, $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(), ilWikiPageGUI\addHeaderAction(), ilObjExerciseGUI\getEditFormCustomValues(), ilPollBlockGUI\getHTML(), ilObjContentObjectGUI\getPropertiesFormValues(), 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 100 of file class.ilNotification.php.

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

References ilObjNotificationSettings\MODE_DEF_ON_NO_OPT_OUT.

Referenced by 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 273 of file class.ilNotification.php.

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

References $DIC, $id, $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 289 of file class.ilNotification.php.

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

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 225 of file class.ilNotification.php.

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

References $DIC, $id, $ilDB, and $type.

Referenced by ilWikiPageGUI\executeCommand(), 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 247 of file class.ilNotification.php.

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

References $DIC, $id, $ilDB, $type, and date.

Referenced by 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 25 of file class.ilNotification.php.

◆ TYPE_BLOG

const ilNotification::TYPE_BLOG = 4

◆ TYPE_DATA_COLLECTION

const ilNotification::TYPE_DATA_COLLECTION = 5

◆ TYPE_EXERCISE_SUBMISSION

const ilNotification::TYPE_EXERCISE_SUBMISSION = 1

◆ TYPE_LM_BLOCKED_USERS

const ilNotification::TYPE_LM_BLOCKED_USERS = 7

◆ TYPE_POLL

const ilNotification::TYPE_POLL = 6

◆ TYPE_WIKI

◆ TYPE_WIKI_PAGE


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