예제 #1
0
 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());
     }
 }
예제 #2
0
 public function is_admin($user)
 {
     $ret = $this->steam_object->is_admin($user);
     if (!$ret) {
         $ret = lms_steam::is_koala_admin($user);
     }
     return $ret;
 }
예제 #3
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];
     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;
 }
예제 #4
0
 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
     $env = $wiki_container->get_environment();
     $grp = $env->get_creator();
     if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") {
         $grp = $grp->get_parent_group();
     }
     if (!isset($wiki_container) || !is_object($wiki_container)) {
         if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
             throw new Exception("Environment unknown.");
         }
         if (!($grp = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]))) {
             throw new Exception("Group unknown");
         }
     }
     $accessmergel = FALSE;
     if (isset($wiki_container) && is_object($wiki_container)) {
         $creator = $wiki_container->get_creator();
         if ($wiki_container->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(\lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         if (get_magic_quotes_gpc()) {
             if (!empty($values['name'])) {
                 $values['name'] = stripslashes($values['name']);
             }
             if (!empty($values['dsc'])) {
                 $values['dsc'] = stripslashes($values['dsc']);
             }
         }
         if (empty($values["name"])) {
             $problems = gettext("The name of new wiki is missing.");
             $hints = gettext("Please type in a name.");
         }
         if (strpos($values["name"], "/")) {
             if (!isset($problems)) {
                 $problems = "";
             }
             $problems .= gettext("Please don't use the \"/\"-char in the name of the wiki.");
         }
         if (empty($problems)) {
             $group_members = $grp;
             $group_admins = 0;
             $group_staff = 0;
             // check if group is a course
             $grouptype = (string) $grp->get_attribute("OBJ_TYPE");
             if ($grouptype == "course") {
                 $group_staff = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".staff");
                 $group_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".admins");
                 $group_members = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners");
                 $workroom = $group_members->get_workroom();
             } else {
                 $workroom = $grp->get_workroom();
             }
             if (!isset($wiki_container) || !is_object($wiki_container)) {
                 $new_wiki = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $values["name"], $env, $values["dsc"]);
                 $new_wiki->set_attribute("OBJ_TYPE", "container_wiki_koala");
                 $_SESSION["confirmation"] = str_replace("%NAME", $values["name"], gettext("New wiki '%NAME' created."));
             } else {
                 $wiki_container->set_attribute(OBJ_NAME, $values["name"]);
                 if ($values["wiki_startpage"] == gettext("Glossary")) {
                     $values["wiki_startpage"] = "glossary";
                 }
                 $wiki_container->set_attribute("OBJ_WIKI_STARTPAGE", $values["wiki_startpage"]);
                 $wiki_container->set_attribute(OBJ_DESC, $values["dsc"]);
                 //$portal->set_confirmation(gettext( "The changes have been saved." ));
                 $new_wiki = $wiki_container;
             }
             $koala_wiki = new \lms_wiki($new_wiki);
             $access = (int) $values["access"];
             $access_descriptions = \lms_wiki::get_access_descriptions($grp);
             if (!$accessmergel) {
                 $koala_wiki->set_access($access, $access_descriptions[$access]["members"], $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins);
             }
             $GLOBALS["STEAM"]->buffer_flush();
             $cache = get_cache_function(\lms_steam::get_current_user()->get_name());
             $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CONTAINER, array("OBJ_TYPE", "WIKI_LANGUAGE"));
             $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             if (!isset($wiki_container) || !is_object($wiki_container)) {
                 header("Location: " . $backlink);
                 exit;
             }
         } else {
             $frameResponseObject->setProblemDescription($problems);
             $frameResponseObject->setProblemSolution(isset($hints) ? $hints : "");
         }
     }
     $content = \Wiki::getInstance()->loadTemplate("object_new.template.html");
     //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES );
     //$content->loadTemplateFile( "object_new.template.html" );
     if (isset($wiki_container) && is_object($wiki_container)) {
         $content->setVariable("INFO_TEXT", str_replace("%NAME", h($wiki_container->get_name()), gettext("You are going to edit the wiki '<b>%NAME</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Save changes"));
         $pagetitle = gettext("Preferences");
         if (empty($values)) {
             $values = array();
             $values["name"] = $wiki_container->get_name();
             $values["dsc"] = $wiki_container->get_attribute(OBJ_DESC);
             $values["wiki_startpage"] = $wiki_container->get_attribute("OBJ_WIKI_STARTPAGE");
             $values["access"] = $wiki_container->get_attribute(KOALA_ACCESS);
         }
         $breadcrumbheader = gettext("Preferences");
         $content->setVariable("OPTION_WIKI_GLOSSARY", gettext("Glossary"));
         $wiki_entries = $wiki_container->get_inventory(CLASS_DOCUMENT);
         $wiki_entries_sorted = array();
         foreach ($wiki_entries as $wiki_entry) {
             if ($wiki_entry->get_attribute(DOC_MIME_TYPE) === "text/wiki") {
                 $wiki_entries_sorted[] = str_replace(".wiki", "", $wiki_entry->get_name());
             }
         }
         sort($wiki_entries_sorted);
         $startpageFound = false;
         foreach ($wiki_entries_sorted as $wiki_entry) {
             $content->setCurrentBlock("BLOCK_WIKI_STARTPAGE_OPTION");
             $content->setVariable("OPTION_WIKI_STARTPAGE", $wiki_entry);
             if ($values["wiki_startpage"] == $wiki_entry) {
                 $content->setVariable("WIKI_STARTPAGE_SELECTED", "selected");
                 $startpageFound = true;
             }
             $content->parse("BLOCK_WIKI_STARTPAGE_OPTION");
         }
         if (!$startpageFound) {
             $content->setVariable("OPTION_WIKI_GLOSSARY_SELECTED", "selected");
         }
     } else {
         $grpname = $grp->get_attribute(OBJ_NAME);
         if ($grp->get_attribute(OBJ_TYPE) == "course") {
             $grpname = $grp->get_attribute(OBJ_DESC);
         }
         $content->setVariable("OPTION_WIKI_GLOSSARY", gettext("Glossary"));
         $content->setVariable("OPTION_WIKI_GLOSSARY_SELECTED", "selected");
         $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new wiki in '<b>%ENV</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Create wiki"));
         $pagetitle = gettext("Create wiki");
         $breadcrumbheader = gettext("Add new wiki");
     }
     if (!empty($values)) {
         if (!empty($values["name"])) {
             $content->setVariable("VALUE_NAME", h($values["name"]));
         }
         if (!empty($values["dsc"])) {
             $content->setVariable("VALUE_DSC", h($values["dsc"]));
         }
         if (!empty($values["wiki_startpage"])) {
             $content->setVariable("VALUE_WIKI_STARTPAGE", h($values["wiki_startpage"]));
         }
     }
     $content->setVariable("VALUE_BACKLINK", $backlink);
     $content->setVariable("LABEL_NAME", gettext("Name"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("LABEL_WIKI_STARTPAGE", gettext("Startpage"));
     $content->setVariable("LABEL_ACCESS", gettext("Access"));
     $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"));
     if ($accessmergel) {
         $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
         $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
         $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
         $content->parse("BLOCK_ACCESSMERGEL");
     } else {
         $access = \lms_wiki::get_access_descriptions($grp);
         if ((string) $grp->get_attribute("OBJ_TYPE") == "course") {
             $access_default = PERMISSION_PUBLIC;
         } else {
             $access_default = PERMISSION_PUBLIC_READONLY;
             if (isset($wiki_container) && is_object($wiki_container) && $creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                 $access[PERMISSION_PRIVATE_READONLY] = str_replace("%NAME", $creator->get_name(), $access[PERMISSION_PRIVATE_READONLY]);
             } else {
                 $access[PERMISSION_PRIVATE_READONLY] = str_replace("%NAME", "you", $access[PERMISSION_PRIVATE_READONLY]);
             }
         }
         if (is_array($access)) {
             $content->setCurrentBlock("BLOCK_ACCESS");
             foreach ($access as $key => $array) {
                 if ($key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) {
                     $content->setCurrentBlock("ACCESS");
                     $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                     $content->setVariable("VALUE", $key);
                     if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) {
                         $content->setVariable("CHECK", "checked=\"checked\"");
                     }
                     $content->parse("ACCESS");
                 }
             }
             $content->parse("BLOCK_ACCESS");
         }
     }
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $rootlink = \lms_steam::get_link_to_root($grp);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication"))) : "";
     if (isset($wiki_container) && is_object($wiki_container)) {
         $headline[] = array("link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/", "name" => h($wiki_container->get_name()));
     }
     $headline[] = array("link" => "", "name" => $breadcrumbheader);
     $frameResponseObject->setTitle($pagetitle);
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
     /*$portal->set_page_main( $headline, $content->get() );
     	 $portal->set_page_title( $pagetitle );
     	 $portal->show_html();*/
 }
예제 #5
0
 public function get_context_menu($context, $params = array())
 {
     if (!isset($_SESSION["LMS_USER"]) || !$_SESSION["LMS_USER"] instanceof lms_user || !$_SESSION["LMS_USER"]->is_logged_in()) {
         return array();
     }
     $current_user = lms_steam::get_current_user();
     $steam_group = $this->course->get_steam_group();
     $learners_group = $this->course->get_group_learners();
     if (!$this->course->is_member($current_user) && !$this->course->is_admin($current_user)) {
         if ($context == "start" && (!$this->course->is_paul_course() && ($steam_group->get_attribute("COURSE_HISLSF_ID") == 0 || $steam_group->get_attribute("COURSE_HISLSF_ID") == "") && ($this->course->get_maxsize() == 0 || $this->course->get_maxsize() > 0 && $this->course->get_maxsize() > $this->course->count_members())) || $this->course->is_paul_course() && $this->course->get_attribute(KOALA_GROUP_ACCESS) != PERMISSION_COURSE_PAUL_SYNC) {
             return array(array("link" => PATH_URL . "group_subscribe.php?group=" . $steam_group->get_id(), "name" => gettext("Join this course")));
         }
         return array();
     }
     $context_menu = array();
     switch ($context) {
         case "reserve_list":
             $rl = $steam_group->get_attribute("SEM_APP_ID");
             if (!empty($rl["SEM_APP_ID"])) {
                 $context_menu[] = array("link" => PATH_URL . "courses_edit_reserve_list.php?course=" . $steam_group->get_id() . "&rlid=" . $rl, "name" => gettext("Edit reserve list"));
                 $context_menu[] = array("link" => PATH_URL . "courses_remove_reserve_list.php?course=" . $steam_group->get_id(), "name" => gettext("Remove reserve list"));
             }
             break;
         case "start":
             if (COURSE_PREFERENCES) {
                 if (COURSE_KOALAADMIN_ONLY) {
                     if (lms_steam::is_koala_admin($current_user)) {
                         $context_menu[] = array("link" => PATH_URL . "course" . "/edit/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/", "name" => gettext("Preferences"));
                     }
                 } else {
                     if ($this->course->is_admin($current_user)) {
                         $context_menu[] = array("link" => PATH_URL . "course" . "/edit/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/", "name" => gettext("Preferences"));
                         //$context_menu[] = array( "link" => PATH_URL . "group_add_admin.php?group=" . $steam_group->get_id() ,	"name" => gettext( "Add staff member" ) );
                         $rl = $steam_group->get_attribute("SEM_APP_ID");
                         if (empty($rl["SEM_APP_ID"])) {
                             if (defined("COURSE_SEM_APP_ENABLED") && COURSE_SEM_APP_ENABLED && defined("SEM_APP_BASE_URL") && SEM_APP_BASE_URL != "") {
                                 $context_menu[] = array("link" => PATH_URL . "courses_add_reserve_list.php?course=" . $steam_group->get_id(), "name" => gettext("Add reserve list"));
                             }
                         }
                     }
                 }
             }
             if (COURSE_LEAVE && (!$this->course->is_paul_course() && ($steam_group->get_attribute("COURSE_HISLSF_ID") == 0 || $steam_group->get_attribute("COURSE_HISLSF_ID") == "") || $this->course->is_paul_course() && $this->course->get_attribute(KOALA_GROUP_ACCESS) != PERMISSION_COURSE_PAUL_SYNC)) {
                 $context_menu[] = array("link" => PATH_URL . "group_cancel.php?group=" . $steam_group->get_id(), "name" => gettext("Cancel membership"));
             }
             break;
         case "members":
             if (lms_steam::is_koala_admin($current_user) || !COURSE_KOALAADMIN_ONLY && $this->course->is_admin($current_user)) {
                 !COURSE_PARTICIPANTS_CIRCULAR or $context_menu[] = array("link" => PATH_URL . "messages_write.php?group=" . $steam_group->get_id(), "name" => gettext("Write circular"));
                 !COURSE_PARTICIPANTS_EXCEL_LIST or $context_menu[] = array("link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/learners/excel/", "name" => gettext("Participant list (Excel)"));
                 !COURSE_PARTICIPANTS_ATTENDANCE_LIST or $context_menu[] = array("link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/learners/excel/attendance", "name" => gettext("Attendance list (Excel)"));
                 !COURSE_PARTICIPANTS_MANAGE_MEMBERSHIP_REQUESTS or $context_menu[] = array("link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/requests/", "name" => gettext("Manage membership requests"));
                 !COURSE_PARTICIPANTS_ADD_MEMBER or $context_menu[] = array("link" => PATH_URL . "group_add_member.php?group=" . $steam_group->get_id(), "name" => gettext("Add member"));
             }
             break;
         case "staff":
             if (lms_steam::is_koala_admin($current_user) || !COURSE_KOALAADMIN_ONLY && $this->course->is_admin($current_user)) {
                 !COURSE_STAFF_CIRCULAR or $context_menu[] = array("link" => PATH_URL . "messages_write.php?group=" . $steam_group->get_id(), "name" => gettext("Write circular"));
                 !COURSE_STAFF_EXCEL_LIST or $context_menu[] = array("link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/staff/excel/", "name" => gettext("staff member list (Excel)"));
                 //$context_menu[] = array( "link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/learners/excel/attendance", "name" => gettext( "Attendance list (Excel)" ) );
                 //$context_menu[] = array( "link" => PATH_URL . SEMESTER_URL . "/" . $this->course->get_semester()->get_name() . "/" . $steam_group->get_name() . "/requests/", "name" => gettext( "Manage membership requests" ) );
                 !COURSE_STAFF_ADD_MEMBER or $context_menu[] = array("link" => PATH_URL . "group_add_admin.php?group=" . $steam_group->get_id(), "name" => gettext("Add staff member"));
             }
             break;
         case "communication":
             if ($learners_group->get_workroom()->check_access_insert($current_user)) {
                 $context_menu[] = array("link" => PATH_URL . "weblog_new.php?env=" . $learners_group->get_workroom()->get_id() . "&group=" . $steam_group->get_id(), "name" => gettext("Create new weblog"));
                 $context_menu[] = array("link" => PATH_URL . "forum_new.php?env=" . $learners_group->get_workroom()->get_id() . "&group=" . $steam_group->get_id(), "name" => gettext("Create new forum"));
                 $context_menu[] = array("link" => PATH_URL . "wiki_new.php?env=" . $learners_group->get_workroom()->get_id() . "&group=" . $steam_group->get_id(), "name" => gettext("Create new wiki"));
             }
             break;
     }
     //TODO: extensionmanager
     /*		// extensions context menu entries:
     		foreach ($this->course->get_extensions() as $extension)
     		{
     			$extension_context_menu = $extension->get_context_menu( $context, $params );
     			if ( is_array( $extension_context_menu ) && !empty( $extension_context_menu ) ) {
     				$context_menu = array_merge( $context_menu, $extension_context_menu );
     			}
     		}*/
     return $context_menu;
 }
예제 #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_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;
 }
