Beispiel #1
0
 /**
  * Return the template for the widget.
  *
  * @return Flexi_PhpTemplate The template containing the widget contents
  */
 public function getPortalTemplate()
 {
     $view = CalendarScheduleModel::getUserCalendarView($GLOBALS['user']->id);
     $template = $GLOBALS['template_factory']->open('shared/string');
     $template->content = CalendarWidgetView::createFromWeekView($view)->render();
     return $template;
 }
 static function getDayDates($user_id, $weekday)
 {
     //get current semester
     $semdata = new \SemesterData();
     $current_semester = $semdata->getCurrentSemesterData();
     $current_semester_id = $current_semester['semester_id'];
     return \CalendarScheduleModel::getEntries($user_id, $current_semester, 00, 2000, array($weekday - 1), false);
 }
Beispiel #3
0
 /**
  * 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;
 }
Beispiel #4
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');
 }
Beispiel #5
0
?>
                        <?php 
echo htmlReady($seminar->getName());
?>
                    </a>
                </td>
                <td width="40%" class="schedule-adminbind">
                    <? $cycles = CalendarScheduleModel::getSeminarCycleId($seminar, $start, $end, $day) ?>

                    <? foreach ($cycles as $cycle) : ?>
                        <span><?php 
echo $cycle->toString();
?>
</span>

                        <? $visible = CalendarScheduleModel::isSeminarVisible($seminar->getId(), $cycle->getMetadateId()) ?>

                        <?php 
echo LinkButton::create(_('Ausblenden'), $controller->url_for('calendar/schedule/adminbind/' . $seminar->getId() . '/' . $cycle->getMetadateId() . '/0'), array('id' => $seminar->getId() . '_' . $cycle->getMetadateId() . '_hide', 'onclick' => "STUDIP.Schedule.instSemUnbind('" . $seminar->getId() . "','" . $cycle->getMetadateId() . "'); return false;", 'style' => $visible ? '' : 'display: none'));
?>

                        <?php 
echo LinkButton::create(_('Einblenden'), $controller->url_for('calendar/schedule/adminbind/' . $seminar->getId() . '/' . $cycle->getMetadateId() . '/1'), array('id' => $seminar->getId() . '_' . $cycle->getMetadateId() . '_show', 'onclick' => "STUDIP.Schedule.instSemBind('" . $seminar->getId() . "','" . $cycle->getMetadateId() . "'); return false;", 'style' => $visible ? 'display: none' : ''));
?>
                        <br>
                    <? endforeach ?>
                </td>
            </tr>
        <? endforeach ?>
    </tbody>
</table>
Beispiel #6
0
/**
 * Removes entries marked in the schedule as virtual.
 * This function serves the following scenario:
 * If a user first added the dates of one seminar to his or her schedule and later did participate in the seminar
 * then the previously as 'virtual' added dates should be removed with this function.
 *
 * @param $user_id the id of the user the schedule belongs to
 * @param $seminar_id the id of the seminar the schedule belongs to
 */
function removeScheduleEntriesMarkedAsVirtual($user_id, $seminar_id)
{
    CalendarScheduleModel::deleteSeminarEntries($user_id, $seminar_id);
}
Beispiel #7
0
 /**
  * Show the given appointment.
  *
  * @param  string  the ID of the course
  * @param  string  the ID of the cycle
  * @param  string  if you give this optional param, it signals an Ajax request
  * @return void
  */
 function bind_action($seminar_id, $cycle_id, $ajax = false)
 {
     CalendarScheduleModel::bind($seminar_id, $cycle_id);
     if (!$ajax) {
         $this->redirect('calendar/schedule');
     } else {
         $this->render_nothing();
     }
 }
