/** * 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); }
/** * fill max members * * @access protected * @param * @return */ protected function fillMaxMembers() { global $ilUser; if (!$this->container->isSubscriptionMembershipLimited()) { return true; } $tpl = new ilTemplate('tpl.max_members_form.html', true, true, 'Services/Membership'); $tpl->setVariable('TXT_MAX', $this->lng->txt('mem_max_users')); $tpl->setVariable('NUM_MAX', $this->container->getSubscriptionMaxMembers()); $tpl->setVariable('TXT_FREE', $this->lng->txt('mem_free_places') . ":"); $free = max(0, $this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers()); if ($free) { $tpl->setVariable('NUM_FREE', $free); } else { $tpl->setVariable('WARN_FREE', $free); } include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $waiting_list = new ilCourseWaitingList($this->container->getId()); if ($this->container->isSubscriptionMembershipLimited() and $this->container->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) { if ($waiting_list->isOnList($ilUser->getId())) { $tpl->setVariable('TXT_WAIT', $this->lng->txt('mem_waiting_list_position')); $tpl->setVariable('NUM_WAIT', $waiting_list->getPosition($ilUser->getId())); } else { $tpl->setVariable('TXT_WAIT', $this->lng->txt('mem_waiting_list')); if ($free and $waiting_list->getCountUsers()) { $tpl->setVariable('WARN_WAIT', $waiting_list->getCountUsers()); } else { $tpl->setVariable('NUM_WAIT', $waiting_list->getCountUsers()); } } } $alert = ''; if (!$free and !$this->container->enabledWaitingList()) { // Disable registration $this->enableRegistration(false); ilUtil::sendFailure($this->lng->txt('mem_alert_no_places')); #$alert = $this->lng->txt('mem_alert_no_places'); } elseif ($this->container->enabledWaitingList() and $this->container->isSubscriptionMembershipLimited() and $waiting_list->isOnList($ilUser->getId())) { // Disable registration $this->enableRegistration(false); } elseif (!$free and $this->container->enabledWaitingList() and $this->container->isSubscriptionMembershipLimited()) { ilUtil::sendFailure($this->lng->txt('crs_warn_no_max_set_on_waiting_list')); #$alert = $this->lng->txt('crs_warn_no_max_set_on_waiting_list'); } elseif ($free and $this->container->enabledWaitingList() and $this->container->isSubscriptionMembershipLimited() and $this->getWaitingList()->getCountUsers()) { ilUtil::sendFailure($this->lng->txt('crs_warn_wl_set_on_waiting_list')); #$alert = $this->lng->txt('crs_warn_wl_set_on_waiting_list'); } $max = new ilCustomInputGUI($this->lng->txt('mem_participants')); $max->setHtml($tpl->get()); if (strlen($alert)) { $max->setAlert($alert); } $this->form->addItem($max); return true; }