ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 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 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

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

References $row.

Referenced by ilObjDataCollection\sendNotification(), ilObjBlog\sendNotification(), ilWikiUtil\sendNotification(), and ilObjExerciseGUI\sendNotifications().

54  {
55  global $ilDB;
56 
57  $sql = "SELECT user_id FROM notification".
58  " WHERE type = ".$ilDB->quote($type, "integer").
59  " AND id = ".$ilDB->quote($id, "integer");
60  if(!$ignore_threshold)
61  {
62  $sql .= " AND (last_mail < ".$ilDB->quote(date("Y-m-d H:i:s",
63  strtotime("-".self::THRESHOLD."minutes")), "timestamp").
64  " OR last_mail IS NULL";
65  if($page_id)
66  {
67  $sql .= " OR page_id <> ".$ilDB->quote($page_id, "integer");
68  }
69  $sql .= ")";
70  }
71  $user = array();
72  $set = $ilDB->query($sql);
73  while($row = $ilDB->fetchAssoc($set))
74  {
75  $user[] = $row["user_id"];
76  }
77  return $user;
78  }
+ 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 33 of file class.ilNotification.php.

Referenced by ilWikiPageGUI\addHeaderAction(), ilObjBibliographicGUI\addHeaderAction(), ilObjDataCollectionGUI\addHeaderAction(), ilObjExerciseGUI\getEditFormCustomValues(), and ilObjBlogGUI\initHeaderAction().

34  {
35  global $ilDB;
36 
37  $set = $ilDB->query("SELECT user_id FROM notification".
38  " WHERE type = ".$ilDB->quote($type, "integer").
39  " AND user_id = ".$ilDB->quote($user_id, "integer").
40  " AND id = ".$ilDB->quote($id, "integer"));
41  return (bool)$ilDB->numRows($set);
42  }
+ 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 144 of file class.ilNotification.php.

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

145  {
146  global $ilDB;
147 
148  $ilDB->query("DELETE FROM notification".
149  " WHERE type = ".$ilDB->quote($type, "integer").
150  " AND id = ".$ilDB->quote($id, "integer"));
151  }
+ 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 158 of file class.ilNotification.php.

Referenced by ilObjUser\delete().

159  {
160  global $ilDB;
161 
162  $ilDB->query("DELETE FROM notification".
163  " WHERE user_id = ".$ilDB->quote($user_id, "integer"));
164  }
+ 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
Returns
bool

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

Referenced by ilWikiPageGUI\executeCommand(), ilObjBlogGUI\setNotification(), ilObjBibliographicGUI\toggleNotification(), ilObjDataCollectionGUI\toggleNotification(), and ilObjExerciseGUI\updateCustom().

90  {
91  global $ilDB;
92 
93  if(!$status)
94  {
95  $ilDB->query("DELETE FROM notification".
96  " WHERE type = ".$ilDB->quote($type, "integer").
97  " AND user_id = ".$ilDB->quote($user_id, "integer").
98  " AND id = ".$ilDB->quote($id, "integer"));
99  }
100  else
101  {
102  $fields = array(
103  "type" => array("integer", $type),
104  "user_id" => array("integer", $user_id),
105  "id" => array("integer", $id)
106  );
107  $ilDB->replace("notification", $fields, array());
108  }
109  }
+ 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 119 of file class.ilNotification.php.

Referenced by ilObjDataCollection\sendNotification(), ilObjBlog\sendNotification(), and ilWikiUtil\sendNotification().

120  {
121  global $ilDB;
122 
123  $sql = "UPDATE notification".
124  " SET last_mail = ".$ilDB->quote(date("Y-m-d H:i:s"), "timestamp");
125 
126  if($page_id)
127  {
128  $sql .= ", page_id = ".$ilDB->quote($page_id, "integer");
129  }
130 
131  $sql .= " WHERE type = ".$ilDB->quote($type, "integer").
132  " AND id = ".$ilDB->quote($id, "integer").
133  " AND ".$ilDB->in("user_id", $user_ids, false, "integer");
134 
135  $ilDB->query($sql);
136  }
+ Here is the caller graph for this function:

Field Documentation

◆ THRESHOLD

const ilNotification::THRESHOLD = 180

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

◆ TYPE_BLOG

const ilNotification::TYPE_BLOG = 4

◆ TYPE_DATA_COLLECTION

◆ TYPE_EXERCISE_SUBMISSION

const ilNotification::TYPE_EXERCISE_SUBMISSION = 1

◆ TYPE_WIKI

◆ TYPE_WIKI_PAGE


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