/** * @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; }
/** * 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; }
/** * 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; } }