34        $this->ref_id = (int) $a_ref_id;
 
   35        $this->custom = array();
 
   36        $this->
setMode(self::MODE_SELF);
 
   62        if (!self::isActive()) {
 
   95        $set = 
$ilDB->query(
"SELECT nmode mode" .
 
   97            " WHERE ref_id = " . 
$ilDB->quote($this->ref_id, 
"integer"));
 
   98        if (
$ilDB->numRows($set)) {
 
   99            $row = 
$ilDB->fetchAssoc($set);
 
  102            if ($row[
"mode"] == self::MODE_CUSTOM) {
 
  103                $set = 
$ilDB->query(
"SELECT *" .
 
  104                    " FROM member_noti_user" .
 
  105                    " WHERE ref_id = " . 
$ilDB->quote($this->ref_id, 
"integer"));
 
  106                while ($row = 
$ilDB->fetchAssoc($set)) {
 
  107                    $this->custom[$row[
"user_id"]] = $row[
"status"];
 
  136            $this->mode = $a_value;
 
  151            ,self::MODE_ALL_BLOCKED
 
  154        return in_array($a_value, 
$valid);
 
  169        if (!$this->ref_id) {
 
  174            $this->mode != $a_new_mode &&
 
  176            $ilDB->manipulate(
"DELETE FROM member_noti" .
 
  177                " WHERE ref_id = " . 
$ilDB->quote($this->ref_id, 
"integer"));
 
  180            if ($a_new_mode != self::MODE_CUSTOM) {
 
  181                $ilDB->manipulate(
"DELETE FROM member_noti_user" .
 
  182                    " WHERE ref_id = " . 
$ilDB->quote($this->ref_id, 
"integer"));
 
  186            if ($a_new_mode != self::MODE_SELF) {
 
  187                $ilDB->insert(
"member_noti", array(
 
  188                    "ref_id" => array(
"integer", $this->ref_id),
 
  189                    "nmode" => array(
"integer", $a_new_mode)
 
  194            if ($a_new_mode == self::MODE_ALL) {
 
  195                $ilDB->manipulate(
"DELETE FROM usr_pref" .
 
  196                    " WHERE " . 
$ilDB->like(
"keyword", 
"text", 
"grpcrs_ntf_" . $this->ref_id));
 
  217        $tree = 
$DIC[
'tree'];
 
  219        if ($this->participants === 
null) {
 
  220            $this->participants = 
false;
 
  222            $grp_ref_id = $tree->checkForParentType($this->ref_id, 
"grp");
 
  224                include_once 
"Modules/Group/classes/class.ilGroupParticipants.php";
 
  228            if (!$this->participants) {
 
  229                $crs_ref_id = $tree->checkForParentType($this->ref_id, 
"crs");
 
  231                    include_once 
"Modules/Course/classes/class.ilCourseParticipants.php";
 
  251        $users = $all = array();
 
  255            $all = $part_obj->getParticipants();
 
  264                $set = 
$ilDB->query(
"SELECT usr_id" .
 
  266                    " WHERE keyword = " . 
$ilDB->quote(
"grpcrs_ntf_".$this->ref_id, 
"text") .
 
  267                    " AND value = " . 
$ilDB->quote(self::VALUE_ON, 
"text"));
 
  268                while ($row = 
$ilDB->fetchAssoc($set)) {
 
  269                    $users[] = $row[
"usr_id"];
 
  277                $set = 
$ilDB->query(
"SELECT usr_id" .
 
  279                    " WHERE keyword = " . 
$ilDB->quote(
"grpcrs_ntf_".$this->ref_id, 
"text") .
 
  280                    " AND value = " . 
$ilDB->quote(self::VALUE_OFF, 
"text"));
 
  281                while ($row = 
$ilDB->fetchAssoc($set)) {
 
  282                    $inactive[] = $row[
"usr_id"];
 
  284                $users = array_diff($all, $inactive);
 
  294                foreach ($this->custom as $user_id => $status) {
 
  295                    if ($status != self::VALUE_OFF) {
 
  303        return  array_intersect($all, $users);
 
  345        if ($a_user_id === 
null ||
 
  346            $a_user_id == 
$ilUser->getId()) {
 
  349            $user = 
new ilUser($a_user_id);
 
  352        if ($user->getId() &&
 
  371        if (!self::isActive()) {
 
  382                    $user->setPref(
"grpcrs_ntf_" . $this->ref_id, (
int) (
bool) $a_status);
 
  389                $user = $this->
getUser($a_user_id);
 
  391                    $user_id = $user->getId();
 
  394                    if (!array_key_exists($user_id, $this->custom) ||
 
  395                        $this->custom[$user_id != $a_status]) {
 
  396                        $this->custom[$user_id] = $a_status;
 
  401                                "ref_id" => array(
"integer", $this->ref_id),
 
  402                                "user_id" => array(
"integer", $user_id),
 
  405                                "status" => array(
"integer", $a_status)
 
  437        return in_array(
$ilUser->getId(), $this->getActiveUsers());
 
  465                return !(array_key_exists($user_id, $this->custom) &&
 
  485        $tree = 
$DIC[
'tree'];
 
  492        if (self::isActive()) {
 
  496            $log->debug(
"read usr_pref");
 
  497            $set = 
$ilDB->query(
"SELECT DISTINCT(keyword) keyword" .
 
  499                " WHERE " . 
$ilDB->like(
"keyword", 
"text", 
"grpcrs_ntf_%") .
 
  500                " AND value = " . 
$ilDB->quote(
"1", 
"text"));
 
  501            while ($row = 
$ilDB->fetchAssoc($set)) {
 
  502                $ref_id = substr($row[
"keyword"], 11);
 
  507            $log->debug(
"read member_noti");
 
  508            $set = 
$ilDB->query(
"SELECT ref_id" .
 
  509                " FROM member_noti");
 
  510            while ($row = 
$ilDB->fetchAssoc($set)) {
 
  511                $objects[(int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
 
  515            foreach (array_unique($objects) as 
$ref_id) {
 
  517                if (!$tree->isDeleted(
$ref_id)) {
 
  518                    $log->debug(
"get active users");
 
  520                    $active = $noti->getActiveUsers();
 
  521                    if (
sizeof($active)) {
 
  549        if (self::isActive() &&
 
  551            $lng->loadLanguageModule(
"membership");
 
  552            $noti = 
new self($a_ref_id);
 
  555            $force_noti->setRequired(
true);
 
  557                $a_form->addItem($force_noti);
 
  559                $a_input->addSubItem($force_noti);
 
  562            if ($noti->isValidMode(self::MODE_SELF)) {
 
  563                $option = 
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_self"), self::MODE_SELF);
 
  564                $force_noti->addOption($option);
 
  566            if ($noti->isValidMode(self::MODE_ALL_BLOCKED)) {
 
  567                $option = 
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_blocked"), self::MODE_ALL_BLOCKED);
 
  568                $force_noti->addOption($option);
 
  570                if ($noti->isValidMode(self::MODE_ALL)) {
 
  571                    $changeable = 
new ilCheckboxInputGUI(
$lng->txt(
"mem_force_notification_mode_all_sub_blocked"), 
"force_noti_allblk");
 
  572                    $option->addSubItem($changeable);
 
  574            } elseif ($noti->isValidMode(self::MODE_ALL)) {
 
  575                $option = 
new ilRadioOption(
$lng->txt(
"mem_force_notification_mode_all"), self::MODE_ALL);
 
  576                $force_noti->addOption($option);
 
  588            $current_mode = $noti->getMode();
 
  589            $has_changeable_cb = ($noti->isValidMode(self::MODE_ALL_BLOCKED) &&
 
  590                $noti->isValidMode(self::MODE_ALL));
 
  591            if (!$has_changeable_cb) {
 
  592                $force_noti->setValue($current_mode);
 
  594                switch ($current_mode) {
 
  596                        $force_noti->setValue($current_mode);
 
  597                        $changeable->setChecked(
true); 
 
  601                        $force_noti->setValue($current_mode);
 
  605                        $force_noti->setValue(self::MODE_ALL_BLOCKED);
 
  606                        $changeable->setChecked(
true);
 
  621        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));
 
  629                if ($has_changeable_cb) {
 
  630                    $changeable = (int) 
$_POST[
"force_noti_allblk"];
 
  633                $mode = $a_form->getInput(
"force_noti");
 
  634                if ($has_changeable_cb) {
 
  635                    $changeable = $a_form->getInput(
"force_noti_allblk");
 
  640                $mode == self::MODE_ALL_BLOCKED) {
 
  643            $noti->switchMode(
$mode);
 
  656        $set = 
$ilDB->queryF(
 
  657            "SELECT * FROM member_noti " .
 
  658            " WHERE ref_id = %s ",
 
  662        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  663            $ilDB->insert(
"member_noti", array(
 
  664                "ref_id" => array(
"integer", $new_ref_id),
 
  665                "nmode" => array(
"integer", $rec[
"nmode"])
 
An exception for terminatinating execution or to throw for unit testing.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getLogger($a_component_id)
Get component logger.
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?
static isActiveForRefId(int $ref_id)
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.
cloneSettings($new_ref_id)
Clone notification object settings.
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.
foreach($_POST as $key=> $value) $res