Esempio n. 1
0
 public function add_topic_action()
 {
     if (!$GLOBALS['perm']->have_studip_perm("tutor", $_SESSION['SessionSeminar'])) {
         throw new AccessDeniedException();
     }
     if (!Request::get("title")) {
         throw new Exception("Geben Sie einen Titel an.");
     }
     $date = new CourseDate(Request::option("termin_id"));
     $seminar_id = $date['range_id'];
     $title = studip_utf8decode(Request::get("title"));
     $topic = CourseTopic::findByTitle($seminar_id, $title);
     if (!$topic) {
         $topic = new CourseTopic();
         $topic['title'] = $title;
         $topic['seminar_id'] = $seminar_id;
         $topic['author_id'] = $GLOBALS['user']->id;
         $topic['description'] = "";
         $topic->store();
     }
     $date->addTopic($topic);
     $factory = $this->get_template_factory();
     $output = array('topic_id' => $topic->getId());
     $template = $factory->open($this->get_default_template("_topic_li"));
     $template->set_attribute("topic", $topic);
     $template->set_attribute("date", $date);
     $output['li'] = $template->render();
     $this->render_json($output);
 }