Пример #1
0
 function edit_action($area_id)
 {
     ForumPerm::check('edit_area', $this->getId(), $area_id);
     if (Request::isAjax()) {
         ForumEntry::update($area_id, studip_utf8decode(Request::get('name')), studip_utf8decode(Request::get('content')));
         $this->render_json(array('content' => ForumEntry::killFormat(ForumEntry::killEdit(studip_utf8decode(Request::get('content'))))));
     } else {
         ForumEntry::update($area_id, Request::get('name'), Request::get('content'));
         $this->flash['messages'] = array('success' => _('Die Änderungen am Bereich wurden gespeichert.'));
         $this->redirect(PluginEngine::getLink('coreforum/index/index'));
     }
 }
Пример #2
0
 /**
  * Create/Update the linked posting for the passed issue_id
  * 
  * @param string $seminar_id
  * @param string $issue_id    issue id to link to
  * @param string $title       (new) title of the posting
  * @param string $content     (new) content of the posting
  */
 static function setThreadForIssue($seminar_id, $issue_id, $title, $content)
 {
     if ($topic_id = self::getThreadIdForIssue($issue_id)) {
         // update
         ForumEntry::update($topic_id, $title ?: _('Ohne Titel'), $content);
     } else {
         // create
         // make sure the forum is set up properly
         ForumEntry::checkRootEntry($seminar_id);
         $topic_id = md5(uniqid(rand()));
         ForumEntry::insert(array('topic_id' => $topic_id, 'seminar_id' => $seminar_id, 'user_id' => $GLOBALS['user']->id, 'name' => $title ?: _('Ohne Titel'), 'content' => $content, 'author' => get_fullname($GLOBALS['user']->id), 'author_host' => getenv('REMOTE_ADDR')), $seminar_id);
         $stmt = DBManager::get()->prepare("INSERT INTO forum_entries_issues\n                (issue_id, topic_id) VALUES (?, ?)");
         $stmt->execute(array($issue_id, $topic_id));
     }
 }
Пример #3
0
 /**
  * Update an existing one forum entry
  *
  * @put /forum_entry/:entry_id
  */
 public function updateForumEntry($entry_id)
 {
     $entry = $this->findEntry($entry_id);
     $cid = $parent['course_id'];
     $perm = self::isArea($entry) ? 'edit_area' : 'edit_entry';
     if (!\ForumPerm::hasEditPerms($entry_id) || !\ForumPerm::has($perm, $cid)) {
         $this->error(401);
     }
     $subject = (string) trim($this->data['subject']);
     $content = (string) trim($this->data['content']);
     // areas and threads need a subject, postings do not
     if ($entry['depth'] < 3 && !$subject) {
         $this->error(400, 'Subject required.');
     }
     // all entries besides the area need content
     if ($entry['depth'] > 1 && !$content) {
         $this->error(400, 'Content required.');
     }
     if ($entry['depth'] >= 3 && $subject) {
         $this->error(400, 'Must not have subject here.');
     }
     \ForumEntry::update($entry_id, $subject, $content);
     $this->status(204);
 }
Пример #4
0
 /**
  * Update the submitted entry.
  * 
  * @param string $topic_id id of the entry to update
  * @throws AccessDeniedException
  */
 function update_entry_action($topic_id)
 {
     if (Request::isXhr()) {
         $name = studip_utf8decode(Request::get('name', _('Kein Titel')));
         $content = Studip\Markup::purifyHtml(studip_utf8decode(Request::get('content', _('Keine Beschreibung'))));
     } else {
         $name = Request::get('name', _('Kein Titel'));
         $content = Studip\Markup::purifyHtml(Request::get('content', _('Keine Beschreibung')));
     }
     ForumPerm::check('add_entry', $this->getId(), $topic_id);
     if (ForumPerm::hasEditPerms($topic_id)) {
         ForumEntry::update($topic_id, $name, $content);
     } else {
         throw new AccessDeniedException(_('Sie haben keine Berechtigung, diesen Eintrag zu editieren!'));
     }
     if (Request::isXhr()) {
         $this->render_text(json_encode(array('name' => studip_utf8encode(htmlReady($name)), 'content' => studip_utf8encode(formatReady($content)))));
     } else {
         $this->redirect(PluginEngine::getLink('coreforum/index/index/' . $topic_id . '#' . $topic_id));
     }
 }