Example #1
0
 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;
 }
Example #2
0
 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();
     $current_semester = $this->params[1];
     $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);
     //$html_handler_course = new \koala_html_course($course);
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST["remove"]) && is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $frameResponseObject->setConfirmText(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             //$portal->set_confirmation( str_replace( "%NAME", h($member_to_kick->get_attribute( "USER_FIRSTNAME" ))." " . h($member_to_kick->get_attribute( "USER_FULLNAME" )), gettext( "User %NAME successfully removed from group members." ) ) );
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         } else {
             if (isset($_POST["hide"]) && is_array($_POST["hide"])) {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $users_to_hide = array_keys($_POST["hide"]);
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $tmp1_users_to_hide = array_unique(array_merge($hidden_members, $users_to_hide));
                 $tmp2_users_to_hide = array_diff($tmp1_users_to_hide, $displayed_staff_members);
                 $final_users_to_hide = array_unique(array_merge($tmp2_users_to_hide, $users_to_hide));
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $final_users_to_hide);
             } else {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $users_to_hide = array();
                 $users_to_hide = array_diff($hidden_members, $displayed_staff_members);
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $users_to_hide);
             }
             $frameResponseObject->setConfirmText("Sucessfully updated the visibility of course staff");
             //$portal->set_confirmation( "Sucessfully updated the visibility of course staff" );
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->steam_group_staff->get_id() );
             $members = \lms_steam::group_get_members($group->steam_group_staff->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->get_id() );
             $members = \lms_steam::group_get_members($group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Course::getInstance()->loadTemplate("list_staff.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "list_staff.template.html" );
     $no_members = count($members);
     //DONE
     if ($no_members > 0) {
         $pageIterator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($group->get_name()), gettext("%TOTAL members in %NAME")) . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
         //$start = $portal->set_paginator( $content, 10, $no_members, "(" . str_replace( "%NAME", h($group->get_name()), gettext( "%TOTAL members in %NAME" ) ) . ")" );
         $end = $start + 10 > $no_members ? $no_members : $start + 10;
         $content->setVariable("LABEL_CONTACTS", gettext("staff member") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
         $content->setCurrentBlock("BLOCK_CONTACT_LIST");
         $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
         !COURSE_STAFF_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
         $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
         if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
             !COURSE_STAFFLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("TH_STAFF_MEMBER_VISIBILITY", gettext("hidden"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("STAFF_MEMBER_VISIBILITY_TITLE", gettext("Selected staff members will not be visible on the course start page."));
         }
         !COURSE_STAFF_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
         $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
         $content->setVariable("END_HTML_FORM", "</form>");
         $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
         if (!is_array($hidden_members)) {
             $hidden_members = array();
         }
         for ($i = $start; $i < $end; $i++) {
             $member = $members[$i];
             if ($member["USER_TRASHED"] === 1) {
                 continue;
             }
             $content->setCurrentBlock("BLOCK_CONTACT");
             $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($member["OBJ_NAME"]) . "/");
             $icon_link = $member["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "download/image/" . h($member["OBJ_ICON"]) . "/26/35";
             $content->setVariable("CONTACT_IMAGE", $icon_link);
             $title = !empty($member["USER_ACADEMIC_TITLE"]) ? h($member["USER_ACADEMIC_TITLE"]) . " " : "";
             $content->setVariable("CONTACT_NAME", $title . h($member["USER_FIRSTNAME"]) . " " . h($member["USER_FULLNAME"]));
             if (!COURSE_SHOW_ONLY_EXTERN_MAIL || COURSE_SHOW_ONLY_EXTERN_MAIL && is_string(\steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_EMAIL")) && steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_EMAIL") != "" && steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_FORWARD_MSG") === 1) {
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($member["OBJ_NAME"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 $content->setVariable("LABEL_SEND", gettext("Send"));
             }
             !COURSE_STAFF_FACULTY_AND_FOCUS or $content->setVariable("FACULTY_AND_FOCUS", h($member["USER_PROFILE_FACULTY"]));
             if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                 !COURSE_STAFFLIST_MANAGE or $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"remove[" . h($member["OBJ_NAME"]) . "]\" value=\"" . gettext("Remove") . "\"/></td>");
                 if (in_array($member["OBJ_ID"], $hidden_members)) {
                     !COURSE_STAFFLIST_HIDE or $content->setVariable("TD_STAFF_MEMBER_VISIBILITY", "<td align=\"center\"><input type=\"checkbox\" name=\"hide[" . $member["OBJ_ID"] . "]\" checked=\"checked\"/>" . "\n\t\t\t<input type=\"hidden\" name=\"displayed_staff_member[" . $member["OBJ_ID"] . "]\" />" . "</td>");
                 } else {
                     !COURSE_STAFFLIST_HIDE or $content->setVariable("TD_STAFF_MEMBER_VISIBILITY", "<td align=\"center\"><input type=\"checkbox\" name=\"hide[" . $member["OBJ_ID"] . "]\" />" . "\n\t\t\t<input type=\"hidden\" name=\"displayed_staff_member[" . $member["OBJ_ID"] . "]\" />" . "</td>");
                 }
             }
             $member_desc = empty($member["OBJ_DESC"]) ? "student" : $member["OBJ_DESC"];
             $status = secure_gettext($member_desc);
             $content->setVariable("OBJ_DESC", h($status));
             if (COURSE_STAFF_EXTENSIONS) {
                 $extensions = $group->get_extensions();
                 $result = "";
                 foreach ($extensions as $extension) {
                     $result .= $extension->get_member_info(\steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $member["OBJ_NAME"]), $group);
                 }
                 $content->setVariable("EXTENSIONS_DATA", $result);
             }
             $content->parse("BLOCK_CONTACT");
         }
         if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
             !COURSE_STAFFLIST_HIDE or $content->setVariable("LABEL_SUBMIT_BUTTON", gettext("Save"));
         }
         $content->parse("BLOCK_CONTACT_LIST");
     } else {
         $content->setVariable("LABEL_NO_MEMBERS", gettext("No staff found."));
     }
     $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;
 }
