예제 #1
0
 /**
  * this action is the main action of the schedule-controller, setting the environment for the timetable,
  * accepting a comma-separated list of days.
  *
  * @param  string  a list of an arbitrary mix of the numbers 0-6, separated with a comma (e.g. 1,2,3,4,5 (for Monday to Friday, the default))
  */
 function index_action($days = false)
 {
     if ($GLOBALS['perm']->have_perm('admin')) {
         $inst_mode = true;
     }
     $my_schedule_settings = $GLOBALS['user']->cfg->SCHEDULE_SETTINGS;
     // set the days to be displayed
     if ($days === false) {
         if (Request::getArray('days')) {
             $this->days = array_keys(Request::getArray('days'));
         } else {
             $this->days = array(0, 1, 2, 3, 4, 5, 6);
         }
     } else {
         $this->days = explode(',', $days);
     }
     // try to find the correct institute-id
     $institute_id = Request::option('institute_id', $SessSemName[1] ? $SessSemName[1] : Request::option('cid', false));
     if (!$institute_id) {
         $institute_id = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;
     }
     if (!$institute_id || in_array(get_object_type($institute_id), words('inst fak')) === false) {
         throw new Exception(sprintf(_('Kann Einrichtungskalendar nicht anzeigen!' . 'Es wurde eine ungültige Instituts-Id übergeben (%s)!', $institute_id)));
     }
     // load semester-data and current semester
     $semdata = new SemesterData();
     $this->semesters = $semdata->getAllSemesterData();
     if (Request::option('semester_id')) {
         $this->current_semester = $semdata->getSemesterData(Request::option('semester_id'));
     } else {
         $this->current_semester = $semdata->getCurrentSemesterData();
     }
     $this->entries = (array) CalendarInstscheduleModel::getInstituteEntries($GLOBALS['user']->id, $this->current_semester, 8, 20, $institute_id, $this->days);
     Navigation::activateItem('/course/main/schedule');
     PageLayout::setHelpKeyword('Basis.TerminkalenderStundenplan');
     PageLayout::setTitle($GLOBALS['SessSemName']['header_line'] . ' - ' . _('Veranstaltungs-Stundenplan'));
     $zoom = Request::int('zoom', 0);
     $this->controller = $this;
     $this->calendar_view = new CalendarWeekView($this->entries, 'instschedule');
     $this->calendar_view->setHeight(40 + 20 * $zoom);
     $this->calendar_view->setRange($my_schedule_settings['glb_start_time'], $my_schedule_settings['glb_end_time']);
     $this->calendar_view->groupEntries();
     // if enabled, group entries with same start- and end-date
     URLHelper::addLinkParam('zoom', $zoom);
     URLHelper::addLinkParam('semester_id', $this->current_semester['semester_id']);
     $style_parameters = array('whole_height' => $this->calendar_view->getOverallHeight(), 'entry_height' => $this->calendar_view->getHeight());
     $factory = new Flexi_TemplateFactory($this->dispatcher->trails_root . '/views');
     PageLayout::addStyle($factory->render('calendar/stylesheet', $style_parameters));
     if (Request::option('printview')) {
         PageLayout::addStylesheet('print.css');
     } else {
         PageLayout::addStylesheet('print.css', array('media' => 'print'));
     }
 }
