コード例 #1
0
ファイル: topics.php プロジェクト: ratbird/hope
 public function edit_action($topic_id = null)
 {
     if (!$GLOBALS['perm']->have_studip_perm("tutor", $_SESSION['SessionSeminar'])) {
         throw new AccessDeniedException();
     }
     $this->topic = new CourseTopic($topic_id);
     $this->dates = CourseDate::findBySeminar_id($_SESSION['SessionSeminar']);
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->set_content_type('text/html;Charset=windows-1252');
         $this->response->add_header('X-Title', $topic_id ? _("Bearbeiten") . ": " . $this->topic['title'] : _("Neues Thema erstellen"));
     }
 }
コード例 #2
0
ファイル: CourseEvent.class.php プロジェクト: ratbird/hope
 public function __construct($id = null)
 {
     $this->permission_user_id = $GLOBALS['user']->id;
     parent::__construct($id);
 }
コード例 #3
0
ファイル: timesrooms.php プロジェクト: ratbird/hope
 /**
  * Deletes a date.
  *
  * @param String $termin_id Id of the date
  * @param String $sub_cmd Sub command to be executed
  * @param String $cycle_id Id of the associated cycle
  */
 private function deleteDate($termin_id, $sub_cmd, $cycle_id)
 {
     //cancel cycledate entry
     if ($sub_cmd === 'cancel') {
         $termin = CourseDate::find($termin_id);
         $seminar_id = $termin->range_id;
         $room = $termin->getRoom();
         $termin->cancelDate();
         log_event('SEM_DELETE_SINGLEDATE', $termin_id, $seminar_id, 'Cycle_id: ' . $cycle_id);
         //delete singledate entry
     } else {
         if ($sub_cmd === 'delete') {
             $termin = CourseDate::find($termin_id) ?: CourseExDate::find($termin_id);
             $seminar_id = $termin->range_id;
             $termin_room = $termin->getRoom();
             $termin_date = $termin->getFullname();
             if ($termin->delete()) {
                 log_event("SEM_DELETE_SINGLEDATE", $termin_id, $seminar_id, 'appointment cancelled');
                 if (Request::get('approveDelete')) {
                     if (Config::get()->RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW) {
                         $this->course->createMessage(sprintf(_('Sie haben den Termin %s gelöscht, dem ein Thema zugeorndet war.' . ' Sie können das Thema in der %sExpertenansicht des Ablaufplans%s einem anderen Termin (z.B. einem Ausweichtermin) zuordnen.'), $termin_date, '<a href="' . URLHelper::getLink('themen.php?cmd=changeViewMode&newFilter=expert') . '">', '</a>'));
                     } elseif ($room) {
                         $this->course->createMessage(sprintf(_('Der Termin %s wurde gelöscht! Die Buchung für den Raum %s wurde gelöscht.'), $termin_date, $termin_room));
                     } else {
                         $this->course->createMessage(sprintf(_('Der Termin %s wurde gelöscht!'), $termin_date));
                     }
                 } else {
                     // no approval needed, delete unquestioned
                     $this->course->createMessage(sprintf(_('Der Termin %s wurde gelöscht!'), $termin_date));
                 }
             }
         }
     }
 }