Example #3
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     $timestamp = $this->params[1];
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->params[0];
     $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"], $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog($GLOBALS["STEAM"], $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);
         }
     }
     $weblog_html_handler = new \lms_weblog($weblog);
     $weblog_html_handler->set_widget_categories();
     $weblog_html_handler->set_widget_archive();
     $first_of_month = $timestamp;
     $last_of_month = strtotime("-1 day", strtotime("+1 month", $first_of_month));
     $date_objects = $weblog->get_date_objects((int) $first_of_month, (int) $last_of_month);
     // $date_objects = $weblog->get_date_objects( );
     $no_entries = count($date_objects);
     //TODO: PAGINATOR REINKNALLEN
     $pageIterator = \lms_portal::get_paginator(5, $no_entries, gettext("%TOTAL entries in this archive."));
     //$content->setVariable("PAGEITERATOR", $pageIterator["html"]);
     $start = $pageIterator["startIndex"];
     //$start = $portal->set_paginator( 5, $no_entries, gettext( "%TOTAL entries in this archive." ) );
     $end = $start + 5 > $no_entries ? $no_entries : $start + 5;
     $weblog_html_handler->print_entries($date_objects, TRUE);
     //$portal->set_rss_feed( PATH_URL . "services/feeds/weblog_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($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => strftime("%B %G", $timestamp)));
     //$portal->set_page_main(
     //	$headline,
     //	$weblog_html_handler->get_html()
     //);
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($weblog_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Example #4
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     $current_user = \lms_steam::get_current_user();
     $login = $current_user->get_name();
     //$path = $request->getPath();
     if (isset($this->id)) {
         $userName = $this->id;
         $user = \steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $userName);
     } else {
         $user = $current_user;
     }
     //$portal=\lms_portal::get_instance();
     $cache = get_cache_function($login, 86400);
     //	$portal->set_page_title( $login );
     $html_handler_profile = new \koala_html_profile($user);
     $html_handler_profile->set_context("groups");
     $content = \Profile::getInstance()->loadTemplate("list_groups.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "list_groups.template.html" );
     if ($this->viewer_authorized($current_user, $user)) {
         $public = $user->get_id() != $current_user->get_id() ? TRUE : FALSE;
         $groups = $cache->call("lms_steam::user_get_groups", $login, $public);
         usort($groups, "sort_objects");
         $no_groups = count($groups);
         if ($no_groups > 0) {
             $content->setCurrentBlock("BLOCK_GROUP_LIST");
             $pageIterator = \lms_portal::get_paginator(10, $no_groups, "(" . gettext("%TOTAL groups in list") . ")");
             $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
             $start = $pageIterator["startIndex"];
             $end = $start + 10 > $no_groups ? $no_groups : $start + 10;
             if ($current_user->get_id() == $user->get_id()) {
                 $content->setVariable("LABEL_GROUPS", gettext("Your groups") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_groups), gettext("%a-%z out of %s")) . ")");
             } else {
                 $content->setVariable("LABEL_GROUPS", str_replace("%NAME", $user->get_attribute("USER_FIRSTNAME") . " " . $user->get_attribute("USER_FULLNAME"), gettext("%NAME's groups")) . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_groups), gettext("%a-%z out of %s")) . ")");
             }
             // GROUPS
             $content->setVariable("LABEL_NAME_DESCRIPTION", gettext("Name, description"));
             $content->setVariable("LABEL_MEMBERS", gettext("Members list"));
             $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             if ($user->get_id() == $current_user->get_id()) {
                 $content->setVariable("TH_MANAGE_GROUP", gettext("Manage membership"));
             }
             for ($i = $start; $i < $end; $i++) {
                 $group = $groups[$i];
                 $content->setCurrentBlock("BLOCK_GROUP");
                 $content->setVariable("GROUP_LINK", PATH_URL . "groups/" . $group["OBJ_ID"] . "/");
                 $content->setVariable("GROUP_NAME", h($group["OBJ_NAME"]));
                 $content->setVariable("MEMBER_LINK", PATH_URL . "groups/" . $group["OBJ_ID"] . "/members/");
                 $content->setVariable("GROUP_MEMBERS", h($group["GROUP_NO_MEMBERS"]));
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?group=" . $group["OBJ_ID"]);
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 $content->setVariable("LABEL_SEND", gettext("Send"));
                 if ($user->get_id() == $current_user->get_id()) {
                     $content->setVariable("TD_MANAGE_GROUP", "<a href=\"" . PATH_URL . "group_cancel.php?group=" . $group["OBJ_ID"] . "\">" . gettext("Resign") . "</a>");
                 }
                 $content->setVariable("OBJ_DESC", h($group["OBJ_DESC"]));
                 $content->parse("BLOCK_GROUP");
             }
             $content->parse("BLOCK_GROUP_LIST");
         } else {
             $content->setVariable("LABEL_GROUPS", gettext("No memberships found."));
         }
     } else {
         $messagebox = "<div class=\"infoBar\"><h2>" . gettext("The user has restricted the display of this information.") . "</h2></div>";
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", $messagebox);
     }
     $frameResponseObject->setHeadline($html_handler_profile->get_headline());
     $html_handler_profile->set_html_left($content->get());
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html_handler_profile->get_html());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
     //$portal->set_page_main( $html_handler_profile->get_headline(), $html_handler_profile->get_html());
     //return $portal->get_html();
 }
