43        $tree = 
$DIC->repositoryTree();
 
   45        $notification = 
false;
 
   47        include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
 
   52                $grp_ref_id = $tree->checkForParentType($ref_id, 
'grp');
 
   53                if ($grp_ref_id > 0) {
 
   54                    include_once(
"./Modules/Group/classes/class.ilGroupParticipants.php");
 
   59                $crs_ref_id = $tree->checkForParentType($ref_id, 
'crs');
 
   60                if ($crs_ref_id > 0) {
 
   61                    include_once(
"./Modules/Course/classes/class.ilCourseParticipants.php");
 
   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);
 
   76                if ($rec[
"user_id"] == $user_id) {
 
   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"));
 
   94        return (
bool) 
$ilDB->numRows($set);
 
  105        include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
 
  127        $tree = 
$DIC->repositoryTree();
 
  129        include_once(
"./Services/Notification/classes/class.ilObjNotificationSettings.php");
 
  132        $recipients = array();
 
  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;
 
  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;
 
  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"]]);
 
  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(
 
  181                strtotime(
"-" . self::THRESHOLD . 
"minutes")
 
  184                $sql .= 
" AND page_id = " . 
$ilDB->quote($page_id, 
"integer");
 
  188            $set = 
$ilDB->query($sql);
 
  189            while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  190                unset($recipients[$rec[
"user_id"]]);
 
  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(
 
  203                    strtotime(
"-" . self::THRESHOLD . 
"minutes")
 
  205                    " OR last_mail IS NULL";
 
  207                    $sql .= 
" OR page_id <> " . 
$ilDB->quote($page_id, 
"integer");
 
  211            $set = 
$ilDB->query($sql);
 
  212            while ($row = 
$ilDB->fetchAssoc($set)) {
 
  213                $recipients[$row[
"user_id"]] = $row[
"user_id"];
 
  235            "type" => array(
"integer", 
$type),
 
  236            "user_id" => array(
"integer", $user_id),
 
  237            "id" => array(
"integer", $id)
 
  239        $ilDB->replace(
"notification", $fields, array(
"activated" => array(
"integer", (
int) $status)));
 
  256        $sql = 
"UPDATE notification" .
 
  257                " SET last_mail = " . 
$ilDB->quote(date(
"Y-m-d H:i:s"), 
"timestamp");
 
  260            $sql .= 
", page_id = " . 
$ilDB->quote($page_id, 
"integer");
 
  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");
 
  282        $ilDB->query(
"DELETE FROM notification" .
 
  283                " WHERE type = " . 
$ilDB->quote(
$type, 
"integer") .
 
  284                " AND id = " . 
$ilDB->quote($id, 
"integer"));
 
  298        $ilDB->query(
"DELETE FROM notification" .
 
  299                " WHERE user_id = " . 
$ilDB->quote($user_id, 
"integer"));
 
  313        $db = 
$DIC->database();
 
  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)
 
  324        while ($rec = $db->fetchAssoc($set)) {
 
An exception for terminatinating execution or to throw for unit testing.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static removeForUser($user_id)
Remove all notifications for given user.
static removeForObject($type, $id)
Remove all notifications for given object.
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
static getActivatedNotifications(int $type, int $user_id)
Get activated notifications of give type for user.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
const TYPE_DATA_COLLECTION
const TYPE_EXERCISE_SUBMISSION
static hasOptOut($obj_id)
Is opt out (disable notification) allowed?
const TYPE_LM_BLOCKED_USERS
Handles general object notification settings, see e.g.
const MODE_DEF_ON_OPT_OUT
const MODE_DEF_ON_NO_OPT_OUT
const MODE_DEF_OFF_USER_ACTIVATION
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.