/** * Shows the current restrictions for course participation. */ function index_action() { URLHelper::addLinkParam('return_to_dialog', Request::isDialog()); $this->sidebar = Sidebar::get(); $this->sidebar->setImage("sidebar/seminar-sidebar.png"); if ($GLOBALS['perm']->have_perm('admin')) { $list = new SelectorWidget(); $list->setUrl("?#admin_top_links"); $list->setSelectParameterName("cid"); foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) { $list->addElement(new SelectElement($seminar['Seminar_id'], $seminar['Name']), 'select-' . $seminar['Seminar_id']); } $list->setSelection($this->course_id); $this->sidebar->addWidget($list); } $this->all_domains = UserDomain::getUserDomains(); $this->seminar_domains = array_map(function ($d) { return $d->getId(); }, UserDomain::getUserDomainsForSeminar($this->course_id)); $this->current_courseset = CourseSet::getSetForCourse($this->course_id); $this->activated_admission_rules = AdmissionRule::getAvailableAdmissionRules(); if (!$this->current_courseset) { $available_coursesets = new SimpleCollection(); foreach (CourseSet::getCoursesetsByInstituteId($this->course->institut_id) as $cs) { $cs = new CourseSet($cs['set_id']); if ($cs->isUserAllowedToAssignCourse($this->user_id, $this->course_id)) { $available_coursesets[] = array('id' => $cs->getId(), 'name' => $cs->getName(), 'chdate' => $cs->chdate, 'my_own' => $cs->getUserId() === $GLOBALS['user']->id); } } foreach (CourseSet::getglobalCoursesets() as $cs) { $cs = new CourseSet($cs['set_id']); if ($cs->isUserAllowedToAssignCourse($this->user_id, $this->course_id)) { $available_coursesets[] = array('id' => $cs->getId(), 'name' => $cs->getName(), 'chdate' => $cs->chdate, 'my_own' => $cs->getUserId() === $GLOBALS['user']->id); } } $available_coursesets = $available_coursesets->findBy('chdate', strtotime('-1 year'), '>'); $available_coursesets->orderBy('name'); $this->available_coursesets = $available_coursesets; PageLayout::postMessage(MessageBox::info(_("Für diese Veranstaltung sind keine Anmelderegeln festgelegt. Die Veranstaltung ist damit für alle Nutzer zugänglich."))); } else { if ($this->current_courseset->isSeatDistributionEnabled() && !$this->course->admission_turnout) { PageLayout::postMessage(MessageBox::info(_("Diese Veranstaltung ist teilnahmebeschränkt, aber die maximale Teilnehmeranzahl ist nicht gesetzt."))); } } $lockdata = LockRules::getObjectRule($this->course_id); if ($lockdata['description'] && LockRules::CheckLockRulePermission($this->course_id, $lockdata['permission'])) { PageLayout::postMessage(MessageBox::info(formatLinks($lockdata['description']))); } }
/** * Show all coursesets the current user has access to. */ public function index_action() { $this->course_set_details = Request::option('course_set_details'); if ($this->course_set_details && Request::isXhr()) { $courseset = new CourseSet($this->course_set_details); return $this->render_text($courseset->toString()); } $this->ruleTypes = RuleAdministrationModel::getAdmissionRuleTypes(); $this->coursesets = array(); foreach (words('current_institut_id current_rule_types set_name_prefix current_semester_id current_rule_types') as $param) { $this->{$param} = $_SESSION[get_class($this)][$param]; } if (Request::submitted('choose_institut')) { $this->current_institut_id = Request::option('choose_institut_id'); $this->current_rule_types = Request::getArray('choose_rule_type'); $this->set_name_prefix = trim(Request::get('set_name_prefix')); $this->current_semester_id = Request::option('select_semester_id'); } if ($this->current_semester_id === null) { $this->current_semester_id = $_SESSION['_default_sem']; } else { if ($this->current_semester_id !== '0') { $_SESSION['_default_sem'] = $this->current_semester_id; } } if (!isset($this->current_rule_types)) { $this->current_rule_types['ParticipantRestrictedAdmission'] = true; } $filter['course_set_name'] = $this->set_name_prefix; $filter['semester_id'] = $this->current_semester_id != 'all' ? $this->current_semester_id : null; $filter['rule_types'] = array_keys($this->current_rule_types); $this->myInstitutes = CoursesetModel::getInstitutes($filter); if (!$this->current_institut_id) { if ($this->myInstitutes['all']['num_sets'] < 100) { $this->current_institut_id = 'all'; } else { next($this->myInstitutes); $this->current_institut_id = key($this->myInstitutes); reset($this->myInstitutes); } } list($institut_id, $all) = explode('_', $this->current_institut_id); if ($institut_id == 'all') { $institutes = array_keys($this->myInstitutes); } else { if ($all == 'all') { $institutes[] = $institut_id; $institutes = array_merge($institutes, Institute::find($institut_id)->sub_institutes->pluck('institut_id')); } else { $institutes = array($institut_id); } } foreach ($institutes as $one) { if ($this->myInstitutes[$one]['num_sets']) { $sets = CourseSet::getCoursesetsByInstituteId($one, $filter); foreach ($sets as $set) { $courseset = new CourseSet($set['set_id']); $this->coursesets[$set['set_id']] = $courseset; } } } uasort($this->coursesets, function ($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }); foreach (words('current_institut_id current_rule_types set_name_prefix current_semester_id current_rule_types') as $param) { $_SESSION[get_class($this)][$param] = $this->{$param}; } $not_distributed_coursesets = array_filter(array_map(function ($cs) { return $cs->isSeatDistributionEnabled() && $cs->getSeatDistributionTime() < time() - 1000 && !$cs->hasAlgorithmRun() ? $cs->getName() : null; }, $this->coursesets)); if (count($not_distributed_coursesets)) { PageLayout::postMessage(MessageBox::info(_("Es existieren Anmeldesets, die zum Zeitpunkt der Platzverteilung nicht gelost wurden. Stellen Sie sicher, dass der Cronjob \"Losverfahren überprüfen\" ausgeführt wird."), array_unique($not_distributed_coursesets))); } }