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) &&
 
  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"));
 
  491                        $log->debug(
"read member_noti");
 
  492                        $set = 
$ilDB->query(
"SELECT ref_id".
 
  493                                " FROM member_noti");
 
  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);
 
  542                        $force_noti->setRequired(
true);
 
  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");                    
 
  565                                        $option->addSubItem($changeable);
 
  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)
 
  595                                                $force_noti->setValue($current_mode);
 
  596                                                $changeable->setChecked(
true); 
 
  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)
 
  649                        $noti->switchMode(
$mode);                       
 
An exception for terminatinating execution or to throw for unit testing.
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?
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.