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") &&
64 $set =
$ilDB->query(
"SELECT nmode mode".
66 " WHERE ref_id = ".
$ilDB->quote($this->ref_id,
"integer"));
67 if(
$ilDB->numRows($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"));
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();
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"));
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"));
263 $inactive[] =
$row[
"usr_id"];
265 $users = array_diff($all, $inactive);
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())
368 $user->setPref(
"grpcrs_ntf_".$this->ref_id, (
int)(
bool)$a_status);
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)
422 return in_array(
$ilUser->getId(), $this->getActiveUsers());
435 if($user_id == ANONYMOUS_USER_ID)
450 return !(array_key_exists($user_id, $this->custom) &&
476 $set =
$ilDB->query(
"SELECT DISTINCT(keyword) keyword".
478 " WHERE ".
$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_%").
479 " AND value = ".$ilDB->quote(
"1",
"text"));
487 $set =
$ilDB->query(
"SELECT ref_id".
488 " FROM member_noti");
491 $objects[] = (int)
$row[
"ref_id"];
495 foreach(array_unique($objects) as
$ref_id)
501 $active = $noti->getActiveUsers();
529 if(self::isActive() &&
532 $lng->loadLanguageModule(
"membership");
533 $noti =
new self($a_ref_id);
536 $force_noti->setRequired(
true);
539 $a_form->addItem($force_noti);
543 $a_input->addSubItem($force_noti);
546 if($noti->isValidMode(self::MODE_SELF))
548 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_self"), self::MODE_SELF);
549 $force_noti->addOption($option);
551 if($noti->isValidMode(self::MODE_ALL_BLOCKED))
553 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_blocked"), self::MODE_ALL_BLOCKED);
554 $force_noti->addOption($option);
556 if($noti->isValidMode(self::MODE_ALL))
558 $changeable =
new ilCheckboxInputGUI(
$lng->txt(
"mem_force_notification_mode_all_sub_blocked"),
"force_noti_allblk");
559 $option->addSubItem($changeable);
562 else if($noti->isValidMode(self::MODE_ALL))
564 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_all"), self::MODE_ALL);
565 $force_noti->addOption($option);
577 $current_mode = $noti->getMode();
578 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
579 $noti->isValidMode(self::MODE_ALL));
580 if(!$has_changeable_cb)
582 $force_noti->setValue($current_mode);
586 switch($current_mode)
589 $force_noti->setValue($current_mode);
590 $changeable->setChecked(
true);
594 $force_noti->setValue($current_mode);
598 $force_noti->setValue(self::MODE_ALL_BLOCKED);
599 $changeable->setChecked(
true);
614 if(self::isActive() &&
617 $noti =
new self($a_ref_id);
618 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
619 $noti->isValidMode(self::MODE_ALL));
624 if($has_changeable_cb)
626 $changeable = (int)
$_POST[
"force_noti_allblk"];
631 $mode = $a_form->getInput(
"force_noti");
632 if($has_changeable_cb)
634 $changeable = $a_form->getInput(
"force_noti_allblk");
639 $mode == self::MODE_ALL_BLOCKED)
643 $noti->switchMode(
$mode);
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Membership notification settings.
isCurrentUserActive()
Get user notification status.
canCurrentUserEdit()
Can user change notification status?
getParticipants()
Init participants for current object.
static isActive()
Is feature active?
getUser($a_user_id=null)
Init user instance.
deactivateUser($a_user_id=null)
Deactivate notification for user.
getActiveUsers()
Get active notifications for current object.
static importFromForm($a_ref_id, ilPropertyFormGUI $a_form=null)
Import notification settings from form.
activateUser($a_user_id=null)
Activate notification for user.
setMode($a_value)
Set mode
toggleUser($a_status, $a_user_id=null)
Toggle user notification status.
switchMode($a_new_mode)
Switch mode for object.
static addToSettingsForm($a_ref_id, ilPropertyFormGUI $a_form=null, ilFormPropertyGUI $a_input=null)
Add notification settings to form.
static getActiveUsersforAllObjects()
Get active notifications for all objects.
__construct($a_ref_id)
Constructor.
isValidMode($a_value)
Is given mode valid?
static _lookupObjId($a_id)
This class represents an option in a radio group.