コード例 #4
0
 /**
  * Import and update the dates
  */
 public function afterUpdate(SimpleORMap $object, $line)
 {
     $weekdays = array('so' => 0, 'su' => 0, 'mo' => 1, 'di' => 2, 'die' => 2, 'tue' => 2, 'mi' => 3, 'we' => 3, 'do' => 4, 'thu' => 4, 'fr' => 5, 'fri' => 5, 'sa' => 6);
     $zeiten = $line['zeit'];
     $zeiten = preg_split("/\\s*,\\s*/", $zeiten, null, PREG_SPLIT_NO_EMPTY);
     $singledates = array();
     $metadates = array();
     $import_type_dates = "karlsruhe_coursedates_import_" . $object->getId();
     $import_type_metadates = "karlsruhe_coursemetadates_import_" . $object->getId();
     foreach ($zeiten as $zeit) {
         if (!is_numeric(trim($zeit[0]))) {
             preg_match("/(\\w+) (\\d+):(\\d+)\\s*-\\s*(\\d+):(\\d+)/", $zeit, $matches);
             $day = strtolower($matches[1]);
             if (isset($weekdays[$day])) {
                 $statement = DBManager::get()->prepare("\n                        SELECT metadate_id \n                        FROM seminar_cycle_dates \n                        WHERE seminar_id = :course_id\n                            AND start_time = :start_time\n                            AND end_time = :end_time\n                            AND weekday = :weekday\n                    ");
                 $statement->execute(array('course_id' => $object->getId(), 'start_time' => $matches[2] . ":" . $matches[3] . ":00", 'end_time' => $matches[4] . ":" . $matches[5] . ":00", 'weekday' => $weekdays[$day]));
                 $found = false;
                 foreach ($statement->fetchAll(PDO::FETCH_COLUMN) as $cycle_id) {
                     if (FleximportMappedItem::findbyItemId($cycle_id, $import_type_metadates)) {
                         $found = $cycle_id;
                         break;
                     }
                 }
                 if (!$found) {
                     /*$semester = $object->end_semester;
                       $cycle = new SeminarCycleDate(); //Does not work yet
                       $cycle['seminar_id'] = $object->getId();
                       $cycle->start_hour = $matches[2];
                       $cycle->start_minute = $matches[3];
                       $cycle->end_hour = $matches[4];
                       $cycle->end_minute = $matches[5];
                       $cycle['weekday'] = $weekdays[$day];
                       $cycle['week_offset'] = 0;
                       $cycle['end_offset'] = floor(($semester->ende - $semester->beginn) / (7*24*60*60)) - 2;
                       $cycle['cycle'] = 0; //wöchentlich
                       $cycle->store();
                       $cycle_id = $cycle->getId();*/
                     $seminar = new Seminar($object->getId());
                     $cycle_id = $seminar->addCycle(array('day' => $weekdays[$day], 'start_stunde' => $matches[2], 'start_minute' => $matches[3], 'end_stunde' => $matches[4], 'end_minute' => $matches[5], 'week_offset' => 0, 'startWeek' => 0, 'turnus' => 0));
                     $mapped = new FleximportMappedItem();
                     $mapped['table_id'] = $import_type_metadates;
                     $mapped['item_id'] = $cycle_id;
                     $mapped->store();
                     $metadates[] = $cycle_id;
                 } else {
                     $seminar = new Seminar($object->getId());
                     $seminar->editCycle(array('cycle_id' => $found, 'day' => $weekdays[$day], 'start_stunde' => $matches[2], 'start_minute' => $matches[3], 'end_stunde' => $matches[4], 'end_minute' => $matches[5], 'week_offset' => 0, 'startWeek' => 0, 'turnus' => 0));
                     /*$semester = $object->end_semester;
                       $cycle = new SeminarCycleDate($found);
                       $cycle['seminar_id'] = $object->getId();
                       $cycle->start_hour = $matches[2];
                       $cycle->start_minute = $matches[3];
                       $cycle->end_hour = $matches[4];
                       $cycle->end_minute = $matches[5];
                       $cycle['weekday'] = $weekdays[$day];
                       $cycle['cycle'] = 0; //wöchentlich
                       $cycle['week_offset'] = 0;
                       $cycle['end_offset'] = floor(($semester->ende - $semester->beginn) / (7*24*60*60)) - 2;
                       $cycle->store();*/
                     $metadates[] = $found;
                 }
             }
         } else {
             //$zeit = explode("-", $zeit);
             preg_match("/(\\d{4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2})\\s*-\\s(\\d{4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2})/", $zeit, $matches);
             $begin = strtotime($matches[1]);
             $end = strtotime($matches[2]);
             $found = false;
             $dates = CourseDate::findBySQL("range_id = :course_id AND date = :begin AND end_time = :end", array('course_id' => $object->getId(), 'begin' => $begin, 'end' => $end));
             foreach ($dates as $date) {
                 if (FleximportMappedItem::findbyItemId($date->getId(), $import_type_dates)) {
                     $found = true;
                     $singledates[] = $date->getId();
                     break;
                 }
             }
             if (!$found) {
                 $date = new CourseDate();
                 $date['range_id'] = $object->getId();
                 $date['date'] = $begin;
                 $date['end_time'] = $end;
                 $date->store();
                 $mapped = new FleximportMappedItem();
                 $mapped['table_id'] = $import_type_dates;
                 $mapped['item_id'] = $date->getId();
                 $mapped->store();
                 $singledates[] = $date->getId();
             }
         }
     }
     $items = FleximportMappedItem::findBySQL("table_id = :table_id AND item_id NOT IN (:ids)", array('table_id' => $import_type_dates, 'ids' => $singledates ?: ""));
     foreach ($items as $item) {
         $date = new CourseDate($item['item_id']);
         $date->delete();
         $item->delete();
     }
     $items = FleximportMappedItem::findBySQL("table_id = :table_id AND item_id NOT IN (:ids)", array('table_id' => $import_type_metadates, 'ids' => $metadates ?: ""));
     foreach ($items as $item) {
         $cycle = new SeminarCycleDate($item['item_id']);
         $cycle->delete();
     }
 }
コード例 #5
0
ファイル: dates.php プロジェクト: ratbird/hope
 public function remove_topic_action()
 {
     if (!$GLOBALS['perm']->have_studip_perm("tutor", $_SESSION['SessionSeminar'])) {
         throw new AccessDeniedException();
     }
     $topic = new CourseTopic(Request::option("issue_id"));
     $date = new CourseDate(Request::option("termin_id"));
     $date->removeTopic($topic);
     $output = array();
     $this->render_json($output);
 }
コード例 #6
0
ファイル: CourseExDate.class.php プロジェクト: ratbird/hope
 /**
  * Converts a CourseExDate Entry to a CourseDate Entry
  * returns instance of the new CourseDate or NULL
  * @return Object CourseDate
  */
 public function unCancelDate()
 {
     $ex_date = $this->toArray();
     //REMOVE content
     unset($ex_date['content']);
     //REMOVE termin_id from ex_termin
     unset($ex_date['termin_id']);
     $date = new CourseDate();
     $date->setData($ex_date);
     if ($date->store()) {
         log_event('SEM_UNDELETE_SINGLEDATE', $this->termin_id, $this->range_id, 'Cycle_id: ' . $this->metadate_id);
         $this->delete();
         return $date;
     }
     return null;
 }
コード例 #7
0
ファイル: CourseDate.class.php プロジェクト: ratbird/hope
 /**
  * Stores this date.
  *
  * @return bool indicating whether the date was stored or not
  */
 public function store()
 {
     $old_entry = CourseDate::find($this->termin_id);
     if ($this->isNew() && !isset($this->metadate_id) && parent::store()) {
         log_event('SEM_ADD_SINGLEDATE', $this->range_id, $this->getFullname());
         return true;
     }
     if (!$this->isNew() && !isset($this->metadate_id) && parent::store()) {
         if ($old_entry->date != $this->date || $old_entry->end_time != $this->end_time) {
             log_event('SINGLEDATE_CHANGE_TIME', $this->range_id, $old_entry->getFullname(), $old_entry->getFullname() . ' -> ' . $this->getFullname());
         }
         return true;
     }
     if (parent::store()) {
         return true;
     }
     return false;
 }