예제 #2
0
 function get_seminars_by_sem_tree_id($sem_tree_id, $term_id)
 {
     $db = DBManager::get();
     $sem_data_obj = new SemesterData();
     $semester = $sem_data_obj->getSemesterData($term_id);
     $stmt = $db->prepare('SELECT s.Seminar_id AS seminar_id, s.Name AS name
                           FROM seminar_sem_tree st
                           JOIN seminare s ON (st.seminar_id = s.Seminar_id)
                           WHERE st.sem_tree_id = ?  AND s.start_time <= ?
                           AND (s.start_time + s.duration_time >= ? OR duration_time = -1)');
     $stmt->execute(array($sem_tree_id, $semester['beginn'], $semester['beginn']));
     return $stmt->fetchAll();
 }
예제 #3
0
 function ShowSemSchedules ($resource_id, $semester_id = null, $timespan = 'sem_time') {
     $sem = new SemesterData();
     if (!$semester_id){
         $this->semester = $sem->getCurrentSemesterData();
     } else {
         $this->semester = $sem->getSemesterData($semester_id);
     }
     $this->timespan = $timespan;
     if  ($this->timespan == 'sem_time'){
         $next_sem = $sem->getNextSemesterData($this->semester['vorles_ende']);
         $this->start_time = $this->semester['vorles_ende'];
         $this->end_time = is_array($next_sem) ? $next_sem['vorles_beginn'] : $this->semester['ende'];
     } else {
         $this->start_time = $this->semester['vorles_beginn'];
         $this->end_time = $this->semester['vorles_ende'];
     }
     parent::ShowSchedules($resource_id);
 }
예제 #4
0
파일: Schedule.php 프로젝트: ratbird/hope
 /**
  * returns schedule for a given user and semester
  *
  * @get /user/:user_id/schedule/:semester_id
  * @get /user/:user_id/schedule
  */
 public function getSchedule($user_id, $semester_id = NULL)
 {
     if ($user_id !== $GLOBALS['user']->id) {
         $this->error(401);
     }
     $semdata = new \SemesterData();
     $current_semester = isset($semester_id) ? $semdata->getSemesterData($semester_id) : $semdata->getCurrentSemesterData();
     if (!$current_semester) {
         $this->notFound('No such semester.');
     }
     $schedule_settings = \UserConfig::get($user_id)->SCHEDULE_SETTINGS;
     $days = $schedule_settings['glb_days'];
     $entries = \CalendarScheduleModel::getEntries($user_id, $current_semester, $schedule_settings['glb_start_time'], $schedule_settings['glb_end_time'], $days, $visible = false);
     $json = array();
     foreach ($entries as $number_of_day => $schedule_of_day) {
         $entries = array();
         foreach ($schedule_of_day->entries as $entry) {
             $entries[$entry['id']] = self::entryToJson($entry);
         }
         $json[$number_of_day + 1] = $entries;
     }
     $this->etag(md5(serialize($json)));
     return $json;
 }
예제 #5
0
        $_SESSION['resources_data']["search_array"]["resources_search_range"]=$_SESSION['resources_data']["browse_open_level"]=Request::quoted('resources_search_range');
        $search_property_val = Request::quotedArray('search_property_val');
        if (is_array($search_property_val))
            foreach ($search_property_val as $key=>$val) {
                if ((substr($val, 0, 4) == "_id_") && (substr($search_property_val[$key+1], 0, 4) != "_id_") && ($search_property_val[$key+1]))
                    $_SESSION['resources_data']["search_array"]["properties"][substr($val, 4, strlen($val))]=$search_property_val[$key+1];
        }

        //handle dates for searching resources that are free for this times
        /// >> changed for advanced room searches
        if (Request::get('search_day_of_week')!=-1) // a day is selected. this indicates the user searches a room for the whole term
        {
            /// search whole term
            $semesterData = new SemesterData();
            $sel_semester = $semesterData->getSemesterData(Request::option('search_semester'));
            $date =  (int)$sel_semester["vorles_beginn"];

            $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');

            $beginn_day = date('w', $date);

            $target_day = array_search(Request::option('search_day_of_week'), $days);

            $diff = $target_day - $beginn_day;

            // wrap around
            if ($diff < 0)
            {
                $diff = 7 + $diff;
            }
예제 #6
0
파일: schedule.php 프로젝트: ratbird/hope
 /**
  * this action is the main action of the schedule-controller, setting the environment
  * for the timetable, accepting a comma-separated list of days.
  *
  * @param  string  $days  a list of an arbitrary mix of the numbers 0-6, separated
  *                        with a comma (e.g. 1,2,3,4,5 (for Monday to Friday, the default))
  * @return void
  */
 function index_action($days = false)
 {
     global $user;
     $schedule_settings = CalendarScheduleModel::getScheduleSettings();
     if ($GLOBALS['perm']->have_perm('admin')) {
         $inst_mode = true;
     }
     if ($inst_mode) {
         // try to find the correct institute-id
         $institute_id = Request::option('institute_id', $SessSemName[1] ? $SessSemName[1] : Request::option('cid', false));
         if (!$institute_id) {
             $institute_id = UserConfig::get($user->id)->MY_INSTITUTES_DEFAULT;
         }
         if (!$institute_id || !in_array(get_object_type($institute_id), words('fak inst'))) {
             throw new Exception('Cannot display institute-calender. No valid ID given!');
         }
         Navigation::activateItem('/browse/my_courses/schedule');
     } else {
         Navigation::activateItem('/calendar/schedule');
     }
     // check, if the hidden seminar-entries shall be shown
     $show_hidden = Request::int('show_hidden', 0);
     // load semester-data and current semester
     $semdata = new SemesterData();
     $this->semesters = array_reverse($semdata->getAllSemesterData());
     if (Request::option('semester_id')) {
         $this->current_semester = $semdata->getSemesterData(Request::option('semester_id'));
     } else {
         $this->current_semester = $semdata->getCurrentSemesterData();
     }
     // check type-safe if days is false otherwise sunday (0) cannot be chosen
     if ($days === false) {
         if (Request::getArray('days')) {
             $this->days = array_keys(Request::getArray('days'));
         } else {
             $this->days = $schedule_settings['glb_days'];
             foreach ($this->days as $key => $day_number) {
                 $this->days[$key] = ($day_number + 6) % 7;
             }
         }
     } else {
         $this->days = explode(',', $days);
     }
     $this->controller = $this;
     $this->calendar_view = $inst_mode ? CalendarScheduleModel::getInstCalendarView($institute_id, $show_hidden, $this->current_semester, $this->days) : CalendarScheduleModel::getUserCalendarView($GLOBALS['user']->id, $show_hidden, $this->current_semester, $this->days);
     // have we chosen an entry to display?
     if ($this->flash['entry']) {
         if ($inst_mode) {
             $this->show_entry = $this->flash['entry'];
         } else {
             if ($this->flash['entry']['id'] == null) {
                 $this->show_entry = $this->flash['entry'];
             } else {
                 foreach ($this->calendar_view->getColumns() as $entry_days) {
                     foreach ($entry_days->getEntries() as $entry) {
                         if ($this->flash['entry']['cycle_id']) {
                             if ($this->flash['entry']['id'] . '-' . $this->flash['entry']['cycle_id'] == $entry['id']) {
                                 $this->show_entry = $entry;
                                 $this->show_entry['id'] = reset(explode('-', $this->show_entry['id']));
                             }
                         } else {
                             if ($entry['id'] == $this->flash['entry']['id']) {
                                 $this->show_entry = $entry;
                             }
                         }
                     }
                 }
             }
         }
     }
     $style_parameters = array('whole_height' => $this->calendar_view->getOverallHeight(), 'entry_height' => $this->calendar_view->getHeight());
     $factory = new Flexi_TemplateFactory($this->dispatcher->trails_root . '/views');
     PageLayout::addStyle($factory->render('calendar/stylesheet', $style_parameters), 'screen, print');
     if (Request::option('printview')) {
         $this->calendar_view->setReadOnly();
         PageLayout::addStylesheet('print.css');
     } else {
         PageLayout::addStylesheet('print.css', array('media' => 'print'));
     }
     $this->show_hidden = $show_hidden;
     $inst = get_object_name($institute_id, 'inst');
     $this->inst_mode = $inst_mode;
     $this->institute_name = $inst['name'];
     $this->institute_id = $institute_id;
     if (Request::get('show_settings')) {
         $this->show_settings = true;
     }
 }