34 $this->ref_id = (int)$a_ref_id;
35 $this->custom =
array();
36 $this->
setMode(self::MODE_SELF);
53 return ($ilSetting->get(
"block_activated_news") &&
54 $ilSetting->get(
"crsgrp_ntf"));
64 $set = $ilDB->query(
"SELECT nmode mode".
66 " WHERE ref_id = ".$ilDB->quote($this->ref_id,
"integer"));
67 if($ilDB->numRows($set))
69 $row = $ilDB->fetchAssoc($set);
72 if(
$row[
"mode"] == self::MODE_CUSTOM)
74 $set = $ilDB->query(
"SELECT *".
75 " FROM member_noti_user".
76 " WHERE ref_id = ".$ilDB->quote($this->ref_id,
"integer"));
77 while(
$row = $ilDB->fetchAssoc($set))
79 $this->custom[
$row[
"user_id"]] = $row[
"status"];
109 $this->mode = $a_value;
124 ,self::MODE_ALL_BLOCKED
127 return in_array($a_value,
$valid);
146 $this->mode != $a_new_mode &&
149 $ilDB->manipulate(
"DELETE FROM member_noti".
150 " WHERE ref_id = ".$ilDB->quote($this->ref_id,
"integer"));
153 if($a_new_mode != self::MODE_CUSTOM)
155 $ilDB->manipulate(
"DELETE FROM member_noti_user".
156 " WHERE ref_id = ".$ilDB->quote($this->ref_id,
"integer"));
160 if($a_new_mode != self::MODE_SELF)
162 $ilDB->insert(
"member_noti",
array(
163 "ref_id" =>
array(
"integer", $this->ref_id),
164 "nmode" =>
array(
"integer", $a_new_mode)
169 if($a_new_mode == self::MODE_ALL)
171 $ilDB->manipulate(
"DELETE FROM usr_pref".
172 " WHERE ".$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_".$this->ref_id));
193 if($this->participants === null)
195 $this->participants =
false;
197 $grp_ref_id = $tree->checkForParentType($this->ref_id,
"grp");
200 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
204 if(!$this->participants)
206 $crs_ref_id = $tree->checkForParentType($this->ref_id,
"crs");
209 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
227 $users = $all =
array();
232 $all = $part_obj->getParticipants();
242 case self::MODE_SELF:
243 $set = $ilDB->query(
"SELECT usr_id".
245 " WHERE ".$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_".$this->ref_id).
246 " AND value = ".$ilDB->quote(self::VALUE_ON,
"text"));
247 while(
$row = $ilDB->fetchAssoc($set))
249 $users[] =
$row[
"usr_id"];
257 $set = $ilDB->query(
"SELECT usr_id".
259 " WHERE ".$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_".$this->ref_id).
260 " AND value = ".$ilDB->quote(self::VALUE_OFF,
"text"));
261 while(
$row = $ilDB->fetchAssoc($set))
263 $inactive[] =
$row[
"usr_id"];
265 $users = array_diff($all, $inactive);
269 case self::MODE_ALL_BLOCKED:
274 case self::MODE_CUSTOM:
275 foreach($this->custom as $user_id => $status)
277 if($status != self::VALUE_OFF)
286 return array_intersect($all, $users);
326 if($a_user_id === null ||
327 $a_user_id == $ilUser->getId())
333 $user =
new ilUser($a_user_id);
337 $user->getId() != ANONYMOUS_USER_ID)
354 if(!self::isActive())
362 case self::MODE_SELF:
368 $user->setPref(
"grpcrs_ntf_".$this->ref_id, (
int)(
bool)$a_status);
374 case self::MODE_CUSTOM:
375 $user = $this->
getUser($a_user_id);
378 $user_id = $user->getId();
381 if(!array_key_exists($user_id, $this->custom) ||
382 $this->custom[$user_id != $a_status])
384 $this->custom[$user_id] = $a_status;
386 $ilDB->replace(
"member_noti_user",
388 "ref_id" =>
array(
"integer", $this->ref_id),
389 "user_id" =>
array(
"integer", $user_id),
392 "status" =>
array(
"integer", $a_status)
400 case self::MODE_ALL_BLOCKED:
434 $user_id = $ilUser->getId();
435 if($user_id == ANONYMOUS_USER_ID)
442 case self::MODE_SELF:
446 case self::MODE_ALL_BLOCKED:
449 case self::MODE_CUSTOM:
450 return !(array_key_exists($user_id, $this->custom) &&
451 $this->custom[$user_id] == self::VALUE_BLOCKED);
479 $log->debug(
"read usr_pref");
480 $set = $ilDB->query(
"SELECT DISTINCT(keyword) keyword".
482 " WHERE ".$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_%").
483 " AND value = ".$ilDB->quote(
"1",
"text"));
484 while(
$row = $ilDB->fetchAssoc($set))
491 $log->debug(
"read member_noti");
492 $set = $ilDB->query(
"SELECT ref_id".
493 " FROM member_noti");
494 while(
$row = $ilDB->fetchAssoc($set))
496 $objects[(int)
$row[
"ref_id"]] = (
int)
$row[
"ref_id"];
500 foreach(array_unique($objects) as
$ref_id)
505 $log->debug(
"get active users");
507 $active = $noti->getActiveUsers();
535 if(self::isActive() &&
538 $lng->loadLanguageModule(
"membership");
539 $noti =
new self($a_ref_id);
545 $a_form->addItem($force_noti);
549 $a_input->addSubItem($force_noti);
552 if($noti->isValidMode(self::MODE_SELF))
554 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_self"), self::MODE_SELF);
555 $force_noti->addOption($option);
557 if($noti->isValidMode(self::MODE_ALL_BLOCKED))
559 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_blocked"), self::MODE_ALL_BLOCKED);
560 $force_noti->addOption($option);
562 if($noti->isValidMode(self::MODE_ALL))
564 $changeable =
new ilCheckboxInputGUI($lng->txt(
"mem_force_notification_mode_all_sub_blocked"),
"force_noti_allblk");
568 else if($noti->isValidMode(self::MODE_ALL))
570 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_all"), self::MODE_ALL);
571 $force_noti->addOption($option);
583 $current_mode = $noti->getMode();
584 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
585 $noti->isValidMode(self::MODE_ALL));
586 if(!$has_changeable_cb)
588 $force_noti->
setValue($current_mode);
592 switch($current_mode)
594 case self::MODE_SELF:
595 $force_noti->setValue($current_mode);
596 $changeable->setChecked(
true);
599 case self::MODE_ALL_BLOCKED:
600 $force_noti->setValue($current_mode);
604 $force_noti->setValue(self::MODE_ALL_BLOCKED);
605 $changeable->setChecked(
true);
620 if(self::isActive() &&
623 $noti =
new self($a_ref_id);
624 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
625 $noti->isValidMode(self::MODE_ALL));
630 if($has_changeable_cb)
632 $changeable = (int)
$_POST[
"force_noti_allblk"];
637 $mode = $a_form->getInput(
"force_noti");
638 if($has_changeable_cb)
640 $changeable = $a_form->getInput(
"force_noti_allblk");
645 $mode == self::MODE_ALL_BLOCKED)
647 $mode = self::MODE_ALL;
649 $noti->switchMode(
$mode);
This class represents an option in a radio group.
static isActive()
Is feature active?
getUser($a_user_id=null)
Init user instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
deactivateUser($a_user_id=null)
Deactivate notification for user.
isCurrentUserActive()
Get user notification status.
static addToSettingsForm($a_ref_id, ilPropertyFormGUI $a_form=null, ilFormPropertyGUI $a_input=null)
Add notification settings to form.
__construct($a_ref_id)
Constructor.
setValue($a_value)
Set Value.
static _lookupObjId($a_id)
isValidMode($a_value)
Is given mode valid?
switchMode($a_new_mode)
Switch mode for object.
setMode($a_value)
Set mode.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
getActiveUsers()
Get active notifications for current object.
getParticipants()
Init participants for current object.
static getLogger($a_component_id)
Get component logger.
static getActiveUsersforAllObjects()
Get active notifications for all objects.
toggleUser($a_status, $a_user_id=null)
Toggle user notification status.
Membership notification settings.
canCurrentUserEdit()
Can user change notification status?
static importFromForm($a_ref_id, ilPropertyFormGUI $a_form=null)
Import notification settings from form.
activateUser($a_user_id=null)
Activate notification for user.