示例#1
0
 /**
  * Returns an array of CalendarColumn's, containing the seminar-entries
  * for the passed user (in the passed semester belonging to the passed institute)
  * The start- and end-hour are used to constrain the returned
  * entries to the passed time-period. The passed days constrain the entries
  * to these.
  *
  * @param string  $user_id       the ID of the user
  * @param array   $semester      an array containing the "beginn" of the semester
  * @param int     $start_hour    the start hour
  * @param int     $end_hour      the end hour
  * @param string  $institute_id  the ID of the institute
  * @param array   $days          the days to be displayed
  * @return array  an array containing the entries
  */
 static function getInstituteEntries($user_id, $semester, $start_hour, $end_hour, $institute_id, $days)
 {
     // fetch seminar-entries, show invisible seminars if the user has enough perms
     $visibility_perms = $GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM'));
     $stmt = DBManager::get()->prepare("SELECT * FROM seminare\n            LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.seminar_id)\n            WHERE seminar_inst.institut_id = :institute\n                AND (start_time = :begin\n                    OR (start_time < :begin AND duration_time = -1)\n                    OR (start_time + duration_time >= :begin AND start_time <= :begin)) " . (!$visibility_perms ? " AND visible='1'" : ""));
     $stmt->bindParam(':begin', $semester['beginn']);
     $stmt->bindParam(':institute', $institute_id);
     $stmt->execute();
     while ($entry = $stmt->fetch()) {
         $seminars[$entry['Seminar_id']] = $entry;
     }
     if (is_array($seminars)) {
         foreach ($seminars as $data) {
             $entries = self::getSeminarEntry($data['Seminar_id'], $user_id);
             foreach ($entries as $entry) {
                 unset($entry['url']);
                 $entry['onClick'] = 'function(id) { STUDIP.Instschedule.showInstituteDetails(id); }';
                 $entry['visible'] = 1;
                 if ($entry['start'] >= $start_hour * 100 && $entry['start'] <= $end_hour * 100 || $entry['end'] >= $start_hour * 100 && $entry['end'] <= $end_hour * 100) {
                     $entry['color'] = DEFAULT_COLOR_SEM;
                     $day_number = ($entry['day'] + 6) % 7;
                     if (!isset($ret[$day_number])) {
                         $ret[$day_number] = CalendarColumn::create($day_number);
                     }
                     $ret[$day_number]->addEntry($entry);
                 }
             }
         }
     }
     return CalendarScheduleModel::addDayChooser($ret, $days, 'instschedule');
 }
示例#2
0
 function test_erase_entries()
 {
     $entry = array('start' => "0800", 'end' => "1000", 'title' => "test_title");
     $column = CalendarColumn::create()->addEntry($entry);
     $column->eraseEntries();
     $entries = $column->getEntries();
     $this->assertInternalType("array", $entries);
     $this->assertEquals(0, count($entries));
 }
示例#3
0
 /**
  * adds a new column to this view. All entries created with addEntry will be
  * added to this column.
  * 
  * @param string  $title  like "monday" to be displayed on top of the column
  * @param string  $url    to be called when clicked on the title of the column
  * @param string  $id     any kind of id of the column
  * @return CalendarView
  */
 public function addColumn($title, $url = "", $id = null)
 {
     $this->entries[] = CalendarColumn::create($id)->setTitle($title)->setURL($url);
     return $this;
 }
示例#4
0
文件: schedule.php 项目: ratbird/hope
 /**
  * adds title and link to CalendarColumn-objects and sorts the objects to be
  * displayed correctly in the calendar-view
  *
  * @param array $entries  an array of CalendarColumn-objects
  * @param array $days     an array of int's, denoting the days to be displayed
  * @return array
  */
 static function addDayChooser($entries, $days, $controller = 'schedule')
 {
     $day_names = array(_("Montag"), _("Dienstag"), _("Mittwoch"), _("Donnerstag"), _("Freitag"), _("Samstag"), _("Sonntag"));
     $ret = array();
     foreach ($days as $day) {
         if (!isset($entries[$day])) {
             $ret[$day] = CalendarColumn::create($day);
         } else {
             $ret[$day] = $entries[$day];
         }
         if (sizeof($days) == 1) {
             $ret[$day]->setTitle($day_names[$day] . ' (' . _('zurück zur Wochenansicht') . ')')->setURL('dispatch.php/calendar/' . $controller . '/index');
         } else {
             $ret[$day]->setTitle($day_names[$day])->setURL('dispatch.php/calendar/' . $controller . '/index/' . $day);
         }
     }
     return $ret;
 }