34 $this->ref_id = (int) $a_ref_id;
35 $this->custom = array();
36 $this->
setMode(self::MODE_SELF);
54 return (
$ilSetting->get(
"block_activated_news") &&
67 $set =
$ilDB->query(
"SELECT nmode mode" .
69 " WHERE ref_id = " .
$ilDB->quote($this->ref_id,
"integer"));
70 if (
$ilDB->numRows($set)) {
74 if (
$row[
"mode"] == self::MODE_CUSTOM) {
75 $set =
$ilDB->query(
"SELECT *" .
76 " FROM member_noti_user" .
77 " WHERE ref_id = " .
$ilDB->quote($this->ref_id,
"integer"));
79 $this->custom[
$row[
"user_id"]] = $row[
"status"];
108 $this->mode = $a_value;
123 ,self::MODE_ALL_BLOCKED
126 return in_array($a_value,
$valid);
139 $ilDB = $DIC[
'ilDB'];
141 if (!$this->ref_id) {
146 $this->mode != $a_new_mode &&
148 $ilDB->manipulate(
"DELETE FROM member_noti" .
149 " WHERE ref_id = " .
$ilDB->quote($this->ref_id,
"integer"));
152 if ($a_new_mode != self::MODE_CUSTOM) {
153 $ilDB->manipulate(
"DELETE FROM member_noti_user" .
154 " WHERE ref_id = " .
$ilDB->quote($this->ref_id,
"integer"));
158 if ($a_new_mode != self::MODE_SELF) {
159 $ilDB->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 $ilDB->manipulate(
"DELETE FROM usr_pref" .
168 " WHERE " .
$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_" . $this->ref_id));
189 $tree = $DIC[
'tree'];
191 if ($this->participants === null) {
192 $this->participants =
false;
194 $grp_ref_id =
$tree->checkForParentType($this->ref_id,
"grp");
196 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
200 if (!$this->participants) {
201 $crs_ref_id =
$tree->checkForParentType($this->ref_id,
"crs");
203 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
221 $ilDB = $DIC->database();
227 $all = $part_obj->getParticipants();
235 case self::MODE_SELF:
236 $set =
$ilDB->query(
"SELECT usr_id" .
238 " WHERE keyword = " .
$ilDB->quote(
"grpcrs_ntf_".$this->ref_id,
"text") .
239 " AND value = " .
$ilDB->quote(self::VALUE_ON,
"text"));
249 $set =
$ilDB->query(
"SELECT usr_id" .
251 " WHERE keyword = " .
$ilDB->quote(
"grpcrs_ntf_".$this->ref_id,
"text") .
252 " AND value = " .
$ilDB->quote(self::VALUE_OFF,
"text"));
254 $inactive[] =
$row[
"usr_id"];
256 $users = array_diff($all, $inactive);
260 case self::MODE_ALL_BLOCKED:
265 case self::MODE_CUSTOM:
266 foreach ($this->custom as $user_id => $status) {
267 if ($status != self::VALUE_OFF) {
275 return array_intersect($all,
$users);
317 if ($a_user_id === null ||
318 $a_user_id ==
$ilUser->getId()) {
321 $user =
new ilUser($a_user_id);
324 if (
$user->getId() &&
325 $user->getId() != ANONYMOUS_USER_ID) {
341 $ilDB = $DIC[
'ilDB'];
343 if (!self::isActive()) {
349 case self::MODE_SELF:
354 $user->setPref(
"grpcrs_ntf_" . $this->ref_id, (
int) (
bool) $a_status);
360 case self::MODE_CUSTOM:
363 $user_id =
$user->getId();
366 if (!array_key_exists($user_id, $this->custom) ||
367 $this->custom[$user_id != $a_status]) {
368 $this->custom[$user_id] = $a_status;
373 "ref_id" => array(
"integer", $this->ref_id),
374 "user_id" => array(
"integer", $user_id),
377 "status" => array(
"integer", $a_status)
385 case self::MODE_ALL_BLOCKED:
424 if ($user_id == ANONYMOUS_USER_ID) {
429 case self::MODE_SELF:
433 case self::MODE_ALL_BLOCKED:
436 case self::MODE_CUSTOM:
437 return !(array_key_exists($user_id, $this->custom) &&
438 $this->custom[$user_id] == self::VALUE_BLOCKED);
456 $ilDB = $DIC[
'ilDB'];
457 $tree = $DIC[
'tree'];
464 if (self::isActive()) {
468 $log->debug(
"read usr_pref");
469 $set =
$ilDB->query(
"SELECT DISTINCT(keyword) keyword" .
471 " WHERE " .
$ilDB->like(
"keyword",
"text",
"grpcrs_ntf_%") .
472 " AND value = " .
$ilDB->quote(
"1",
"text"));
479 $log->debug(
"read member_noti");
480 $set =
$ilDB->query(
"SELECT ref_id" .
481 " FROM member_noti");
483 $objects[(int)
$row[
"ref_id"]] = (
int)
$row[
"ref_id"];
487 foreach (array_unique($objects) as
$ref_id) {
490 $log->debug(
"get active users");
492 $active = $noti->getActiveUsers();
493 if (
sizeof($active)) {
521 if (self::isActive() &&
523 $lng->loadLanguageModule(
"membership");
524 $noti =
new self($a_ref_id);
529 $a_form->addItem($force_noti);
531 $a_input->addSubItem($force_noti);
534 if ($noti->isValidMode(self::MODE_SELF)) {
535 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_self"), self::MODE_SELF);
536 $force_noti->addOption($option);
538 if ($noti->isValidMode(self::MODE_ALL_BLOCKED)) {
539 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_blocked"), self::MODE_ALL_BLOCKED);
540 $force_noti->addOption($option);
542 if ($noti->isValidMode(self::MODE_ALL)) {
543 $changeable =
new ilCheckboxInputGUI(
$lng->txt(
"mem_force_notification_mode_all_sub_blocked"),
"force_noti_allblk");
546 } elseif ($noti->isValidMode(self::MODE_ALL)) {
547 $option =
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_all"), self::MODE_ALL);
548 $force_noti->addOption($option);
560 $current_mode = $noti->getMode();
561 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
562 $noti->isValidMode(self::MODE_ALL));
563 if (!$has_changeable_cb) {
564 $force_noti->
setValue($current_mode);
566 switch ($current_mode) {
567 case self::MODE_SELF:
568 $force_noti->setValue($current_mode);
569 $changeable->setChecked(
true);
572 case self::MODE_ALL_BLOCKED:
573 $force_noti->setValue($current_mode);
577 $force_noti->setValue(self::MODE_ALL_BLOCKED);
578 $changeable->setChecked(
true);
593 if (self::isActive() &&
595 $noti =
new self($a_ref_id);
596 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
597 $noti->isValidMode(self::MODE_ALL));
601 if ($has_changeable_cb) {
602 $changeable = (int)
$_POST[
"force_noti_allblk"];
605 $mode = $a_form->getInput(
"force_noti");
606 if ($has_changeable_cb) {
607 $changeable = $a_form->getInput(
"force_noti_allblk");
612 $mode == self::MODE_ALL_BLOCKED) {
613 $mode = self::MODE_ALL;
615 $noti->switchMode(
$mode);
628 $set = $ilDB->queryF(
629 "SELECT * FROM member_noti " .
630 " WHERE ref_id = %s ",
634 while ($rec = $ilDB->fetchAssoc($set)) {
635 $ilDB->insert(
"member_noti", array(
636 "ref_id" => array(
"integer", $new_ref_id),
637 "nmode" => array(
"integer", $rec[
"nmode"])
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.
foreach($_POST as $key=> $value) $res
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.
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.
cloneSettings($new_ref_id)
Clone notification object settings.
activateUser($a_user_id=null)
Activate notification for user.