/** * Waiting list tes * @param * @return */ public function testMembership() { include_once './Services/Membership/classes/class.ilWaitingList.php'; include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $wait = new ilCourseWaitingList(999999); $ret = $wait->addToList(111111); $this->assertEquals($ret, true); $wait->updateSubscriptionTime(111111, time()); $wait->removeFromList(111111); $wait->addToList(111111); $ret = $wait->isOnList(111111); $this->assertEquals($ret, true); $wait->addToList(111111); ilWaitingList::_deleteAll(999999); $wait->addToList(111111); ilWaitingList::_deleteUser(111111); }
/** * @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; }
/** * 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; } }