예제 #7
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $group_id = $this->params[0];
     $user = \lms_steam::get_current_user();
     try {
         $steam_group = !empty($group_id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group_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 (!$steam_group->check_access_write($user)) {
         throw new Exception(str_replace("%USER", $user->get_login(), sr_replace("%GROUP", $group->get_id(), gettext("Access denied: User %USER has no right to delete the group %GROUP"))), E_USER_RIGHTS);
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         $env = $steam_group->get_environment();
         // TODO: Passt der link?
         $upper_link = PATH_URL . "groups/" . (is_object($env) ? "?cat=" . $env->get_id() : "");
         $group_name = $group->get_display_name();
         $members = $group->get_members();
         $inventory = $group->get_workroom()->get_inventory_raw();
         $deleted = TRUE;
         foreach ($inventory as $object) {
             if (!$object instanceof \steam_user) {
                 try {
                     \lms_steam::delete($object);
                 } catch (Exception $ex3) {
                     \logging::write_log(LOG_DEBUGLOG, "groups_delete:error deleting object from group workroom\t" . $login . " \t" . $group->get_display_name() . " \t" . $steam_group->get_id() . " \t" . $object->get_id());
                 }
             }
         }
         if ($steam_group->delete()) {
             $user->get_attributes(array(OBJ_NAME, USER_FIRSTNAME, USER_FULLNAME));
             foreach ($members as $member) {
                 $cache = get_cache_function($member->get_name());
                 $cache->drop("lms_steam::user_get_groups", $member->get_name(), TRUE);
                 $cache->drop("lms_steam::user_get_groups", $member->get_name(), FALSE);
                 $cache->drop("lms_steam::user_get_profile", $member->get_name());
                 $cache->drop("lms_portal::get_menu_html", $member->get_name(), TRUE);
             }
             $cache = get_cache_function($steam_group->get_id());
             $cache->drop("lms_steam::group_get_members", $steam_group->get_id());
             foreach ($members as $member) {
                 \lms_steam::mail($member, $user, PLATFORM_NAME . ": " . str_replace("%NAME", h($group_name), gettext("Group %NAME has been deleted.")), str_replace("%USER", $user->get_name() . " (" . $user->get_attribute(USER_FIRSTNAME) . " " . $user->get_attribute(USER_FULLNAME) . ")", str_replace("%NAME", h($group_name), gettext("The group '%NAME' has been deleted from he koaLA System by %USER."))) . "\n\n-- \n" . str_replace("%NAME", h($group_name), gettext("This system generated notification message was sent to you as a former member of the deleted group \"%NAME\"")));
             }
             $_SESSION["confirmation"] = str_replace("%NAME", h($group_name), gettext("The group '%NAME' has been deleted. A notification has been sent to former members."));
             header("Location: " . $upper_link);
             exit;
         } else {
             throw new Exception("Deletion of group failed");
         }
     }
     $content = \Group::getInstance()->loadTemplate("group_delete.template.html");
     $content->setVariable("FORM_ACTION", "");
     $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure?"));
     $content->setVariable("INFO_DELETE_GROUP", str_replace("%GROUP_NAME", h($group->get_name()), gettext("You are going to delete '%GROUP_NAME'.")) . "<br />" . gettext("All data of this group will be removed from the system including weblogs, wikis, forums and documents. All members of this group will be notified about the deletion automatically.") . "<br /><br /><strong>" . gettext("The deletion process may take several minutes.")) . "</strong>";
     $content->setVariable("LABEL_DELETE_IT", gettext("Yes, delete this group"));
     $content->setVariable("DELETE_BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #8
0
<?php

if (!$course->is_staff(lms_steam::get_current_user()) && !lms_steam::is_koala_admin(lms_steam::get_current_user())) {
    throw new Exception("No rights to view this.", E_USER_RIGHTS);
}
require_once "Spreadsheet/Excel/Writer.php";
$cache = get_cache_function($unit->get_id(), CACHE_LIFETIME_STATIC);
$participant_group = $unit->get_attribute("UNIT_POINTLIST_PARTICIPANTS");
$proxy = $unit->get_attribute("UNIT_POINTLIST_PROXY");
if (defined("LOG_DEBUGLOG")) {
    $time1 = microtime(TRUE);
    $login = lms_steam::get_current_user()->get_name();
    logging::write_log(LOG_DEBUGLOG, "units_pointlist_excel:\t " . $login . "\t" . $unit->get_display_name() . "\t" . $participant_group->get_identifier() . "\t" . $participant_group->count_members() . "\t" . date("d.m.y G:i:s", time()) . "... ");
}
$members = $cache->call("lms_steam::group_get_members", $participant_group->get_id(), TRUE);
// INITIALIZATION
$course_id = $course->get_course_id();
$course_name = $course->get_course_name();
$semester = $course->get_semester();
$proxy_data = $proxy->get_all_attributes();
$points = units_pointlist::extract_pointlist($proxy_data);
$maxpoints = $proxy_data["UNIT_POINTLIST_MAXPOINTS"];
$count = $unit->get_attribute("UNIT_POINTLIST_COUNT");
$bonus_1 = $unit->get_attribute("UNIT_POINTLIST_BONUS_1");
$bonus_2 = $unit->get_attribute("UNIT_POINTLIST_BONUS_2");
$unit_name = $unit->get_display_name();
$excel = new Spreadsheet_Excel_Writer();
$excel->setTempDir(PATH_TEMP);
$format_table_header =& $excel->addFormat(array('Size' => 12, 'Align' => 'left', 'Bold' => 1));
$format_table_header_number =& $excel->addFormat(array('Size' => 12, 'Align' => 'right', 'Bold' => 1));
$sheet_table_header =& $excel->addFormat(array('Size' => 14, 'Align' => 'left'));
예제 #9
0
파일: Staff.class.php 프로젝트: rolwi/koala
 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;
 }
예제 #10
0
 public function is_admin($steam_user)
 {
     $ret = $this->is_staff($steam_user);
     if (!$ret) {
         $ret = lms_steam::is_koala_admin($steam_user);
     }
     return $ret;
 }
예제 #11
0
파일: install_spm.php 프로젝트: rolwi/koala
<?php

include_once "../../etc/koala.conf.php";
ini_set('memory_limit', '2024M');
ini_set('max_execution_time', '300');
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
if (!lms_steam::is_koala_admin($user)) {
    header("location:/");
    exit;
}
$STEAM = $GLOBALS["STEAM"];
echo "<h1>Installing SPM</h1>";
$package_container = steam_factory::get_object_by_name($STEAM->get_id(), "/packages");
if (!is_object($package_container)) {
    echo "Could not find /packages on your open-sTeam server.<br>";
    die;
}
echo "Reading file <br>";
$myFile = PATH_TEMP . "elearning_stahl_verkauf-1_40.spm";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo "Uploading File <br>";
$package = steam_factory::create_document($STEAM->get_id(), "elearning_stahl_verkauf-1_40.spm", $theData, "application/download", $package_container);
echo "Installiere Package<br>";
echo $STEAM->install_package($package);
예제 #12
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;
 }
예제 #13
0
파일: View.class.php 프로젝트: rolwi/koala
 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;
     }
     $html_handler_group = new \koala_html_group($steam_group);
     $html_handler_group->set_context("start");
     $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 ($id != STEAM_PUBLIC_GROUP) {
         //TODO: Somethings wrong here... again a 404 error while loading koala_html_group
         /*
          $html_handler_group = new \koala_html_group( $group );
         $html_handler_group->set_context( "start" );
         */
         $content = \Group::getInstance()->loadTemplate("group_start.template.html");
         $content->setVariable("LABEL_DESCRIPTION", gettext("Description"));
         $desc = $group->get_attribute("OBJ_DESC");
         if (empty($desc)) {
             $content->setVariable("OBJ_DESC", gettext("No description available."));
         } else {
             $content->setVariable("OBJ_DESC", get_formatted_output($desc));
         }
         $about = $group->get_attribute("OBJ_LONG_DSC");
         if (!empty($about)) {
             $content->setCurrentBlock("BLOCK_ABOUT");
             $content->setVariable("VALUE_ABOUT", get_formatted_output($about));
             $content->parse("BLOCK_ABOUT");
         }
         $content->setVariable("LABEL_ADMINS", gettext("Moderated by"));
         if ($group->get_maxsize() > 0) {
             $content->setCurrentBlock("BLOCK_GROUPSIZE");
             $content->setVariable("LABEL_MAXSIZE_HEADER", gettext("The number of participants of this group is limited."));
             $content->setVariable("LABEL_MAXSIZE_DESCRIPTION", str_replace("%MAX", $group->get_maxsize(), str_replace("%ACTUAL", $group->count_members(), gettext("The actual participant count is %ACTUAL of %MAX."))));
             $content->parse("BLOCK_GROUPSIZE");
         }
         $admins = $group->get_admins();
         if (count($admins) > 0) {
             foreach ($admins as $admin) {
                 $content->setCurrentBlock("BLOCK_ADMIN");
                 $admin_attributes = $admin->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "OBJ_DESC", "OBJ_NAME"));
                 if ($admin instanceof \steam_user) {
                     $content->setVariable("ADMIN_NAME", h($admin_attributes["USER_FIRSTNAME"]) . " " . h($admin_attributes["USER_FULLNAME"]));
                     $content->setVariable("ADMIN_LINK", PATH_URL . "user/" . h($admin->get_name()) . "/");
                 } else {
                     $content->setVariable("ADMIN_NAME", h($admin_attributes["OBJ_NAME"]));
                     $content->setVariable("ADMIN_LINK", PATH_URL . "groups/" . $admin->get_id() . "/");
                 }
                 $content->setVariable("ADMIN_ICON", PATH_URL . "cached/get_document.php?id=" . $admin_attributes["OBJ_ICON"]->get_id() . "&type=usericon&width=40&height=47");
                 $admin_desc = empty($admin_attributes["OBJ_DESC"]) ? "student" : $admin_attributes["OBJ_DESC"];
                 $content->setVariable("ADMIN_DESC", secure_gettext($admin_desc));
                 $content->parse("BLOCK_ADMIN");
             }
         } else {
             $content->setVariable("LABEL_UNMODERATED", gettext("Group is unmoderated."));
         }
         //TODO: Somethings wrong here... again a 404 error while loading koala_html_group
         //$html_handler_group->set_html_left( $content->get() );
         // TODO: Portal...!
         //$portal->set_page_main( $html_handler_group->get_headline(), $html_handler_group->get_html() , "" );
         //$portal->show_html();
     } else {
         //TODO: Wann wird das hier aufgerufen??
         $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
         $user = \lms_steam::get_current_user();
         $content = \Group::getInstance()->loadTemplate("groups_public.template.html");
         if (MANAGE_GROUPS_MEMBERSHIP || CREATE_GROUPS) {
             $content->setCurrentBlock("BLOCK_ACTION_BAR_GROUPS");
             if (MANAGE_GROUPS_MEMBERSHIP) {
                 $content->setCurrentBlock("BLOCK_MANAGE_GROUPS_MEMBERSHIP");
                 $content->setVariable("LINK_MANAGE_SUBSCRIPTIONS", PATH_URL . "user/" . $user->get_name() . "/groups/");
                 $content->setVariable("LABEL_MANAGE_SUBSCRIPTIONS", gettext("Manage subscriptions"));
                 $content->parse("BLOCK_MANAGE_GROUPS_MEMBERSHIP");
             }
             if (CREATE_GROUPS) {
                 $content->setCurrentBlock("BLOCK_CREATE_GROUPS");
                 $content->setVariable("LINK_CREATE_NEW_GROUP", PATH_URL . "groups_create_dsc.php?parent=" . (isset($_GET["cat"]) ? $_GET["cat"] : $public->get_id()));
                 $content->setVariable("LABEL_CREATE_NEW_GROUP", gettext("Create new group"));
                 $content->parse("BLOCK_CREATE_GROUPS");
             }
             $content->parse("BLOCK_ACTION_BAR_GROUPS");
         }
         $content->setVariable("LABEL_NAME", gettext("Name"));
         $content->setVariable("LABEL_DESC", gettext("Description"));
         if (!empty($_GET["cat"])) {
             // EINE KATEGORIE ANZEIGEN
             if (!($category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["cat"]))) {
                 include "bad_link.php";
                 exit;
             }
             if (!$category instanceof \steam_container) {
                 include "bad_link.php";
                 exit;
             }
             $subgroups = $category->get_inventory(CLASS_GROUP);
             $content->setVariable("LABEL_ALL_CATEGORIES", str_replace(array("%i", "%NAME"), array(count($subgroups), $category->get_name()), gettext("%i groups in %NAME")));
             $content->setVariable("LABEL_SUBGROUPS_MEMBERS", gettext("Members"));
             $tnr = array();
             $attributes = array(OBJ_NAME, OBJ_DESC);
             $tnr = array();
             $attributes = array(OBJ_NAME, OBJ_DESC);
             foreach ($subgroups as $subgroup) {
                 $tnr[$subgroup->get_id()] = array();
                 $tnr[$subgroup->get_id()][OBJ_NAME] = $subgroup->get_attribute(OBJ_NAME, TRUE);
                 $tnr[$subgroup->get_id()][OBJ_DESC] = $subgroup->get_attribute(OBJ_DESC, TRUE);
                 $tnr[$subgroup->get_id()]["membercount"] = $subgroup->count_members(TRUE);
             }
             $result = $GLOBALS["STEAM"]->buffer_flush();
             foreach ($subgroups as $subgroup) {
                 $subgroup->set_value(OBJ_NAME, $result[$tnr[$subgroup->get_id()][OBJ_NAME]]);
                 $subgroup->set_value(OBJ_DESC, $result[$tnr[$subgroup->get_id()][OBJ_DESC]]);
             }
             usort($subgroups, "sort_objects_new");
             foreach ($subgroups as $subgroup) {
                 $content->setCurrentBlock("BLOCK_CATEGORY_GROUP");
                 $content->setVariable("VALUE_LINK", PATH_URL . "groups/" . $subgroup->get_id() . "/");
                 $content->setVariable("VALUE_NAME", h($subgroup->get_name()));
                 $content->setVariable("VALUE_SUBGROUPS_MEMBERS", $result[$subgroup->get_id()]["membercount"]);
                 $content->setVariable("VALUE_DESC", h($subgroup->get_attribute("OBJ_DESC")));
                 $content->parse("BLOCK_CATEGORY_GROUP");
             }
             $headline = array(array("link" => PATH_URL . "groups/", "name" => gettext("Public Groups")), array("link" => "", "name" => h($category->get_name())));
         } else {
             // KATEGORIEN ANZEIGEN
             $categories = $public->get_workroom()->get_inventory(CLASS_ROOM | CLASS_CONTAINER);
             $content->setVariable("LABEL_ALL_CATEGORIES", str_replace("%i", count($categories), gettext("%i categories in Public Groups")));
             $content->setVariable("LABEL_SUBGROUPS_MEMBERS", gettext("Groups"));
             if (count($categories) > 0) {
                 $tnr = array();
                 $attributes = array(OBJ_NAME, OBJ_DESC);
                 foreach ($categories as $category) {
                     $tnr[$category->get_id()] = array();
                     $tnr[$category->get_id()]["attributes"] = $category->get_attributes($attributes, TRUE);
                     $tnr[$category->get_id()]["inventory"] = $category->get_inventory_raw(CLASS_GROUP, TRUE);
                 }
                 $result = $GLOBALS["STEAM"]->buffer_flush();
                 foreach ($categories as $category) {
                     $category->set_value(OBJ_NAME, $result[$tnr[$category->get_id()]["attributes"]][OBJ_NAME]);
                     $category->set_value(OBJ_DESC, $result[$tnr[$category->get_id()]["attributes"]][OBJ_DESC]);
                 }
                 usort($categories, "sort_objects_new");
                 foreach ($categories as $category) {
                     $content->setCurrentBlock("BLOCK_CATEGORY_GROUP");
                     $content->setVariable("VALUE_LINK", PATH_URL . "groups/?cat=" . $category->get_id());
                     $content->setVariable("VALUE_NAME", h($category->get_name()));
                     $content->setVariable("VALUE_DESC", h($category->get_attribute(OBJ_DESC)));
                     $subgroups = $result[$tnr[$category->get_id()]["inventory"]];
                     $no_subgroups = count($subgroups);
                     if ($no_subgroups == 0) {
                         $content->setVariable("VALUE_SUBGROUPS_MEMBERS", "-");
                     } else {
                         $content->setVariable("VALUE_SUBGROUPS_MEMBERS", $no_subgroups);
                     }
                     $content->parse("BLOCK_CATEGORY_GROUP");
                 }
             }
             $headline = gettext("Public Groups");
         }
         $portal->set_page_main($headline, $content->get(), "");
         $portal->show_html();
     }
     $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;
 }
