Пример #1
0
 /**
  * Show the user lists the current user has access to.
  */
 public function index_action()
 {
     $this->userlists = array();
     foreach (AdmissionUserList::getUserLists($GLOBALS['user']->id) as $list) {
         $this->userlists[$list->getId()] = $list;
     }
 }
Пример #2
0
 /**
  * Configure a new or existing course set.
  */
 public function configure_action($coursesetId = '')
 {
     if ($GLOBALS['perm']->have_perm('root')) {
         if ($coursesetId) {
             // Load course set data.
             $this->courseset = new CourseSet($coursesetId);
             $this->myInstitutes = array();
             $selectedInstitutes = $this->courseset->getInstituteIds();
             foreach ($selectedInstitutes as $id => $selected) {
                 $this->myInstitutes[$id] = new Institute($id);
             }
             $this->selectedInstitutes = $this->myInstitutes;
             $selectedCourses = $this->courseset->getCourses();
             if (!$this->instant_course_set_view) {
                 $allCourses = CoursesetModel::getInstCourses(array_keys($this->selectedInstitutes), $coursesetId, array(), $this->courseset->getSemester());
                 $this->selectedSemester = $this->courseset->getSemester();
             }
         } else {
             $this->myInstitutes = array();
             $this->selectedInstitutes = array();
             $allCourses = array();
             $selectedCourses = array();
             $this->selectedSemester = Semester::findCurrent()->semester_id;
         }
         Config::get()->AJAX_AUTOCOMPLETE_DISABLED = false;
         $this->instSearch = QuickSearch::get("institute_id", new StandardSearch("Institut_id"))->withoutButton()->render();
     } else {
         $this->myInstitutes = array();
         $myInstitutes = Institute::getMyInstitutes();
         foreach ($myInstitutes as $institute) {
             $this->myInstitutes[$institute['Institut_id']] = $institute;
         }
         if ($coursesetId) {
             // Load course set data.
             $this->courseset = new CourseSet($coursesetId);
             $selectedInstitutes = $this->courseset->getInstituteIds();
             $this->selectedInstitutes = array();
             foreach ($selectedInstitutes as $id => $selected) {
                 $this->selectedInstitutes[$id] = new Institute($id);
             }
             $selectedCourses = $this->courseset->getCourses();
             if (!$this->instant_course_set_view) {
                 $allCourses = CoursesetModel::getInstCourses(array_keys($this->selectedInstitutes), $coursesetId, array(), $this->courseset->getSemester(), $this->onlyOwnCourses);
                 $this->selectedSemester = $this->courseset->getSemester();
             }
         } else {
             $this->selectedSemester = Semester::findCurrent()->semester_id;
             $this->selectedInstitutes = $this->myInstitutes;
             $allCourses = CoursesetModel::getInstCourses(array_keys($this->myInstitutes), $coursesetId, array(), $this->selectedSemester, $this->onlyOwnCourses);
             $selectedCourses = array();
         }
     }
     // If an institute search has been conducted, we need to consider parameters from flash.
     if ($this->flash['name'] || $this->flash['institutes'] || $this->flash['courses'] || $this->flash['rules'] || $this->flash['userlists'] || $this->flash['infotext'] || $this->flash['semester']) {
         if (!$this->courseset) {
             $this->courseset = new CourseSet($coursesetId);
         }
         if ($this->flash['name']) {
             $this->courseset->setName($this->flash['name']);
         }
         if ($this->flash['institutes']) {
             $institutes = $this->flash['institutes'];
             $this->courseset->setInstitutes($institutes);
             if ($GLOBALS['perm']->have_perm('root')) {
                 $this->myInstitutes = array();
                 foreach ($institutes as $id) {
                     $this->myInstitutes[$id] = new Institute($id);
                     $this->selectedInstitutes[$id] = $this->myInstitutes[$id];
                 }
             }
             $selectedCourses = $this->courseset->getCourses();
             $allCourses = CoursesetModel::getInstCourses(array_flip($institutes), $coursesetId, $selectedCourses, $this->selectedSemester, $this->onlyOwnCourses);
         }
         if ($this->flash['courses']) {
             $courses = $this->flash['courses'];
             $this->courseset->setCourses($courses);
             $selectedCourses = $courses;
         }
         if ($this->flash['rules']) {
             $this->courseset->setAdmissionRules($this->flash['rules']);
         }
         if ($this->flash['userlists']) {
             $this->courseset->setUserlists($this->flash['userlists']);
         }
         if ($this->flash['infotext']) {
             $this->courseset->setInfoText($this->flash['infotext']);
         }
         if ($this->flash['private']) {
             $this->courseset->setPrivate($this->flash['private']);
         }
     }
     // Fetch all lists with special user chances.
     $this->myUserlists = AdmissionUserList::getUserLists($GLOBALS['user']->id);
     $fac = $this->get_template_factory();
     $tpl = $fac->open('admission/courseset/instcourses');
     $tpl->set_attribute('allCourses', $allCourses);
     $tpl->set_attribute('selectedCourses', $selectedCourses);
     $this->coursesTpl = $tpl->render();
     $tpl = $fac->open('admission/courseset/institutes');
     if ($coursesetId) {
         $tpl->set_attribute('courseset', $this->courseset);
     }
     $tpl->set_attribute('instSearch', $this->instSearch);
     $tpl->set_attribute('selectedInstitutes', $this->selectedInstitutes);
     $tpl->set_attribute('myInstitutes', $this->myInstitutes);
     $tpl->set_attribute('controller', $this);
     if ($GLOBALS['perm']->have_perm('admin') || $GLOBALS['perm']->have_perm('dozent') && get_config('ALLOW_DOZENT_COURSESET_ADMIN')) {
         $tpl->set_attribute('rights', true);
     } else {
         $tpl->set_attribute('rights', false);
     }
     $this->instTpl = $tpl->render();
 }