public function __construct($steam_user) { if (!$steam_user instanceof steam_user) { throw new Exception("not a user", E_PARAMETER); } parent::__construct(PATH_EXTENSIONS . "content/profile/ui/html/user_profile.template.html"); $this->steam_user = $steam_user; $this->networking_profile = new lms_networking_profile($steam_user); $this->networking_profile->count_profile_visit(lms_steam::get_current_user()); $cache = get_cache_function($steam_user->get_name(), 86400); $user_profile = $cache->call("lms_steam::user_get_profile", $steam_user->get_name()); $itemId = $user_profile["OBJ_ICON"]; $icon_link = $user_profile["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "download/image/" . $itemId . "/140/185"; //$icon_link = ( $user_profile[ "OBJ_ICON" ] == 0 ) ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . $user_profile[ "OBJ_ICON" ] . "&type=usericon&width=140&height=185"; $this->template->setVariable("USER_IMAGE", $icon_link); $this->template->setVariable("GIVEN_NAME", $user_profile["USER_FIRSTNAME"]); $this->template->setVariable("FAMILY_NAME", $user_profile["USER_FULLNAME"]); if (!empty($user_profile["USER_ACADEMIC_TITLE"])) { $this->template->setVariable("ACADEMIC_TITLE", $user_profile["USER_ACADEMIC_TITLE"]); } if (!empty($user_profile["USER_ACADEMIC_DEGREE"])) { $this->template->setVariable("ACADEMIC_DEGREE", "(" . $user_profile["USER_ACADEMIC_DEGREE"] . ")"); } $user = lms_steam::get_current_user(); if (lms_steam::is_koala_admin($user)) { $this->template->setVariable("LABEL_LAST_LOGIN", gettext("last login") . ":"); $this->template->setVariable("LABEL_PAGE_HITS", gettext("page hits") . ":"); $this->template->setVariable("LAST_LOGIN", how_long_ago($user_profile["USER_LAST_LOGIN"])); $this->template->setVariable("PAGE_HITS", $this->networking_profile->get_profile_visits()); } }
function time_left($timestamp) { $timeleft = $timestamp - time(); if ($timeleft < 0) { return how_long_ago($timestamp); } $days = ceil($timeleft / 86400); return str_replace("%d", $days, gettext("%d days left")); }
} $content = new HTML_TEMPLATE_IT(); $content->loadTemplateFile(PATH_TEMPLATES . "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 wiki '%NAME' ?"))); $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 wiki!")); } $content->setVariable("TEXT_INFORMATION", gettext("The Wiki and all its entries will 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); $rootlink = lms_steam::get_link_to_root($wiki_container); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/" . $wiki_container->get_id() . "/"), array("name" => gettext("Delete wiki"), "link" => "")); $portal->set_page_main($headline, $content->get(), ""); $portal->show_html();
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) { $path = $this->params; $user = \lms_steam::get_current_user(); $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP); $id = $path[0]; try { $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE; } catch (\Exception $ex) { include "bad_link.php"; exit; } $group_is_private = FALSE; if ($steam_group && is_object($steam_group)) { switch ((string) $steam_group->get_attribute("OBJ_TYPE")) { case "course": $group = new \koala_group_course($steam_group); // TODO: Passt der backlink? $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/"; break; default: $group = new \koala_group_default($steam_group); // TODO: Passt der backlink? $backlink = PATH_URL . "groups/" . $group->get_id() . "/"; // Determine if group is public or private $parent = $group->get_parent_group(); if ($parent->get_id() == STEAM_PRIVATE_GROUP) { $group_is_private = TRUE; } break; } } if ($group_is_private) { if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) { throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS); } } if (!$group instanceof \koala_group) { throw new \Exception("Is not a koala_group: " . $group_id, E_PARAMETER); } switch (get_class($group)) { case "koala_group_course": $html_handler_group = new \koala_html_course($group); $html_handler_group->set_context("communication"); break; default: $html_handler_group = new \koala_html_group($group); $html_handler_group->set_context("communication"); break; } $content = \Group::getInstance()->loadTemplate("groups_communication.template.html"); $workroom = $group->get_workroom(); $read_access = $workroom->check_access_read($user); if (!$read_access) { throw new \Exception("No read access on container: id=" . $workroom->get_id(), E_USER_RIGHTS); } $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $communication_objects = $cache->call("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); $forums = array(); $weblogs = array(); $wikis = array(); foreach ($communication_objects as $object) { if ($object["OBJ_CLASS"] === "steam_messageboard") { $forums[] = $object; } else { if ($object["OBJ_CLASS"] === "steam_calendar") { $weblogs[] = $object; } else { if (($object["OBJ_CLASS"] === "steam_container" || $object["OBJ_CLASS"] === "steam_room") && ($object["OBJ_TYPE"] != null && ($object["OBJ_TYPE"] == "KOALA_WIKI" || $object["OBJ_TYPE"] == "container_wiki_koala"))) { $wikis[] = $object; } } } } $content->setVariable("LABEL_FORUMS", gettext("Discussion Boards")); if (count($forums) > 0) { $content->setCurrentBlock("BLOCK_FORUMS"); $content->setVariable("LABEL_FORUM_DESCRIPTION", gettext("Forum / description")); $content->setVariable("LABEL_ARTICLES", gettext("Articles")); $content->setVariable("LABEL_ACCESS", gettext("Access")); $content->setVariable("LABEL_LAST_COMMENT", gettext("Last comment")); $access_descriptions = \lms_forum::get_access_descriptions($group); foreach ($forums as $forum) { $cache = get_cache_function($forum["OBJ_ID"], 600); $discussions = $cache->call("lms_forum::get_discussions", $forum["OBJ_ID"]); $latest_post = isset($discussions[0]) ? $discussions[0] : FALSE; $content->setCurrentBlock("BLOCK_FORUM"); $content->setVariable("NAME_FORUM", h($forum["OBJ_NAME"])); $content->setVariable("LINK_FORUM", PATH_URL . "messageboard/index/" . $forum["OBJ_ID"]); $content->setVariable("OBJ_DESC", get_formatted_output($forum["OBJ_DESC"])); $language = !empty($forum["FORUM_LANGUAGE"]) ? $forum["FORUM_LANGUAGE"] : "German"; $content->setVariable("VALUE_LANGUAGE", $language); $access = "<span title=\"" . $access_descriptions[$forum["KOALA_ACCESS"]]["label"] . "\">" . $access_descriptions[$forum["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_ACCESS", $access); $content->setVariable("VALUE_ARTICLES", count($discussions)); if ($latest_post) { $content->setVariable("SUBJECT_LAST_COMMENT", h($latest_post["LATEST_POST_TITLE"])); $content->setVariable("LINK_LAST_COMMENT", PATH_URL . "forums/" . $latest_post["OBJ_ID"] . "/"); $content->setVariable("POSTED_BY_LABEL", "(" . h($latest_post["LATEST_POST_AUTHOR"]) . ", " . how_long_ago($latest_post["LATEST_POST_TS"]) . ")"); } else { $content->setVariable("POSTED_BY_LABEL", gettext("-")); } $content->parse("BLOCK_FORUM"); } $content->parse("BLOCK_FORUMS"); } else { $content->setVariable("LABEL_NO_FORUMS_FOUND", "<b>" . gettext("No forums available. Either no forums are created in this context, or you have no rights to read them.") . "</b>"); } $content->setVariable("LABEL_WEBLOGS", gettext("Weblogs")); if (count($weblogs) > 0) { $content->setCurrentBlock("BLOCK_WEBLOGS"); $content->setVariable("LABEL_WEBLOG_DESCRIPTION", gettext("Weblog / description")); $content->setVariable("LABEL_WEBLOG_ENTRIES", gettext("Entries")); $content->setVariable("LABEL_WEBLOG_ACCESS", gettext("Access")); $content->setVariable("LABEL_WEBLOG_LAST_ENTRY", gettext("Last entry")); $access_descriptions = \lms_weblog::get_access_descriptions($group); foreach ($weblogs as $weblog) { $cache = get_cache_function($weblog["OBJ_ID"], 600); $entries = $cache->call("lms_weblog::get_items", $weblog["OBJ_ID"]); $last_entry = isset($entries[0]) ? $entries[0] : FALSE; $content->setCurrentBlock("BLOCK_WEBLOG"); $content->setVariable("NAME_WEBLOG", h($weblog["OBJ_NAME"])); $content->setVariable("LINK_WEBLOG", PATH_URL . "weblog/" . $weblog["OBJ_ID"] . "/"); $content->setVariable("WEBLOG_OBJ_DESC", get_formatted_output($weblog["OBJ_DESC"])); $title = $access_descriptions[$weblog["KOALA_ACCESS"]]["label"]; if ($weblog["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof \koala_html_course) { $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblog["OBJ_ID"], CLASS_CALENDAR); $creator = $obj->get_creator(); if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) { $title = str_replace("%NAME", $creator->get_name(), $title); } else { $title = str_replace("%NAME", "you", $title); } } $content->setVariable("VALUE_WEBLOG_LANGUAGE", "German"); $access = "<span title=\"" . $title . "\">" . $access_descriptions[$weblog["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_WEBLOG_ACCESS", $access); $content->setVariable("VALUE_WEBLOG_ARTICLES", count($entries)); $content->setVariable("LINK_WEBLOG_LAST_ENTRY", PATH_URL . "weblog/" . $last_entry["OBJ_ID"] . "/"); if ($last_entry) { $content->setVariable("SUBJECT_WEBLOG_LAST_ENTRY", h($last_entry["DATE_TITLE"])); $content->setVariable("WEBLOG_POSTED_BY_LABEL", "(" . h($last_entry["AUTHOR"]) . ", " . how_long_ago($last_entry["DATE_START_DATE"]) . ")"); } else { $content->setVariable("WEBLOG_POSTED_BY_LABEL", gettext("-")); } $content->parse("BLOCK_WEBLOG"); } $content->parse("BLOCK_WEBLOGS"); } else { $content->setVariable("LABEL_NO_WEBLOGS_FOUND", "<b>" . gettext("No weblogs available. Either no weblogs are created in this context, or you have no rights to read them.") . "</b>"); } $content->setVariable("LABEL_WIKIS", gettext("Wikis")); if (count($wikis) > 0) { $content->setCurrentBlock("BLOCK_WIKIS"); $content->setVariable("LABEL_WIKI_DESCRIPTION", gettext("Wiki / description")); $content->setVariable("LABEL_WIKI_ENTRIES", gettext("Entries")); $content->setVariable("LABEL_WIKI_ACCESS", gettext("Access")); $content->setVariable("LABEL_WIKI_LAST_ENTRY", gettext("Last entry")); $access_descriptions = \lms_wiki::get_access_descriptions($group); foreach ($wikis as $wiki) { $cache = get_cache_function($wiki["OBJ_ID"], 600); $entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]); $last_entry = isset($entries[0]) ? $entries[0] : FALSE; $content->setCurrentBlock("BLOCK_WIKI"); $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"])); $content->setVariable("LINK_WIKI", PATH_URL . "wiki/index/" . $wiki["OBJ_ID"] . "/"); $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"])); $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"]; if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof \koala_html_course) { $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER); $creator = $obj->get_creator(); if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) { $title = str_replace("%NAME", $creator->get_name(), $title); } else { $title = str_replace("%NAME", "you", $title); } } $access = "<span title=\"" . $title . "\">" . $access_descriptions[$wiki["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_WIKI_ACCESS", $access); $content->setVariable("VALUE_WIKI_ARTICLES", count($entries)); $content->setVariable("LINK_WIKI_LAST_ENTRY", PATH_URL . "wiki/" . $last_entry["OBJ_ID"] . "/"); $content->setVariable("SUBJECT_WIKI_LAST_ENTRY", str_replace(".wiki", "", h($last_entry["OBJ_NAME"]))); $content->setVariable("WIKI_POSTED_BY_LABEL", $last_entry["DOC_LAST_MODIFIED"] != null ? "(" . h($last_entry["DOC_USER_MODIFIED"]) . ", " . how_long_ago($last_entry["DOC_LAST_MODIFIED"]) . ")" : "-"); $content->parse("BLOCK_WIKI"); } $content->parse("BLOCK_WIKIS"); } else { $content->setVariable("LABEL_NO_WIKIS_FOUND", "<b>" . gettext("No wikis available. Either no wikis are created in this context, or you have no rights to read them.") . "</b>"); } $html_handler_group->set_html_left($content->get()); $frameResponseObject->setTitle("Group"); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($html_handler_group->get_html()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }
<div class="meta-wrap"> <?php echo get_avatar($comment, 48, $template_path . '' . get_bloginfo('template_directory') . '/images/gravatar.png'); ?> <br /> <p class="authorcomment"> <?php comment_author_link(); ?> <br /> </p> <p><small> <?php if (!function_exists('how_long_ago')) { comment_date('M d, Y'); } else { echo how_long_ago(get_comment_time('U')); } ?> </small></p> </div> </div> <div class="text-right <?php if (1 == $comment->user_id) { $oddcomment = "authcomment"; } echo $oddcomment; ?> "> <?php comment_text(); ?>
public function execute(\FrameResponseObject $frameResponseObject) { //$portal = \lms_portal::get_instance(); //$portal->initialize( GUEST_NOT_ALLOWED ); //$portal->set_guest_allowed( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); //$portal_user = $portal->get_user(); //$path = $request->getPath(); $group_course = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "Courses." . $this->params[0] . "." . $this->params[1]); $group = new \koala_group_course($group_course); if (!$group instanceof \koala_group) { throw new \Exception("Is not a koala_group: " . $group_id, E_PARAMETER); } switch (get_class($group)) { case "koala_group_course": $html_handler_group = new \koala_html_course($group); $html_handler_group->set_context("communication"); break; default: $html_handler_group = new \koala_html_group($group); $html_handler_group->set_context("communication"); break; } $content = \Course::getInstance()->loadTemplate("groups_communication.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "groups_communication.template.html" ); $workroom = $group->get_workroom(); $read_access = $workroom->check_access_read($user); if (!$read_access) { throw new Exception("No read access on container: id=" . $workroom->get_id(), E_USER_RIGHTS); } $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $communication_objects = $cache->call("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); $forums = array(); $weblogs = array(); $wikis = array(); foreach ($communication_objects as $object) { if ($object["OBJ_CLASS"] === "steam_messageboard") { $forums[] = $object; } else { if ($object["OBJ_CLASS"] === "steam_calendar") { $weblogs[] = $object; } else { if (($object["OBJ_CLASS"] === "steam_container" || $object["OBJ_CLASS"] === "steam_room") && ($object["OBJ_TYPE"] != null && ($object["OBJ_TYPE"] == "KOALA_WIKI" || $object["OBJ_TYPE"] == "container_wiki_koala"))) { $wikis[] = $object; } } } } $content->setVariable("LABEL_FORUMS", gettext("Discussion Boards")); if (count($forums) > 0) { $content->setCurrentBlock("BLOCK_FORUMS"); $content->setVariable("LABEL_FORUM_DESCRIPTION", gettext("Forum / description")); $content->setVariable("LABEL_ARTICLES", gettext("Articles")); $content->setVariable("LABEL_ACCESS", gettext("Access")); $content->setVariable("LABEL_LAST_COMMENT", gettext("Last comment")); $access_descriptions = \lms_forum::get_access_descriptions($group); foreach ($forums as $forum) { $cache = get_cache_function($forum["OBJ_ID"], 600); $discussions = $cache->call("lms_forum::get_discussions", $forum["OBJ_ID"]); $latest_post = isset($discussions[0]) ? $discussions[0] : FALSE; $content->setCurrentBlock("BLOCK_FORUM"); $content->setVariable("NAME_FORUM", h($forum["OBJ_NAME"])); $content->setVariable("LINK_FORUM", PATH_URL . "forums/" . $forum["OBJ_ID"] . "/"); $content->setVariable("OBJ_DESC", get_formatted_output($forum["OBJ_DESC"])); $language = !empty($forum["FORUM_LANGUAGE"]) ? $forum["FORUM_LANGUAGE"] : "German"; $content->setVariable("VALUE_LANGUAGE", $language); $access = "<span title=\"" . $access_descriptions[$forum["KOALA_ACCESS"]]["label"] . "\">" . $access_descriptions[$forum["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_ACCESS", $access); $content->setVariable("VALUE_ARTICLES", count($discussions)); if ($latest_post) { $content->setVariable("SUBJECT_LAST_COMMENT", h($latest_post["LATEST_POST_TITLE"])); $content->setVariable("LINK_LAST_COMMENT", PATH_URL . "forums/" . $latest_post["OBJ_ID"] . "/"); $content->setVariable("POSTED_BY_LABEL", "(" . h($latest_post["LATEST_POST_AUTHOR"]) . ", " . how_long_ago($latest_post["LATEST_POST_TS"]) . ")"); } else { $content->setVariable("POSTED_BY_LABEL", gettext("-")); } $content->parse("BLOCK_FORUM"); } $content->parse("BLOCK_FORUMS"); } else { $content->setVariable("LABEL_NO_FORUMS_FOUND", "<b>" . gettext("No forums available. Either no forums are created in this context, or you have no rights to read them.") . "</b>"); } $content->setVariable("LABEL_WEBLOGS", gettext("Weblogs")); if (count($weblogs) > 0) { $content->setCurrentBlock("BLOCK_WEBLOGS"); $content->setVariable("LABEL_WEBLOG_DESCRIPTION", gettext("Weblog / description")); $content->setVariable("LABEL_WEBLOG_ENTRIES", gettext("Entries")); $content->setVariable("LABEL_WEBLOG_ACCESS", gettext("Access")); $content->setVariable("LABEL_WEBLOG_LAST_ENTRY", gettext("Last entry")); $access_descriptions = \lms_weblog::get_access_descriptions($group); foreach ($weblogs as $weblog) { $cache = get_cache_function($weblog["OBJ_ID"], 600); $entries = $cache->call("lms_weblog::get_items", $weblog["OBJ_ID"]); $last_entry = isset($entries[0]) ? $entries[0] : FALSE; $content->setCurrentBlock("BLOCK_WEBLOG"); $content->setVariable("NAME_WEBLOG", h($weblog["OBJ_NAME"])); $content->setVariable("LINK_WEBLOG", PATH_URL . "weblog/" . $weblog["OBJ_ID"] . "/"); $content->setVariable("WEBLOG_OBJ_DESC", get_formatted_output($weblog["OBJ_DESC"])); $title = $access_descriptions[$weblog["KOALA_ACCESS"]]["label"]; if ($weblog["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) { $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblog["OBJ_ID"], CLASS_CALENDAR); $creator = $obj->get_creator(); if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) { $title = str_replace("%NAME", $creator->get_name(), $title); } else { $title = str_replace("%NAME", "you", $title); } } $content->setVariable("VALUE_WEBLOG_LANGUAGE", "German"); $access = "<span title=\"" . $title . "\">" . $access_descriptions[$weblog["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_WEBLOG_ACCESS", $access); $content->setVariable("VALUE_WEBLOG_ARTICLES", count($entries)); $content->setVariable("LINK_WEBLOG_LAST_ENTRY", PATH_URL . "weblog/" . $last_entry["OBJ_ID"] . "/"); if ($last_entry) { $content->setVariable("SUBJECT_WEBLOG_LAST_ENTRY", h($last_entry["DATE_TITLE"])); $content->setVariable("WEBLOG_POSTED_BY_LABEL", "(" . h($last_entry["AUTHOR"]) . ", " . how_long_ago($last_entry["DATE_START_DATE"]) . ")"); } else { $content->setVariable("WEBLOG_POSTED_BY_LABEL", gettext("-")); } $content->parse("BLOCK_WEBLOG"); } $content->parse("BLOCK_WEBLOGS"); } else { $content->setVariable("LABEL_NO_WEBLOGS_FOUND", "<b>" . gettext("No weblogs available. Either no weblogs are created in this context, or you have no rights to read them.") . "</b>"); } $content->setVariable("LABEL_WIKIS", gettext("Wikis")); if (count($wikis) > 0) { $content->setCurrentBlock("BLOCK_WIKIS"); $content->setVariable("LABEL_WIKI_DESCRIPTION", gettext("Wiki / description")); $content->setVariable("LABEL_WIKI_ENTRIES", gettext("Entries")); $content->setVariable("LABEL_WIKI_ACCESS", gettext("Access")); $content->setVariable("LABEL_WIKI_LAST_ENTRY", gettext("Last entry")); $access_descriptions = lms_wiki::get_access_descriptions($group); foreach ($wikis as $wiki) { $cache = get_cache_function($wiki["OBJ_ID"], 600); $entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]); $last_entry = isset($entries[0]) ? $entries[0] : FALSE; $content->setCurrentBlock("BLOCK_WIKI"); $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"])); $content->setVariable("LINK_WIKI", PATH_URL . "wiki/" . $wiki["OBJ_ID"] . "/"); $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"])); $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"]; if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) { $obj = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER); $creator = $obj->get_creator(); if ($creator->get_id() != lms_steam::get_current_user()->get_id()) { $title = str_replace("%NAME", $creator->get_name(), $title); } else { $title = str_replace("%NAME", "you", $title); } } $access = "<span title=\"" . $title . "\">" . $access_descriptions[$wiki["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_WIKI_ACCESS", $access); $content->setVariable("VALUE_WIKI_ARTICLES", count($entries)); $content->setVariable("LINK_WIKI_LAST_ENTRY", PATH_URL . "wiki/" . $last_entry["OBJ_ID"] . "/"); $content->setVariable("SUBJECT_WIKI_LAST_ENTRY", str_replace(".wiki", "", h($last_entry["OBJ_NAME"]))); $content->setVariable("WIKI_POSTED_BY_LABEL", $last_entry["DOC_LAST_MODIFIED"] != null ? "(" . h($last_entry["DOC_USER_MODIFIED"]) . ", " . how_long_ago($last_entry["DOC_LAST_MODIFIED"]) . ")" : "-"); $content->parse("BLOCK_WIKI"); } $content->parse("BLOCK_WIKIS"); } else { $content->setVariable("LABEL_NO_WIKIS_FOUND", "<b>" . gettext("No wikis available. Either no wikis are created in this context, or you have no rights to read them.") . "</b>"); } $html_handler_group->set_html_left($content->get()); //$portal->set_page_main( $html_handler_group->get_headline(), $html_handler_group->get_html(), ""); $frameResponseObject->setHeadline($html_handler_group->get_headline()); $widget = new \Widgets\RawHtml(); $widget->setHtml($html_handler_group->get_html()); $frameResponseObject->addWidget($widget); 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; }
function get_comment_html($document, $url) { $cache = get_cache_function($document->get_id(), 600); $user = lms_steam::get_current_user(); $write_access = $document->check_access(SANCTION_ANNOTATE, $user); $template = new HTML_TEMPLATE_IT(); $template->loadTemplateFile(PATH_TEMPLATES . "comments.template.html"); $headline = gettext("Add your comment"); if ($_SERVER["REQUEST_METHOD"] == "POST" && $write_access) { $values = $_POST["values"]; if (!empty($values["preview_comment"])) { $template->setCurrentBlock("BLOCK_PREVIEW_COMMENT"); $template->setVariable("TEXT_COMMENT", $values["comment"]); $template->setVariable("PREVIEW", gettext("Preview")); $template->setVariable("POST_COMMENT", gettext("Post comment")); $template->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your comment")); $template->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["comment"])); $template->parse("BLOCK_PREVIEW_COMMENT"); $headline = gettext("Change it?"); } if (!empty($values["submit_comment"]) && !empty($values["comment"])) { $new_comment = steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $user->get_name() . "-" . time(), $values["comment"]); $all_user = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER); $new_comment->set_acquire($document); $new_comment->set_read_access($all_user); $document->add_annotation($new_comment); $cache->drop("lms_steam::get_annotations", $document->get_id()); } } $comments = $cache->call("lms_steam::get_annotations", $document->get_id()); if (count($comments) > 0) { $template->setVariable("LABEL_COMMENTS", gettext("comments")); } $comments = array_reverse($comments); //reverse comment order (oldest first) foreach ($comments as $comment) { $obj_comment = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment["OBJ_ID"]); $template->setCurrentBlock("BLOCK_ANNOTATION"); $template->setVariable("COMMENT_ID", $comment["OBJ_ID"]); $template->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $comment["OBJ_CREATOR_LOGIN"] . "/"); $template->setVariable("AUTHOR_NAME", $comment["OBJ_CREATOR"]); $template->setVariable("IMAGE_LINK", PATH_URL . "get_document.php?id=" . $comment["OBJ_ICON"]); $template->setVariable("LABEL_SAYS", gettext("says")); $template->setVariable("ANNOTATION_COMMENT", get_formatted_output($comment["CONTENT"], 80, "\n")); $template->setVariable("HOW_LONG_AGO", how_long_ago($comment["OBJ_CREATION_TIME"])); $template->setVariable('LINK_PERMALINK', $url . '/#comment' . $comment['OBJ_ID']); $template->setVariable("LABEL_PERMALINK", gettext("permalink")); if ($obj_comment->check_access_write($user)) { $template->setCurrentBlock("BLOCK_OWN_COMMENT"); $template->setVariable("LINK_DELETE", $url . "/deletecomment" . $comment["OBJ_ID"] . "/"); $template->setVariable("LABEL_DELETE", gettext("delete")); $template->setVariable("LINK_EDIT", $url . "/editcomment" . $comment["OBJ_ID"] . "/"); $template->setVariable("LABEL_EDIT", gettext("edit")); $template->parse("BLOCK_OWN_COMMENT"); } $template->parse("BLOCK_ANNOTATION"); } if ($write_access) { $template->setCurrentBlock("BLOCK_ADD_COMMENT"); $template->setVariable("LABEL_ADD_YOUR_COMMENT", $headline); $template->setVariable("LABEL_PREVIEW", gettext("Preview")); $template->setVariable("LABEL_OR", gettext("or")); $template->setVariable("LABEL_COMMENT", gettext("Add comment")); $template->setVariable("LABEL_BB_BOLD", gettext("B")); $template->setVariable("HINT_BB_BOLD", gettext("boldface")); $template->setVariable("LABEL_BB_ITALIC", gettext("I")); $template->setVariable("HINT_BB_ITALIC", gettext("italic")); $template->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $template->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $template->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $template->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $template->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $template->setVariable("HINT_BB_IMAGE", gettext("image")); $template->setVariable("LABEL_BB_URL", gettext("URL")); $template->setVariable("HINT_BB_URL", gettext("web link")); $template->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $template->setVariable("HINT_BB_MAIL", gettext("email link")); $template->parse("BLOCK_ADD_COMMENT"); } return $template->get(); }
public function execute(\FrameResponseObject $frameResponseObject) { //CODE FOR ALL COMMANDS OF THIS PACKAGE START $user = \lms_steam::get_current_user(); // Disable caching // TODO: Work on cache handling. An enabled cache leads to bugs // if used with the wiki. \CacheSettings::disable_caching(); if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) { include "bad_link.php"; exit; } if (!$wiki_container instanceof \steam_container) { $wiki_doc = $wiki_container; $wiki_container = $wiki_doc->get_environment(); if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") { include "bad_link.php"; exit; } } //CODE FOR ALL COMMANDS OF THIS PACKAGE END $object = $wiki_container; $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 wiki '%NAME' has been deleted.")); $workroom = $object->get_environment(); \lms_steam::delete($object); $wid = $object->get_id(); // Clean Cache for the deleted wiki require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache = get_cache_function($wid, 600); $cache->drop("lms_steam::get_items", $wid); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($wid); // clean wiki cache (not used by wiki) $fcache = get_cache_function($object->get_id(), 600); $fcache->drop("lms_wiki::get_items", $object->get_id()); // 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_CONTAINER | CLASS_ROOM, array("OBJ_TYPE", "WIKI_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); // clean rsscache $rcache = get_cache_function("rss", 600); $feedlink = PATH_URL . "services/feeds/wiki_public.php?id=" . $wid; $rcache->drop("lms_rss::get_items", $feedlink); } header("Location: " . $values["return_to"]); exit; } } $content = \Wiki::getInstance()->loadTemplate("object_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "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 wiki '%NAME' ?"))); $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 wiki!")); } $content->setVariable("TEXT_INFORMATION", gettext("The Wiki and all its entries will 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); $rootlink = \lms_steam::get_link_to_root($wiki_container); WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("name" => gettext("Delete wiki"), "link" => "")) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("name" => gettext("Delete wiki"), "link" => ""))); $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; /* $portal->set_page_main( $headline, $content->get(), "" ); $portal->show_html();*/ }
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 execute(\FrameResponseObject $frameResponseObject) { //$portal = \lms_portal::get_instance(); //$portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); //$path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!isset($date)) { throw new \Exception("variable date is not set."); } //$date = $weblog; if ($_SERVER["REQUEST_METHOD"] == "POST" && $date->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($weblog->get_id()); $cache->clean($date->get_id()); $trashbin = $GLOBALS["STEAM"]->get_current_steam_user(); if (is_object($trashbin)) { $date->move($trashbin); } else { $date->delete(); } } header("Location: " . $values["return_to"]); exit; } $content = \Weblog::getInstance()->loadTemplate("weblog_entry_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_entry_delete.template.html" ); $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this entry?")); $content->setVariable("TEXT_COMMENT", get_formatted_output($date->get_attribute("DATE_DESCRIPTION"))); $creator = $date->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/index/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($date->get_attribute("OBJ_CREATION_TIME"))); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $creator_data["OBJ_ICON"]->get_id()); $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/"), array("name" => str_replace("%NAME", h($date->get_attribute("DATE_TITLE")), gettext("Delete '%NAME'?")))); /*$portal->set_page_main( $headline, $content->get(), "" ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
$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); $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->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 . "forums/" . $discussion["OBJ_ID"] . "/"); $content->setVariable("THREAD_SUBJECT", h($discussion["OBJ_NAME"])); $content->setVariable("THREAD_LAST_ENTRY", how_long_ago($discussion["LATEST_POST_TS"])); $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"))); $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()))); $portal->set_page_main($headline, $content->get()); $portal->show_html();
public function execute(\FrameResponseObject $frameResponseObject) { if (!defined("OBJ_ID")) { define("OBJ_ID", $weblog->get_id()); } $user = \lms_steam::get_current_user(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); if (!defined("OBJ_ID")) { define("OBJ_ID", $weblog->get_id()); } /*if ( ! $weblog = \steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) { include( "bad_link.php" ); exit; }*/ if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $weblogId); //define( "OBJ_ID", $weblogId ); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $object = $weblog; $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 weblog '%NAME' has been deleted.")); $workroom = $object->get_environment(); \lms_steam::delete($object); // Clean Cache for the deleted Weblog 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 weblog cache (not used by weblog) // $fcache = get_cache_function( OBJ_ID, 600 ); //$fcache->drop( "lms_forum::get_discussions", OBJ_ID ); // clean cache for Weblog RSS Feed for the Comments (not used by weblog) // $fcache->drop( "lms_steam::get_annotations", OBJ_ID ); // clean rsscache $rcache = get_cache_function("rss", 600); $feedlink = PATH_URL . "services/feeds/weblog_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_CALENDAR, array("WEBLOG_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); } header("Location: " . $values["return_to"]); exit; } } $content = \Weblog::getInstance()->loadTemplate("object_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "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 weblog '%NAME' ?"))); $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 weblog!")); } $content->setVariable("TEXT_INFORMATION", gettext("The weblog and all its entries will 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); $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 . "weblog/" . $object->get_id() . "/"), array("name" => gettext("Delete weblog"))); $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; /*$portal->set_page_main( $headline, $content->get(), "" ); $portal->show_html();*/ }
$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 . "forums/" . $thread->get_id() . "/deletecomment" . $annotation["OBJ_ID"] . "/"); $content->setVariable("REPLY_LABEL_DELETE", gettext("delete")); $content->setVariable("REPLY_LABEL_EDIT", gettext("edit")); $content->setVariable("REPLY_LINK_EDIT", PATH_URL . "forums/" . $thread->get_id() . "/editcomment" . $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"));
function comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <?php if ($comment->comment_author_email == get_the_author_email()) { $commentDivClass = 'comment-admin'; } else { $commentDivClass = 'comment-normal'; } ?> <div class="mod comments <?php echo $commentDivClass; ?> "> <div <?php comment_class(); ?> > <div id="comment-<?php comment_ID(); ?> "> <div class="mod-meta comment-author"> <a class="comment-number" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?> "><?php echo gtcn_comment_numbering($comment->comment_ID, ''); ?> </a> <a class="comment-gravatar" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?> "><?php echo get_avatar($comment, $size = '35'); ?> </a> <div class="clear"></div> </div> <div class="mod-body"> <div class="entry"> <?php if ($comment->comment_approved == '0') { ?> <em><?php _e('Your comment is awaiting moderation.'); ?> </em> <?php } ?> <div class="comment-meta commentmetadata"><?php printf(__('<strong>%s</strong>'), get_comment_author_link()); ?> <span class="date"><?php if (!function_exists('how_long_ago')) { comment_date() . ' at ' . comment_time(); } else { echo how_long_ago(get_comment_time('U')); } ?> </span><?php edit_comment_link(__('Edit'), '<span class="edit">', '</span>'); ?> </div> <?php comment_text(); ?> <div class="reply"><?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?> </div> </div> <!-- end div.entry --> </div> <!-- end div.mod-body --> </div> <!-- end #comment-ID --> <div class="clear"></div> </div> <!-- end div.comment --> <?php }
</div> <div class="news" id="article_list"> <?php if ($articles->num_rows() > 0) { foreach ($articles->result() as $article) { ?> <div class="article"> <h3><?php echo anchor('blog/' . $article->slug, $article->headline); ?> </h3> <!--<p class="post_date">Posted <?php echo how_long_ago(strtotime($article->datestamp)); ?> --> <?php echo '<p class="post_date">Posted on ' . date('l, F dS, Y', strtotime($article->datestamp)) . '</p>'; ?> <p><?php echo word_limiter(strip_tags($article->story), 25); ?> <?php echo anchor('blog/' . $article->slug, 'Read Post'); ?> </p> </div> <?php
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; }
$content->setVariable('LABEL_CONTEXT', gettext('Context')); $content->setVariable('LABEL_POSTED', gettext('Posted')); $content->setVariable('LABEL_XML', gettext('RSS')); foreach ($news_items as $feed) { $content->setCurrentBlock('BLOCK_NEWS'); $ts = $feed['date']; if ($ts > $_SESSION['last_login']) { $content->setCurrentBlock('BLOCK_NEW'); $content->setVariable('NEW_LABEL', gettext('New')); $content->parse('BLOCK_NEW'); } $content->setVariable('VALUE_AUTHOR', h($feed['author']->get_full_name())); $content->setVariable('VALUE_SUBJECT', h($feed['title'])); $content->setVariable('VALUE_BODY', h($feed['name'])); //TODO: body? $content->setVariable('LINK_MESSAGE', h($feed['url'])); $content->setVariable('VALUE_SOURCE', h($feed['feed_obj']->get_name())); $content->setVariable('VALUE_CONTEXT_LINK', h($feed['context_link'])); $content->setVariable('VALUE_CONTEXT_NAME', h($feed['context_name'])); $content->setVariable('VALUE_HOW_LONG_AGO', how_long_ago($ts)); $content->setVariable('LINK_RSS', h($feed['link'])); $content->setVariable('RSS_SYMBOL', PATH_STYLE . 'images/feed-icon-16x16.png'); $content->parse('BLOCK_NEWS'); } $content->parse('BLOCK_NEWS_AVAILABLE'); } else { $content->setVariable('LABEL_NEWS', gettext('No news available.')); } $portal->set_page_title(gettext('News')); $portal->set_page_main(array(array('link' => '', 'name' => gettext('News'))), $content->get()); $portal->show_html();
$entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]); $last_entry = isset($entries[0]) ? $entries[0] : FALSE; $content->setCurrentBlock("BLOCK_WIKI"); $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"])); $content->setVariable("LINK_WIKI", PATH_URL . "wiki/" . $wiki["OBJ_ID"] . "/"); $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"])); $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"]; if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) { $obj = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER); $creator = $obj->get_creator(); if ($creator->get_id() != lms_steam::get_current_user()->get_id()) { $title = str_replace("%NAME", $creator->get_name(), $title); } else { $title = str_replace("%NAME", "you", $title); } } $access = "<span title=\"" . $title . "\">" . $access_descriptions[$wiki["KOALA_ACCESS"]]["summary_short"] . "</span>"; $content->setVariable("VALUE_WIKI_ACCESS", $access); $content->setVariable("VALUE_WIKI_ARTICLES", count($entries)); $content->setVariable("LINK_WIKI_LAST_ENTRY", PATH_URL . "wiki/" . $last_entry["OBJ_ID"] . "/"); $content->setVariable("SUBJECT_WIKI_LAST_ENTRY", str_replace(".wiki", "", h($last_entry["OBJ_NAME"]))); $content->setVariable("WIKI_POSTED_BY_LABEL", $last_entry["DOC_LAST_MODIFIED"] != null ? "(" . h($last_entry["DOC_USER_MODIFIED"]) . ", " . how_long_ago($last_entry["DOC_LAST_MODIFIED"]) . ")" : "-"); $content->parse("BLOCK_WIKI"); } $content->parse("BLOCK_WIKIS"); } else { $content->setVariable("LABEL_NO_WIKIS_FOUND", "<b>" . gettext("No wikis available. Either no wikis are created in this context, or you have no rights to read them.") . "</b>"); } $html_handler_group->set_html_left($content->get()); $portal->set_page_main($html_handler_group->get_headline(), $html_handler_group->get_html(), ""); $portal->show_html();
public function set_widget_last_changed($linked_list) { if ($linked_list->get_current_size() == 0) { return NULL; } $t = new HTML_TEMPLATE_IT(); $t->loadTemplateFile(PATH_TEMPLATES . "widget_wiki_changed.template.html"); $forward = FALSE; $linked_list->reset($forward); while ($list_element = $linked_list->get_element($forward)) { $t->setCurrentBlock("BLOCK_LINK"); $wiki_doc = $list_element->get_data(); $t->setVariable("WIKI_DOC_NAME", str_replace(".wiki", "", h($wiki_doc["OBJ_NAME"]))); $t->setVariable("LINK_TITLE", str_replace("%NAME", h($wiki_doc["DOC_USER_MODIFIED"]), gettext("by %NAME")) . ", " . how_long_ago($wiki_doc["DOC_LAST_MODIFIED"])); $t->setVariable("WIKI_DOC_LINK", PATH_URL . "wiki/viewentry/" . $wiki_doc["OBJ_ID"] . "/"); $t->parse("BLOCK_LINK"); } $this->set_widget_html(gettext("Last Modified"), $t->get()); }