예제 #14
0
파일: Edit.class.php 프로젝트: rolwi/koala
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //if (!defined("OBJ_ID")) define( "OBJ_ID", $weblog->get_id() );
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblogId);
     if (!defined("OBJ_ID")) {
         define("OBJ_ID", $weblog->get_id());
     }
     $env = $weblog->get_environment();
     $grp = $env->get_creator();
     if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") {
         $grp = $grp->get_parent_group();
     }
     $accessmergel = FALSE;
     if (isset($weblog) && is_object($weblog)) {
         $creator = $weblog->get_creator();
         if ($weblog->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         if (get_magic_quotes_gpc()) {
             if (!empty($values['name'])) {
                 $values['name'] = stripslashes($values['name']);
             }
             if (!empty($values['dsc'])) {
                 $values['dsc'] = stripslashes($values['dsc']);
             }
         }
         if (empty($values["name"])) {
             $problems = gettext("The name of the weblog is missing.");
             $hints = gettext("Please type in a name.");
         }
         if (strpos($values["name"], "/")) {
             if (!isset($problems)) {
                 $problems = "";
             }
             $problems .= gettext("Please don't use the \"/\"-char in the name of the weblog.");
         }
         if (empty($problems)) {
             $group_members = $grp;
             $group_admins = 0;
             $group_staff = 0;
             // check if group is a course
             $grouptype = (string) $grp->get_attribute("OBJ_TYPE");
             if ($grouptype == "course") {
                 $group_staff = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".staff");
                 $group_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".admins");
                 $group_members = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners");
                 $workroom = $group_members->get_workroom();
             } else {
                 $workroom = $grp->get_workroom();
             }
             if (!isset($weblog) || !is_object($weblog)) {
                 $weblog_new = \steam_weblog::create_steam_structure($GLOBALS["STEAM"], $values["name"], $values["dsc"], $env);
                 $_SESSION["confirmation"] = str_replace("%NAME", h($values["name"]), gettext("New weblog '%NAME' created."));
             } else {
                 $weblog->set_attribute(OBJ_NAME, $values["name"]);
                 $weblog->set_attribute(OBJ_DESC, $values["dsc"]);
                 $frameResponseObject->setConfirmText(gettext("The changes have been saved."));
                 //$portal->set_confirmation( gettext( "The changes have been saved." ));
                 $weblog_new = $weblog;
             }
             //var_dump($weblog_new);die;
             $koala_weblog = new \lms_weblog($weblog_new);
             $access = (int) $values["access"];
             //var_dump($access);
             $access_descriptions = \lms_weblog::get_access_descriptions($grp);
             //var_dump(!$accessmergel);die;
             //if (!$accessmergel) $koala_weblog->set_access( $access, $access_descriptions[$access]["members"] , $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins );
             // HIER DER NEUE CODE::ENDE
             $GLOBALS["STEAM"]->buffer_flush();
             $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
             $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CALENDAR, array("WEBLOG_LANGUAGE"));
             $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             if (!isset($weblog) || !is_object($weblog)) {
                 header("Location: " . $backlink);
                 exit;
             }
         } else {
             //TODO:PROBLEMDESCRIPTION
             //$portal->set_problem_description( $problems, isset($hints)?$hints:"" );
         }
     }
     $content = \Weblog::getInstance()->loadTemplate("object_new.template.html");
     //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES );
     //$content->loadTemplateFile( "object_new.template.html" );
     if (isset($weblog) && is_object($weblog)) {
         $content->setVariable("INFO_TEXT", str_replace("%NAME", h($weblog->get_name()), gettext("You are going to edit the weblog '<b>%NAME</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Save changes"));
         $pagetitle = gettext("Preferences");
         if (empty($values)) {
             $values = array();
             $values["name"] = $weblog->get_name();
             $values["dsc"] = $weblog->get_attribute(OBJ_DESC);
             $values["access"] = $weblog->get_attribute(KOALA_ACCESS);
         }
         $breadcrumbheader = gettext("Preferences");
     } else {
         $grpname = $grp->get_attribute(OBJ_NAME);
         if ($grp->get_attribute(OBJ_TYPE) == "course") {
             $grpname = $grp->get_attribute(OBJ_DESC);
         }
         $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new weblog in '<b>%ENV</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Create weblog"));
         $pagetitle = gettext("Create weblog");
         $breadcrumbheader = gettext("Add new weblog");
     }
     if (!empty($values)) {
         if (!empty($values["name"])) {
             $content->setVariable("VALUE_NAME", h($values["name"]));
         }
         if (!empty($values["dsc"])) {
             $content->setVariable("VALUE_DSC", h($values["dsc"]));
         }
     }
     $content->setVariable("VALUE_BACKLINK", $backlink);
     $content->setVariable("LABEL_NAME", gettext("Name"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("LABEL_ACCESS", gettext("Access"));
     $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"));
     if ($accessmergel) {
         $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
         $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
         $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
         $content->parse("BLOCK_ACCESSMERGEL");
     } else {
         $access = \lms_weblog::get_access_descriptions($grp);
         if ((string) $grp->get_attribute("OBJ_TYPE") == "course") {
             $access_default = PERMISSION_PUBLIC;
         } else {
             $access_default = PERMISSION_PUBLIC_READONLY;
             if (is_object($weblog) && $creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                 $access[PERMISSION_PRIVATE_READONLY]["label"] = str_replace("%NAME", $creator->get_name(), $access[PERMISSION_PRIVATE_READONLY]["label"]);
             } else {
                 $access[PERMISSION_PRIVATE_READONLY]["label"] = gettext("Only members can read and comment. Only you can post.");
             }
         }
         if (is_array($access)) {
             $content->setCurrentBlock("BLOCK_ACCESS");
             foreach ($access as $key => $array) {
                 if ($key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) {
                     $content->setCurrentBlock("ACCESS");
                     $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                     $content->setVariable("VALUE", $key);
                     if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) {
                         $content->setVariable("CHECK", "checked=\"checked\"");
                     }
                     $content->parse("ACCESS");
                 }
             }
             $content->parse("BLOCK_ACCESS");
         }
     }
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $rootlink = \lms_steam::get_link_to_root($grp);
     //var_dump($rootlink);die;
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")));
     if (isset($weblog) && is_object($weblog)) {
         $headline[] = array("link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/", "name" => $weblog->get_name());
     }
     $headline[] = array("link" => "", "name" => $breadcrumbheader);
     //$portal->set_page_main( $headline, $content->get() );
     //$portal->set_page_title( $pagetitle );
     //return $portal->get_html();
     $frameResponseObject->setHeadline($headline);
     $frameResponseObject->setTitle($pagetitle);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
예제 #15
0
 function reset_elearning_unit_user_data()
 {
     $user = lms_steam::get_current_user();
     if (lms_steam::is_koala_admin($user)) {
         //delete old preferences
         $this->unit_elearning_preferences->delete();
         //create new
         $this->check_elearning_data();
     }
 }
예제 #16
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);
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $create_new = isset($path[0]) && $path[0] == "createGroup" ? TRUE : FALSE;
     $id = isset($path[1]) ? $path[1] : null;
     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);
         }
     }
     $all_users = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
     $accessmergel = FALSE;
     if (isset($group) && is_object($group)) {
         $creator = $group->get_steam_group()->get_creator();
         if ($group->get_steam_group()->get_attribute(KOALA_GROUP_ACCESS) != PERMISSION_GROUP_PRIVATE && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(\lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     if ($create_new) {
         // CREATE
         if (isset($_POST) && isset($_POST["grouptype"]) && $_POST["grouptype"] == "group_private") {
             $is_public = FALSE;
         } else {
             $is_public = TRUE;
         }
         $waspassword = FALSE;
         // TODO: Passt der backlink?
         $backlink = PATH_URL . "groups_create.php";
         //TODO: 404 Fehler!!!
         //$extensions = \lms_steam::get_extensionmanager()->get_extensions_by_class( 'koala_group' );
         $submit_text = gettext("Create group");
     } else {
         // EDIT
         // TODO: Pfad anpassen!
         $backlink = PATH_URL . "groups/" . $group->get_steam_group()->get_id() . "/";
         if (!$group->is_admin($user)) {
             include "bad_link.php";
             exit;
         }
         $is_public = $group->is_public();
         $waspassword = $group->get_steam_group()->has_password();
         //$extensions = $group->get_extensions( TRUE );
         $submit_text = gettext("Save changes");
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["save"])) {
         $values = $_POST["values"];
         $problems = "";
         $hints = "";
         if (empty($values["name"])) {
             $problems = gettext("You have to specify a name for this group.") . " ";
             $hints = gettext("Choose a clear synonym which helps people to find your group by name.") . " ";
         } else {
             if (strpos($values['name'], '/')) {
                 $problems .= gettext("Please don't use the \"/\"-char in the groupname.") . ' ';
             }
             if (strpos($values['name'], '.')) {
                 $problems .= gettext("Please don't use the \".\"-char in the groupname.") . ' ';
             } else {
                 if ($is_public && $values["category"] == "0") {
                     $problems .= gettext("You have to choose a category.") . " ";
                     $hints .= gettext("Choose a category to help the users find your group. ") . " ";
                 }
                 if (empty($problems)) {
                     if ($create_new) {
                         if ($is_public) {
                             $pgroup_id = STEAM_PUBLIC_GROUP;
                         } else {
                             $pgroup_id = STEAM_PRIVATE_GROUP;
                         }
                     } else {
                         $parent = $group->get_steam_group()->get_parent_group();
                         if (is_object($parent)) {
                             $pgroup_id = $parent->get_id();
                         } else {
                             $pgroup_id = -1;
                         }
                         // no koala group. its a steam only group
                     }
                     if ($pgroup_id != -1) {
                         $parentgroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $pgroup_id);
                         if (!is_object($parentgroup) || !$parentgroup instanceof \steam_group) {
                             throw new \Exception("Configuration Error: Invalid Public or Private Group Setting. False Group id=" . $pgroup_id, E_CONFIGURATION);
                             exit;
                         }
                         $siblings = $parentgroup->get_subgroups();
                         \steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $siblings, array(OBJ_NAME));
                         foreach ($siblings as $sibling) {
                             if (strtolower($sibling->get_name()) == strtolower($values["name"])) {
                                 if ($create_new || $sibling->get_id() != $group->get_steam_group()->get_id()) {
                                     $problems .= gettext("The groupname you've choosen is used for another group already.") . " ";
                                     $hints .= gettext("Please choose another groupname.") . " ";
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (empty($values["short_dsc"])) {
             $problems .= gettext("The short description is missing.") . " ";
             $hints .= gettext("Sometimes, keywords are sufficient to help people understand what your group is for.") . " ";
         }
         $max_members = -1;
         $sizeproblems = FALSE;
         if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && preg_match('/[^-.0-9]/', trim($values["maxsize"]))) {
             $problems .= gettext("Invalid max number of participants.") . " ";
             $hints .= gettext("Please enter a valid number for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
             $sizeproblems = TRUE;
         } else {
             if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && trim($values["maxsize"]) < 0) {
                 $problems .= gettext("Invalid max number of participants.") . " ";
                 $hints .= gettext("Please enter a number equal or greater than '0' for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
                 $sizeproblems = TRUE;
             } else {
                 if (isset($values["maxsize"])) {
                     if (trim($values["maxsize"]) === "") {
                         $max_members = 0;
                     } else {
                         $max_members = (int) trim($values["maxsize"]);
                     }
                 }
             }
         }
         if (!$create_new && !$sizeproblems && isset($max_members) && $max_members > 0 && $max_members < $group->count_members()) {
             $problems .= gettext("Cannot set max number of participants.") . " ";
             $hints .= str_replace("%ACTUAL", $group->count_members(), str_replace("%CHOSEN", $max_members, gettext("You choosed to limit your group's max number of participants of %CHOSEN but your course already has %ACTUAL participants. If you want to set the max number of participants below %ACTUAL you have to remove some participants first."))) . " ";
         }
         if (!empty($values["access"]) && $values["access"] == PERMISSION_GROUP_PUBLIC_PASSWORD && empty($values["password"])) {
             $problems .= gettext("The group password is missing.") . " ";
             $hints .= gettext("You chose to password protect your group. Please provide a password.") . " ";
         }
         if (empty($problems)) {
             $access = $values["access"];
             $waspassword = 0;
             if ($create_new) {
                 // CREATE
                 $akt_access = PERMISSION_GROUP_UNDEFINED;
                 $environment = !empty($values["category"]) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]) : FALSE;
                 $new_group = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["name"], $parentgroup, $environment, $values["short_dsc"]);
                 if (!is_object($new_group)) {
                     throw new \Exception("Error creating group with name=" . $values["name"] . " in parent=" . $parentgroup->get_name(), E_PARAMETER);
                     exit;
                 }
                 $group = new \koala_group_default($new_group);
                 $group->add_member(\lms_steam::get_current_user());
             } else {
                 // EDIT
                 $akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
             }
             if ($is_public) {
                 // PUBLIC
                 if ($akt_access == PERMISSION_GROUP_PUBLIC_PASSWORD) {
                     $waspassword = 1;
                 }
                 if (!$accessmergel) {
                     $group->set_group_access($access);
                 }
                 if (isset($values) && $waspassword == 1 && isset($values["password"]) && $values["password"] == "******" && $values["access"] == PERMISSION_GROUP_PUBLIC_PASSWORD) {
                     // Do nothing in case of valid password dummy
                 } elseif ($values["access"] != PERMISSION_GROUP_PUBLIC_PASSWORD) {
                     $group->get_steam_group()->set_password("");
                 } else {
                     $group->get_steam_group()->set_password(isset($values["password"]) ? trim($values["password"]) : "");
                 }
                 if ($max_members > -1) {
                     $group->set_attribute(GROUP_MAXSIZE, $max_members);
                 }
             } else {
                 // PRIVATE
                 // Set Group access only, if there is no problem with the access rights
                 // Set group access only for koala groups. Skip this for the steam only groups
                 if (!$accessmergel && ($create_new || $group->get_steam_group()->get_parent_group()->get_id() == STEAM_PRIVATE_GROUP)) {
                     $group->set_group_access(PERMISSION_GROUP_PRIVATE);
                 }
             }
             //echo "*part. '" . $values["privacy_deny_participants"] . "'<br/>"; //TODO
             $newvalues = array(OBJ_DESC => $values["short_dsc"], "OBJ_LONG_DSC" => $values["dsc"], "GROUP_PRIVACY" => $values["privacy_deny_documents"] | $values["privacy_deny_participants"]);
             $group->set_attributes($newvalues);
             if ($group->get_attribute('OBJ_NAME') != $values['name']) {
                 if (!$group->set_name($values['name'])) {
                     $problems .= gettext("A group with this name already exists.") . " ";
                     $hints .= gettext("Please choose another name for your group.") . " ";
                 }
             }
             if ($max_members > -1) {
                 $group->set_attribute(GROUP_MAXSIZE, $max_members);
             }
             // extensions:
             /* TODO: An Dominik! Dieser Code gibt einen Fehler zurück!
             			    if ( isset( $_POST["extensions_available"] ) && !empty( $_POST["extensions_available"] ) ) {
             		      		$extensions_available = explode( "/", $_POST["extensions_available"] );
             		      		if ( isset( $_POST["extensions_enabled"] ) )
             		        		$extensions_enabled = array_keys( $_POST["extensions_enabled"] );
             		      		else
             		        		$extensions_enabled = array();
             
             		        	if ( is_array( $extensions_available ) ) {
             		        		foreach ( $extensions_available as $extension_name ) {
             		          			$extension = \lms_steam::get_extensionmanager()->get_extension( $extension_name );
             		          			if ( !is_object( $extension ) ) continue;
             		          			if ( array_search( $extension_name, $extensions_enabled ) === FALSE )
             		            			$extension->disable_for( $group );
             		          			else
             		            			$extension->enable_for( $group );
             		        		}
             		      		}
             		    	}
             				*/
             if ($create_new) {
                 if ($is_public) {
                     $_SESSION["confirmation"] = str_replace("%CATEGORY", $environment->get_name(), str_replace("%NAME", $values["name"], gettext("The public group '%NAME' has been created in '%CATEGORY'.")));
                 } else {
                     $_SESSION["confirmation"] = str_replace("%NAME", $values["name"], gettext("The private group '%NAME' has been created."));
                 }
                 header("Location: " . PATH_URL . "group/view/" . $group->get_steam_group()->get_id() . "/");
                 exit;
             } else {
                 $_SESSION["confirmation"] = gettext("The changes have been saved.");
                 header("Location: " . $_SERVER["REQUEST_URI"]);
                 exit;
             }
         } else {
             $portal->set_problem_description($problems, $hints);
         }
     } else {
         if (!$create_new) {
             // EDIT
             $current_values = $group->get_attributes(array(OBJ_NAME, OBJ_DESC, "OBJ_LONG_DSC", GROUP_MAXSIZE, "GROUP_PRIVACY"));
             //TODO
             // Convert "0" into "" for values which are not set yet
             foreach ($current_values as $key => $value) {
                 if ($value == "0") {
                     $current_values[$key] = "";
                 }
             }
             $values = array("name" => $current_values[OBJ_NAME], "short_dsc" => $current_values[OBJ_DESC], "dsc" => $current_values["OBJ_LONG_DSC"], "maxsize" => $current_values[GROUP_MAXSIZE], "privacy_deny_documents" => $current_values["GROUP_PRIVACY"] & PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS, "privacy_deny_participants" => $current_values["GROUP_PRIVACY"] & PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS);
             //echo "**part. '" . $values["privacy_deny_participants"] . "'<br/>"; //TODO
             //$values["privacy_deny_participants"] = $act_privacy_deny_participants;
             //echo "***part. '" . $values["privacy_deny_participants"] . "'<br/>";
             $ms = $values["maxsize"];
             if ($ms === 0) {
                 $values["maxsize"] = "";
             } else {
                 $values["maxsize"] = $ms;
             }
             $grouptype = $group->get_attribute(OBJ_TYPE);
         } else {
             // CREATE
             $grouptype = "";
             if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["save"])) {
                 $values = $_POST["values"];
             }
         }
     }
     $content = \Group::getInstance()->loadTemplate("groups_edit.template.html");
     if ($create_new) {
         // CREATE
         //TODO: Muss eine grouptype gesetzt sein?
         $content->setVariable("VALUE_GROUPTYPE", isset($_POST["grouptype"]) ? $_POST["grouptype"] : "");
         $infotext = gettext("You are going to create a new group. ");
     } else {
         // EDIT
         $infotext = gettext("You are going to edit information for '<b>%NAME</b>'. ");
         if ($is_public) {
             $infotext .= "<br />" . gettext("'%NAME' is a <b>public group</b>. Feel free to edit the groups description, choose extension modules for your group or change the participant management method.");
         } else {
             $infotext .= "<br />" . gettext("'%NAME' is a <b>private group</b>. Feel free to edit the groups description or choose extension modules for your group. The participant management method for private courses is invite only. Only group moderators can add users to this group.");
         }
         $infotext = str_replace("%NAME", h($values["name"]), $infotext);
     }
     $content->setVariable("INFO_TEXT", $infotext);
     $content->setVariable("LABEL_NAME", gettext("Name"));
     isset($values["name"]) ? $content->setVariable("VALUE_NAME", h($values["name"])) : "";
     $content->setVariable("LABEL_SHORT_DSC", gettext("Short description"));
     isset($values["short_dsc"]) ? $content->setVariable("VALUE_SHORT_DSC", h($values["short_dsc"])) : "";
     $content->setVariable("LABEL_LONG_DSC", gettext("Long description"));
     isset($values["dsc"]) ? $content->setVariable("VALUE_LONG_DSC", h($values["dsc"])) : "";
     $content->setVariable("GROUP_SAVE", $submit_text);
     $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"));
     //hier Voreinstellung?!
     //$values[ "privacy_deny_participants" ] = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS; //TODO
     //$values[ "privacy_deny_documents" ] = PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS;
     //$privacy_deny_participants_default = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS;
     //$privacy_deny_documents_default = PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS;
     if ($create_new && $is_public || $grouptype !== "group_moderated" && $grouptype !== "group_private") {
         // Add group maxsize field
         $m = \Group::getInstance()->loadTemplate("groups_maxsize_widget.template.html");
         $m->setCurrentBlock("BLOCK_MAXSIZE");
         $m->setVariable("LABEL_MAXSIZE", gettext("Max number of participants"));
         $m->setVariable("LABEL_MAXSIZE_DSC", gettext("To limit the max number of participants for your course enter a number greater than 0. Leave this field blank or enter a '0' for no limitation."));
         isset($values["maxsize"]) ? $m->setVariable("VALUE_MAXSIZE", h($values["maxsize"])) : "";
         $mhtml = $m->get();
     }
     $content->setVariable("BACKLINK", "<a class=\"button\" href=\"{$backlink}\">" . gettext("back") . "</a>");
     // extensions:
     /* TODO: an Dominik! 
     		 if ( count( $extensions ) > 0 ) {
     			$content->setCurrentBlock( "BLOCK_EXTENSIONS" );
     			$content->setVariable( "LABEL_EXTENSIONS", gettext( "Extensions" ) );
     			$extension_list = array();
     			foreach ( $extensions as $extension ) {
     				$extension_name = $extension->get_name();
     				$content->setCurrentBlock( "BLOCK_EXTENSION" );
     				$content->setVariable( "EXTENSION_ID", $extension_name );
     				$content->setVariable( "EXTENSION_NAME", $extension->get_display_name() );
     				$content->setVariable( "EXTENSION_DESC", $extension->get_display_description() );
     				if ( $extension->is_enabled( $group ) )
     					$content->setVariable( "EXTENSION_ENABLED", "checked='checked'" );
     				$content->parse( "BLOCK_EXTENSION" );
     				$extension_list[] = $extension_name;
     			}
     			$content->setVariable( "VALUE_EXTENSIONS", implode( "/", $extension_list ) );
     			$content->parse( "BLOCK_EXTENSIONS" );
     		}
     		*/
     if ($is_public) {
         // PUBLIC GROUP
         if ($create_new) {
             $privacy_deny_participants_default = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS;
             //TODO //Voreinstellung?!
             $privacy_deny_documents_default = PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS;
             $values["privacy_deny_participants"] = $privacy_deny_participants_default;
             $values["privacy_deny_documents"] = $privacy_deny_documents_default;
             $content->setCurrentBlock("BLOCK_CATEGORIES");
             $content->setVariable("LABEL_CATEGORIES", gettext("Categories"));
             $content->setVariable("LABEL_PLEASE_CHOOSE", gettext("Please choose"));
             $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
             $categories = $public->get_workroom()->get_inventory(CLASS_CONTAINER | CLASS_ROOM);
             foreach ($categories as $category) {
                 $content->setCurrentBlock("BLOCK_CATEGORY_DISPLAY");
                 $content->setVariable("CAT_ID", $category->get_id());
                 $content->setVariable("CAT_NAME", h($category->get_name()));
                 $parent = isset($path[1]) ? $path[1] : null;
                 if (!isset($values["category"]) && isset($parent) && $parent == $category->get_id() || isset($values["category"]) && $category->get_id() == $values["category"]) {
                     $content->setVariable("CAT_SELECTED", 'selected="selected"');
                 }
                 $content->parse("BLOCK_CATEGORY_DISPLAY");
             }
             $content->parse("BLOCK_CATEGORIES");
         } else {
             $content->setCurrentBlock("BLOCK_CATEGORY");
             $category = $group->get_steam_group()->get_environment();
             if (is_object($category)) {
                 $catname = $category->get_name();
             } else {
                 $catname = gettext("Miscellaneous");
             }
             $content->setVariable("LABEL_CATEGORY", gettext("Category"));
             $content->setVariable("VALUE_CATEGORY", $catname . "<br/><small>(" . gettext("The category cannot be changed") . ")</small>");
             $content->parse("BLOCK_CATEGORY");
         }
         // MAXSIZE
         $content->setCurrentBlock("BLOCK_MAXSIZE");
         $content->setVariable("LABEL_MAXSIZE", gettext("Max number of participants"));
         $content->setVariable("LABEL_MAXSIZE_DSC", gettext("To limit the max number of participants for your course enter a number greater than 0. Leave this field blank or enter a '0' for no limitation."));
         $content->setVariable("VALUE_MAXSIZE", isset($values["maxsize"]) ? h($values["maxsize"]) : "");
         $content->parse("BLOCK_MAXSIZE");
         // PARTICIPANT MANAGEMENT
         $content->setCurrentBlock("BLOCK_ACCESS");
         $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
         if ($accessmergel) {
             $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
             $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
             $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the participant management settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
             $content->parse("BLOCK_ACCESSMERGEL");
         } else {
             $waspassword = 0;
             $access = \koala_group_default::get_group_access_descriptions();
             if (isset($values) && isset($values["access"])) {
                 $akt_access = $values["access"];
             } else {
                 if ($create_new) {
                     // CREATE
                     $akt_access = PERMISSION_GROUP_PUBLIC_FREEENTRY;
                 } else {
                     // EDIT
                     $akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
                     if ($akt_access == PERMISSION_GROUP_PUBLIC_PASSWORD) {
                         $waspassword = 1;
                     }
                 }
             }
             if (is_array($access)) {
                 $content->setVariable("WASPASSWORD", $waspassword);
                 foreach ($access as $key => $array) {
                     if (($key != PERMISSION_GROUP_UNDEFINED || $akt_access == PERMISSION_GROUP_UNDEFINED) && $key != PERMISSION_GROUP_PRIVATE) {
                         $content->setCurrentBlock("ACCESS");
                         $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                         $content->setVariable("VALUE", $key);
                         if ($key == $akt_access) {
                             $content->setVariable("CHECK", "checked=\"checked\"");
                         }
                         if ($key == PERMISSION_GROUP_PUBLIC_PASSWORD) {
                             $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='block'\"");
                             $content->setCurrentBlock("ACCESS_PASSWORD");
                             $content->setVariable("LABEL_PASSWORD", gettext("Password"));
                             if (!empty($values["password"])) {
                                 $content->setVariable("VALUE_PASSWORD", $values["password"]);
                             } else {
                                 if ($waspassword == 1) {
                                     $content->setVariable("VALUE_PASSWORD", "******");
                                 }
                             }
                             if ($akt_access == PERMISSION_GROUP_PUBLIC_PASSWORD) {
                                 $content->setVariable("PASSWORDDIV_DISPLAY", "block");
                             } else {
                                 $content->setVariable("PASSWORDDIV_DISPLAY", "none");
                             }
                             $content->parse("ACCESS_PASSWORD");
                         } else {
                             $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='none'\"");
                         }
                         $content->parse("ACCESS");
                     }
                 }
             }
         }
         // PARTICIPANT AND DOCUMENT PRIVACY //TODO
         //$values[ "privacy_deny_participants" ] = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS; //voreingestellt//TODO
         //$values[ "privacy_deny_documents" ] = PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS;
         //$privacy_deny_participants_default = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS;
         //$privacy_deny_documents_default = PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS;
         //$values[ "privacy_deny_participants" ] = $privacy_deny_participants_default;
         $content->setCurrentBlock("BLOCK_PRIVACY");
         $content->setVariable("LABEL_PRIVACY", gettext("Privacy"));
         $content->setVariable("LABEL_PRIVACY_DSC", gettext("Set the privacy of participants and documents."));
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", gettext("Hide participants"));
         $content->setVariable("LABEL_PRIVACY_DENY_DOCUMENTS", gettext("Hide documents"));
         $content->setVariable("VALUE_PRIVACY_DENY_PARTICIPANTS", PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS);
         $content->setVariable("VALUE_PRIVACY_DENY_DOCUMENTS", PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS);
         //echo "****part. '" . $values["privacy_deny_participants"] . "'<br/>"; //todo
         if (isset($values) && isset($values["privacy_deny_participants"])) {
             $privacy_deny_participants = $values["privacy_deny_participants"];
         }
         if (isset($values) && isset($values["privacy_deny_documents"])) {
             $privacy_deny_documents = $values["privacy_deny_documents"];
         }
         //if (isset($values) && isset($values["privacy_deny_participants"])) $privacy_deny_participants = PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS;
         //if ((isset($values) && $key == (int)$values[ "privacy_deny_participants" ]) || (empty($values) && $key == $privacy_deny_participants_default)) {
         if (isset($values) && $values["privacy_deny_participants"] == PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS) {
             $content->setVariable("CHECK1", "checked=\"checked\"");
         }
         //if ((isset($values) && $key == (int)$values[ "privacy_deny_documents" ]) || (empty($values) && $key == $privacy_deny_documents_default)) {
         if (isset($values) && $values["privacy_deny_documents"] == PERMISSION_GROUP_PRIVACY_DENY_DOCUMENTS) {
             $content->setVariable("CHECK2", "checked=\"checked\"");
         }
         $content->parse("BLOCK_PRIVACY");
         //echo "*****part. '" . $values["privacy_deny_participants"] . "'"; //TODO
     } else {
         // PRIVATE GROUP
         if ($create_new || $group->get_steam_group()->get_parent_group()->get_id() == STEAM_PRIVATE_GROUP) {
             // Display the participant management access block only for koala groups
             // The participant management select box wont be displayed for steam only groups
             $content->setCurrentBlock("BLOCK_ACCESS");
             $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
             if (!$create_new) {
                 $akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
             } else {
                 $akt_access = PERMISSION_GROUP_PRIVATE;
             }
             $access = \oala_group_default::get_group_access_descriptions();
             $content->setCurrentBlock("ACCESS");
             if ($akt_access != PERMISSION_GROUP_PRIVATE) {
                 if ($accessmergel) {
                     $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
                     $content->setVariable("ACCESS_TEXT", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by saving the properties one time.")));
                 } else {
                     $content->setVariable("ACCESS_TEXT", "A Problem with the access rights was detected. Please save the permissions one time to fix this issue.");
                 }
             } else {
                 $content->setVariable("ACCESS_TEXT", $access[PERMISSION_GROUP_PRIVATE]["label"]);
             }
             $content->parse("ACCESS");
             $content->parse("BLOCK_ACCESS");
         }
     }
     if ($create_new) {
         // CREATE
         if ($is_public) {
             $headertext = gettext("Create public group");
         } else {
             $headertext = gettext("Create private group");
         }
         $headernavi = array(array("link" => PATH_URL . "user/" . $user->get_name() . "/groups/", "name" => gettext("Your groups")), array("link" => $backlink, "name" => gettext("Create Group")), array("link" => "", "name" => $headertext));
     } else {
         // EDIT
         $headernavi = array(array("link" => $backlink, "name" => h($group->get_name())), array("link" => "", "name" => gettext("Preferences")));
     }
     /* TODO: Portal
     		$portal->set_page_main(
     			$headernavi,
     			$content->get()
     		);
     		$portal->show_html();
     				*/
     $frameResponseObject->setTitle("Group edit");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #17
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $portal = \lms_portal::get_instance();
     if (!isset($messageboard) || !is_object($messageboard)) {
         if (empty($this->params[0])) {
             throw new \Exception("Environment not set.");
         }
         if (empty($this->params[1])) {
             throw new \Exception("Group not set.");
         }
         if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[0]))) {
             throw new \Exception("Environment unknown.");
         }
         if (!($grp = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]))) {
             throw new \Exception("Group unknown");
         }
     }
     $accessmergel = FALSE;
     if (isset($messageboard) && is_object($messageboard)) {
         $creator = $messageboard->get_creator();
         if ($messageboard->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(\lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     // TODO: Passt der link?
     $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         if (get_magic_quotes_gpc()) {
             if (!empty($values['name'])) {
                 $values['name'] = stripslashes($values['name']);
             }
             if (!empty($values['dsc'])) {
                 $values['dsc'] = stripslashes($values['dsc']);
             }
         }
         if (empty($values["name"])) {
             $problems = gettext("The name of new message board is missing.");
             $hints = gettext("Please type in a name.");
         }
         if (strpos($values["name"], "/")) {
             if (!isset($problems)) {
                 $problems = "";
             }
             $problems .= gettext("Please don't use the \"/\"-char in the the forum name.");
         }
         if (empty($problems)) {
             $group_members = $grp;
             $group_admins = 0;
             $group_staff = 0;
             // check if group is a course
             $grouptype = (string) $grp->get_attribute("OBJ_TYPE");
             if ($grouptype == "course") {
                 $group_staff = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".staff");
                 $group_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".admins");
                 $group_members = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners");
                 $workroom = $group_members->get_workroom();
             } else {
                 $workroom = $grp->get_workroom();
             }
             if (!isset($messageboard) || !is_object($messageboard)) {
                 $new_forum = \steam_factory::create_messageboard($GLOBALS["STEAM"]->get_id(), $values["name"], $env, $values["dsc"]);
                 $_SESSION["confirmation"] = str_replace("%NAME", h($values["name"]), gettext("New forum '%NAME' created."));
             } else {
                 $messageboard->set_attribute(OBJ_NAME, $values["name"]);
                 $messageboard->set_attribute(OBJ_DESC, $values["dsc"]);
                 $portal->set_confirmation(gettext("The changes have been saved."));
                 $new_forum = $messageboard;
             }
             $koala_forum = new \lms_forum($new_forum);
             $access = (int) $values["access"];
             $access_descriptions = \lms_forum::get_access_descriptions($grp);
             if (!$accessmergel) {
                 $koala_forum->set_access($access, $access_descriptions[$access]["members"], $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins);
             }
             $GLOBALS["STEAM"]->buffer_flush();
             $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
             $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_MESSAGEBOARD, array("FORUM_LANGUAGE"));
             $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             if (!isset($messageboard) || !is_object($messageboard)) {
                 header("Location: " . $backlink);
                 exit;
             }
         } else {
             $portal->set_problem_description($problems, isset($hints) ? $hints : "");
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("object_new.template.html");
     if (isset($messageboard) && is_object($messageboard)) {
         $content->setVariable("INFO_TEXT", str_replace("%NAME", h($messageboard->get_name()), gettext("You are going to edit the forum '<b>%NAME</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Save changes"));
         $pagetitle = gettext("Preferences");
         if (empty($values)) {
             $values = array();
             $values["name"] = $messageboard->get_name();
             $values["dsc"] = $messageboard->get_attribute(OBJ_DESC);
             $values["access"] = $messageboard->get_attribute(KOALA_ACCESS);
         }
         $breadcrumbheader = gettext("Preferences");
     } else {
         $grpname = $grp->get_attribute(OBJ_NAME);
         if ($grp->get_attribute(OBJ_TYPE) == "course") {
             $grpname = $grp->get_attribute(OBJ_DESC);
         }
         $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new forum in '<b>%ENV</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Create forum"));
         $pagetitle = gettext("Create forum");
         $breadcrumbheader = gettext("Add new forum");
     }
     if (!empty($values)) {
         if (!empty($values["name"])) {
             $content->setVariable("VALUE_NAME", h($values["name"]));
         }
         if (!empty($values["dsc"])) {
             $content->setVariable("VALUE_DSC", h($values["dsc"]));
         }
     }
     $content->setVariable("VALUE_BACKLINK", $backlink);
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $content->setVariable("LABEL_NAME", gettext("Name"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("LABEL_ACCESS", gettext("Access"));
     if ((string) $grp->get_attribute("OBJ_TYPE") == "course") {
         $access_default = PERMISSION_PUBLIC;
     } else {
         $access_default = PERMISSION_PUBLIC;
     }
     if ($accessmergel) {
         $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
         $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
         $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
         $content->parse("BLOCK_ACCESSMERGEL");
     } else {
         $access = \lms_forum::get_access_descriptions($grp);
         if (is_array($access)) {
             $content->setCurrentBlock("BLOCK_ACCESS");
             foreach ($access as $key => $array) {
                 if ($key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) {
                     $content->setCurrentBlock("ACCESS");
                     $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                     $content->setVariable("VALUE", $key);
                     if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) {
                         $content->setVariable("CHECK", "checked=\"checked\"");
                     }
                     $content->parse("ACCESS");
                 }
             }
             $content->parse("BLOCK_ACCESS");
         }
     }
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($grp);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")));
     if (isset($messageboard) && is_object($messageboard)) {
         $headline[] = array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name());
     }
     $headline[] = array("link" => "", "name" => $breadcrumbheader);
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #18
0
 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 . "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");
 }
