3 declare(strict_types=1);
    50         $this->db = $DIC->database();
    51         $this->ref_id = $a_ref_id;
    53         $this->setting = $DIC->settings();
    54         $this->tree = $DIC->repositoryTree();
    55         $this->
user = $DIC->user();
    57         $this->
setMode(self::MODE_SELF);
    58         if ($this->ref_id !== 0) {
    76         if (!self::isActive()) {
    93     protected function read(): void
    95         $set = $this->db->query(
"SELECT nmode mode" .
    97             " WHERE ref_id = " . $this->db->quote($this->ref_id, 
"integer"));
    98         if ($this->db->numRows($set)) {
    99             $row = $this->db->fetchAssoc($set);
   100             $this->
setMode((
int) $row[
"mode"]);
   102             if ((
int) $row[
"mode"] === self::MODE_CUSTOM) {
   103                 $set = $this->db->query(
"SELECT *" .
   104                     " FROM member_noti_user" .
   105                     " WHERE ref_id = " . $this->db->quote($this->ref_id, 
"integer"));
   106                 while ($row = $this->db->fetchAssoc($set)) {
   107                     $this->
custom[(
int) $row[
"user_id"]] = (
int) $row[
"status"];
   118     protected function setMode(
int $a_value): void
   121             $this->mode = $a_value;
   132             self::MODE_ALL_BLOCKED
   134         return in_array($a_value, 
$valid);
   139         if (!$this->ref_id) {
   145             $this->mode !== $a_new_mode &&
   148             $this->db->manipulate(
"DELETE FROM member_noti" .
   149                 " WHERE ref_id = " . $this->db->quote($this->ref_id, 
"integer"));
   152             if ($a_new_mode !== self::MODE_CUSTOM) {
   153                 $this->db->manipulate(
"DELETE FROM member_noti_user" .
   154                     " WHERE ref_id = " . $this->db->quote($this->ref_id, 
"integer"));
   158             if ($a_new_mode !== self::MODE_SELF) {
   159                 $this->db->insert(
"member_noti", array(
   160                     "ref_id" => array(
"integer", $this->ref_id),
   161                     "nmode" => array(
"integer", $a_new_mode)
   166             if ($a_new_mode === self::MODE_ALL) {
   167                 $this->db->manipulate(
"DELETE FROM usr_pref" .
   168                     " WHERE " . $this->db->like(
"keyword", 
"text", 
"grpcrs_ntf_" . $this->ref_id));
   176         if ($this->participants === null) {
   177             $grp_ref_id = $this->tree->checkForParentType($this->ref_id, 
"grp");
   182             if (!$this->participants) {
   183                 $crs_ref_id = $this->tree->checkForParentType($this->ref_id, 
"crs");
   194         $users = $all = array();
   197             $all = $part_obj->getParticipants();
   205             case self::MODE_SELF:
   206                 $set = $this->db->query(
"SELECT usr_id" .
   208                     " WHERE keyword = " . $this->db->quote(
"grpcrs_ntf_" . $this->ref_id, 
"text") .
   209                     " AND value = " . $this->db->quote(self::VALUE_ON, 
"text"));
   210                 while ($row = $this->db->fetchAssoc($set)) {
   211                     $users[] = (
int) $row[
"usr_id"];
   219                 $set = $this->db->query(
"SELECT usr_id" .
   221                     " WHERE keyword = " . $this->db->quote(
"grpcrs_ntf_" . $this->ref_id, 
"text") .
   222                     " AND value = " . $this->db->quote(self::VALUE_OFF, 
"text"));
   223                 while ($row = $this->db->fetchAssoc($set)) {
   224                     $inactive[] = (
int) $row[
"usr_id"];
   226                 $users = array_diff($all, $inactive);
   230             case self::MODE_ALL_BLOCKED:
   235             case self::MODE_CUSTOM:
   237                     if ($status !== self::VALUE_OFF) {
   243         return array_intersect($all, $users);
   259             $a_user_id === null ||
   260             $a_user_id === $this->
user->getId()
   276     protected function toggleUser(
bool $a_status, 
int $a_user_id = null): bool
   278         if (!self::isActive()) {
   284             case self::MODE_SELF:
   289                     if ($a_status === 
true) {
   295                     $user->
setPref(
"grpcrs_ntf_" . $this->ref_id, $string_value);
   301             case self::MODE_CUSTOM:
   302                 $user = $this->
getUser($a_user_id);
   303                 if ($user instanceof ilObjUser) {
   313                                 "ref_id" => array(
"integer", $this->ref_id),
   314                                 "user_id" => array(
"integer", 
$user_id),
   317                                 "status" => array(
"integer", (
int) $a_status)
   325             case self::MODE_ALL_BLOCKED:
   345             case self::MODE_SELF:
   349             case self::MODE_ALL_BLOCKED:
   352             case self::MODE_CUSTOM:
   365         $ilDB = $DIC->database();
   366         $tree = $DIC->repositoryTree();
   367         $log = $DIC->logger()->mmbr();
   370         if (self::isActive()) {
   374             $log->debug(
"read usr_pref");
   375             $set = 
$ilDB->query(
"SELECT DISTINCT(keyword) keyword" .
   377                 " WHERE " . 
$ilDB->like(
"keyword", 
"text", 
"grpcrs_ntf_%") .
   378                 " AND value = " . 
$ilDB->quote(
"1", 
"text"));
   379             while ($row = 
$ilDB->fetchAssoc($set)) {
   380                 $ref_id = substr($row[
"keyword"], 11);
   385             $log->debug(
"read member_noti");
   386             $set = 
$ilDB->query(
"SELECT ref_id" .
   387                 " FROM member_noti");
   388             while ($row = 
$ilDB->fetchAssoc($set)) {
   389                 $objects[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
   393             foreach (array_unique($objects) as 
$ref_id) {
   396                     $log->debug(
"get active users");
   398                     $active = $noti->getActiveUsers();
   399                     if (count($active)) {
   418         $lng = $DIC->language();
   420         if (self::isActive() &&
   422             $lng->loadLanguageModule(
"membership");
   423             $noti = 
new self($a_ref_id);
   428                 $a_form->addItem($force_noti);
   430                 $a_input->addSubItem($force_noti);
   433             if ($noti->isValidMode(self::MODE_SELF)) {
   434                 $option = 
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_self"), (string) self::MODE_SELF);
   435                 $force_noti->addOption($option);
   437             if ($noti->isValidMode(self::MODE_ALL_BLOCKED)) {
   439                     $lng->txt(
"mem_force_notification_mode_blocked"),
   440                     (string) self::MODE_ALL_BLOCKED
   442                 $force_noti->addOption($option);
   444                 if ($noti->isValidMode(self::MODE_ALL)) {
   446                         $lng->txt(
"mem_force_notification_mode_all_sub_blocked"),
   449                     $option->addSubItem($changeable);
   451             } elseif ($noti->isValidMode(self::MODE_ALL)) {
   452                 $option = 
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_all"), (string) self::MODE_ALL);
   453                 $force_noti->addOption($option);
   457             $current_mode = $noti->getMode();
   458             $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
   459                 $noti->isValidMode(self::MODE_ALL));
   460             if (!$has_changeable_cb) {
   461                 $force_noti->setValue((
string) $current_mode);
   463                 switch ($current_mode) {
   464                     case self::MODE_SELF:
   465                         $force_noti->setValue((
string) $current_mode);
   467                         $changeable->setChecked(
true); 
   470                     case self::MODE_ALL_BLOCKED:
   471                         $force_noti->setValue((
string) $current_mode);
   475                         $force_noti->setValue((
string) self::MODE_ALL_BLOCKED);
   477                         $changeable->setChecked(
true);
   488         $http = $DIC->http();
   491         if ($a_ref_id && self::isActive()) {
   492             $noti = 
new self($a_ref_id);
   493             $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) && $noti->isValidMode(self::MODE_ALL));
   497                 if (
$http->wrapper()->post()->has(
'force_noti')) {
   498                     $mode = 
$http->wrapper()->post()->retrieve(
   504                 if ($has_changeable_cb) {
   506                     if (
$http->wrapper()->post()->has(
'force_noti_allblk')) {
   507                         $changeable = 
$http->wrapper()->post()->retrieve(
   514                 $mode = (
int) $a_form->getInput(
"force_noti");
   515                 if ($has_changeable_cb) {
   516                     $changeable = $a_form->getInput(
"force_noti_allblk");
   520             if ($changeable && $mode === self::MODE_ALL_BLOCKED) {
   521                 $mode = self::MODE_ALL;
   523             $noti->switchMode($mode);
   529         $set = $this->db->queryF(
   530             "SELECT * FROM member_noti " .
   531             " WHERE ref_id = %s ",
   535         while ($rec = $this->db->fetchAssoc($set)) {
   536             $this->db->insert(
"member_noti", array(
   537                 "ref_id" => array(
"integer", $new_ref_id),
   538                 "nmode" => array(
"integer", $rec[
"nmode"])
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
isValidMode(int $a_value)
 
deactivateUser(int $a_user_id=null)
 
static isActiveForRefId(int $ref_id)
 
switchMode(int $a_new_mode)
 
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name. 
 
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
 
static _lookupObjId(int $ref_id)
 
static _getInstanceByObjId(int $a_obj_id)
 
getUser(int $a_user_id=null)
 
ilParticipants $participants
 
activateUser(int $a_user_id=null)
 
cloneSettings(int $new_ref_id)
 
static importFromForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null)
 
setPref(string $a_keyword, ?string $a_value)
 
__construct(int $a_ref_id)
 
Base class for course and group participants. 
 
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance. 
 
toggleUser(bool $a_status, int $a_user_id=null)
 
custom()
 expected output: > ILIAS shows a base horizontal bar chart but customized with e.g. 
 
static getActiveUsersforAllObjects()
Get active notifications for all objects. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static addToSettingsForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null, ?ilFormPropertyGUI $a_input=null)
Add notification settings to form.