40 $ilDB = $DIC->database();
41 $tree = $DIC->repositoryTree();
43 $notification =
false;
45 include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
50 $grp_ref_id =
$tree->checkForParentType($ref_id,
'grp');
51 if ($grp_ref_id > 0) {
52 include_once(
"./Modules/Group/classes/class.ilGroupParticipants.php");
57 $crs_ref_id =
$tree->checkForParentType($ref_id,
'crs');
58 if ($crs_ref_id > 0) {
59 include_once(
"./Modules/Course/classes/class.ilCourseParticipants.php");
67 $set =
$ilDB->query(
"SELECT user_id FROM notification" .
68 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
69 " AND user_id = " .
$ilDB->quote($user_id,
"integer") .
70 " AND id = " .
$ilDB->quote(
$id,
"integer") .
71 " AND activated = " .
$ilDB->quote(0,
"integer"));
72 $rec =
$ilDB->fetchAssoc($set);
74 if ($rec[
"user_id"] == $user_id) {
86 $set =
$ilDB->query(
"SELECT user_id FROM notification" .
87 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
88 " AND user_id = " .
$ilDB->quote($user_id,
"integer") .
89 " AND id = " .
$ilDB->quote(
$id,
"integer") .
90 " AND activated = " .
$ilDB->quote(1,
"integer"));
92 return (
bool)
$ilDB->numRows($set);
103 include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
124 $ilDB = $DIC->database();
125 $tree = $DIC->repositoryTree();
127 include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
130 $recipients = array();
134 $grp_ref_id =
$tree->checkForParentType($ref_id,
'grp');
135 if ($grp_ref_id > 0) {
136 include_once(
"./Modules/Group/classes/class.ilGroupParticipants.php");
138 foreach ($p->getMembers() as $user_id) {
139 if (!in_array($user_id, $recipients)) {
140 $recipients[$user_id] = $user_id;
144 $crs_ref_id =
$tree->checkForParentType($ref_id,
'crs');
145 if ($crs_ref_id > 0) {
146 include_once(
"./Modules/Course/classes/class.ilCourseParticipants.php");
148 foreach ($p->getMembers() as $user_id) {
149 if (!in_array($user_id, $recipients)) {
150 $recipients[$user_id] = $user_id;
159 $sql =
"SELECT user_id FROM notification" .
160 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
161 " AND id = " .
$ilDB->quote(
$id,
"integer") .
162 " AND activated = " .
$ilDB->quote(0,
"integer") .
163 " AND " .
$ilDB->in(
"user_id", $recipients,
false,
"integer");
164 $set =
$ilDB->query($sql);
165 while ($rec =
$ilDB->fetchAssoc($set)) {
166 unset($recipients[$rec[
"user_id"]]);
172 $sql =
"SELECT user_id FROM notification" .
173 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
174 " AND id = " .
$ilDB->quote(
$id,
"integer") .
175 " AND activated = " .
$ilDB->quote(1,
"integer") .
176 " AND " .
$ilDB->in(
"user_id", $recipients,
false,
"integer");
177 $sql .=
" AND (last_mail > " .
$ilDB->quote(date(
179 strtotime(
"-" . self::THRESHOLD .
"minutes")
182 $sql .=
" AND page_id = " .
$ilDB->quote($page_id,
"integer");
186 $set =
$ilDB->query($sql);
187 while ($rec =
$ilDB->fetchAssoc($set)) {
188 unset($recipients[$rec[
"user_id"]]);
194 $sql =
"SELECT user_id FROM notification" .
195 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
196 " AND id = " .
$ilDB->quote(
$id,
"integer") .
197 " AND activated = " .
$ilDB->quote(1,
"integer");
198 if (!$ignore_threshold) {
199 $sql .=
" AND (last_mail < " .
$ilDB->quote(date(
201 strtotime(
"-" . self::THRESHOLD .
"minutes")
203 " OR last_mail IS NULL";
205 $sql .=
" OR page_id <> " .
$ilDB->quote($page_id,
"integer");
209 $set =
$ilDB->query($sql);
211 $recipients[
$row[
"user_id"]] = $row[
"user_id"];
230 $ilDB = $DIC->database();
233 "type" => array(
"integer",
$type),
234 "user_id" => array(
"integer", $user_id),
235 "id" => array(
"integer",
$id)
237 $ilDB->replace(
"notification", $fields, array(
"activated" => array(
"integer", (
int) $status)));
252 $ilDB = $DIC->database();
254 $sql =
"UPDATE notification" .
255 " SET last_mail = " .
$ilDB->quote(date(
"Y-m-d H:i:s"),
"timestamp");
258 $sql .=
", page_id = " .
$ilDB->quote($page_id,
"integer");
261 $sql .=
" WHERE type = " .
$ilDB->quote(
$type,
"integer") .
262 " AND id = " .
$ilDB->quote(
$id,
"integer") .
263 " AND " .
$ilDB->in(
"user_id", $user_ids,
false,
"integer");
278 $ilDB = $DIC->database();
280 $ilDB->query(
"DELETE FROM notification" .
281 " WHERE type = " .
$ilDB->quote(
$type,
"integer") .
282 " AND id = " .
$ilDB->quote(
$id,
"integer"));
294 $ilDB = $DIC->database();
296 $ilDB->query(
"DELETE FROM notification" .
297 " WHERE user_id = " .
$ilDB->quote($user_id,
"integer"));
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static removeForObject($type, $id)
Remove all notifications for given object.
const TYPE_LM_BLOCKED_USERS
Handles general object notification settings, see e.g.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
if(!array_key_exists('StateId', $_REQUEST)) $id
static hasOptOut($obj_id)
Is opt out (disable notification) allowed?
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
const MODE_DEF_ON_OPT_OUT
static _getAllReferences($a_id)
get all reference ids of object
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
static _lookupObjectId($a_ref_id)
lookup object id
const TYPE_DATA_COLLECTION
static removeForUser($user_id)
Remove all notifications for given user.
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
const MODE_DEF_OFF_USER_ACTIVATION
const TYPE_EXERCISE_SUBMISSION
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
const MODE_DEF_ON_NO_OPT_OUT