43         $ilDB = $DIC->database();
    44         $tree = $DIC->repositoryTree();
    46         $notification = 
false;
    52                 $grp_ref_id = $tree->checkForParentType(
$ref_id, 
'grp');
    56                 $crs_ref_id = $tree->checkForParentType(
$ref_id, 
'crs');
    63                 $set = 
$ilDB->query(
"SELECT user_id FROM notification" .
    64                     " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
    65                     " AND user_id = " . 
$ilDB->quote($user_id, 
"integer") .
    66                     " AND id = " . 
$ilDB->quote($id, 
"integer") .
    67                     " AND activated = " . 
$ilDB->quote(0, 
"integer"));
    68                 $rec = 
$ilDB->fetchAssoc($set);
    70                 if (!isset($rec[
"user_id"])) {
    74                 return isset($rec[
"user_id"]) && ((
int) $rec[
"user_id"] !== $user_id);
    83         $set = 
$ilDB->query(
"SELECT user_id FROM notification" .
    84             " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
    85             " AND user_id = " . 
$ilDB->quote($user_id, 
"integer") .
    86             " AND id = " . 
$ilDB->quote($id, 
"integer") .
    87             " AND activated = " . 
$ilDB->quote(1, 
"integer"));
    89         return (
bool) 
$ilDB->numRows($set);
   107         ?
int $page_id = null,
   108         bool $ignore_threshold = 
false   112         $ilDB = $DIC->database();
   113         $tree = $DIC->repositoryTree();
   117         $log->debug(
"Get notifications for type " . $type . 
", id " . $id . 
", page_id " . $page_id .
   118             ", ignore threshold " . $ignore_threshold);
   121         $recipients = array();
   125                 $grp_ref_id = $tree->checkForParentType(
$ref_id, 
'grp');
   126                 if ($grp_ref_id > 0) {
   128                     foreach ($p->getMembers() as 
$user_id) {
   129                         if (!in_array(
$user_id, $recipients)) {
   134                 $crs_ref_id = $tree->checkForParentType(
$ref_id, 
'crs');
   135                 if ($crs_ref_id > 0) {
   137                     foreach ($p->getMembers() as 
$user_id) {
   138                         if (!in_array(
$user_id, $recipients)) {
   146         $log->debug(
"Step 1 recipients: " . print_r($recipients, 
true));
   150             $sql = 
"SELECT user_id FROM notification" .
   151                 " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
   152                 " AND id = " . 
$ilDB->quote($id, 
"integer") .
   153                 " AND activated = " . 
$ilDB->quote(0, 
"integer") .
   154                 " AND " . 
$ilDB->in(
"user_id", $recipients, 
false, 
"integer");
   155             $set = 
$ilDB->query($sql);
   156             while ($rec = 
$ilDB->fetchAssoc($set)) {
   157                 unset($recipients[$rec[
"user_id"]]);
   158                 $log->debug(
"Remove due to deactivation: " . $rec[
"user_id"]);
   164             $sql = 
"SELECT user_id FROM notification" .
   165                 " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
   166                 " AND id = " . 
$ilDB->quote($id, 
"integer") .
   167                 " AND activated = " . 
$ilDB->quote(1, 
"integer");
   168             if (!$ignore_threshold) {
   169                 $sql .= 
" AND (last_mail < " . 
$ilDB->quote(date(
   171                     strtotime(
"-" . self::THRESHOLD . 
"minutes")
   173                     " OR last_mail IS NULL";
   175                     $sql .= 
" OR page_id <> " . 
$ilDB->quote($page_id, 
"integer");
   179             $set = 
$ilDB->query($sql);
   180             while ($row = 
$ilDB->fetchAssoc($set)) {
   181                 $recipients[$row[
"user_id"]] = $row[
"user_id"];
   182                 $log->debug(
"Adding single subscription: " . $row[
"user_id"]);
   189         if (!$ignore_threshold) {
   190             $sql = 
"SELECT user_id FROM notification" .
   191                 " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
   192                 " AND id = " . 
$ilDB->quote($id, 
"integer") .
   193                 " AND " . 
$ilDB->in(
"user_id", $recipients, 
false, 
"integer");
   194             $sql .= 
" AND (last_mail > " . 
$ilDB->quote(date(
   196                 strtotime(
"-" . self::THRESHOLD . 
"minutes")
   199                 $sql .= 
" AND page_id = " . 
$ilDB->quote($page_id, 
"integer");
   202             $set = 
$ilDB->query($sql);
   203             while ($rec = 
$ilDB->fetchAssoc($set)) {
   204                 unset($recipients[$rec[
"user_id"]]);
   205                 $log->debug(
"Remove due to got mail: " . $rec[
"user_id"]);
   208             if ($type === self::TYPE_WIKI) {
   209                 $sql = 
"SELECT user_id FROM notification" .
   210                     " WHERE type = " . 
$ilDB->quote(self::TYPE_WIKI_PAGE, 
"integer") .
   211                     " AND id = " . 
$ilDB->quote($page_id, 
"integer") .
   212                     " AND " . 
$ilDB->in(
"user_id", $recipients, 
false, 
"integer");
   213                 $sql .= 
" AND (last_mail > " . 
$ilDB->quote(date(
   215                     strtotime(
"-" . self::THRESHOLD . 
"minutes")
   218                 $set = 
$ilDB->query($sql);
   219                 while ($rec = 
$ilDB->fetchAssoc($set)) {
   220                     unset($recipients[$rec[
"user_id"]]);
   221                     $log->debug(
"Remove due to got mail: " . $rec[
"user_id"]);
   241         $ilDB = $DIC->database();
   244             "type" => array(
"integer", $type),
   245             "user_id" => array(
"integer", $user_id),
   246             "id" => array(
"integer", $id)
   248         $ilDB->replace(
"notification", $fields, array(
"activated" => array(
"integer", (
int) $status)));
   258         ?
int $page_id = null,
   259         bool $activate_new_entries = 
true   263         $ilDB = $DIC->database();
   267         if (in_array($type, [self::TYPE_WIKI_PAGE, self::TYPE_WIKI, self::TYPE_BLOG])) {
   268             $set = 
$ilDB->queryF(
   269                 "SELECT user_id FROM notification " .
   270                 " WHERE type = %s AND id = %s AND " .
   271                 $ilDB->in(
"user_id", $user_ids, 
false, 
"integer"),
   272                 [
"integer", 
"integer"],
   276             while ($rec = 
$ilDB->fetchAssoc($set)) {
   277                 $noti_users[] = $rec[
"user_id"];
   280                 if (!in_array($user_id, $noti_users)) {
   281                     $ilDB->insert(
"notification", [
   282                         "type" => [
"integer", $type],
   283                         "id" => [
"integer", $id],
   284                         "user_id" => [
"integer", $user_id],
   285                         "page_id" => [
"integer", (
int) $page_id],
   286                         "activated" => [
"integer", (
int) $activate_new_entries]
   292         $sql = 
"UPDATE notification" .
   293                 " SET last_mail = " . 
$ilDB->quote(date(
"Y-m-d H:i:s"), 
"timestamp");
   296             $sql .= 
", page_id = " . 
$ilDB->quote($page_id, 
"integer");
   299         $sql .= 
" WHERE type = " . 
$ilDB->quote($type, 
"integer") .
   300                 " AND id = " . 
$ilDB->quote($id, 
"integer") .
   301                 " AND " . 
$ilDB->in(
"user_id", $user_ids, 
false, 
"integer");
   314         $ilDB = $DIC->database();
   316         $ilDB->query(
"DELETE FROM notification" .
   317                 " WHERE type = " . 
$ilDB->quote($type, 
"integer") .
   318                 " AND id = " . 
$ilDB->quote($id, 
"integer"));
   329         $ilDB = $DIC->database();
   331         $ilDB->query(
"DELETE FROM notification" .
   332                 " WHERE user_id = " . 
$ilDB->quote($user_id, 
"integer"));
   345         $db = $DIC->database();
   348             "SELECT id FROM notification " .
   349             " WHERE type = %s " .
   350             " AND user_id = %s " .
   351             " AND activated = %s ",
   352             array(
"integer", 
"integer", 
"integer"),
   353             array($type, $user_id, 1)
   356         while ($rec = $db->fetchAssoc($set)) {
 static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object. 
 
static getLogger(string $a_component_id)
Get component logger. 
 
const TYPE_LM_BLOCKED_USERS
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _getAllReferences(int $id)
get all reference ids for object ID 
 
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object. 
 
const MODE_DEF_ON_OPT_OUT
 
static getActivatedNotifications(int $type, int $user_id)
Get activated notifications of give type for user. 
 
const TYPE_DATA_COLLECTION
 
static _getInstanceByObjId(int $a_obj_id)
 
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user. 
 
static removeForUser(int $user_id)
Remove all notifications for given user. 
 
static _lookupObjectId(int $ref_id)
 
const MODE_DEF_OFF_USER_ACTIVATION
 
const TYPE_EXERCISE_SUBMISSION
 
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users. 
 
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user. 
 
static removeForObject(int $type, int $id)
Remove all notifications for given object. 
 
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object. 
 
const MODE_DEF_ON_NO_OPT_OUT
 
static hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?