Example #5
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $group_id = $path[1];
     $content = \Semester::getInstance()->loadTemplate("search_persons.template.html");
     if (!($steam_group = \steam_factory::get_object($GLOBALS['STEAM']->get_id(), $group_id))) {
         throw new \Exception('Group not found: ' . $group_id);
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception('Is not a group: ' . $group_id);
     }
     // always try to use the correct specialized group:
     if (!isset($group)) {
         $group = \koala_object::get_koala_object($steam_group);
     } else {
         if ($group instanceof \koala_object) {
             $group = \koala_object::get_koala_object($group->get_steam_object());
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     // TODO: Passt der Link?
     $backlink = $group->get_url();
     if (!$group->is_admin($user)) {
         throw new \Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
     }
     if (!empty($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
         $login = key($_REQUEST["add"]);
         $new_member = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
         if ($group instanceof \koala_group_tutorial) {
             if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                 $course_learners_group = $group->steam_group_course_learners;
                 $subgroups = $course_learners_group->get_subgroups();
                 foreach ($subgroups as $sg) {
                     if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($new_member) && $sg != $steam_group) {
                         $already_member_and_exclusive = true;
                         $in_group = $sg;
                     }
                 }
             }
         }
         if (isset($already_member_and_exclusive) && $already_member_and_exclusive) {
             if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                 $content->setVariable("WARNING_TEXT", "<p/>" . gettext("Attention! The user you want to add already became member in another tutorial in the meantime."));
             }
             if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                 if ($group->add_member($new_member)) {
                     // PROCEDURE FOR COURSE ADMINS
                     if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                         // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                         $steam_group->set_sanction_all($new_member);
                     }
                     if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                         $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                         $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                     }
                     $group_name = \koala_object::get_koala_object($group)->get_display_name();
                     $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                     $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                     $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                     \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                     $cache = get_cache_function($new_member->get_name());
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                     $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                     $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                     $cache = get_cache_function($group->get_id());
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
                 }
             }
         } else {
             if ($group->add_member($new_member)) {
                 // PROCEDURE FOR COURSE ADMINS
                 if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                     // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                     $steam_group->set_sanction_all($new_member);
                 }
                 if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                     $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                     $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                 }
                 $group_name = \koala_object::get_koala_object($group)->get_display_name();
                 $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                 $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                 $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                 \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                 $cache = get_cache_function($new_member->get_name());
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                 $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                 $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                 $cache = get_cache_function($group->get_id());
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
             }
         }
     }
     if ($group->get_maxsize() > 0 && $group->get_maxsize() <= $group->count_members()) {
         $html_content = "<div class=\"infoBar\">" . gettext("The group is full! You can not add any further members, because the maximum size of the group has been reached. Please increase this value to add more members.") . "</div>";
     } else {
         $content->setVariable("HEAD_SEARCH", gettext("Search"));
         $content->setVariable("INFO_TEXT", gettext("Here you can lookup some people.") . " " . str_replace("%GROUP", $group->get_display_name(), gettext("You can add a search result as member to '<b>%GROUP</b>'.")));
         if (!empty($_REQUEST["pattern"])) {
             $content->setVariable("VALUE_PATTERN", $_REQUEST["pattern"]);
         }
         $content->setVariable("LABEL_CHECK_NAME", gettext("Name"));
         $content->setVariable("LABEL_CHECK_LOGIN", gettext("Email address or login"));
         $content->setVariable("LABEL_SEARCH", gettext("Search"));
         $content->setVariable("GROUP_ID", $group->get_id());
         $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
         // SEARCH RESULTS
         if (!empty($_REQUEST["pattern"])) {
             $cache = get_cache_function($user->get_name(), 60);
             $result = $cache->call("lms_steam::search_user", $_REQUEST["pattern"], $_REQUEST["lookin"]);
             if ($_REQUEST["lookin"] == "name") {
                 $content->setVariable("CHECKED_NAME", 'checked="checked"');
             } else {
                 $content->setVariable("CHECKED_LOGIN", 'checked="checked"');
             }
             // PROCEED RESULT SET
             $html_people = \Semester::getInstance()->loadTemplate("list_users.template.html");
             $no_people = count($result);
             if ($no_people > 0) {
                 if (isset($_REQUEST["backlink"])) {
                     $tmp_backlink = $_REQUEST["backlink"];
                 } else {
                     if (isset($backlink)) {
                         $tmp_backlink = $backlink;
                     }
                 }
                 //$start = $portal->set_paginator( 10, $no_people, "(" . gettext( "%TOTAL people in result set" ) . ")", "?pattern=" . $_REQUEST[ "pattern" ] . "&lookin=" . $_REQUEST[ "lookin" ] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink );
                 $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL people in result set") . ")", "?pattern=" . $_REQUEST["pattern"] . "&lookin=" . $_REQUEST["lookin"] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink);
                 $start = $paginator["startIndex"];
                 $end = $start + 10 > $no_people ? $no_people : $start + 10;
                 $html_people->setVariable("PAGINATOR", $paginator["html"]);
                 $html_people->setVariable("LABEL_CONTACTS", gettext("Results") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_people), gettext("%a-%z out of %s")) . ")");
                 $html_people->setCurrentBlock("BLOCK_CONTACT_LIST");
                 $html_people->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
                 $html_people->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
                 $html_people->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
                 $html_people->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
                 for ($i = $start; $i < $end; $i++) {
                     $person = $result[$i];
                     $html_people->setCurrentBlock("BLOCK_CONTACT");
                     // TODO: Passt der Link?
                     $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . $person["OBJ_NAME"] . "/");
                     // TODO: Passt der Link?
                     $icon_link = PATH_URL . "download/" . $person["OBJ_ICON"] . "/usericon/30/40";
                     $html_people->setVariable("CONTACT_IMAGE", $icon_link);
                     $html_people->setVariable("CONTACT_NAME", h($person["USER_FIRSTNAME"]) . " " . h($person["USER_FULLNAME"]));
                     $html_people->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . $person["OBJ_NAME"]);
                     $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
                     $html_people->setVariable("LABEL_SEND", gettext("Send"));
                     $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
                     $p = new \steam_object($GLOBALS["STEAM"]->get_id(), $person["OBJ_ID"]);
                     //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
                     //see if our person is already member in one of the other tutorials.
                     $already_member_and_exclusive = false;
                     if ($group instanceof \koala_group_tutorial) {
                         if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                             $course_learners_group = $steam_group->get_parent_group();
                             $subgroups = $course_learners_group->get_subgroups();
                             foreach ($subgroups as $sg) {
                                 if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($p) && $sg != $steam_group) {
                                     $already_member_and_exclusive = true;
                                     $in_group = $sg;
                                 }
                             }
                         }
                     }
                     if (!$group->is_member($p)) {
                         if ($already_member_and_exclusive) {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><small><b>" . gettext("Attention: User already in tutorial") . " " . $in_group->get_name() . "<p /></b></small><input type=\"hidden\" name=\"confirmed\" value=\"true\"/><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add anyhow") . "\"/></td>");
                         } else {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add") . "\"/></td>");
                         }
                     } else {
                         $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\">" . gettext("Already a member.") . "</td>");
                     }
                     $html_people->parse("BLOCK_CONTACT");
                 }
                 $html_people->parse("BLOCK_CONTACT_LIST");
             } else {
                 $html_people->setVariable("LABEL_CONTACTS", gettext("No results."));
             }
             $content->setVariable("HTML_USER_LIST", $html_people->get());
         } else {
             $content->setVariable("CHECKED_NAME", 'checked="checked"');
         }
     }
     /*
     $portal->set_page_title( gettext( "Add member" ) );
     
     // give input focus to search field:
     $portal->add_javascript_onload("group_add_member", "document.getElementById('pattern').focus();");
     
     if(!isset($html_content))
     {
     	$portal->set_page_main(
     		array( $group->get_link(), array( "name" => gettext( "Add member" ) ) ),
     		$content->get(),
     		""
     		);
     } 
     else
     {
     	$portal->set_page_main(
     		array( $group->get_link(), array( "name" => gettext( "Add member" ) ) ),
     		$html_content,
     		""
     		);
     }
     $portal->show_html();
     */
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #6
0
 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];
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $portal_user = $portal->get_user();
     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);
         }
     }
     $content = \Group::getInstance()->loadTemplate("membership_requests.template.html");
     $content->setVariable("INFO_TEXT", gettext("The people listed are interested in becoming a member of your group.") . " " . gettext("Here, you can choose wether to affirm their membership or cancel the request.") . " " . gettext("In both cases, the user concerned will automatically get informed by mail about your decision."));
     // always try to use the correct specialized group:
     if ($group instanceof \koala_object) {
         $group = \koala_object::get_koala_object($group->get_steam_object());
     } else {
         if ($group instanceof \steam_object) {
             $group = \koala_object::get_koala_object($group);
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     $type = $group->get_attribute("OBJ_TYPE");
     switch ($type) {
         case "group_tutorial_koala":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         case "course_tutorial":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         default:
             // TODO: Passt der backlink?
             $backlink = $backlink . "members/";
     }
     if (!$group->is_admin($user)) {
         //				throw new Exception( $user->get_name() . " is no admin of " . $group->get_name() );
         header("Location: " . PATH_URL . "error.php?error=" . E_USER_RIGHTS);
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST['affirm']) && is_array($_POST['affirm'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["affirm"]));
             if ($group instanceof \koala_group_tutorial) {
                 if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                     $course_learners_group = $group->steam_group_course_learners;
                     $subgroups = $course_learners_group->get_subgroups();
                     foreach ($subgroups as $sg) {
                         if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             if ($already_member_and_exclusive) {
                 if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                     $content->setCurrentBlock("BLOCK_WARNING");
                     $content->setVariable("WARNING_TEXT", gettext("Attention! The user whose membership you wish to affirm already became member in another tutorial in the meantime."));
                     $content->parse("BLOCK_WARNING");
                 }
                 if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                     $group->add_member($candidate);
                     $group->remove_membership_request($candidate);
                     $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                     $message = gettext("Your membership was affirmed.");
                     $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                     // uncache group members page:
                     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     // uncache menu so that course/group appears:
                     $cache = get_cache_function($candidate->get_name());
                     $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                     $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
                 }
             } else {
                 $group->add_member($candidate);
                 $group->remove_membership_request($candidate);
                 $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                 $message = gettext("Your membership was affirmed.");
                 $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                 // uncache group members page:
                 $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 // uncache menu so that course/group appears:
                 $cache = get_cache_function($candidate->get_name());
                 $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                 $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
             }
         } elseif (isset($_POST['cancel']) && is_array($_POST['cancel'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["cancel"]));
             $group->remove_membership_request($candidate);
             $subject = str_replace("%GROUP", $group->get_name(), gettext("Your membership for '%GROUP' was rejected"));
             $message = gettext("Your membership was rejected.");
             $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME rejected.")));
         }
         //$candidate->mail( $subject, $message, $user->get_attribute( "USER_EMAIL" ));
         \lms_steam::mail($candidate, $user, $subject, $message);
     }
     $result = $group->get_membership_requests();
     $html_people = \Group::getInstance()->loadTemplate("list_users.template.html");
     $no_people = count($result);
     if ($no_people > 0) {
         $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL membership requests") . ")");
         $start = $paginator["startIndex"];
         //$start = $portal->set_paginator( 10, $no_people, "(" . gettext( "%TOTAL membership requests" ). ")" );
         $end = $start + 10 > $no_people ? $no_people : $start + 10;
         $content->setVariable("PAGINATOR", $paginator["html"]);
         $html_people->setVariable("LABEL_CONTACTS", gettext("Membership requests") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_people), gettext("%a-%z out of %s")) . ")");
         $html_people->setCurrentBlock("BLOCK_CONTACT_LIST");
         $html_people->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
         $html_people->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
         $html_people->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
         $html_people->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
         foreach ($result as $candidate) {
             $person = $candidate->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "OBJ_NAME", "OBJ_DESC"));
             $html_people->setCurrentBlock("BLOCK_CONTACT");
             $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($person["OBJ_NAME"]) . "/");
             if (is_object($person["OBJ_ICON"])) {
                 // TODO: Passt der link?
                 $icon_link = PATH_URL . "cached/get_document.php?id=" . $person["OBJ_ICON"]->get_id() . "&type=usericon";
             } else {
                 // TODO: Passt der link?
                 $icon_link = PATH_STYLE . "images/anonymous.jpg";
             }
             $html_people->setVariable("CONTACT_IMAGE", $icon_link);
             $html_people->setVariable("CONTACT_NAME", h($person["USER_FIRSTNAME"]) . " " . h($person["USER_FULLNAME"]));
             $html_people->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($person["OBJ_NAME"]));
             $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
             $html_people->setVariable("LABEL_SEND", gettext("Send"));
             //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
             //see if our candidate is already member in one of the other tutorials.
             $already_member_and_exclusive = false;
             if ($group instanceof \koala_group_tutorial) {
                 if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                     $course_learners_group = $group->steam_group_course_learners;
                     $subgroups = $course_learners_group->get_subgroups();
                     foreach ($subgroups as $sg) {
                         if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             if ($already_member_and_exclusive) {
                 $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><small><b>" . gettext("Attention: User already in tutorial") . " " . $in_group->get_name() . "<p /></b></small><input type=\"hidden\" name=\"confirmed\" value=\"true\"/><input type=\"submit\"  name=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm anyhow") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             } else {
                 $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             }
             $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
             $html_people->parse("BLOCK_CONTACT");
         }
         $html_people->parse("BLOCK_CONTACT_LIST");
         $content->setVariable("HTML_USER_LIST", $html_people->get());
     } else {
         $content->setVariable("LABEL_NO_REQUESTS", "<h3>" . gettext("No membership request found.") . "</h3>");
     }
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #7
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $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 PAKAGE END
     $wiki_html_handler = new \lms_wiki($wiki_container);
     $wiki_html_handler->set_admin_menu("versions", $wiki_doc);
     $content = \Wiki::getInstance()->loadTemplate("wiki_versions.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_versions.template.html" );
     $prev_versions = $wiki_doc->get_previous_versions();
     if (!is_array($prev_versions)) {
         $prev_versions = array();
     }
     array_unshift($prev_versions, $wiki_doc);
     $no_versions = count($prev_versions);
     $content->setCurrentBlock("BLOCK_VERSION_LIST");
     if (isset($_GET["markedfordiff"]) && !empty($_GET["markedfordiff"])) {
         $uri_params = "?markedfordiff=" . $_GET["markedfordiff"];
         //$start = $portal->set_paginator( $content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")", $uri_params );
         $pageIterator = \lms_portal::get_paginator(10, $no_versions, "(" . gettext("%TOTAL groups in list") . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
     } else {
         $pageIterator = \lms_portal::get_paginator(10, $no_versions, "(" . gettext("%TOTAL groups in list") . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
     }
     //$start = $portal->set_paginator( $content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")" );
     $end = $start + 10 > $no_versions ? $no_versions : $start + 10;
     $entry_name = str_replace(".wiki", "", $wiki_doc->get_identifier());
     $content->setVariable("LABEL_VERSIONS", gettext("Available Versions for the entry") . " \"" . h($entry_name) . "\" (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_versions), gettext("%a-%z out of %s")) . ")");
     $content->setVariable("LABEL_VERSION_NUMBER", gettext("Version number"));
     $content->setVariable("LABEL_SIZE", gettext("Size"));
     $content->setVariable("LABEL_DATE", gettext("Modification date"));
     $content->setVariable("LABEL_CREATOR", gettext("Modified by"));
     $content->setVariable("LABEL_ACTION", gettext("Action"));
     // Use buffer for document attributes
     $attributes_tnr = array();
     for ($i = $start; $i < $end; $i++) {
         $attributes_tnr[$prev_versions[$i]->get_id()] = $prev_versions[$i]->get_attributes(array(DOC_USER_MODIFIED, DOC_LAST_MODIFIED, DOC_VERSION, DOC_SIZE), TRUE);
     }
     $attributes_result = $GLOBALS["STEAM"]->buffer_flush();
     // use buffer for author attributes
     $author_tnr = array();
     for ($i = $start; $i < $end; $i++) {
         $author_tnr[$prev_versions[$i]->get_id()] = $attributes_result[$attributes_tnr[$prev_versions[$i]->get_id()]][DOC_USER_MODIFIED]->get_attributes(array(USER_FIRSTNAME, USER_FULLNAME, OBJ_NAME), TRUE);
     }
     $author_result = $GLOBALS["STEAM"]->buffer_flush();
     for ($i = $start; $i < $end; $i++) {
         $doc = $prev_versions[$i];
         $attributes = $attributes_result[$attributes_tnr[$doc->get_id()]];
         $last_author = $author_result[$author_tnr[$doc->get_id()]];
         $content->setCurrentBlock("BLOCK_VERSION");
         if ($doc instanceof \steam_document) {
             $content->setVariable("VALUE_SIZE", get_formatted_filesize($doc->get_content_size()));
             $content->setVariable("VALUE_CREATOR_LINK", PATH_URL . "user/index/" . $author_result[$author_tnr[$doc->get_id()]][OBJ_NAME] . "/");
             $content->setVariable("VALUE_CREATOR", h($last_author[USER_FIRSTNAME]) . " " . h($last_author[USER_FULLNAME]));
             $content->setVariable("VALUE_DATE", strftime("%x %X", $attributes["DOC_LAST_MODIFIED"]));
             if ($doc->get_id() !== $wiki_doc->get_id()) {
                 $content->setVariable("VALUE_VERSION_LINK", PATH_URL . "wiki/viewversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/");
                 $content->setVariable("VALUE_VERSION_NUMBER", "Version " . h($attributes_result[$attributes_tnr[$doc->get_id()]][DOC_VERSION]));
                 $content->setCurrentBlock("BLOCK_RECOVER");
                 $content->setVariable("VALUE_ACTION_RECOVER", "&raquo; " . gettext("Recover this version"));
                 $content->setVariable("VALUE_RECOVER_LINK", PATH_URL . "wiki/recoverversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/");
                 $content->parse("BLOCK_RECOVER");
             } else {
                 $content->setVariable("VALUE_VERSION_LINK", PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/");
                 $content->setVariable("VALUE_VERSION_NUMBER", "Version " . h($attributes_result[$attributes_tnr[$doc->get_id()]][DOC_VERSION]) . " (" . gettext("current") . ")");
             }
             if (isset($_GET["markedfordiff"]) && $_GET["markedfordiff"] == $doc->get_id()) {
                 $content->setVariable("VALUE_ACTION_MARK", "&raquo; " . gettext("Currently marked for version compare"));
             } else {
                 $content->setVariable("VALUE_ACTION_MARK", "<a href=\"" . PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id() . "/?markedfordiff=" . $doc->get_id() . "\">" . "&raquo; " . gettext("Mark for version compare") . "</a>");
             }
             if ($attributes[DOC_VERSION] != 1) {
                 $content->setVariable("VALUE_ACTION_DIFF", "&raquo; " . gettext("Compare to previous version") . " " . ($attributes[DOC_VERSION] - 1));
                 $content->setVariable("VALUE_DIFF_LINK", PATH_URL . "wiki/compareversions/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/" . $prev_versions[$i + 1]->get_id());
             }
             if (isset($_GET["markedfordiff"]) && $_GET["markedfordiff"] != $doc->get_id()) {
                 $marked = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["markedfordiff"]);
                 $content->setVariable("VALUE_ACTION_MARKED_DIFF", "<a href=\"" . PATH_URL . "wiki/compareversions/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/" . $_GET["markedfordiff"] . "\">" . "&raquo; " . gettext("Compare to marked version") . " " . $marked->get_version() . "</a>");
             }
         }
         //is user authorized to delete version?
         $content->setVariable("MESSAGE_DELETION", gettext("Do you really want to delete this version?"));
         $current_user = \lms_steam::get_current_user();
         $admin_group = \steam_factory::get_group($GLOBALS["STEAM"]->get_id(), "admin");
         $isAdmin = is_object($admin_group) && $admin_group->is_member($current_user);
         $usersEntry = $last_author["OBJ_NAME"] === $current_user->get_name();
         $notCurrentVersion = $doc->get_id() !== $wiki_doc->get_id();
         if (($isAdmin || $usersEntry) && $notCurrentVersion) {
             $content->setVariable("VALUE_ACTION_DELETE", "<a href=\"" . PATH_URL . "wiki/deleteversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/\" onclick=\"return confirmDeletion();\">" . "&raquo; " . gettext("Delete this version") . "</a><br \\/>");
         }
         $content->parse("BLOCK_VERSION");
     }
     $content->parse("BLOCK_VERSION_LIST");
     $wiki_html_handler->set_main_html($content->get());
     $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("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => "", "name" => gettext("Version management"))) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => "", "name" => gettext("Version management"))));
     /*	$portal->set_page_main(
     		 $headline,
     		 $wiki_html_handler->get_html()
     		 );
     		 $portal->show_html();
     		 */
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Example #8
0
 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];
     $portal = \lms_portal::get_instance();
     $portal_user = $portal->get_user();
     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("Variable group not set.");
     }
     if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
         header("location:../");
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Group::getInstance()->loadTemplate("list_users.template.html");
     $is_member = $group->is_member($user);
     //echo "is_member? " . $is_member;
     $privacy_deny_participants = $group->get_attribute("GROUP_PRIVACY");
     //echo "attribute: ''" . $privacy_deny_participants . "''";
     if ($privacy_deny_participants == PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS && !$is_member) {
         //echo "*** deny ***";
         //TODO
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", gettext("Participants are hidden."));
     } else {
         //echo "*** permit ***";
         $no_members = count($members);
         if ($no_members > 0) {
             switch (get_class($group)) {
                 case "koala_group_course":
                     $groupname = $group->get_course_id();
                     break;
                 default:
                     $groupname = $group->get_name();
                     break;
             }
             if (!USER_LIST_NO_PAGEING) {
                 $paginator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($groupname), gettext("%TOTAL members in %NAME")) . ")");
                 $start = $paginator["startIndex"];
                 $end = $start + 10 > $no_members ? $no_members : $start + 10;
                 $content->setVariable("PAGINATOR", $paginator["html"]);
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
             } else {
                 //if (count($members) > 10) {
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (Anzahl " . count($members) . ")");
                 $content->setCurrentBlock("BLOCK_FILTER");
                 $content->setVariable("HELP_TEXT", "Benutzer lassen sich einfacher finden, indem Sie den Filter verwenden. Tippen Sie einfach einen Teil des Benutzernamen oder der Benutzerkennung in das Textfeld.");
                 $content->setVariable('LABEL_FILTER', "<b>" . gettext('Filter') . "</b>");
                 $start = 0;
                 $end = count($members);
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $html = "";
                     foreach ($extensions as $extension) {
                         $html .= $extension->get_filter_html($portal, "filter_user", "extension_data");
                     }
                     $content->setCurrentBlock("BLOCK_EXTENSION_FILTER");
                     $content->setVariable("EXTENSION_FILTER", $html);
                     $content->parse("BLOCK_EXTENSION_FILTER");
                 }
                 $content->parse("BLOCK_FILTER");
                 //}
             }
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
             !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
             !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                 !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             }
             !COURSE_PARTICIPANTS_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
             $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
             $content->setVariable("END_HTML_FORM", "</form>");
             for ($i = $start; $i < $end; $i++) {
                 $member = $members[$i];
                 if ($member["USER_TRASHED"] === 1) {
                     continue;
                 }
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($member["OBJ_NAME"]) . "/");
                 // TODO: Passt der link?
                 $icon_link = $member["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . h($member["OBJ_ICON"]) . "&type=usericon&width=30&height=40";
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 $title = !empty($member["USER_ACADEMIC_TITLE"]) ? h($member["USER_ACADEMIC_TITLE"]) . " " : "";
                 $content->setVariable("CONTACT_NAME", $title . h($member["USER_FIRSTNAME"]) . " " . h($member["USER_FULLNAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($member["OBJ_NAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_SEND", gettext("Send"));
                 !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("FACULTY_AND_FOCUS", h($member["USER_PROFILE_FACULTY"]));
                 if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                     !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"remove[" . h($member["OBJ_NAME"]) . "]\" value=\"" . gettext("Remove") . "\"/></td>");
                 }
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $result = "";
                     foreach ($extensions as $extension) {
                         $result .= $extension->get_member_info(\steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $member["OBJ_NAME"]), $group);
                     }
                     $content->setVariable("EXTENSIONS_DATA", $result);
                 }
                 $member_desc = empty($member["OBJ_DESC"]) ? "student" : $member["OBJ_DESC"];
                 $status = secure_gettext($member_desc);
                 $content->setVariable("OBJ_DESC", h($status) . " " . ($i + 1));
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_NO_MEMBERS", gettext("No members found."));
         }
     }
     $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;
 }
