示例#1
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;
 }
示例#2
0
    }
    $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 = koala_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");
    }
}
示例#3
0
$path = url_parse_rewrite_path(isset($_GET["path"]) ? $_GET["path"] : "");
try {
    $steam_group = !empty($_GET["id"]) ? steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["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);
            $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) {
示例#4
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;
 }
示例#5
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;
     }
     $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;
 }
示例#6
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     if (isset($path[0])) {
         if (\steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]) instanceof \steam_group) {
             $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]);
         } else {
             header("Location: " . PATH_URL . "404/");
             die;
         }
     } else {
         $current_semester = \lms_steam::get_current_semester();
     }
     $current_semester_name = $current_semester->get_name();
     if (\lms_steam::is_steam_admin($user)) {
         if (!$portal->get_user()->is_logged_in()) {
             throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
         }
         $semester_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $current_semester->get_groupname() . ".admins");
         $admin_group = new \koala_group_default($semester_admins);
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
             $delete = $_POST["delete"];
             if (count($delete) == 1) {
                 $login = key($delete);
                 $admin = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
                 $admin_group->remove_member($admin);
             }
         }
         $content = \Semester::getInstance()->loadTemplate("semester_admins.template.html");
         $content->setVariable("INFORMATION_ADMINS", str_replace("%SEMESTER", h($current_semester->get_attribute("OBJ_DESC")), gettext("These people are allowed to create courses for %SEMESTER.")) . " " . gettext("They can appoint other users as staff members/moderators for their own courses."));
         $content->setVariable("LINK_ADD_ADMIN", PATH_URL . "semester/addAdmin/" . $current_semester_name . "/" . $admin_group->get_id());
         $content->setVariable("LABEL_ADD_ADMIN", gettext("Add another admin"));
         //TODO: Messages extension schreiben
         // TODO: Passt der Link?
         $content->setVariable("LINK_MESSAGE", PATH_URL . "mail/write/" . $admin_group->get_id());
         $content->setVariable("LABEL_MESSAGE_ADMINS", gettext("Mail to admins"));
         $admins = $admin_group->get_members();
         $no_admins = count($admins);
         if ($no_admins > 0) {
             $content->setVariable("LABEL_ADMINS", gettext("Course admins"));
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name") . "/" . gettext("Position"));
             $content->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
             $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             $content->setVariable("LABEL_REMOVE_ADMIN", gettext("Action"));
             foreach ($admins as $admin) {
                 $adm_attributes = $admin->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_DESC", "OBJ_ICON"));
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_NAME", h($adm_attributes["USER_FIRSTNAME"]) . " " . h($adm_attributes["USER_FULLNAME"]));
                 // TODO: Profile Image einfügen
                 // TODO: Passt der Link?
                 $icon_link = \lms_user::get_user_image_url(30, 40);
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 // TODO: Passt der Link?
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . $admin->get_name() . "/");
                 $content->setVariable("OBJ_DESC", h($adm_attributes["OBJ_DESC"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 // TODO: Passt der Link?
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "mail/write/" . $admin->get_name());
                 $content->setVariable("LABEL_SEND", gettext("Send"));
                 $content->setVariable("LABEL_REMOVE", gettext("Remove"));
                 $content->setVariable("CONTACT_ID", $admin->get_name());
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_ADMINS", gettext("No admins found."));
         }
         /* TODO: Portal anpassen
         			$portal->set_page_title( h($current_semester->get_name()) . " Admins" );
         			$portal->set_page_main( 
         				array(
         					array( "link" => PATH_URL . SEMESTER_URL . "/" . h($current_semester->get_name()) . "/", "name" => h($current_semester->get_attribute( "OBJ_DESC" ))), array( "link" => "", "name" => gettext( "Admins" ) )
         				),
         				$content->get(),
         				""
         			);
         			$portal->show_html( );
         			*/
     } else {
         header("Location: " . PATH_URL . "404/");
         die;
     }
     $frameResponseObject->setTitle("Semester " . $current_semester_name);
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
示例#7
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;
 }
示例#8
0
     // if the object the mail is sent to is some kind of group, we have to
     // get some further information which should be sent to the recievers
     $type = (string) $receiver->get_attribute("OBJ_TYPE");
     // Creating object of different types by the OBJ_TYPE
     switch ($type) {
         case "course":
             $lms_grp = new koala_group_course($receiver);
             break;
         default:
             //////////////////////////////////////////////////////////////
             // look for group objects in extensions
             $extension = $em->get_extension_by_obj_type($type);
             if (is_object($extension)) {
                 $lms_grp = $extension->get_wrapper_class($receiver);
             } else {
                 $lms_grp = new koala_group_default($receiver);
             }
             break;
     }
     // build the footer
     $footer = "<br /><br />--- <br />" . gettext("This E-Mail was sent to %GROUP in koaLA.");
     $footer = str_replace("%GROUP", $lms_grp->get_display_name(), $footer);
     $subject = gettext("Circular") . ": " . $subject;
 }
 $body = $values["body"];
 // Prevent the usage of HTML-Code in Mail body and subject as this is a possible
 // security issue when mails are shown in a browser
 $body = str_replace('<', '&lt;', $body);
 $body = str_replace('>', '&gt;', $body);
 $subject = str_replace('<', '&lt;', $subject);
 $subject = str_replace('>', '&gt;', $subject);
示例#9
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;
 }
示例#10
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;
 }
示例#11
0
$user = lms_steam::get_current_user();
if (!($steam_group = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_REQUEST["group"]))) {
    throw new Exception("Group not found: " . $_REQUEST["group"]);
}
$iscourse = $steam_group->get_attribute(OBJ_TYPE) === "course";
if (!$steam_group instanceof steam_group) {
    throw new Exception("Is not a group: " . $_REQUEST["group"]);
}
$type = (string) $steam_group->get_attribute("OBJ_TYPE");
switch ($type) {
    case "course":
        $group = new koala_group_course($steam_group);
        $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . $group->get_name();
        break;
    default:
        $group = new koala_group_default($steam_group);
        $backlink = PATH_URL . "groups/" . $group->get_id() . "/members/";
        break;
}
if (!$group->is_admin($user)) {
    throw new Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
}
if (isset($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
    $login = key($_REQUEST["add"]);
    $new_member = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
    if ($group->add_admin($new_member)) {
        //$group_name = $group->get_attribute("OBJ_DESC");
        //if ( !is_string($group_name) || empty($group_name) )
        $group_name = $group->get_display_name();
        $message = str_replace("%NAME", $new_member->get_attribute("USER_FIRSTNAME") . " " . $new_member->get_attribute("USER_FULLNAME"), gettext("Dear %NAME,")) . "\n\n";
        $message .= str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new admin.")) . "\n\n";