Beispiel #8
0
 static function get_next_courses($user_id)
 {
     /*
     
             
     		$items = array();
     	    $db = \DBManager::get();
     	
     		$semester = \SemesterData::getCurrentSemesterData();
     		$semester_begin = $semester["beginn"];
     		$semester_ende  = $semester["ende"];
     	
     		$today =date("N");
     		
     		// !!! bisher ohne cycling, kein Dozent
     		// !! bisher die ersten 5 in der woche
     		// was ist cycle bzw weekoffset inseminar seminar_cycle_dates
     		$fields= "seminar_user.Seminar_id 		AS Seminar_id,
     			  seminar_user.user_id,
     			  seminar_user.visible,
     		 	  seminare.Seminar_id,
     			  seminare.start_time,
     			  seminare.Name				AS name,
     			  seminar_cycle_dates.start_time 	AS beginn,
     			  seminar_cycle_dates.end_time		AS ende,
     			  seminar_cycle_dates.start_time,	
     			  seminar_cycle_dates.weekday		AS weekday,
     			  seminar_cycle_dates.seminar_id,
     			  seminar_cycle_dates.description	AS description
     			 ";
     		$query = "SELECT $fields
     			  FROM  seminar_user
     			  JOIN  seminare ON seminar_user.Seminar_id = seminare.Seminar_id
     			  JOIN  seminar_cycle_dates ON seminar_user.Seminar_id = seminar_cycle_dates.seminar_id
     			  WHERE     seminar_user.user_id = '$user_id' 
     			  		AND seminar_user.visible = 'yes'
     			        AND seminare.start_time  >= '$semester_begin'
     			  ORDER BY seminar_cycle_dates.weekday, seminar_cycle_dates.start_time	
     			 ";
     		$result = $db->query($query);
     		
     		$i = 0;
     		foreach($result as $row)
     		{
     			$i++;
     			$items[$i] = array(
     	                        'id'            => $row['Seminar_id'],
     	                        'title'         => $row['name'],
     	                        'beginn'     	=> substr($row['beginn'], 0, 5),
     	                        'ende'       	=> substr($row['ende'], 0, 5),
     	                        'weekday'       => $row['weekday'],
     	                        'description'   => $row['description']
     	                    );
     		}
     */
     //get current semester
     $semdata = new \SemesterData();
     $current_semester = $semdata->getCurrentSemesterData();
     $current_semester_id = $current_semester['semester_id'];
     $entries = \CalendarScheduleModel::getEntries($user_id, $current_semester, 00, 2000, array(0, 1, 2, 3, 4, 5, 6), false);
     $output = array();
     $counter = 0;
     $currentWeekDay = date("N") - 1;
     $currentTime = date("Gi");
     if (!empty($entries)) {
         for ($i = 0; $i <= 6; $i++) {
             $currentWeekDay += $i;
             if ($currentWeekDay > 6) {
                 $currentWeekDay = 0;
             }
             $currentDayObject = $entries[$currentWeekDay];
             if (!empty($currentDayObject)) {
                 //sortieren der einträge des tages
                 $arrayObject = new \ArrayObject($currentDayObject->getEntries());
                 $arrayObject->uasort('Helper::cmpEarlier');
                 foreach ($arrayObject->getArrayCopy() as $entry) {
                     if ($counter >= 3) {
                         break;
                         $i = 7;
                     }
                     if ($entry["start"] > $currentTime || $i != 0) {
                         $output[$counter] = array("title" => $entry["title"], "description" => $entry["content"], "beginn" => $entry["start_formatted"], "ende" => $entry["end_formatted"], "weekday" => $currentWeekDay + 1, "id" => substr($entry["id"], 0, 32));
                         $counter++;
                     }
                 }
             }
         }
     } else {
         return null;
     }
     return $output;
     /*
     //var_dump($output);
     		//nur die nächsten 3 sollen auftauchen
     		$currentWeekDay =date("N");
     		$i = 0;
     
     		if (!empty($items))
     		{
     			$ausgabe = array();
     			//suchen des nächsten Cycles
     			for ($i = 0; $i <= 6; $i++)
     			{
     				$currentWeekDay +=$i;
     				if($currentWeekDay > 7) $currentWeekDay = 1;
     				foreach($items AS $item)
     				{
     					//an dem gesuchten wochentag event ....
     					if ($item['weekday'] == $currentWeekDay)
     					{
     						//nächstes event gefunden
     						//Auffinden der nächsten beiden
     						$ausgabe[1] = $item;
     						$nextitemID = $item['weekday'];
     						if (isset($items[ $nextitemID ]))
     						{
     							//zweites gefunden
     							$ausgabe[2] = $items[ 1 ];
     							$nextitemID++;
     						}
     						else
     						{
     							$ausgabe[2] = $items[ 1 ];
     							$nextitemID = 2;
     						}
     						if (isset($items[ $nextitemID ]))
     						{
     							//zweites gefunden
     							$ausgabe[3] = $items[ 1 ];
     						}
     						else
     						{
     							$ausgabe[3] = $items[ 1 ];
     						}
     						//fertig
     						$i=8;
     						break;
     					}
     				}
     			}
     		}
     		else
     		{
     			return null;
     		}
     		
     		return $ausgabe;
     */
 }
Beispiel #9
0
 /**
  * Create a CalendarWeekView (a schedule) for the current user and return it.
  *
  * @param string $user_id  the institute to get the calendar for
  * @param bool $show_hidden     show hidden entries
  * @param mixed $semester       the semester to use
  * @param mixed $days           the days to consider
  *
  * @return CalendarWeekView
  */
 static function getUserCalendarView($user_id, $show_hidden = false, $semester = false, $days = false)
 {
     $schedule_settings = self::getScheduleSettings($user_id);
     if (!$semester) {
         $semester = self::getCurrentSemester();
     }
     if (!$days) {
         $days = $schedule_settings['glb_days'];
         foreach ($days as $key => $day_number) {
             $days[$key] = ($day_number + 6) % 7;
         }
     }
     $entries = CalendarScheduleModel::getEntries($user_id, $semester, $schedule_settings['glb_start_time'], $schedule_settings['glb_end_time'], $days, $show_hidden);
     $view = new CalendarWeekView($entries, 'schedule');
     $view->setHeight(40 + 20 * $schedule_settings['zoom']);
     $view->setRange($schedule_settings['glb_start_time'], $schedule_settings['glb_end_time']);
     $view->setInsertFunction("function (entry, column, hour, end_hour) {\n            STUDIP.Schedule.newEntry(entry, column, hour, end_hour)\n        }");
     return $view;
 }