/**
  * Preload data
  *
  * @param array $a_obj_ids array of object ids
  */
 function _preloadData($a_obj_ids, $a_ref_ids)
 {
     global $ilDB, $ilUser;
     include_once "./Modules/Group/classes/class.ilGroupWaitingList.php";
     ilGroupWaitingList::_preloadOnListInfo($ilUser->getId(), $a_obj_ids);
 }
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $rbacsystem, $ilUser;
     // BEGIN WebDAV get parent properties
     $props = parent::getProperties();
     // END WebDAV get parent properties
     include_once './Modules/Course/classes/class.ilObjCourseAccess.php';
     $info = ilObjGroupAccess::lookupRegistrationInfo($this->obj_id);
     //var_dump($info);
     if ($info['reg_info_list_prop']) {
         $props[] = array('alert' => false, 'newline' => true, 'property' => $info['reg_info_list_prop']['property'], 'value' => $info['reg_info_list_prop']['value']);
     }
     if ($info['reg_info_list_prop_limit']) {
         $props[] = array('alert' => false, 'newline' => false, 'property' => $info['reg_info_list_prop_limit']['property'], 'propertyNameVisible' => strlen($info['reg_info_list_prop_limit']['property']) ? true : false, 'value' => $info['reg_info_list_prop_limit']['value']);
     }
     // waiting list
     include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
     if (ilGroupWaitingList::_isOnList($ilUser->getId(), $this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt('member_status'), "value" => $lng->txt('on_waiting_list'));
     }
     return $props;
 }
 /**
  * @see ilMembershipRegistrationCodes::register()
  * @param int user_id
  * @param int role
  * @param bool force registration and do not check registration constraints.
  */
 public function register($a_user_id, $a_role = IL_GRP_MEMBER, $a_force_registration = false)
 {
     include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
     include_once "./Modules/Group/classes/class.ilGroupParticipants.php";
     $part = ilGroupParticipants::_getInstanceByObjId($this->getId());
     if ($part->isAssigned($a_user_id)) {
         return true;
     }
     if (!$a_force_registration) {
         // Availability
         include_once './Modules/Group/classes/class.ilObjGroupAccess.php';
         if (!ilObjGroupAccess::_registrationEnabled($this->getId())) {
             $this->lng->loadLanguageModule('crs');
             throw new ilMembershipRegistrationException('456', $this->getRefId());
         }
         // Max members
         if (!$this->isRegistrationUnlimited()) {
             $free = max(0, $this->getMaxMembers() - $part->getCountMembers());
             include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
             $waiting_list = new ilGroupWaitingList($this->getId());
             if ($this->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) {
                 throw new ilMembershipRegistrationException('123', $this->getRefId());
             }
         }
     }
     $part->add($a_user_id, $a_role);
     $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);
     return true;
 }
 /**
  * Send notification mail
  * @param int $a_type
  * @param int $a_usr_id
  * @return 
  */
 public function sendNotification($a_type, $a_usr_id)
 {
     include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
     switch ($a_type) {
         case ilGroupMembershipMailNotification::TYPE_ADMISSION_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_ADMISSION_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_DISMISS_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_DISMISS_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION);
             $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
             $mail->setRefId($this->ref_id);
             $mail->setRecipients($this->getNotificationRecipients());
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_UNSUBSCRIBE_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_UNSUBSCRIBE_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_NOTIFICATION_UNSUBSCRIBE:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_UNSUBSCRIBE);
             $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
             $mail->setRefId($this->ref_id);
             $mail->setRecipients($this->getNotificationRecipients());
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_SUBSCRIBE_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_SUBSCRIBE_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION_REQUEST);
             $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
             $mail->setRefId($this->ref_id);
             $mail->setRecipients($this->getNotificationRecipients());
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_REFUSED_SUBSCRIPTION_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER:
             include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
             $wl = new ilGroupWaitingList($this->obj_id);
             $pos = $wl->getPosition($a_usr_id);
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->setAdditionalInformation(array('position' => $pos));
             $mail->send();
             break;
         case ilGroupMembershipMailNotification::TYPE_STATUS_CHANGED:
             $mail = new ilGroupMembershipMailNotification();
             $mail->setType(ilGroupMembershipMailNotification::TYPE_STATUS_CHANGED);
             $mail->setRefId($this->ref_id);
             $mail->setRecipients(array($a_usr_id));
             $mail->send();
             break;
     }
     return true;
 }
 function getTabs(&$tabs_gui)
 {
     global $rbacsystem, $ilUser, $ilAccess, $lng, $ilHelp;
     $ilHelp->setScreenIdComponent("grp");
     if ($rbacsystem->checkAccess('read', $this->ref_id)) {
         $tabs_gui->addTab("view_content", $lng->txt("content"), $this->ctrl->getLinkTarget($this, ""));
     }
     if ($rbacsystem->checkAccess('visible', $this->ref_id)) {
         $tabs_gui->addTarget("info_short", $this->ctrl->getLinkTargetByClass(array("ilobjgroupgui", "ilinfoscreengui"), "showSummary"), "infoScreen", "", "", false);
     }
     if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings"), get_class($this), "");
     }
     $is_participant = ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId());
     // Members
     $mem_cmd = $ilAccess->checkAccess('write', '', $this->ref_id) ? "members" : "membersGallery";
     if ($mem_cmd != "membersGallery" || $is_participant) {
         $tabs_gui->addTarget("members", $this->ctrl->getLinkTarget($this, $mem_cmd), array(), get_class($this));
     }
     // learning progress
     include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
     if (ilLearningProgressAccess::checkAccess($this->object->getRefId(), $is_participant)) {
         $tabs_gui->addTarget('learning_progress', $this->ctrl->getLinkTargetByClass(array('ilobjgroupgui', 'illearningprogressgui'), ''), '', array('illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui'));
     }
     if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilexportgui', ''), 'export', 'ilexportgui');
     }
     /*
     if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
     {
     	
     	
     	$tabs_gui->addTarget('export',
     						 $this->ctrl->getLinkTarget($this,'listExportFiles'),
     						 array('listExportFiles','exportXML','confirmDeleteExportFile','downloadExportFile'),
     						 get_class($this));
     }
     */
     // parent tabs (all container: edit_permission, clipboard, trash
     parent::getTabs($tabs_gui);
     if ($ilAccess->checkAccess('join', '', $this->object->getRefId()) and !$this->object->members_obj->isAssigned($ilUser->getId())) {
         include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
         if (ilGroupWaitingList::_isOnList($ilUser->getId(), $this->object->getId())) {
             $tabs_gui->addTab('leave', $this->lng->txt('membership_leave'), $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', 'show', ''));
         } else {
             $tabs_gui->addTarget("join", $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', "show"), 'show', "");
         }
     }
     if ($ilAccess->checkAccess('leave', '', $this->object->getRefId()) and $this->object->members_obj->isMember($ilUser->getId())) {
         $tabs_gui->addTarget("grp_btn_unsubscribe", $this->ctrl->getLinkTarget($this, "leave"), '', "");
     }
 }
 /**
  * @see ilMembershipRegistrationCodes::register()
  * @param int user_id
  * @param int role
  * @param bool force registration and do not check registration constraints.
  */
 public function register($a_user_id, $a_role = IL_GRP_MEMBER, $a_force_registration = false)
 {
     include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
     include_once "./Modules/Group/classes/class.ilGroupParticipants.php";
     $part = ilGroupParticipants::_getInstanceByObjId($this->getId());
     if ($part->isAssigned($a_user_id)) {
         return true;
     }
     if (!$a_force_registration) {
         // Availability
         if (!$this->isRegistrationEnabled()) {
             include_once './Modules/Group/classes/class.ilObjGroupAccess.php';
             if (!ilObjGroupAccess::_usingRegistrationCode()) {
                 throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', group subscription is deactivated.', '456');
             }
         }
         // Time Limitation
         if (!$this->isRegistrationUnlimited()) {
             $start = $this->getRegistrationStart();
             $end = $this->getRegistrationEnd();
             $time = new ilDateTime(time(), IL_CAL_UNIX);
             if (!(ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end))) {
                 throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', group is out of registration time.', '789');
             }
         }
         // Max members
         if ($this->isMembershipLimited()) {
             $free = max(0, $this->getMaxMembers() - $part->getCountMembers());
             include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
             $waiting_list = new ilGroupWaitingList($this->getId());
             if ($this->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) {
                 $this->lng->loadLanguageModule("grp");
                 $waiting_list->addToList($a_user_id);
                 $info = sprintf($this->lng->txt('grp_added_to_list'), $this->getTitle(), $waiting_list->getPosition($a_user_id));
                 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
                 include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
                 $participants = ilGroupParticipants::_getInstanceByObjId($this->getId());
                 $participants->sendNotification(ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER, $a_user_id);
                 throw new ilMembershipRegistrationException($info, '124');
             }
             if (!$free or $waiting_list->getCountUsers()) {
                 throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', membership is limited.', '123');
             }
         }
     }
     $part->add($a_user_id, $a_role);
     $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);
     return true;
 }
 /**
  * add user 
  *
  * @access protected
  * @param
  * @return
  */
 protected function add()
 {
     global $ilUser, $tree, $rbacreview, $lng, $ilCtrl;
     // set aggreement accepted
     $this->setAccepted(true);
     include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
     $free = max(0, $this->container->getMaxMembers() - $this->participants->getCountMembers());
     $waiting_list = new ilGroupWaitingList($this->container->getId());
     if ($this->container->isMembershipLimited() and $this->container->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) {
         $waiting_list->addToList($ilUser->getId());
         $info = sprintf($this->lng->txt('grp_added_to_list'), $this->container->getTitle(), $waiting_list->getPosition($ilUser->getId()));
         $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER, $ilUser->getId());
         ilUtil::sendSuccess($info, true);
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
         $ilCtrl->redirectByClass("ilrepositorygui", "");
     }
     switch ($this->container->getRegistrationType()) {
         case GRP_REGISTRATION_REQUEST:
             $this->participants->addSubscriber($ilUser->getId());
             $this->participants->updateSubscriptionTime($ilUser->getId(), time());
             $this->participants->updateSubject($ilUser->getId(), ilUtil::stripSlashes($_POST['subject']));
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION_REQUEST, $ilUser->getId());
             ilUtil::sendSuccess($this->lng->txt("application_completed"), true);
             $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId()));
             $ilCtrl->redirectByClass("ilrepositorygui", "");
             break;
         default:
             $this->participants->add($ilUser->getId(), IL_GRP_MEMBER);
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_REGISTRATION, $ilUser->getId());
             $this->participants->sendNotification(ilGroupMembershipMailNotification::TYPE_SUBSCRIBE_MEMBER, $ilUser->getId());
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId());
             if (!$_SESSION["pending_goto"]) {
                 ilUtil::sendSuccess($this->lng->txt("grp_registration_completed"), true);
                 $this->ctrl->returnToParent($this);
             } else {
                 $tgt = $_SESSION["pending_goto"];
                 unset($_SESSION["pending_goto"]);
                 ilUtil::redirect($tgt);
             }
             break;
     }
 }