public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); $author_id = isset($this->params[1]) ? $this->params[1] : null; if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } $content = \Messageboard::getInstance()->loadTemplate("forum_all_topics.template.html"); $dsc = $messageboard->get_attribute("OBJ_DESC"); if (!empty($dsc)) { $content->setCurrentBlock("BLOCK_DESCRIPTION"); $content->setVariable("FORUM_DESCRIPTION", get_formatted_output($dsc)); $content->parse("BLOCK_DESCRIPTION"); } $grp = $messageboard->get_environment()->get_creator(); if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") { $grp = $grp->get_parent_group(); } $content->setVariable("CURRENT_DISCUSSIONS_LABEL", gettext("Current Thread")); $content->setVariable("LABEL_SEARCH", gettext("Search")); if (isset($_GET["action"]) && $_GET["action"] == "bookmark_rss") { \lms_steam::user_add_rssfeed($messageboard->get_id(), PATH_URL . "services/feeds/forum_public.php?id=" . $messageboard->get_id(), "discussion board", \lms_steam::get_link_to_root($messageboard)); $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("You are keeping an eye on '%NAME' from now on.")); header("Location: " . PATH_URL . "forums/" . $messageboard->get_id() . "/"); exit; } if (isset($_GET["action"]) && $_GET["action"] == "delete_bookmark") { $user = \lms_steam::get_current_user(); $id = (int) $_GET["unsubscribe"]; $feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!is_array($feeds)) { $feeds = array(); } unset($feeds[$id]); $user->set_attribute("USER_RSS_FEEDS", $feeds); $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("subscription of '%NAME' canceled.")); header("Location: " . PATH_URL . "forums/" . $messageboard->get_id() . "/"); exit; } if (empty($_GET["pattern"]) && !isset($author_id)) { $cache = get_cache_function(OBJ_ID, 300); $discussions = $cache->call("lms_forum::get_discussions", OBJ_ID); } elseif (isset($author_id)) { $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 300); $discussions = $cache->call("lms_forum::search_user_posts", $messageboard->get_id(), $author_id); } else { $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 300); $discussions = $cache->call("lms_forum::search_pattern", $messageboard->get_id(), $_GET["pattern"]); } $content->setVariable("LABEL_ALL_TOPICS", gettext("All Threads")); if ($messageboard->check_access_annotate(\lms_steam::get_current_user())) { $content->setCurrentBlock("BLOCK_WRITE_ACCESS"); if (isset($author_id)) { $content->setVariable("LABEL_THREADS_POSTED_IN", gettext("All Threads")); // TODO: Passt der link? $content->setVariable("LINK_AUTHOR", PATH_URL . "forums/" . $messageboard->get_id() . "/"); } else { $content->setVariable("LABEL_THREADS_POSTED_IN", gettext("Threads you've posted in")); // TODO: Passt der link? $content->setVariable("LINK_AUTHOR", PATH_URL . "forums/" . $messageboard->get_id() . "/?author=" . \lms_steam::get_current_user()->get_name()); } // TODO: Passt der link? $content->setVariable("LINK_POST_NEW", PATH_URL . "messageboard/newDiscussion/" . $messageboard->get_id()); $content->setVariable("LABEL_POST_NEW_THREAD", gettext("Post a new thread")); $content->parse("BLOCK_WRITE_ACCESS"); } if ($messageboard->check_access_write(\lms_steam::get_current_user())) { $content->setCurrentBlock("BLOCK_ADMIN"); $content->setVariable("LINK_EDIT", PATH_URL . "messageboard/editMessageboard/" . $messageboard->get_id()); $content->setVariable("LABEL_EDIT", gettext("Preferences")); $content->setVariable("LINK_DELETE", PATH_URL . "messageboard/deleteMessageboard/" . $messageboard->get_id()); $content->setVariable("LABEL_DELETE", gettext("Delete forum")); $content->parse("BLOCK_ADMIN"); } $content->setCurrentBlock("BLOCK_WATCH"); if ($is_watching) { $content->setVariable("LABEL_BOOKMARK", gettext("End watching")); // TODO: Passt der link? $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $messageboard->get_id() . "/?action=delete_bookmark&unsubscribe=" . $messageboard->get_id()); } else { $content->setVariable("LABEL_BOOKMARK", gettext("Watch this forum")); // TODO: Passt der link? $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $messageboard->get_id() . "/?action=bookmark_rss"); } $content->parse("BLOCK_WATCH"); // ACCESS $access_descriptions = \lms_forum::get_access_descriptions($grp); $access_descriptions = $access_descriptions[$messageboard->get_attribute(KOALA_ACCESS)]; $access = $access_descriptions["summary_short"] . ": " . $access_descriptions["label"]; $content->setCurrentBlock("BLOCK_ACCESS"); $content->setVariable("TITLE_ACCESS", gettext("Access")); $content->setVariable("LABEL_ACCESS", $access); $content->parse("BLOCK_ACCESS"); $content->setVariable("LABEL_TITLE", gettext("Title")); $content->setVariable("LABEL_AUTHOR", gettext("Author")); $content->setVariable("LABEL_REPLIES", gettext("Replies")); $content->setVariable("LABEL_LATEST_POST", gettext("Latest Post")); // PAGE SETZEN $no_discussions = count($discussions); $paginator = \lms_portal::get_paginator(20, $no_discussions, gettext("(%TOTAL discussions in forum)")); $start = $paginator["startIndex"]; //$start = $portal->set_paginator( $content, 20, $no_discussions, gettext( "(%TOTAL discussions in forum)" ) ); $end = $start + 20 > $no_discussions ? $no_discussions : $start + 20; for ($i = $start; $i < $end; $i++) { $discussion = $discussions[$i]; $content->setVariable("PAGINATOR", $paginator["html"]); $content->setCurrentBlock("BLOCK_THREAD"); if (time() - $discussion["LATEST_POST_TS"] > $_SESSION["last_login"]) { $content->setCurrentBlock("BLOCK_THREAD_NEW"); $content->setVariable("NEW_LABEL", gettext("New")); $content->parse("BLOCK_THREAD_NEW"); } $content->setVariable("THREAD_LINK", PATH_URL . "messageboard/viewDiscussion/" . $discussion["OBJ_ID"] . "/"); $content->setVariable("THREAD_SUBJECT", h($discussion["OBJ_NAME"])); $content->setVariable("THREAD_LAST_ENTRY", how_long_ago($discussion["LATEST_POST_TS"])); // TODO: Passt der link? $content->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $discussion["AUTHOR_LOGIN"] . "/"); $content->setVariable("AUTHOR_IMAGE", PATH_URL . "cached/get_document.php?id=" . $discussion["OBJ_ICON"] . "&type=usericon&width=30&height=40"); $title = !empty($discussion["USER_ACADEMIC_TITLE"]) ? $discussion["USER_ACADEMIC_TITLE"] . " " : ""; $content->setVariable("AUTHOR_NAME", h($title . $discussion["USER_FIRSTNAME"] . " " . $discussion["USER_FULLNAME"])); $content->setVariable("THREAD_REPLIES", h($discussion["REPLIES"])); $content->parse("BLOCK_THREAD"); } $portal->set_rss_feed(PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID, gettext("Feed"), str_replace("%l", isset($login) ? $login : "", gettext("Subscribe to this forum's Newsfeed"))); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($messageboard); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($messageboard->get_name()))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $comment_id = $this->params[1]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment_id); $content = \Messageboard::getInstance()->loadTemplate("comment_edit.template.html"); if ($_SERVER["REQUEST_METHOD"] == "GET") { $content->setVariable("LABEL_HERE_IT_IS", ""); $content->setVariable("TEXT_COMMENT", h($comment->get_content())); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); } else { $values = $_POST["values"]; if (!empty($values["save"])) { $comment->set_content($values["message"]); require_once "Cache/Lite.php"; // Handle Related Cache-Data (for the case that the subject may be editable in the future) require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean forumcache $fcache = get_cache_function(OBJ_ID, 600); $fcache->drop("lms_forum::get_discussions", OBJ_ID); // clean cache for Weblog RSS Feed for the Comments $cache = get_cache_function(OBJ_ID, 600); $discussions = $cache->drop("lms_steam::get_annotations", OBJ_ID); // clean rsscache $rcache = get_cache_function("rss", 600); // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); header("Location: " . $values["return_to"]); exit; } else { // PREVIEW $content->setCurrentBlock("BLOCK_PREVIEW"); $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit")); $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["message"])); $content->parse("BLOCK_PREVIEW"); $content->setVariable("LABEL_HERE_IT_IS", gettext("Change it?")); $content->setVariable("TEXT_COMMENT", h($values["message"])); $content->setVariable("BACK_LINK", $values["return_to"]); } } $content->setVariable("LABEL_BB_BOLD", gettext("B")); $content->setVariable("HINT_BB_BOLD", gettext("boldface")); $content->setVariable("LABEL_BB_ITALIC", gettext("I")); $content->setVariable("HINT_BB_ITALIC", gettext("italic")); $content->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $content->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $content->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $content->setVariable("HINT_BB_IMAGE", gettext("image")); $content->setVariable("LABEL_BB_URL", gettext("URL")); $content->setVariable("HINT_BB_URL", gettext("web link")); $content->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $content->setVariable("HINT_BB_MAIL", gettext("email link")); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("LABEL_RETURN", gettext("back")); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($messageboard); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Edit a comment"))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $portal = \lms_portal::get_instance(); if (!isset($messageboard) || !is_object($messageboard)) { if (empty($this->params[0])) { throw new \Exception("Environment not set."); } if (empty($this->params[1])) { throw new \Exception("Group not set."); } if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[0]))) { throw new \Exception("Environment unknown."); } if (!($grp = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]))) { throw new \Exception("Group unknown"); } } $accessmergel = FALSE; if (isset($messageboard) && is_object($messageboard)) { $creator = $messageboard->get_creator(); if ($messageboard->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(\lms_steam::get_current_user())) { $accessmergel = TRUE; } } // TODO: Passt der link? $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { $values = $_POST["values"]; if (get_magic_quotes_gpc()) { if (!empty($values['name'])) { $values['name'] = stripslashes($values['name']); } if (!empty($values['dsc'])) { $values['dsc'] = stripslashes($values['dsc']); } } if (empty($values["name"])) { $problems = gettext("The name of new message board is missing."); $hints = gettext("Please type in a name."); } if (strpos($values["name"], "/")) { if (!isset($problems)) { $problems = ""; } $problems .= gettext("Please don't use the \"/\"-char in the the forum name."); } if (empty($problems)) { $group_members = $grp; $group_admins = 0; $group_staff = 0; // check if group is a course $grouptype = (string) $grp->get_attribute("OBJ_TYPE"); if ($grouptype == "course") { $group_staff = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".staff"); $group_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".admins"); $group_members = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners"); $workroom = $group_members->get_workroom(); } else { $workroom = $grp->get_workroom(); } if (!isset($messageboard) || !is_object($messageboard)) { $new_forum = \steam_factory::create_messageboard($GLOBALS["STEAM"]->get_id(), $values["name"], $env, $values["dsc"]); $_SESSION["confirmation"] = str_replace("%NAME", h($values["name"]), gettext("New forum '%NAME' created.")); } else { $messageboard->set_attribute(OBJ_NAME, $values["name"]); $messageboard->set_attribute(OBJ_DESC, $values["dsc"]); $portal->set_confirmation(gettext("The changes have been saved.")); $new_forum = $messageboard; } $koala_forum = new \lms_forum($new_forum); $access = (int) $values["access"]; $access_descriptions = \lms_forum::get_access_descriptions($grp); if (!$accessmergel) { $koala_forum->set_access($access, $access_descriptions[$access]["members"], $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins); } $GLOBALS["STEAM"]->buffer_flush(); $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_MESSAGEBOARD, array("FORUM_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); if (!isset($messageboard) || !is_object($messageboard)) { header("Location: " . $backlink); exit; } } else { $portal->set_problem_description($problems, isset($hints) ? $hints : ""); } } $content = \Messageboard::getInstance()->loadTemplate("object_new.template.html"); if (isset($messageboard) && is_object($messageboard)) { $content->setVariable("INFO_TEXT", str_replace("%NAME", h($messageboard->get_name()), gettext("You are going to edit the forum '<b>%NAME</b>'."))); $content->setVariable("LABEL_CREATE", gettext("Save changes")); $pagetitle = gettext("Preferences"); if (empty($values)) { $values = array(); $values["name"] = $messageboard->get_name(); $values["dsc"] = $messageboard->get_attribute(OBJ_DESC); $values["access"] = $messageboard->get_attribute(KOALA_ACCESS); } $breadcrumbheader = gettext("Preferences"); } else { $grpname = $grp->get_attribute(OBJ_NAME); if ($grp->get_attribute(OBJ_TYPE) == "course") { $grpname = $grp->get_attribute(OBJ_DESC); } $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new forum in '<b>%ENV</b>'."))); $content->setVariable("LABEL_CREATE", gettext("Create forum")); $pagetitle = gettext("Create forum"); $breadcrumbheader = gettext("Add new forum"); } if (!empty($values)) { if (!empty($values["name"])) { $content->setVariable("VALUE_NAME", h($values["name"])); } if (!empty($values["dsc"])) { $content->setVariable("VALUE_DSC", h($values["dsc"])); } } $content->setVariable("VALUE_BACKLINK", $backlink); $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>"); $content->setVariable("LABEL_NAME", gettext("Name")); $content->setVariable("LABEL_DSC", gettext("Description")); $content->setVariable("LABEL_BB_BOLD", gettext("B")); $content->setVariable("HINT_BB_BOLD", gettext("boldface")); $content->setVariable("LABEL_BB_ITALIC", gettext("I")); $content->setVariable("HINT_BB_ITALIC", gettext("italic")); $content->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $content->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $content->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $content->setVariable("HINT_BB_IMAGE", gettext("image")); $content->setVariable("LABEL_BB_URL", gettext("URL")); $content->setVariable("HINT_BB_URL", gettext("web link")); $content->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $content->setVariable("HINT_BB_MAIL", gettext("email link")); $content->setVariable("LABEL_ACCESS", gettext("Access")); if ((string) $grp->get_attribute("OBJ_TYPE") == "course") { $access_default = PERMISSION_PUBLIC; } else { $access_default = PERMISSION_PUBLIC; } if ($accessmergel) { $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n"); $content->setCurrentBlock("BLOCK_ACCESSMERGEL"); $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again."))); $content->parse("BLOCK_ACCESSMERGEL"); } else { $access = \lms_forum::get_access_descriptions($grp); if (is_array($access)) { $content->setCurrentBlock("BLOCK_ACCESS"); foreach ($access as $key => $array) { if ($key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) { $content->setCurrentBlock("ACCESS"); $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]); $content->setVariable("VALUE", $key); if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) { $content->setVariable("CHECK", "checked=\"checked\""); } $content->parse("ACCESS"); } } $content->parse("BLOCK_ACCESS"); } } // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($grp); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication"))); if (isset($messageboard) && is_object($messageboard)) { $headline[] = array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()); } $headline[] = array("link" => "", "name" => $breadcrumbheader); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } $object = $messageboard; $user = \lms_steam::get_current_user(); if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The forum '%NAME' has been deleted.")); $workroom = $object->get_environment(); \lms_steam::delete($object); // Clean Cache for the deleted Forum require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache = get_cache_function(OBJ_ID, 600); $cache->drop("lms_steam::get_annotations", OBJ_ID); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean forum cache $fcache = get_cache_function(OBJ_ID, 600); $fcache->drop("lms_forum::get_discussions", OBJ_ID); // clean cache for forum RSS Feed for the Comments $fcache->drop("lms_steam::get_annotations", OBJ_ID); // clean rsscache $rcache = get_cache_function("rss", 600); // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); // Clean communication summary cache für the group/course if (is_object($workroom)) { $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_MESSAGEBOARD, array("FORUM_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); } header("Location: " . PATH_URL . "group/index"); exit; } } $content = \Messageboard::getInstance()->loadTemplate("object_delete.template.html"); if ($object->check_access_write($user)) { $content->setVariable("LABEL_ARE_YOU_SURE", str_replace("%NAME", h($object->get_name()), gettext("Are you sure you want to delete the forum '%NAME' ?"))); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($object); $content->setVariable("DELETE_BACK_LINK", $rootlink[1]["link"] . "communication/"); $content->setCurrentBlock("BLOCK_DELETE"); $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $content->parse("BLOCK_DELETE"); } else { $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this forum!")); } $content->setVariable("TEXT_INFORMATION", gettext("The forum and all its entries be deleted.")); $creator = $object->get_creator(); $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON")); $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($object->get_attribute("OBJ_CREATION_TIME"))); $icon = $creator_data["OBJ_ICON"]; if ($icon instanceof \steam_object) { $icon_id = $icon->get_id(); } else { $icon_id = 0; } $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id); // TODO: Passt der Link? $rootlink = \lms_steam::get_link_to_root($object); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($object->get_name()), "link" => PATH_URL . "forums/" . $object->get_id() . "/"), array("name" => gettext("Delete forum"))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $comment_id = $this->params[1]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } // no direct call /* TODO: Soll das rein? if (!defined('_VALID_KOALA')) { header("location:/"); exit; } */ $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment_id); $user = \lms_steam::get_current_user(); if ($_SERVER["REQUEST_METHOD"] == "POST" && $comment->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { $_SESSION["confirmation"] = str_replace("%NAME", h($comment->get_name()), gettext("The comment '%NAME' has been deleted.")); $annotating = $comment->get_annotating(); $annotating->remove_annotation($comment); \lms_steam::delete($comment); require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache = get_cache_function(OBJ_ID, 600); $cache->drop("lms_steam::get_annotations", OBJ_ID); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean forumcache $fcache = get_cache_function(OBJ_ID, 600); $fcache->drop("lms_forum::get_discussions", OBJ_ID); // clean cache for Weblog RSS Feed for the Comments $fcache->drop("lms_steam::get_annotations", OBJ_ID); // clean rsscache $rcache = get_cache_function("rss", 600); // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); header("Location: " . PATH_URL . "messageboard/viewDiscussion/" . $forum_id); exit; } } $content = \Messageboard::getInstance()->loadTemplate("comment_delete.template.html"); if ($comment->check_access_write($user)) { $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this comment?")); if (isset($document)) { // TODO: Passt der link? $content->setVariable("DELETE_BACK_LINK", PATH_URL . "doc/" . OBJ_ID . "/"); } else { if (isset($weblog)) { // TODO: Passt der link? $content->setVariable("DELETE_BACK_LINK", PATH_URL . "weblog/" . OBJ_ID . "/"); } else { // TODO: Passt der link? $content->setVariable("DELETE_BACK_LINK", PATH_URL . "forums/" . OBJ_ID . "/"); } } $content->setCurrentBlock("BLOCK_DELETE"); $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $content->parse("BLOCK_DELETE"); } else { $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this comment!")); } $content->setVariable("TEXT_COMMENT", get_formatted_output($comment->get_content())); $creator = $comment->get_creator(); $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON")); $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($comment->get_attribute("OBJ_CREATION_TIME"))); $icon = $creator_data["OBJ_ICON"]; if ($icon instanceof \steam_object) { $icon_id = $icon->get_id(); } else { $icon_id = 0; } $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($messageboard); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Delete comment"))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } $content = \Messageboard::getInstance()->loadTemplate("forum_discussion.template.html"); $content->setVariable("REPLY_LABEL", gettext("Reply to this topic?")); if ($_SERVER["REQUEST_METHOD"] == "POST" && $thread->check_access_annotate(\lms_steam::get_current_user())) { $values = $_POST["values"]; if (empty($values["body"])) { $portal->set_problem_description(gettext("Please enter your message.")); } if (!empty($values["save"]) && !empty($values["body"])) { $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "Re: " . $thread->get_name(), $values["body"]); // $all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER ); // $new_comment->set_acquire( FALSE ); // $new_comment->set_read_access( $all_user, TRUE ); // $new_comment->set_write_access( $all_user, FALSE ); // $new_comment->set_annotate_access( $all_user, TRUE ); $thread->add_annotation($new_comment); $new_comment->set_acquire($thread); $mbid = $messageboard->get_id(); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($mbid); // clean forumcache $fcache = get_cache_function($forum_id, 600); $fcache->drop("lms_forum::get_discussions", $forum_id); // clean forumcache $fcache = get_cache_function($mbid, 600); $fcache->drop("lms_forum::get_discussions", $mbid); // clean rsscache of the forum // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID; $rcache = get_cache_function("rss", 600); $rcache->drop("lms_rss::get_items", $feedlink); } else { if (empty($values["save"]) && !empty($values["body"])) { // PREVIEW $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT"); $content->setVariable("LABEL_PREVIEW_COMMENT", gettext("Preview the edit")); $content->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["body"])); $content->setVariable("TEXT_COMMENT", h($values["body"])); $content->parse("BLOCK_PREVIEW_COMMENT"); $content->setVariable("REPLY_LABEL", gettext("Change it?")); } } } if (isset($_GET["action"]) && $_GET["action"] == "bookmark_rss") { \lms_steam::user_add_rssfeed($messageboard->get_id(), PATH_URL . "services/feeds/forum_public.php?id=" . $messageboard->get_id(), "discussion board", \lms_steam::get_link_to_root($messageboard)); $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("You are keeping an eye on '%NAME' from now on.")); header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/"); exit; } if (isset($_GET["action"]) && $_GET["action"] == "delete_bookmark") { $user = \lms_steam::get_current_user(); $id = (int) $_GET["unsubscribe"]; $feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!is_array($feeds)) { $feeds = array(); } unset($feeds[$id]); $user->set_attribute("USER_RSS_FEEDS", $feeds); $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("subscription of '%NAME' canceled.")); header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/"); exit; } $content->setVariable("CURRENT_DISCUSSIONS_LABEL", gettext("Current Thread")); $cache = get_cache_function($messageboard->get_id(), 600); $discussions = $cache->call("lms_forum::get_discussions", $messageboard->get_id()); $max_discussions = 12; foreach ($discussions as $discussion) { $max_discussions--; if ($max_discussions == 0) { $content->setCurrentBlock("BLOCK_TOPIC_INFO"); $content->setVariable("TOPIC_LINK", PATH_URL . "forums/" . $messageboard->get_id() . "/"); $content->setVariable("TOPIC_TITLE", gettext("More...")); $content->parse("BLOCK_TOPIC_INFO"); break; } $content->setCurrentBlock("BLOCK_TOPIC_INFO"); if (time() - $discussion["LATEST_POST_TS"] > $_SESSION["last_login"]) { $content->setCurrentBlock("BLOCK_TOPIC_NEW"); $content->setVariable("NEW_LABEL", gettext("New")); $content->parse("BLOCK_TOPIC_NEW"); } $content->setVariable("TOPIC_LINK", PATH_URL . "messageboard/viewDiscussion/" . $discussion["OBJ_ID"] . "/"); $content->setVariable("TOPIC_TITLE", h($discussion["OBJ_NAME"])); $content->setVariable("TOPIC_LAST_ENTRY", gettext("Latest:") . how_long_ago($discussion["LATEST_POST_TS"])); $content->parse("BLOCK_TOPIC_INFO"); } $content->setVariable("LABEL_TOPICS_POSTED", gettext("Topics you've posted in")); $content->setVariable("LINK_AUTHOR", PATH_URL . "forums/" . $messageboard->get_id() . "/?author=" . \lms_steam::get_current_user()->get_name()); $content->setVariable("LABEL_POST_NEW", gettext("Post a new topic")); $content->setVariable("LINK_POST_NEW", PATH_URL . "messageboard/newDiscussion/" . $messageboard->get_id()); $content->setCurrentBlock("BLOCK_WATCH"); if ($is_watching) { $content->setVariable("LABEL_BOOKMARK", gettext("End watching")); $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=delete_bookmark&unsubscribe=" . $messageboard->get_id()); } else { $content->setVariable("LABEL_BOOKMARK", gettext("Watch this forum")); $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=bookmark_rss"); } $content->parse("BLOCK_WATCH"); $content->setVariable("DISCUSSION_SUBJECT", h($thread->get_name())); $author = $thread->get_creator(); $author_data = $author->get_attributes(array("OBJ_NAME", "USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON")); $content->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/"); $icon = $author_data["OBJ_ICON"]; if ($icon instanceof \steam_object) { $icon_id = $icon->get_id(); } else { $icon_id = 0; } $content->setVariable("AUTHOR_IMAGE", PATH_URL . "cached/get_document.php?id=" . $icon_id . "&type=usericon&width=60&height=70"); $content->setVariable("NAME_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/\">" . h($author_data["USER_FIRSTNAME"]) . " " . h($author_data["USER_FULLNAME"]) . "</a>", gettext("%n says:"))); $content->setVariable("DISCUSSION_TEXT", get_formatted_output($thread->get_content(), 65, "\n")); $ts = $thread->get_attribute("OBJ_CREATION_TIME"); $content->setVariable("DISCUSSION_STARTED_TS", gettext("Posted at") . " " . strftime("%H:%M", $ts) . " | " . strftime("%d. %B %Y", $ts)); $content->setVariable("DISCUSSION_PERMALINK", PATH_URL . 'forums/' . $discussion['OBJ_ID'] . '/'); $content->setVariable("DISCUSSION_PERMALINK_TEXT", gettext("permalink")); $steam_user = \lms_steam::get_current_user(); if ($thread->check_access_write($steam_user)) { $content->setCurrentBlock("BLOCK_OWN_DISCUSSION"); $content->setVariable("DISCUSSION_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $messageboard->get_id() . "/" . $thread->get_id()); $content->setVariable("DISCUSSION_LABEL_DELETE", gettext("delete")); $content->setVariable("DISCUSSION_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $thread->get_id()); $content->setVariable("DISCUSSION_LABEL_EDIT", gettext("edit")); $content->parse("BLOCK_OWN_DISCUSSION"); } $annotations = \lms_steam::get_annotations($thread->get_id()); $annotations = array_reverse($annotations); $access_tnr = array(); foreach ($annotations as $annotation) { $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT); $access_tnr[$steam_obj->get_id()] = $steam_obj->check_access_write($steam_user, TRUE); } $access_result = $GLOBALS["STEAM"]->buffer_flush(); foreach ($annotations as $annotation) { $content->setCurrentBlock("REPLY"); $content->setVariable('REPLY_ID', $annotation['OBJ_ID']); $content->setVariable("REPLYER_LINK", PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/"); $content->setVariable("REPLYER_IMAGE", PATH_URL . "cached/get_document.php?id=" . $annotation["OBJ_ICON"] . "&type=usericon&width=60&height=70"); $content->setVariable("REPLYER_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/\">" . h($annotation["OBJ_CREATOR"]) . "</a>", gettext("%n says:"))); //$content->setVariable( "REPLYERS_SAYS_LABEL", str_replace ); $content->setVariable("REPLY_CONTENT", get_formatted_output($annotation["CONTENT"], 60, "\n")); $content->setVariable("REPLY_TS", how_long_ago($annotation["OBJ_CREATION_TIME"])); $content->setVariable("REPLY_PERMALINK", PATH_URL . 'forums/' . $thread->get_id() . '/#comment' . $annotation['OBJ_ID']); $content->setVariable("REPLY_PERMALINK_TEXT", gettext("permalink")); $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT); if ($access_result[$access_tnr[$steam_obj->get_id()]]) { $content->setCurrentBlock("BLOCK_OWN_REPLY"); $content->setVariable("REPLY_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/"); $content->setVariable("REPLY_LABEL_DELETE", gettext("delete")); $content->setVariable("REPLY_LABEL_EDIT", gettext("edit")); $content->setVariable("REPLY_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/"); $content->parse("BLOCK_OWN_REPLY"); } $content->parse("REPLY"); } $content->setVariable("LABEL_BB_BOLD", gettext("B")); $content->setVariable("HINT_BB_BOLD", gettext("boldface")); $content->setVariable("LABEL_BB_ITALIC", gettext("I")); $content->setVariable("HINT_BB_ITALIC", gettext("italic")); $content->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $content->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $content->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $content->setVariable("HINT_BB_IMAGE", gettext("image")); $content->setVariable("LABEL_BB_URL", gettext("URL")); $content->setVariable("HINT_BB_URL", gettext("web link")); $content->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $content->setVariable("HINT_BB_MAIL", gettext("email link")); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_OR", gettext("or")); $content->setVariable("LABEL_POST_NOW", gettext("Post now")); $portal->set_rss_feed(PATH_URL . "services/feeds/discussion_public.php?id=" . OBJ_ID, gettext("Feed"), gettext("Subscribe to this forum's Newsfeed")); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($messageboard); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Discussion"))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $forum_id = $this->params[0]; $portal = \lms_portal::get_instance(); $user = \lms_steam::get_current_user(); $rss_feeds = $user->get_attribute("USER_RSS_FEEDS"); if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) { include "bad_link.php"; exit; } if ($messageboard instanceof \steam_document) { $thread = $messageboard; $messageboard = $thread->get_annotating(); define("OBJ_ID", $thread->get_id()); if (!$thread->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } else { define("OBJ_ID", $messageboard->get_id()); if (!$messageboard->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!$messageboard instanceof \steam_messageboard) { include "bad_link.php"; exit; } $is_watching = FALSE; if (is_array($rss_feeds)) { foreach (array_keys($rss_feeds) as $item) { if ($item == $messageboard->get_id()) { $is_watching = TRUE; } } } $content = \Messageboard::getInstance()->loadTemplate("forum_post.template.html"); $headline = gettext("Post a new topic"); // TODO: Passt der link? $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { $values = $_POST["values"]; $problems = ""; if (empty($values["title"])) { $problems = gettext("Please enter a subject for your message."); } if (empty($values["body"])) { $problems .= empty($problems) ? gettext("Please enter your message.") : "<br>" . gettext("Please enter your message."); } if (get_magic_quotes_gpc()) { if (!empty($values['title'])) { $values['title'] = stripslashes($values['title']); } if (!empty($values['body'])) { $values['body'] = stripslashes($values['body']); } } if (!empty($problems)) { $portal->set_problem_description($problems); } if (!empty($values["preview_comment"])) { $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT"); $content->setVariable("TEXT_COMMENT", get_formatted_output($values["body"])); $content->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your comment")); $template->parse("BLOCK_PREVIEW_COMMENT"); $headline = gettext("Change it?"); } if (!empty($values["save"]) && empty($problems)) { if (!strpos($values["title"], "/")) { $new_thread = $messageboard->add_thread($values["title"], $values["body"]); // $all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER ); // $new_thread->set_acquire( FALSE ); // $new_thread->set_read_access( $all_user, TRUE ); // $new_thread->set_write_access( $all_user, FALSE ); // $new_thread->set_annotate_access( $all_user, TRUE ); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean forumcache $fcache = get_cache_function($forum_id, 600); $fcache->drop("lms_forum::get_discussions", $forum_id); // clean rsscache of the forum // TODO: Passt der link? $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . $forum_id; $rcache = get_cache_function("rss", 600); $rcache->drop("lms_rss::get_items", $feedlink); header("Location: " . PATH_URL . "messageboard/viewDiscussion/" . $new_thread->get_id() . "/"); exit; } else { $portal->set_problem_description(gettext("Please don't use the \"/\"-char in the title.")); } } if (!empty($values["preview"]) && !empty($values['body'])) { // PREVIEW $content->setCurrentBlock("BLOCK_PREVIEW"); $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit")); $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"])); $content->parse("BLOCK_PREVIEW"); $headline = gettext("Change it?"); } } $subject = isset($values["title"]) ? htmlentities($values["title"], ENT_NOQUOTES, "utf-8") : ""; $text = isset($values["body"]) ? htmlentities($values["body"], ENT_NOQUOTES, "utf-8") : ""; $content->setVariable("INFO_TEXT", $headline); $content->setVariable("LABEL_TOPIC", gettext("Topic")); $content->setVariable("LABEL_YOUR_POST", gettext("Your Post")); $content->setVariable("TEXT_COMMENT", $text); $content->setVariable("TITLE_COMMENT", $subject); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Create entry")); $content->setVariable("VALUE_BACKLINK", $backlink); $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>"); $content->setVariable("LABEL_BB_BOLD", gettext("B")); $content->setVariable("HINT_BB_BOLD", gettext("boldface")); $content->setVariable("LABEL_BB_ITALIC", gettext("I")); $content->setVariable("HINT_BB_ITALIC", gettext("italic")); $content->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $content->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $content->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $content->setVariable("HINT_BB_IMAGE", gettext("image")); $content->setVariable("LABEL_BB_URL", gettext("URL")); $content->setVariable("HINT_BB_URL", gettext("web link")); $content->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $content->setVariable("HINT_BB_MAIL", gettext("email link")); $portal->set_rss_feed(PATH_URL . "services/feeds/forum_public.php?id={$forum_id}", gettext("Feed"), str_replace("%l", $login, gettext("Subscribe to this forum's Newsfeed"))); // TODO: Passt der link? $rootlink = \lms_steam::get_link_to_root($messageboard); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("New Thread"))); $frameResponseObject->setTitle("Messageboard"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }