/** * add user * * @access protected * @param * @return */ protected function add() { global $ilUser, $tree, $ilCtrl; // TODO: language vars // set aggreement accepted $this->setAccepted(true); include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $free = max(0, $this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers()); $waiting_list = new ilCourseWaitingList($this->container->getId()); if ($this->container->isSubscriptionMembershipLimited() and $this->container->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) { $waiting_list->addToList($ilUser->getId()); $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($ilUser->getId())); ilUtil::sendSuccess($info, true); $this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST, $ilUser->getId()); $this->participants->sendNotification($this->participants->NOTIFY_WAITING_LIST, $ilUser->getId()); $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $tree->getParentId($this->container->getRefId())); $ilCtrl->redirectByClass("ilrepositorygui", ""); } switch ($this->container->getSubscriptionType()) { case IL_CRS_SUBSCRIPTION_CONFIRMATION: $this->participants->addSubscriber($ilUser->getId()); $this->participants->updateSubscriptionTime($ilUser->getId(), time()); $this->participants->updateSubject($ilUser->getId(), ilUtil::stripSlashes($_POST['subject'])); $this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_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_CRS_MEMBER); $this->participants->sendNotification($this->participants->NOTIFY_ADMINS, $ilUser->getId()); $this->participants->sendNotification($this->participants->NOTIFY_REGISTERED, $ilUser->getId()); include_once './Modules/Forum/classes/class.ilForumNotification.php'; ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId()); if ($this->container->getType() == "crs") { $this->container->checkLPStatusSync($ilUser->getId()); } if (!$_SESSION["pending_goto"]) { ilUtil::sendSuccess($this->lng->txt("crs_subscription_successful"), true); $this->ctrl->returnToParent($this); } else { $tgt = $_SESSION["pending_goto"]; unset($_SESSION["pending_goto"]); ilUtil::redirect($tgt); } break; } }
/** * @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 = ilCourseConstants::CRS_MEMBER, $a_force_registration = false) { global $ilCtrl, $tree; include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php'; include_once "./Modules/Course/classes/class.ilCourseParticipants.php"; $part = ilCourseParticipants::_getInstanceByObjId($this->getId()); if ($part->isAssigned($a_user_id)) { return true; } if (!$a_force_registration) { // Availability if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) { include_once './Modules/Group/classes/class.ilObjGroupAccess.php'; if (!ilObjCourseAccess::_usingRegistrationCode()) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course subscription is deactivated.', '456'); } } // Time Limitation if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) { if (!$this->inSubscriptionTime()) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course is out of registration time.', '789'); } } // Max members if ($this->isSubscriptionMembershipLimited()) { $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers()); include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $waiting_list = new ilCourseWaitingList($this->getId()); if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) { $waiting_list->addToList($a_user_id); $this->lng->loadLanguageModule("crs"); $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($a_user_id)); include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $participants = ilCourseParticipants::_getInstanceByObjId($this->getId()); $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id); throw new ilMembershipRegistrationException($info, '124'); } if (!$this->enabledWaitingList() && !$free) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', membership is limited.', '123'); } } } $part->add($a_user_id, $a_role); $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id); $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id); include_once './Modules/Forum/classes/class.ilForumNotification.php'; ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id); return true; }
function sendNotification($a_type, $a_usr_id) { include_once './Modules/Course/classes/class.ilCourseMembershipMailNotification.php'; global $ilObjDataCache, $ilUser; switch ($a_type) { case $this->NOTIFY_DISMISS_SUBSCRIBER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_REFUSED_SUBSCRIPTION_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_ACCEPT_SUBSCRIBER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_DISMISS_MEMBER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_DISMISS_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_BLOCK_MEMBER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_BLOCKED_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_UNBLOCK_MEMBER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_UNBLOCKED_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_ACCEPT_USER: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_ADMISSION_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_STATUS_CHANGED: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_STATUS_CHANGED); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_UNSUBSCRIBE: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_UNSUBSCRIBE_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_REGISTERED: $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_SUBSCRIBE_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->send(); break; case $this->NOTIFY_WAITING_LIST: include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $wl = new ilCourseWaitingList($this->obj_id); $pos = $wl->getPosition($a_usr_id); $mail = new ilCourseMembershipMailNotification(); $mail->setType(ilCourseMembershipMailNotification::TYPE_WAITING_LIST_MEMBER); $mail->setRefId($this->ref_id); $mail->setRecipients(array($a_usr_id)); $mail->setAdditionalInformation(array('position' => $pos)); $mail->send(); break; case $this->NOTIFY_SUBSCRIPTION_REQUEST: $this->sendSubscriptionRequestToAdmins($a_usr_id); break; case $this->NOTIFY_ADMINS: $this->sendNotificationToAdmins($a_usr_id); return true; break; } return true; }