예제 #19
0
            $group = new koala_group_course($steam_group);
            $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
            break;
        default:
            $group = new koala_group_default($steam_group);
            $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);
    }
}
switch (TRUE) {
    case $steam_group && empty($path[0]):
        if ($_GET["id"] != STEAM_PUBLIC_GROUP) {
            include "groups_start.php";
        } else {
            include "groups_public.php";
        }
        exit;
        break;
    case $steam_group && $path[0] == "members" && empty($path[1]):
        if (!$portal_user->is_logged_in()) {
            throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
예제 #20
0
파일: serverstats.php 프로젝트: rolwi/koala
<?php

include_once "../etc/koala.conf.php";
if (!defined("SERVERMONITOR") || !SERVERMONITOR) {
    header("location:/");
    exit;
}
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
if (!lms_steam::is_koala_admin(lms_steam::get_current_user())) {
    echo "Access denied";
    exit;
}
if (isset($_GET["img"])) {
    $file = PATH_KOALA . "scripts/serverstats/" . $_GET["img"];
    header("Content-Type: " . "image/png");
    header("Content-Length: " . filesize($file));
    readfile($file);
    exit;
}
$portal->set_page_title(gettext("Server Monitor"));
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "serverstats.template.html");
$content->setCurrentBlock("BLOCK_STAT");
$content->setVariable("STAT_TYPE", "steam");
$content->parse("BLOCK_STAT");
$content->setCurrentBlock("BLOCK_STAT");
$content->setVariable("STAT_TYPE", "user");
$content->parse("BLOCK_STAT");
$portal->set_page_main(array(array("link" => ".", "name" => gettext("Server Monitor"))), $content->get(), "");
$portal->show_html();
예제 #21
0
파일: groups_edit.php 프로젝트: rolwi/koala
<?php

require_once "../etc/koala.conf.php";
if (!isset($create_new)) {
    $create_new = FALSE;
}
$user = lms_steam::get_current_user();
$all_users = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
$accessmergel = FALSE;
if (isset($group) && is_object($group)) {
    $creator = $group->get_steam_group()->get_creator();
    if ($group->get_steam_group()->get_attribute(KOALA_GROUP_ACCESS) != PERMISSION_GROUP_PRIVATE && lms_steam::get_current_user()->get_id() != $creator->get_id() && !lms_steam::is_koala_admin(lms_steam::get_current_user())) {
        $accessmergel = TRUE;
    }
}
if ($create_new) {
    // CREATE
    if (isset($_POST) && isset($_POST["grouptype"]) && $_POST["grouptype"] == "group_private") {
        $is_public = FALSE;
    } else {
        $is_public = TRUE;
    }
    $waspassword = FALSE;
    $backlink = PATH_URL . "groups_create.php";
    $extensions = lms_steam::get_extensionmanager()->get_extensions_by_class('koala_group');
    $submit_text = gettext("Create group");
} else {
    // EDIT
    $backlink = PATH_URL . "groups/" . $group->get_steam_group()->get_id() . "/";
    if (!$group->is_admin($user)) {
        include "bad_link.php";
예제 #22
0
} else {
    $values = $group->get_attributes(array("OBJ_NAME", "OBJ_DESC", "COURSE_TUTORS", "COURSE_SHORT_DSC", "COURSE_LONG_DSC"));
    $ms = $group->get_group_learners()->get_attribute(GROUP_MAXSIZE);
    if ($ms === 0) {
        $values["maxsize"] = "";
    } else {
        $values["maxsize"] = $ms;
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "courses_edit.template.html");
$content->setVariable("LABEL_EDIT_COURSE_DESCRIPTION", gettext("Course Preferences"));
$course_name = $group->get_attribute(OBJ_NAME);
$course_number = $group->get_attribute("COURSE_NUMBER");
$course_name = koala_group_course::convert_course_id($course_name, $course_number);
if (koala_group_course::is_paul_course($course_number) && lms_steam::is_koala_admin($user)) {
    $content->setVariable("VALUE_PAUL_ID", "  (" . gettext("PAUL-ID: " . h($group->get_attribute(OBJ_NAME))) . ")");
    $content->setVariable("ACTION_PAUL_COURSE_DATA", "<input type=\"submit\"  name=\"get_paul_course_data\" id=\"get_paul_course_data\" title=\"" . gettext("Get the course name and short description from PAUL") . "\" value=\"" . gettext("Get PAUL course data") . "\">");
}
$content->setVariable("LABEL_COURSE_ID", gettext("Course ID"));
$content->setVariable("VALUE_COURSE_ID", h($course_name));
$content->setVariable("LABEL_COURSE_NAME", gettext("Name"));
$content->setVariable("VALUE_COURSE_NAME", h($values["OBJ_DESC"]));
$content->setVariable("LABEL_COURSE_SHORT_INFORMATION", gettext("Short Info"));
$content->setVariable("VALUE_SHORT_DSC", h($values["COURSE_SHORT_DSC"]));
$content->setVariable("SHORT_DSC_SHOW_UP", gettext("This value will show up in the semester's courses list beside id, name and staff members."));
$content->setVariable("LABEL_COURSE_TUTORS", gettext("Staff members"));
$content->setVariable("VALUE_TUTORS", h($values["COURSE_TUTORS"]));
$content->setVariable("LABEL_LONG_DSC", gettext("Long description"));
$content->setVariable("LONG_DSC_SHOW_UP", gettext("This is for your course page. Please add information about schedule and locations at least."));
$content->setVariable("VALUE_LONG_DSC", h($values["COURSE_LONG_DSC"]));
예제 #23
0
 public static function get_menu_html($cacheid, $is_logged_in)
 {
     $koala_html_menu = new koala_html_menu();
     if ($is_logged_in) {
         $user = lms_steam::get_current_user();
         // HOME
         // removed for version 1_5
         //$koala_html_menu->add_menu_entry( array( "name" => gettext( "Home" ), "link" => PATH_URL ) );
         // YOU
         if (YOU_MENU) {
             $koala_html_menu->add_menu_entry(array("name" => MENU_YOU ? gettext("You") : $user->get_attribute("USER_FIRSTNAME") . " " . $user->get_attribute("USER_FULLNAME"), "link" => PATH_URL . "desktop/", "menu" => array(YOUR_DESKTOP ? array("name" => MENU_YOU ? gettext("Your desktop") : "Schreibtisch", "link" => PATH_URL . "desktop/") : "", YOUR_PORTFOLIO ? array("name" => MENU_YOU ? "Mein Portfolio" : "Portfolio", "link" => PATH_URL . "portfolio/") : "", YOUR_DOCUMENTS ? array("name" => MENU_YOU ? gettext("Your documents") : "Dokumente", "link" => PATH_URL . "explorer/") : "", YOUR_PROFILE ? array("name" => MENU_YOU ? gettext("Your profile") : "Profil", "link" => PATH_URL . "user/index/" . $user->get_name() . "/") : "", YOUR_BOOKMARKS ? array("name" => MENU_YOU ? gettext("Meine Lesezeichen") : "Lesezeichen", "link" => PATH_URL . "bookmarks/") : "", YOUR_SCHOOLBOOKMARKS ? array("name" => MENU_YOU ? gettext("Meine Schul-Lesezeichen") : "Schul-Lesezeichen", "link" => PATH_URL . "school/") : "", YOUR_CONTACTS ? array("name" => MENU_YOU ? gettext("Your contacts") : "Kontakte") : "", YOUR_MOKODESK && $user->get_attribute("LARS_DESKTOP") !== 0 ? array("name" => MENU_YOU ? gettext("Mein MokoDesk") : "MokoDesk", "link" => MOKODESK_URL) : "")));
         }
         // COURSES
         if (YOUR_COURSES) {
             $scg = null;
             if (defined("STEAM_COURSES_GROUP")) {
                 $scg = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
             }
             if ($scg instanceof steam_group) {
                 $current_semester = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $scg->get_groupname() . "." . STEAM_CURRENT_SEMESTER);
                 if (!is_object($current_semester)) {
                     throw new Exception("cant find current_semester. please check setting of CURRENT_SEMESTER in koala.def.php", E_CONFIGURATION);
                 }
                 $cache = get_cache_function($user->get_name());
                 $courses = $cache->call("lms_steam::user_get_booked_courses", $user->get_id());
                 //COURSES SUBMENU
                 $submenu = array(YOUR_COURSES ? array("name" => gettext("Your courses"), "link" => PATH_URL . SEMESTER_URL . "/?filter=booked") : "", ALL_COURSES && (!ADMIN_ONLY_ALL_COURSES || ADMIN_ONLY_ALL_COURSES && lms_steam::is_koala_admin($user)) ? array("name" => gettext("Browse courses"), "link" => PATH_URL . SEMESTER_URL . "/") : "");
                 if (count($courses) > 0) {
                     $submenu[] = koala_html_menu::get_separator();
                 }
                 foreach ($courses as $course) {
                     $submenu[] = array("name" => $course["COURSE_NAME"], "link" => $course["COURSE_LINK"]);
                 }
                 if (COURSES_MENU) {
                     if (ADD_COURSE) {
                         $koala_html_menu->add_menu_entry(array("name" => gettext("Courses"), "link" => PATH_URL . SEMESTER_URL . "/?filter=booked", "menu" => $submenu));
                     } else {
                         $koala_html_menu->add_menu_entry(array("name" => gettext("Courses"), "menu" => $submenu));
                     }
                 }
             }
         }
         // CONTACTS
         if (CONTACTS_MENU) {
             $koala_html_menu->add_menu_entry(array("name" => gettext("Contacts"), "link" => PATH_URL . "user/" . $user->get_name() . "/contacts/", "menu" => array(YOUR_CONTACTS ? array("name" => gettext("Contact list"), "link" => PATH_URL . "user/" . $user->get_name() . "/contacts/") : "", PROFILE_VISITORS ? array("name" => gettext("Visitors of your profile"), "link" => PATH_URL . "profile_visitors.php") : "", USER_SEARCH ? koala_html_menu::get_separator() : "", USER_SEARCH ? array("name" => gettext("Find people"), "link" => PATH_URL . "search/people/") : "")));
         }
         // GROUPS
         if (YOUR_GROUPS) {
             $submenu = array(YOUR_GROUPS ? array("name" => gettext("Your groups"), "link" => PATH_URL . "user/" . $user->get_name() . "/groups/") : "", BROWSE_GROUPS ? array("name" => gettext("Browse groups"), "link" => PATH_URL . "groups/") : "", CREATE_GROUPS ? array("name" => gettext("Create group"), "link" => PATH_URL . "groups_create.php") : "");
             $cache = get_cache_function($user->get_name(), 86400);
             $groups = $cache->call("lms_steam::user_get_groups", $user->get_name(), FALSE);
             usort($groups, "sort_objects");
             if (count($groups) > 0) {
                 $submenu[] = koala_html_menu::get_separator();
             }
             foreach ($groups as $usergroup) {
                 $submenu[] = array("name" => $usergroup["OBJ_NAME"], "link" => $usergroup["GROUP_LINK"]);
             }
             if (GROUPS_MENU) {
                 $koala_html_menu->add_menu_entry(array("name" => gettext("Groups"), "link" => PATH_URL . "user/" . $user->get_name() . "/groups/", "menu" => $submenu));
             }
         }
         // additional platform menus
         $menus = json_decode(PLATFROM_MENUS, true);
         if (!is_array($menus)) {
             $menus = array();
         }
         foreach ($menus as $menu) {
             $koala_html_menu->add_menu_entry($menu);
         }
         $extensions = ExtensionMaster::getInstance()->getExtensionByType("IMenuExtension");
         foreach ($extensions as $extension) {
             $entries = $extension->getMenuEntries();
             if (isset($entries) && is_array($entries)) {
                 foreach ($entries as $entry) {
                     $koala_html_menu->add_menu_entry($entry);
                 }
             }
         }
         // EXTRAS removed for Version 1_5
         /*
         $koala_html_menu->add_menu_entry( array( "name" => gettext( "Extras" ), "link" => PATH_URL . "downloads/", "menu" => array(
         	// SUBMENUS EXTRAS
         	array( "name" => gettext( "Downloads" ), "link" => PATH_URL . "downloads/" ),
         	array( "name" => gettext( "More information"), "link" => PATH_URL ),
         	koala_html_menu::get_separator(),
         	array( "name" => gettext( "Help"), "link" => HELP_URL )
         ) ) );
         */
     } else {
         //removed for version 1_5
         //$koala_html_menu->add_menu_entry( array( "name" => gettext( "Home" ), "link" => PATH_URL ) );
         //$koala_html_menu->add_menu_entry( array( "name" => gettext( "Sign in" ), "link" => PATH_URL . "sign_in.php" ) );
         //$koala_html_menu->add_menu_entry( array( "name" => gettext( "Downloads" ), "link" => PATH_URL . "downloads/" ) );
         //$koala_html_menu->add_menu_entry(array("name" => " ", "link" => "#"));
         return "<div id='menu'></div>";
     }
     return $koala_html_menu->get_html();
 }
예제 #24
0
파일: wiki_new.php 프로젝트: rolwi/koala
        throw new Exception("Environment not set.");
    }
    if (empty($_GET["group"])) {
        throw new Exception("Group not set.");
    }
    if (!($env = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
        throw new Exception("Environment unknown.");
    }
    if (!($grp = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]))) {
        throw new Exception("Group unknown");
    }
}
$accessmergel = FALSE;
if (isset($wiki_container) && is_object($wiki_container)) {
    $creator = $wiki_container->get_creator();
    if ($wiki_container->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && lms_steam::get_current_user()->get_id() != $creator->get_id() && !lms_steam::is_koala_admin(lms_steam::get_current_user())) {
        $accessmergel = TRUE;
    }
}
$backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $values = $_POST["values"];
    if (get_magic_quotes_gpc()) {
        if (!empty($values['name'])) {
            $values['name'] = stripslashes($values['name']);
        }
        if (!empty($values['dsc'])) {
            $values['dsc'] = stripslashes($values['dsc']);
        }
    }
    if (empty($values["name"])) {
예제 #25
0
파일: Edit.class.php 프로젝트: rolwi/koala
 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 = $path[3];
     $scg = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
     $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $scg->get_groupname() . "." . STEAM_CURRENT_SEMESTER);
     $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);
     $all_users = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
     if (!$group->is_admin($user)) {
         include "bad_link.php";
         exit;
     }
     $lsfid = $group->get_steam_group()->get_attribute("COURSE_HISLSF_ID");
     $is_lsfcourse = is_string($lsfid) && strlen($lsfid) > 0 && $lsfid > 0;
     $paul_id = $group->get_attribute("COURSE_NUMBER");
     $is_paul_course = \koala_group_course::is_paul_course($paul_id);
     $accessmergel = FALSE;
     if (is_object($group)) {
         $creator = $group->get_steam_group()->get_creator();
         if ($group->get_steam_group()->get_attribute(KOALA_GROUP_ACCESS) == PERMISSION_UNDEFINED && lms_steam::get_current_user()->get_id() != $creator->get_id() && !lms_steam::is_koala_admin(lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     if (isset($_POST["course_save"])) {
         $values = $_POST["values"];
         $problems = "";
         $hints = "";
         if (empty($values["OBJ_DESC"])) {
             $problems .= gettext("The course name is missing.") . " ";
             $hints .= gettext("A name is necessary for identification.") . " ";
         }
         if (empty($values["COURSE_TUTORS"])) {
             $values["COURSE_TUTORS"] = "NN";
         }
         $max_members = -1;
         $sizeproblems = FALSE;
         if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && preg_match('/[^-.0-9]/', trim($values["maxsize"]))) {
             $problems .= gettext("Invalid max number of participants.") . " ";
             $hints .= gettext("Please enter a valid number for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
             $sizeproblems = TRUE;
         } else {
             if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && trim($values["maxsize"]) < 0) {
                 $problems .= gettext("Invalid max number of participants.") . " ";
                 $hints .= gettext("Please enter a number equal or greater than '0' for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
                 $sizeproblems = TRUE;
             } else {
                 if (isset($values["maxsize"])) {
                     if (trim($values["maxsize"]) === "") {
                         $max_members = 0;
                     } else {
                         $max_members = (int) trim($values["maxsize"]);
                     }
                 }
             }
         }
         if (!$sizeproblems && isset($max_members) && $max_members > 0 && $max_members < $group->count_members()) {
             $problems .= gettext("Cannot set max number of participants.") . " ";
             $hints .= str_replace("%ACTUAL", $group->count_members(), str_replace("%CHOSEN", $max_members, gettext("You choosed to limit your course's max number of participants of %CHOSEN but your course already has %ACTUAL participants. If you want to set the max number of participants below %ACTUAL you have to remove some participants first."))) . " ";
         }
         if (!empty($values["access"]) && $values["access"] == PERMISSION_COURSE_PASSWORD && empty($values["password"])) {
             $problems .= gettext("The course password is missing.") . " ";
             $hints .= gettext("You chose to password protect your course. Please provide a password.") . " ";
         }
         if (empty($problems)) {
             $group->set_attributes(array_diff_key($values, array("password" => "", "maxsize" => "")));
             $learners = $group->get_group_learners();
             if (!$is_lsfcourse) {
                 $access = $values["access"];
                 $waspassword = 0;
                 $akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
                 if ($akt_access == PERMISSION_COURSE_PASSWORD) {
                     $waspassword = 1;
                 }
                 if (!$accessmergel) {
                     $group->set_access($access, $learners, $group->get_group_staff());
                 }
                 if (isset($values) && $waspassword == 1 && isset($values["password"]) && $values["password"] == "******" && $values["access"] == PERMISSION_COURSE_PASSWORD) {
                     // Do nothing in case of valid password dummy
                 } elseif ($values["access"] != PERMISSION_COURSE_PASSWORD) {
                     $learners->set_password("");
                 } else {
                     $learners->set_password(isset($values["password"]) ? trim($values["password"]) : "");
                 }
                 if ($max_members > -1) {
                     $learners->set_attribute(GROUP_MAXSIZE, $max_members);
                 }
             }
             // extensions:
             if (isset($_POST["extensions_available"]) && !empty($_POST["extensions_available"])) {
                 $extensions_available = explode("/", $_POST["extensions_available"]);
                 if (isset($_POST["extensions_enabled"])) {
                     $extensions_enabled = $_POST["extensions_enabled"];
                 } else {
                     $extensions_enabled = array();
                 }
                 if (isset($_POST["extensions_enabled_add"])) {
                     $extensions_enabled = array_merge($extensions_enabled, explode("/", $_POST["extensions_enabled_add"]));
                 }
                 if (is_array($extensions_available)) {
                     foreach ($extensions_available as $extension_name) {
                         $extension = \lms_steam::get_extensionmanager()->get_extension($extension_name);
                         if (!is_object($extension)) {
                             continue;
                         }
                         if (array_search($extension_name, $extensions_enabled) === FALSE) {
                             $extension->disable_for($group);
                         } else {
                             $extension->enable_for($group);
                         }
                     }
                 }
             }
             $cache = get_cache_function("ORGANIZATION");
             $cache->drop("lms_steam::semester_get_courses", $current_semester->get_id());
             $_SESSION["confirmation"] = gettext("The changes have been saved.");
             header("Location: " . $_SERVER["REQUEST_URI"]);
             exit;
         } else {
             //$portal->set_problem_description( $problems, $hints );
         }
     } elseif (isset($_POST["get_paul_course_data"])) {
         //at this time only the course name and short description are updated/changed
         $paul_client = new \paul_soap();
         $paul_course_id = h($group->get_attribute(OBJ_NAME));
         try {
             $paul_course_info = $paul_client->get_course_information($paul_course_id);
         } catch (Exception $exception) {
             $problem = $exception->getMessage();
             error_log($problem);
             throw new Exception("PAUL_SOAP exception: " . $problem);
         }
         //the same as in the following else-block
         $values = $group->get_attributes(array("OBJ_NAME", "OBJ_DESC", "COURSE_TUTORS", "COURSE_SHORT_DSC", "COURSE_LONG_DSC"));
         $ms = $group->get_group_learners()->get_attribute(GROUP_MAXSIZE);
         if ($ms === 0) {
             $values["maxsize"] = "";
         } else {
             $values["maxsize"] = $ms;
         }
         $values["OBJ_DESC"] = $paul_course_info["course_name_german"];
         $values["COURSE_SHORT_DSC"] = $paul_course_info["short_description"];
         //$portal->set_confirmation("test");
         //print_r($paul_course_values);
     } else {
         $values = $group->get_attributes(array("OBJ_NAME", "OBJ_DESC", "COURSE_TUTORS", "COURSE_SHORT_DSC", "COURSE_LONG_DSC"));
         $ms = $group->get_group_learners()->get_attribute(GROUP_MAXSIZE);
         if ($ms === 0) {
             $values["maxsize"] = "";
         } else {
             $values["maxsize"] = $ms;
         }
     }
     $content = \Course::getInstance()->loadTemplate("courses_edit.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "courses_edit.template.html" );
     $content->setVariable("LABEL_EDIT_COURSE_DESCRIPTION", gettext("Course Preferences"));
     $course_name = $group->get_attribute(OBJ_NAME);
     $course_number = $group->get_attribute("COURSE_NUMBER");
     $course_name = \koala_group_course::convert_course_id($course_name, $course_number);
     if (\koala_group_course::is_paul_course($course_number) && \lms_steam::is_koala_admin($user)) {
         $content->setVariable("VALUE_PAUL_ID", "  (" . gettext("PAUL-ID: " . h($group->get_attribute(OBJ_NAME))) . ")");
         $content->setVariable("ACTION_PAUL_COURSE_DATA", "<input type=\"submit\"  name=\"get_paul_course_data\" id=\"get_paul_course_data\" title=\"" . gettext("Get the course name and short description from PAUL") . "\" value=\"" . gettext("Get PAUL course data") . "\">");
     }
     $content->setVariable("LABEL_COURSE_ID", gettext("Course ID"));
     $content->setVariable("VALUE_COURSE_ID", h($course_name));
     $content->setVariable("LABEL_COURSE_NAME", gettext("Name"));
     $content->setVariable("VALUE_COURSE_NAME", h($values["OBJ_DESC"]));
     $content->setVariable("LABEL_COURSE_SHORT_INFORMATION", gettext("Short Info"));
     $content->setVariable("VALUE_SHORT_DSC", h($values["COURSE_SHORT_DSC"]));
     $content->setVariable("SHORT_DSC_SHOW_UP", gettext("This value will show up in the semester's courses list beside id, name and staff members."));
     $content->setVariable("LABEL_COURSE_TUTORS", gettext("Staff members"));
     $content->setVariable("VALUE_TUTORS", h($values["COURSE_TUTORS"]));
     $content->setVariable("LABEL_LONG_DSC", gettext("Long description"));
     $content->setVariable("LONG_DSC_SHOW_UP", gettext("This is for your course page. Please add information about schedule and locations at least."));
     $content->setVariable("VALUE_LONG_DSC", h($values["COURSE_LONG_DSC"]));
     $content->setVariable("COURSE_SAVE", gettext("Save changes"));
     $content->setVariable("AENDERN", gettext("Are you sure about your changes?"));
     $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"));
     if (!$is_lsfcourse) {
         $content->setCurrentBlock("BLOCK_MAXSIZE");
         $content->setVariable("LABEL_MAXSIZE", gettext("Max number of participants"));
         $content->setVariable("LABEL_MAXSIZE_DSC", gettext("To limit the max number of participants for your course enter a number greater than 0. Leave this field blank or enter a '0' for no limitation."));
         $content->setVariable("VALUE_MAXSIZE", h($values["maxsize"]));
         $content->parse("BLOCK_MAXSIZE");
         $content->setCurrentBlock("BLOCK_ACCESS");
         $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
         if ($accessmergel) {
             $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
             $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
             $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
             $content->parse("BLOCK_ACCESSMERGEL");
         } else {
             $waspassword = 0;
             $access = \koala_group_course::get_access_descriptions();
             if (isset($values) && isset($values["access"])) {
                 $akt_access = $values["access"];
             } else {
                 $akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
                 if ($akt_access == PERMISSION_COURSE_PASSWORD) {
                     $waspassword = 1;
                 }
             }
             if (is_array($access)) {
                 $content->setVariable("WASPASSWORD", $waspassword);
                 foreach ($access as $key => $array) {
                     if ($key != PERMISSION_UNDEFINED || $akt_access == PERMISSION_UNDEFINED) {
                         if ($key != PERMISSION_COURSE_PAUL_SYNC || $is_paul_course || $akt_access == PERMISSION_COURSE_PAUL_SYNC) {
                             $content->setCurrentBlock("ACCESS");
                             $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                             $content->setVariable("VALUE", $key);
                             if ($key == $akt_access) {
                                 $content->setVariable("CHECK", "checked=\"checked\"");
                             }
                             if ($key == PERMISSION_COURSE_PASSWORD) {
                                 $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='block'\"");
                                 $content->setCurrentBlock("ACCESS_PASSWORD");
                                 $content->setVariable("LABEL_PASSWORD", gettext("Password"));
                                 if (!empty($values["password"])) {
                                     $content->setVariable("VALUE_PASSWORD", $values["password"]);
                                 } else {
                                     if ($waspassword == 1) {
                                         $content->setVariable("VALUE_PASSWORD", "******");
                                     }
                                 }
                                 if ($akt_access == PERMISSION_COURSE_PASSWORD) {
                                     $content->setVariable("PASSWORDDIV_DISPLAY", "block");
                                 } else {
                                     $content->setVariable("PASSWORDDIV_DISPLAY", "none");
                                 }
                                 $content->parse("ACCESS_PASSWORD");
                             } else {
                                 $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='none'\"");
                             }
                             $content->parse("ACCESS");
                         }
                     }
                 }
             }
         }
         $content->parse("BLOCK_ACCESS");
     } else {
         $content->setCurrentBlock("BLOCK_ACCESS");
         $content->setCurrentBlock("BLOCK_HISLSF");
         $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
         $hislink = "<a href=\"https://lsf.uni-paderborn.de/qisserver/rds?state=wsearchv&search=2&veranstaltung.veranstid=" . trim($lsfid) . "\" target=\"_blank\">HIS-LSF</a>";
         $content->setVariable("PARTICIPANT_MANAGEMENT_VALUE", str_replace("%LINK", $hislink, gettext("The participant management for this course is handled by <b>%LINK</b>.")));
         $content->parse("BLOCK_HISLSF");
         $content->parse("BLOCK_ACCESS");
     }
     // extensions:
     //$extensions = \lms_steam::get_extensionmanager()->get_extensions_by_class( 'koala_group_course' );
     $extensions = 0;
     /*	if ( count( $extensions ) > 0 ) {
     			$content->setCurrentBlock( "BLOCK_EXTENSIONS" );
     			$content->setVariable( "LABEL_EXTENSIONS", gettext( "Extensions" ) );
     			$extension_list = array();
     			foreach ( $extensions as $extension ) {
     				if( $extension->get_requirements() === array() )
     				{
     					$extension_name = $extension->get_name();
     					$content->setCurrentBlock( "BLOCK_EXTENSION" );
     					$content->setVariable( "EXTENSION_ID", $extension_name );
     					$content->setVariable( "EXTENSION_NAME", $extension->get_display_name() );
     					$content->setVariable( "EXTENSION_DESC", $extension->get_display_description() );
     					$extension_enabled = $extension->is_enabled( $group );
     					if ( $extension_enabled )
     					$content->setVariable( "EXTENSION_ENABLED", "checked='checked'" );
     					$subextensions = lms_steam::get_extensionmanager()->get_dependent_extensions($extension);
     					if( count( $subextensions ) > 0 )
     					{
     						$content->setCurrentBlock( "BLOCK_SUBEXTENSIONS" );
     						$content->setVariable( "LABEL_SUBEXTENSIONS", str_replace( "%EXTENSION", h($extension->get_display_name()), gettext( "The following sub-extensions are available for %EXTENSION" ) ));
     						foreach($subextensions as $subextension)
     						{
     							$subextension_name = $subextension->get_name();
     							$content->setCurrentBlock( "BLOCK_SUBEXTENSION" );
     							$content->setVariable( "PARENT_EXTENSION_ID", $extension_name );
     							$content->setVariable( "SUBEXTENSION_ID", $subextension->get_name() );
     							$content->setVariable( "SUBEXTENSION_NAME", $subextension->get_display_name() );
     							$content->setVariable( "SUBEXTENSION_DESC", $subextension->get_display_description() );
     							$checkbox_attributes = '';
     							if ( $subextension->is_enabled_for( $group ) )
     							$checkbox_attributes .= "checked='checked'";
     							if ( ! $extension_enabled || $subextension_name === "units_docpool")
     							$checkbox_attributes .= " disabled='disabled'";
     							$content->setVariable( "SUBEXTENSION_ENABLED", $checkbox_attributes );
     							$content->parse( "BLOCK_SUBEXTENSION" );
     							$extension_list[] = $subextension_name;
     						}
     						$content->parse( "BLOCK_SUBEXTENSIONS" );
     					}
     					$content->parse( "BLOCK_EXTENSION" );
     					$extension_list[] = $extension_name;
     				}
     			}
     			$content->setVariable( "VALUE_EXTENSIONS", implode( "/", $extension_list ) );
     			$content->parse( "BLOCK_EXTENSIONS" );
     		}*/
     $backlink = PATH_URL . "course/index/" . $this->params[0] . "/" . $this->params[1] . "/";
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     //$portal->set_page_main(
     //array( array( "link" => $backlink, "name" => h($values["OBJ_DESC"]) ), array( "linK" => "", "name" => gettext( "Course Preferences" ) ) ),
     //$content->get()
     //);
     $frameResponseObject->setHeadline(array(array("link" => $backlink, "name" => h($values["OBJ_DESC"])), array("linK" => "", "name" => gettext("Course Preferences"))));
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
 function get_context_menu($context, $params = array())
 {
     $course = $params["owner"];
     $room = $course->get_workroom();
     $units = $room->get_inventory();
     if (isset($units[0])) {
         //TODO: Little Hack: only 1 unit supported
         $steam_unit = $units[0];
         $mediathek = elearning_mediathek::get_instance();
         $mediathek->set_unit($steam_unit);
         $elearning_course = elearning_mediathek::get_elearning_course_for_unit($steam_unit);
         $exam = $elearning_course->get_exam_by_type("final_exam");
         if (is_array($params) && isset($params["owner"])) {
             $course = $params["owner"];
             $current_user = lms_steam::get_current_user();
             $is_admin = $course->is_admin($current_user);
             $path = $course->get_url();
             if (!$course instanceof koala_group_course) {
                 throw new Exception("The 'owner' param is not a koala_group_course.", E_PARAMETER);
             }
             if (lms_steam::is_koala_admin($current_user) && $context == "start") {
                 return array(array("name" => "Prüfung verwalten", "link" => "units_elearning/reporting/"));
             }
             if ($exam->is_global_enabled()) {
                 if ($course->is_staff($current_user) && $context == "members") {
                     return array(array("name" => "Prüfungsstatistik", "link" => "../units_elearning/chart/"));
                 }
             } else {
                 return array();
             }
         }
     } else {
         return array();
     }
     return array();
 }