コード例 #1
0
ファイル: ruleadministration.php プロジェクト: ratbird/hope
 /**
  * Deletes the given admission rule type from the system, including all
  * data belonging to it (especially saved values in DB!).
  */
 public function uninstall_action($ruleType)
 {
     if (Request::int('really')) {
         try {
             $ruleAdmin = new RuleAdministrationModel();
             $ruleAdmin->uninstall($ruleType);
             $this->flash['success'] = _('Die Anmelderegel wurde erfolgreich gelöscht.');
         } catch (AdmissionRuleInstallationException $e) {
             $this->flash['error'] = $e->getMessage();
         }
         $this->redirect($this->url_for('admission/ruleadministration'));
     }
     if (Request::int('cancel')) {
         $this->redirect($this->url_for('admission/ruleadministration'));
     }
 }
コード例 #2
0
ファイル: courseset.php プロジェクト: ratbird/hope
 /**
  * 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)));
     }
 }