public function edit_posting_action() { $posting = new ForumPosting(Request::get("topic_id")); $thread = new ForumPosting($posting['root_id']); if ($posting['user_id'] !== $GLOBALS['user']->id && !$GLOBALS['perm']->have_studip_perm("tutor", $posting['Seminar_id'])) { throw new AccessDeniedException("Kein Zugriff"); } $old_content = $posting['description']; $messaging = new messaging(); ForumPosting::$mention_thread_id = $thread->getId(); StudipTransformFormat::addStudipMarkup("mention1", '@\\"[^\\n\\"]*\\"', "", "ForumPosting::mention"); StudipTransformFormat::addStudipMarkup("mention2", '@[^\\s]*[\\d\\w_]+', "", "ForumPosting::mention"); $new_content = transformBeforeSave(studip_utf8decode(Request::get("content"))); //$new_content = preg_replace("/(@\"[^\n\"]*\")/e", "ForumPosting::mention('\\1', '".$thread->getId()."')", $new_content); //$new_content = preg_replace("/(@[^\s]+)/e", "ForumPosting::mention('\\1', '".$thread->getId()."')", $new_content); if ($new_content && $old_content !== $new_content) { $posting['description'] = $new_content; if ($posting['topic_id'] === $posting['root_id']) { if (strpos($new_content, "\n") !== false) { $posting['name'] = substr($new_content, 0, strpos($new_content, "\n")); } else { if (strlen($new_content) > 255) { $posting['name'] = ""; } else { $posting['name'] = $new_content; } } } $posting->store(); if ($posting['user_id'] !== $GLOBALS['user']->id) { $messaging->insert_message(sprintf(_("%s hat als Moderator gerade Ihren Beitrag im Blubberforum editiert.\n\nDie alte Version des Beitrags lautete:\n\n%s\n\nDie neue lautet:\n\n%s\n"), get_fullname(), $old_content, $posting['description']), get_username($posting['user_id']), $GLOBALS['user']->id, null, null, null, null, _("Änderungen an Ihrem Posting.")); } } elseif (!$new_content) { if ($posting['user_id'] !== $GLOBALS['user']->id) { $messaging->insert_message(sprintf(_("%s hat als Moderator gerade Ihren Beitrag im Blubberforum GELÖSCHT.\n\nDer alte Beitrag lautete:\n\n%s\n"), get_fullname(), $old_content), get_username($posting['user_id']), $GLOBALS['user']->id, null, null, null, null, _("Ihr Posting wurde gelöscht.")); } $posting->delete(); } ForumPosting::$course_hashes = $thread['user_id'] !== $thread['Seminar_id'] ? $thread['Seminar_id'] : false; $this->render_text(studip_utf8encode(ForumPosting::format($posting['description']))); }