34 $this->ref_id = (int) $a_ref_id;
35 $this->custom =
array();
36 $this->
setMode(self::MODE_SELF);
52 return ($ilSetting->get(
"block_activated_news") &&
53 $ilSetting->get(
"crsgrp_ntf"));
63 $set = $ilDB->query(
"SELECT nmode mode" .
65 " WHERE ref_id = " . $ilDB->quote($this->ref_id,
"integer"));
66 if ($ilDB->numRows($set)) {
67 $row = $ilDB->fetchAssoc($set);
70 if (
$row[
"mode"] == self::MODE_CUSTOM) {
71 $set = $ilDB->query(
"SELECT *" .
72 " FROM member_noti_user" .
73 " WHERE ref_id = " . $ilDB->quote($this->ref_id,
"integer"));
74 while (
$row = $ilDB->fetchAssoc($set)) {
75 $this->custom[
$row[
"user_id"]] = $row[
"status"];
104 $this->mode = $a_value;
119 ,self::MODE_ALL_BLOCKED
122 return in_array($a_value,
$valid);
135 if (!$this->ref_id) {
140 $this->mode != $a_new_mode &&
142 $ilDB->manipulate(
"DELETE FROM member_noti" .
143 " WHERE ref_id = " . $ilDB->quote($this->ref_id,
"integer"));
146 if ($a_new_mode != self::MODE_CUSTOM) {
147 $ilDB->manipulate(
"DELETE FROM member_noti_user" .
148 " WHERE ref_id = " . $ilDB->quote($this->ref_id,
"integer"));
152 if ($a_new_mode != self::MODE_SELF) {
153 $ilDB->insert(
"member_noti",
array(
154 "ref_id" =>
array(
"integer", $this->ref_id),
155 "nmode" =>
array(
"integer", $a_new_mode)
160 if ($a_new_mode == self::MODE_ALL) {
161 $ilDB->manipulate(
"DELETE FROM usr_pref" .
162 " WHERE " . $ilDB->like(
"keyword",
"text",
"grpcrs_ntf_" . $this->ref_id));
183 if ($this->participants === null) {
184 $this->participants =
false;
186 $grp_ref_id = $tree->checkForParentType($this->ref_id,
"grp");
188 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
192 if (!$this->participants) {
193 $crs_ref_id = $tree->checkForParentType($this->ref_id,
"crs");
195 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
217 $all = $part_obj->getParticipants();
225 case self::MODE_SELF:
226 $set = $ilDB->query(
"SELECT usr_id" .
228 " WHERE " . $ilDB->like(
"keyword",
"text",
"grpcrs_ntf_" . $this->ref_id) .
229 " AND value = " . $ilDB->quote(self::VALUE_ON,
"text"));
230 while (
$row = $ilDB->fetchAssoc($set)) {
239 $set = $ilDB->query(
"SELECT usr_id" .
241 " WHERE " . $ilDB->like(
"keyword",
"text",
"grpcrs_ntf_" . $this->ref_id) .
242 " AND value = " . $ilDB->quote(self::VALUE_OFF,
"text"));
243 while (
$row = $ilDB->fetchAssoc($set)) {
244 $inactive[] =
$row[
"usr_id"];
246 $users = array_diff($all, $inactive);
250 case self::MODE_ALL_BLOCKED:
255 case self::MODE_CUSTOM:
256 foreach ($this->custom as $user_id => $status) {
257 if ($status != self::VALUE_OFF) {
265 return array_intersect($all,
$users);
305 if ($a_user_id === null ||
306 $a_user_id == $ilUser->getId()) {
309 $user =
new ilUser($a_user_id);
312 if ($user->getId() &&
313 $user->getId() != ANONYMOUS_USER_ID) {
329 if (!self::isActive()) {
335 case self::MODE_SELF:
340 $user->setPref(
"grpcrs_ntf_" . $this->ref_id, (
int) (
bool) $a_status);
346 case self::MODE_CUSTOM:
347 $user = $this->
getUser($a_user_id);
349 $user_id = $user->getId();
352 if (!array_key_exists($user_id, $this->custom) ||
353 $this->custom[$user_id != $a_status]) {
354 $this->custom[$user_id] = $a_status;
359 "ref_id" =>
array(
"integer", $this->ref_id),
360 "user_id" =>
array(
"integer", $user_id),
363 "status" =>
array(
"integer", $a_status)
371 case self::MODE_ALL_BLOCKED:
405 $user_id = $ilUser->getId();
406 if ($user_id == ANONYMOUS_USER_ID) {
411 case self::MODE_SELF:
415 case self::MODE_ALL_BLOCKED:
418 case self::MODE_CUSTOM:
419 return !(array_key_exists($user_id, $this->custom) &&
420 $this->custom[$user_id] == self::VALUE_BLOCKED);
443 if (self::isActive()) {
447 $log->debug(
"read usr_pref");
448 $set = $ilDB->query(
"SELECT DISTINCT(keyword) keyword" .
450 " WHERE " . $ilDB->like(
"keyword",
"text",
"grpcrs_ntf_%") .
451 " AND value = " . $ilDB->quote(
"1",
"text"));
452 while (
$row = $ilDB->fetchAssoc($set)) {
458 $log->debug(
"read member_noti");
459 $set = $ilDB->query(
"SELECT ref_id" .
460 " FROM member_noti");
461 while (
$row = $ilDB->fetchAssoc($set)) {
462 $objects[(int)
$row[
"ref_id"]] = (
int)
$row[
"ref_id"];
466 foreach (array_unique($objects) as
$ref_id) {
468 if (!$tree->isDeleted(
$ref_id)) {
469 $log->debug(
"get active users");
471 $active = $noti->getActiveUsers();
472 if (
sizeof($active)) {
498 if (self::isActive() &&
500 $lng->loadLanguageModule(
"membership");
501 $noti =
new self($a_ref_id);
506 $a_form->addItem($force_noti);
508 $a_input->addSubItem($force_noti);
511 if ($noti->isValidMode(self::MODE_SELF)) {
512 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_self"), self::MODE_SELF);
513 $force_noti->addOption($option);
515 if ($noti->isValidMode(self::MODE_ALL_BLOCKED)) {
516 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_blocked"), self::MODE_ALL_BLOCKED);
517 $force_noti->addOption($option);
519 if ($noti->isValidMode(self::MODE_ALL)) {
520 $changeable =
new ilCheckboxInputGUI($lng->txt(
"mem_force_notification_mode_all_sub_blocked"),
"force_noti_allblk");
523 } elseif ($noti->isValidMode(self::MODE_ALL)) {
524 $option =
new ilRadioOption($lng->txt(
"mem_force_notification_mode_all"), self::MODE_ALL);
525 $force_noti->addOption($option);
537 $current_mode = $noti->getMode();
538 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
539 $noti->isValidMode(self::MODE_ALL));
540 if (!$has_changeable_cb) {
541 $force_noti->
setValue($current_mode);
543 switch ($current_mode) {
544 case self::MODE_SELF:
545 $force_noti->setValue($current_mode);
546 $changeable->setChecked(
true);
549 case self::MODE_ALL_BLOCKED:
550 $force_noti->setValue($current_mode);
554 $force_noti->setValue(self::MODE_ALL_BLOCKED);
555 $changeable->setChecked(
true);
570 if (self::isActive() &&
572 $noti =
new self($a_ref_id);
573 $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
574 $noti->isValidMode(self::MODE_ALL));
578 if ($has_changeable_cb) {
579 $changeable = (int)
$_POST[
"force_noti_allblk"];
582 $mode = $a_form->getInput(
"force_noti");
583 if ($has_changeable_cb) {
584 $changeable = $a_form->getInput(
"force_noti_allblk");
589 $mode == self::MODE_ALL_BLOCKED) {
590 $mode = self::MODE_ALL;
592 $noti->switchMode(
$mode);
605 $set = $ilDB->queryF(
606 "SELECT * FROM member_noti " .
607 " WHERE ref_id = %s ",
611 while ($rec = $ilDB->fetchAssoc($set)) {
612 $ilDB->insert(
"member_noti",
array(
613 "ref_id" =>
array(
"integer", $new_ref_id),
614 "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.
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.
cloneSettings($new_ref_id)
Clone notification object settings.
activateUser($a_user_id=null)
Activate notification for user.