Example #9
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     $current_user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     if ($this->id != "") {
         $userName = $this->id;
         $user = \steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $userName);
     } else {
         $user = $current_user;
     }
     $login = $current_user->get_name();
     $cache = get_cache_function($login, 86400);
     //$portal = \lms_portal::get_instance();
     //$portal->set_page_title( $login );
     $html_handler_profile = new \koala_html_profile($user);
     $html_handler_profile->set_context("contacts");
     if ($this->viewer_authorized($current_user, $user)) {
         // Display Contacts
         $unconfirmed_html = "";
         // Contacts to confirm (visible only for the user himself)
         if ($current_user->get_id() == $user->get_id()) {
             $content = \Profile::getInstance()->loadTemplate("list_users.template.html");
             //$content = new HTML_TEMPLATE_IT();
             //$content->loadTemplateFile( PATH_TEMPLATES . "list_users.template.html" );
             $contacts = $cache->call("lms_steam::user_get_contacts_to_confirm", $login);
             $no_contacts = count($contacts);
             if ($no_contacts > 0) {
                 $content->setCurrentBlock("BLOCK_CONTACT_LIST");
                 $result = \lms_portal::get_paginator($content, 10, $no_contacts, "(" . gettext("%TOTAL contact requests in list") . ")");
                 $content->setVariable("PAGEITERATOR", $result["html"]);
                 $start = $result["start"];
                 $end = $start + 10 > $no_contacts ? $no_contacts : $start + 10;
                 if ($current_user->get_id() == $user->get_id()) {
                     $content->setVariable("LABEL_CONTACTS", gettext("Contact requests") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_contacts), gettext("%a-%z out of %s")) . ")");
                 } else {
                     $content->setVariable("LABEL_CONTACTS", str_replace("%NAME", h($user->get_attribute("USER_FIRSTNAME")) . " " . h($user->get_attribute("USER_FULLNAME")), gettext("%NAME's contacts")) . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_contacts), gettext("%a-%z out of %s")) . ")");
                 }
                 // CONTACTS
                 $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
                 $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
                 $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
                 if ($user->get_id() == $current_user->get_id()) {
                     $content->setVariable("TH_MANAGE_CONTACT", gettext("Manage request"));
                 }
                 for ($i = $start; $i < $end; $i++) {
                     $contact = $contacts[$i];
                     $content->setCurrentBlock("BLOCK_CONTACT");
                     $content->setVariable("CONTACT_LINK", PATH_URL . "profile/" . h($contact["OBJ_NAME"]) . "/");
                     $icon_link = $contact["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . h($contact["OBJ_ICON"]) . "&type=usericon&width=30&height=40";
                     $content->setVariable("CONTACT_IMAGE", $icon_link);
                     $title = !empty($contact["USER_ACADEMIC_TITLE"]) ? h($contact["USER_ACADEMIC_TITLE"]) . " " : "";
                     $content->setVariable("CONTACT_NAME", $title . h($contact["USER_FIRSTNAME"]) . " " . h($contact["USER_FULLNAME"]));
                     $faf = \lms_steam::get_faculty_name($contact["USER_PROFILE_FACULTY"]);
                     $faf .= empty($contact["USER_PROFILE_FOCUS"]) ? "" : ": " . h($contact["USER_PROFILE_FOCUS"]);
                     $content->setVariable("FACULTY_AND_FOCUS", $faf);
                     $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($contact["OBJ_NAME"]));
                     $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                     $content->setVariable("LABEL_SEND", gettext("Send"));
                     if ($user->get_id() == $current_user->get_id()) {
                         $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><a href=\"" . PATH_URL . "contact_confirm.php?id=" . h($contact["OBJ_ID"]) . "\">" . gettext("Confirm") . " / " . gettext("Deny") . "</a></td>");
                     }
                     $contact_desc = empty($contact["OBJ_DESC"]) ? "student" : $contact["OBJ_DESC"];
                     $status = secure_gettext($contact_desc);
                     $content->setVariable("OBJ_DESC", h($status));
                     $content->parse("BLOCK_CONTACT");
                 }
                 $content->parse("BLOCK_CONTACT_LIST");
             }
             $unconfirmed_html = $content->get();
         }
         $content = \Profile::getInstance()->loadTemplate("list_users.template.html");
         //$content = new HTML_TEMPLATE_IT();
         //$content->loadTemplateFile( PATH_TEMPLATES . "list_users.template.html" );
         // Contact list
         $confirmed = $user->get_id() != $current_user->get_id() ? TRUE : FALSE;
         $contacts = $cache->call("lms_steam::user_get_buddies", $login, $confirmed);
         // If user views his own contact list, get information about the confirmed contacts too
         //HACK START DOMINIK FRAGEN!
         $confirmed_contacts = "";
         //HACK END
         if (!$confirmed) {
             $confirmed_contacts = $user->get_attribute("USER_CONTACTS_CONFIRMED");
         }
         if (!is_array($confirmed_contacts)) {
             $confirmed_contacts = array();
         }
         $no_contacts = count($contacts);
         if ($no_contacts > 0) {
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $start = $portal->set_paginator($content, 10, $no_contacts, "(" . gettext("%TOTAL contacts in list") . ")");
             $end = $start + 10 > $no_contacts ? $no_contacts : $start + 10;
             if ($current_user->get_id() == $user->get_id()) {
                 $content->setVariable("LABEL_CONTACTS", gettext("Your contacts") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_contacts), gettext("%a-%z out of %s")) . ")");
             } else {
                 $content->setVariable("LABEL_CONTACTS", str_replace("%NAME", h($user->get_attribute("USER_FIRSTNAME")) . " " . h($user->get_attribute("USER_FULLNAME")), gettext("%NAME's contacts")) . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_contacts), gettext("%a-%z out of %s")) . ")");
             }
             // CONTACTS
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
             $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
             $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             if ($user->get_id() == $current_user->get_id()) {
                 $content->setVariable("TH_MANAGE_CONTACT", gettext("Manage contact"));
             }
             for ($i = $start; $i < $end; $i++) {
                 $contact = $contacts[$i];
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_LINK", PATH_URL . "profile/" . h($contact["OBJ_NAME"]) . "/");
                 $icon_link = $contact["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . h($contact["OBJ_ICON"]) . "&type=usericon&width=30&height=40";
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 $title = !empty($contact["USER_ACADEMIC_TITLE"]) ? h($contact["USER_ACADEMIC_TITLE"]) . " " : "";
                 $content->setVariable("CONTACT_NAME", $title . h($contact["USER_FIRSTNAME"]) . " " . h($contact["USER_FULLNAME"]));
                 $faf = lms_steam::get_faculty_name($contact["USER_PROFILE_FACULTY"]);
                 $faf .= empty($contact["USER_PROFILE_FOCUS"]) ? "" : ": " . h($contact["USER_PROFILE_FOCUS"]);
                 $content->setVariable("FACULTY_AND_FOCUS", $faf);
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($contact["OBJ_NAME"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 $content->setVariable("LABEL_SEND", gettext("Send"));
                 $cmessage = "";
                 if ($user->get_id() == $current_user->get_id()) {
                     if (isset($confirmed_contacts[$contact["OBJ_ID"]]) && $confirmed_contacts[$contact["OBJ_ID"]]) {
                         $cmessage .= "(" . gettext("Confirmed") . ")";
                     } else {
                         $cmessage .= "(" . gettext("Unconfirmed") . ")";
                     }
                     $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><a href=\"" . PATH_URL . "contact_delete.php?id=" . h($contact["OBJ_ID"]) . "\">" . gettext("Delete") . "</a></td>");
                 }
                 $contact_desc = empty($contact["OBJ_DESC"]) ? "student" : $contact["OBJ_DESC"];
                 $status = secure_gettext($contact_desc);
                 $content->setVariable("OBJ_DESC", h($status) . (strlen($cmessage) > 0 ? "<br />" . $cmessage : ""));
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_CONTACTS", gettext("No contacts yet."));
         }
     } else {
         $messagebox = "<div class=\"infoBar\"><h2>" . gettext("The user has restricted the display of this information.") . "</h2></div>";
         $content = \Profile::getInstance()->loadTemplate("list_users.template.html");
         //$content = new \HTML_TEMPLATE_IT();
         //$content->loadTemplateFile( PATH_TEMPLATES . "list_users.template.html" );
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", $messagebox);
     }
     $html_handler_profile->set_html_left($unconfirmed_html . $content->get());
     $frameResponseObject->setHeadline($html_handler_profile->get_headline());
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html_handler_profile->get_html());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
     //$portal->set_page_main( $html_handler_profile->get_headline(), $html_handler_profile->get_html(), "vcard" );
     //return $portal->get_html();
 }