Example #1
0
 public function actionDisplay()
 {
     $task = Request::getVar('task', "");
     if ($task == "hidden" or $task == 'publish' or $task == "unpublish") {
         $cids = Request::getVar('cid');
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             if ($task == "publish") {
                 $this->changeStatus($cid, 1);
             } else {
                 if ($task == "hidden") {
                     $this->changeStatus($cid, 2);
                 } else {
                     $this->changeStatus($cid, 0);
                 }
             }
         }
         YiiMessage::raseSuccess("Successfully saved changes status for user group");
     }
     $this->addIconToolbar("Edit", Router::buildLink("users", array("view" => "group", "layout" => "edit")), "edit", 1, 1, "Please select a item from the list to edit");
     $this->addIconToolbar("New", Router::buildLink("users", array("view" => "group", "layout" => "new")), "new");
     //        $this->addIconToolbarDelete();
     $this->addIconToolbar("Delete", Router::buildLink("users", array("view" => "group", "layout" => "remove")), "trash", 1, 1, "Please select a item from the list to Remove");
     $this->addBarTitle("Group <small>[list]</small>", "group");
     $model = Group::getInstance();
     global $user;
     $groupID = $user->groupID;
     $group = $model->getItem($user->groupID);
     if ($group->parentID == 1) {
         $items = $model->getItems();
     } else {
         $items = $model->getItems($groupID);
     }
     $this->render('list', array('items' => $items));
 }
Example #2
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;
 }
Example #3
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
     $cat = isset($path[0]) ? $path[0] : null;
     $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");
             //TODO: Pfad anpassen!
             $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 . "group/manageGroup/createGroup/" . (isset($cat) ? $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 (isset($cat)) {
         //EINE KATEGORIE ANZEIGEN
         if (!($category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $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");
             //TODO: Pfad anpassen!
             $content->setVariable("VALUE_LINK", PATH_URL . "group/view/" . $subgroup->get_id() . "/");
             $content->setVariable("VALUE_NAME", h($subgroup->get_name()));
             $content->setVariable("VALUE_SUBGROUPS_MEMBERS", isset($result[$subgroup->get_id()]["membercount"]) ? $result[$subgroup->get_id()]["membercount"] : 0);
             $content->setVariable("VALUE_DESC", h($subgroup->get_attribute("OBJ_DESC")));
             $content->parse("BLOCK_CATEGORY_GROUP");
         }
         //TODO: Pfad anpassen!
         $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 . "group/index/" . $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");
     }
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #4
0
 /**
  * onIndex 
  * 
  * @param string $type
  * @param integer $id 
  * @param boolean $run 
  * @access public
  * @return void
  */
 public function onIndex($type, $id, $run = false)
 {
     if ($type == 'ticket') {
         if ($run === true) {
             // Establish a db connection
             $db = App::get('db');
             // Sanitize the string
             $id = \Hubzero\Utility\Sanitize::paranoid($id);
             // Get the record
             $sql = "SELECT * FROM #__support_tickets WHERE id={$id};";
             $row = $db->setQuery($sql)->query()->loadObject();
             ddie($row);
             // Get the name of the author
             $sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
             $author = $db->setQuery($sql1)->query()->loadResult();
             // Get any tags
             $sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'blog';";
             $tags = $db->setQuery($sql2)->query()->loadColumn();
             // Determine the path
             $year = Date::of(strtotime($row->publish_up))->toLocal('Y');
             $month = Date::of(strtotime($row->publish_up))->toLocal('m');
             $alias = $row->alias;
             if ($row->scope == 'site') {
                 $path = '/blog/' . $year . '/' . $month . '/' . $alias;
             } elseif ($row->scope == 'member') {
                 $path = '/members/' . $row->scope_id . '/blog/' . $year . '/' . $month . '/' . $alias;
             } elseif ($row->scope == 'group') {
                 $group = Group::getInstance($row->scope_id);
                 // Make sure group is valid.
                 if (is_object($group)) {
                     $cn = $group->get('cn');
                     $path = '/groups/' . $cn . '/blog/' . $year . '/' . $month . '/' . $alias;
                 } else {
                     $path = '';
                 }
             }
             // Public condition
             if ($row->state == 1 && $row->access == 1) {
                 $access_level = 'public';
             } elseif ($row->state == 1 && $row->access == 2) {
                 $access_level = 'registered';
             } else {
                 $access_level = 'private';
             }
             if ($row->scope != 'group') {
                 $owner_type = 'user';
                 $owner = $row->created_by;
             } else {
                 $owner_type = 'group';
                 $owner = $row->scope_id;
             }
             // Get the title
             $title = $row->title;
             // Build the description, clean up text
             $content = preg_replace('/<[^>]*>/', ' ', $row->content);
             $content = preg_replace('/ {2,}/', ' ', $content);
             $description = \Hubzero\Utility\Sanitize::stripAll($content);
             // Create a record object
             $record = new \stdClass();
             $record->id = $type . '-' . $id;
             $record->hubtype = $type;
             $record->title = $title;
             $record->description = $description;
             $record->author = array($author);
             $record->tags = $tags;
             $record->path = $path;
             $record->access_level = $access_level;
             $record->owner = $owner;
             $record->owner_type = $owner_type;
             // Return the formatted record
             return $record;
         } else {
             $db = App::get('db');
             $sql = "SELECT id FROM #__blog_entries;";
             $ids = $db->setQuery($sql)->query()->loadColumn();
             return $ids;
         }
     }
 }
Example #5
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;
 }
Example #6
0
 /**
  * __construct
  *
  * sets up the user. will take an id
  * or an array of user info
  *
  * @params int|array $user
  * @return bool
  * @access private
  */
 private function __construct($user)
 {
     if (!is_array($user)) {
         $user = row('select *,group_concat(' . DB_USERS_GROUPS . '.group_id) as groups from ' . DB_USERS . ',' . DB_USERS_GROUPS . ' where ' . DB_USERS_GROUPS . '.user_id=' . $user . ' group by ' . DB_USERS . '.id');
     }
     // user doesn't exist
     if (count($user) == 0) {
         return false;
     }
     $this->id = $user['id'];
     $this->name = $user['name'];
     $this->email = $user['email'];
     $this->password = $user['password'];
     $groups = $user['groups'];
     $this->groups = array();
     $this->hash = $user['hash'];
     $this->data = json_decode(stripslashes($user['data']), true);
     /**
      * create an instance of each group of which
      * the user is a member in order to inherit
      * permissions
      */
     $groups = explode(',', $groups);
     /**
      * if superuser, set in _superuser field
      */
     if (in_array('_superuser', $groups)) {
         $this->_superuser = true;
         unset($groups[array_search('_superuser', $groups)]);
     }
     Group::createInstances($groups);
     foreach ($groups as $id) {
         array_push($this->groups, $id);
         $group = Group::getInstance($id);
         $this->perm = array_merge($this->perm, $group->perm());
         $this->filePerm = merge_perm($this->filePerm, $group->filePerm());
     }
     return true;
 }
Example #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];
     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;
 }
Example #8
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $group_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $user = \lms_steam::get_current_user();
     $content = \Group::getInstance()->loadTemplate("search_persons.template.html");
     if (!($steam_group = \steam_factory::get_object($GLOBALS['STEAM']->get_id(), $group_id))) {
         throw new \Exception('Group not found: ' . $_REQUEST['group']);
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception('Is not a group: ' . $group_id);
     }
     // always try to use the correct specialized group:
     if (!isset($group)) {
         $group = \koala_object::get_koala_object($steam_group);
     } else {
         if ($group instanceof \koala_object) {
             $group = \koala_object::get_koala_object($group->get_steam_object());
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     // TODO: Passt der backlink?
     $backlink = $group->get_url();
     if (!$group->is_admin($user)) {
         throw new \Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
     }
     if (!empty($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
         $login = key($_REQUEST["add"]);
         $new_member = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
         if ($group instanceof \koala_group_tutorial) {
             if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                 $course_learners_group = $group->steam_group_course_learners;
                 $subgroups = $course_learners_group->get_subgroups();
                 foreach ($subgroups as $sg) {
                     if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($new_member) && $sg != $steam_group) {
                         $already_member_and_exclusive = true;
                         $in_group = $sg;
                     }
                 }
             }
         }
         if ($already_member_and_exclusive) {
             if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                 $content->setVariable("WARNING_TEXT", "<p/>" . gettext("Attention! The user you want to add already became member in another tutorial in the meantime."));
             }
             if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                 if ($group->add_member($new_member)) {
                     // PROCEDURE FOR COURSE ADMINS
                     if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                         // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                         $steam_group->set_sanction_all($new_member);
                     }
                     if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                         $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                         $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                     }
                     $group_name = \koala_object::get_koala_object($group)->get_display_name();
                     $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                     $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                     $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                     \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                     $cache = get_cache_function($new_member->get_name());
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                     $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                     $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                     $cache = get_cache_function($group->get_id());
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
                 }
             }
         } else {
             if ($group->add_member($new_member)) {
                 // PROCEDURE FOR COURSE ADMINS
                 if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                     // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                     $steam_group->set_sanction_all($new_member);
                 }
                 if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                     $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                     $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                 }
                 $group_name = \koala_object::get_koala_object($group)->get_display_name();
                 $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                 $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                 $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                 \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                 $cache = get_cache_function($new_member->get_name());
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                 $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                 $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                 $cache = get_cache_function($group->get_id());
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
             }
         }
     }
     if ($group->get_maxsize() > 0 && $group->get_maxsize() <= $group->count_members()) {
         $html_content = "<div class=\"infoBar\">" . gettext("The group is full! You can not add any further members, because the maximum size of the group has been reached. Please increase this value to add more members.") . "</div>";
     } else {
         $content->setVariable("HEAD_SEARCH", gettext("Search"));
         $content->setVariable("INFO_TEXT", gettext("Here you can lookup some people.") . " " . str_replace("%GROUP", $group->get_display_name(), gettext("You can add a search result as member to '<b>%GROUP</b>'.")));
         if (!empty($_REQUEST["pattern"])) {
             $content->setVariable("VALUE_PATTERN", $_REQUEST["pattern"]);
         }
         $content->setVariable("LABEL_CHECK_NAME", gettext("Name"));
         $content->setVariable("LABEL_CHECK_LOGIN", gettext("Email address or login"));
         $content->setVariable("LABEL_SEARCH", gettext("Search"));
         $content->setVariable("GROUP_ID", $group->get_id());
         $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
         // SEARCH RESULTS
         if (!empty($_REQUEST["pattern"])) {
             $cache = get_cache_function($user->get_name(), 60);
             $result = $cache->call("lms_steam::search_user", $_REQUEST["pattern"], $_REQUEST["lookin"]);
             if ($_REQUEST["lookin"] == "name") {
                 $content->setVariable("CHECKED_NAME", 'checked="checked"');
             } else {
                 $content->setVariable("CHECKED_LOGIN", 'checked="checked"');
             }
             // PROCEED RESULT SET
             $html_people = \Group::getInstance()->loadTemplate("list_users.template.html");
             $no_people = count($result);
             if ($no_people > 0) {
                 // TODO: Passt der backlink?
                 if (isset($_REQUEST["backlink"])) {
                     $tmp_backlink = $_REQUEST["backlink"];
                 } else {
                     if (isset($backlink)) {
                         $tmp_backlink = $backlink;
                     }
                 }
                 $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL people in result set") . ")", "?pattern=" . $_REQUEST["pattern"] . "&lookin=" . $_REQUEST["lookin"] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink);
                 $start = $paginator["startIndex"];
                 //$start = $portal->set_paginator( $html_people, 10, $no_people, "(" . gettext( "%TOTAL people in result set" ) . ")", "?pattern=" . $_REQUEST[ "pattern" ] . "&lookin=" . $_REQUEST[ "lookin" ] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink );
                 $end = $start + 10 > $no_people ? $no_people : $start + 10;
                 $html_people->setVariable("PAGINATOR", $paginator["html"]);
                 $html_people->setVariable("LABEL_CONTACTS", gettext("Results") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_people), gettext("%a-%z out of %s")) . ")");
                 $html_people->setCurrentBlock("BLOCK_CONTACT_LIST");
                 $html_people->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
                 $html_people->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
                 $html_people->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
                 $html_people->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
                 for ($i = $start; $i < $end; $i++) {
                     $person = $result[$i];
                     $html_people->setCurrentBlock("BLOCK_CONTACT");
                     $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . $person["OBJ_NAME"] . "/");
                     // TODO: Passt der link?
                     $icon_link = $person["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . $person["OBJ_ICON"];
                     $html_people->setVariable("CONTACT_IMAGE", $icon_link);
                     $html_people->setVariable("CONTACT_NAME", h($person["USER_FIRSTNAME"]) . " " . h($person["USER_FULLNAME"]));
                     $html_people->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . $person["OBJ_NAME"]);
                     $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
                     $html_people->setVariable("LABEL_SEND", gettext("Send"));
                     $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
                     $p = new \steam_object($GLOBALS["STEAM"]->get_id(), $person["OBJ_ID"]);
                     //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
                     //see if our person is already member in one of the other tutorials.
                     $already_member_and_exclusive = false;
                     if ($group instanceof \koala_group_tutorial) {
                         if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                             $course_learners_group = $steam_group->get_parent_group();
                             $subgroups = $course_learners_group->get_subgroups();
                             foreach ($subgroups as $sg) {
                                 if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($p) && $sg != $steam_group) {
                                     $already_member_and_exclusive = true;
                                     $in_group = $sg;
                                 }
                             }
                         }
                     }
                     if (!$group->is_member($p)) {
                         if ($already_member_and_exclusive) {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><small><b>" . gettext("Attention: User already in tutorial") . " " . $in_group->get_name() . "<p /></b></small><input type=\"hidden\" name=\"confirmed\" value=\"true\"/><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add anyhow") . "\"/></td>");
                         } else {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add") . "\"/></td>");
                         }
                     } else {
                         $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\">" . gettext("Already a member.") . "</td>");
                     }
                     $html_people->parse("BLOCK_CONTACT");
                 }
                 $html_people->parse("BLOCK_CONTACT_LIST");
             } else {
                 $html_people->setVariable("LABEL_CONTACTS", gettext("No results."));
             }
             $content->setVariable("HTML_USER_LIST", $html_people->get());
         } else {
             $content->setVariable("CHECKED_NAME", 'checked="checked"');
         }
     }
     $portal->set_page_title(gettext("Add member"));
     // give input focus to search field:
     $portal->add_javascript_onload("group_add_member", "document.getElementById('pattern').focus();");
     if (!isset($html_content)) {
         $portal->set_page_main(array($group->get_link(), array("name" => gettext("Add member"))), $content->get(), "");
     } else {
         $portal->set_page_main(array($group->get_link(), array("name" => gettext("Add member"))), $html_content, "");
     }
     //$portal->show_html();
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #9
0
    /**
     * get all groups
     *
     * @return array
     * @author Elias Müller
     **/
    public static function getAll()
    {
        $db = new DB();
        $sql = 'SELECT idstatus
				  FROM groups';
        $result = $db->query($sql);
        if ($result->length() > 0) {
            do {
                $g[$result->idstatus] = Group::getInstance($result->idstatus);
            } while ($result->next());
            return $g;
        }
        return false;
    }
Example #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->initialize(GUEST_NOT_ALLOWED);
     $portal_user = $portal->get_user();
     try {
         $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE;
     } catch (\Exception $ex) {
         include "bad_link.php";
         exit;
     }
     $group_is_private = FALSE;
     if ($steam_group && is_object($steam_group)) {
         switch ((string) $steam_group->get_attribute("OBJ_TYPE")) {
             case "course":
                 $group = new \koala_group_course($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
                 break;
             default:
                 $group = new \koala_group_default($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . "groups/" . $group->get_id() . "/";
                 // Determine if group is public or private
                 $parent = $group->get_parent_group();
                 if ($parent->get_id() == STEAM_PRIVATE_GROUP) {
                     $group_is_private = TRUE;
                 }
                 break;
         }
     }
     if ($group_is_private) {
         if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) {
             throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS);
         }
     }
     $content = \Group::getInstance()->loadTemplate("membership_requests.template.html");
     $content->setVariable("INFO_TEXT", gettext("The people listed are interested in becoming a member of your group.") . " " . gettext("Here, you can choose wether to affirm their membership or cancel the request.") . " " . gettext("In both cases, the user concerned will automatically get informed by mail about your decision."));
     // always try to use the correct specialized group:
     if ($group instanceof \koala_object) {
         $group = \koala_object::get_koala_object($group->get_steam_object());
     } else {
         if ($group instanceof \steam_object) {
             $group = \koala_object::get_koala_object($group);
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     $type = $group->get_attribute("OBJ_TYPE");
     switch ($type) {
         case "group_tutorial_koala":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         case "course_tutorial":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         default:
             // TODO: Passt der backlink?
             $backlink = $backlink . "members/";
     }
     if (!$group->is_admin($user)) {
         //				throw new Exception( $user->get_name() . " is no admin of " . $group->get_name() );
         header("Location: " . PATH_URL . "error.php?error=" . E_USER_RIGHTS);
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST['affirm']) && is_array($_POST['affirm'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["affirm"]));
             if ($group instanceof \koala_group_tutorial) {
                 if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                     $course_learners_group = $group->steam_group_course_learners;
                     $subgroups = $course_learners_group->get_subgroups();
                     foreach ($subgroups as $sg) {
                         if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             if ($already_member_and_exclusive) {
                 if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                     $content->setCurrentBlock("BLOCK_WARNING");
                     $content->setVariable("WARNING_TEXT", gettext("Attention! The user whose membership you wish to affirm already became member in another tutorial in the meantime."));
                     $content->parse("BLOCK_WARNING");
                 }
                 if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                     $group->add_member($candidate);
                     $group->remove_membership_request($candidate);
                     $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                     $message = gettext("Your membership was affirmed.");
                     $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                     // uncache group members page:
                     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     // uncache menu so that course/group appears:
                     $cache = get_cache_function($candidate->get_name());
                     $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                     $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
                 }
             } else {
                 $group->add_member($candidate);
                 $group->remove_membership_request($candidate);
                 $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                 $message = gettext("Your membership was affirmed.");
                 $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                 // uncache group members page:
                 $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 // uncache menu so that course/group appears:
                 $cache = get_cache_function($candidate->get_name());
                 $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                 $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
             }
         } elseif (isset($_POST['cancel']) && is_array($_POST['cancel'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["cancel"]));
             $group->remove_membership_request($candidate);
             $subject = str_replace("%GROUP", $group->get_name(), gettext("Your membership for '%GROUP' was rejected"));
             $message = gettext("Your membership was rejected.");
             $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME rejected.")));
         }
         //$candidate->mail( $subject, $message, $user->get_attribute( "USER_EMAIL" ));
         \lms_steam::mail($candidate, $user, $subject, $message);
     }
     $result = $group->get_membership_requests();
     $html_people = \Group::getInstance()->loadTemplate("list_users.template.html");
     $no_people = count($result);
     if ($no_people > 0) {
         $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL membership requests") . ")");
         $start = $paginator["startIndex"];
         //$start = $portal->set_paginator( 10, $no_people, "(" . gettext( "%TOTAL membership requests" ). ")" );
         $end = $start + 10 > $no_people ? $no_people : $start + 10;
         $content->setVariable("PAGINATOR", $paginator["html"]);
         $html_people->setVariable("LABEL_CONTACTS", gettext("Membership requests") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_people), gettext("%a-%z out of %s")) . ")");
         $html_people->setCurrentBlock("BLOCK_CONTACT_LIST");
         $html_people->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
         $html_people->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
         $html_people->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
         $html_people->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
         foreach ($result as $candidate) {
             $person = $candidate->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "OBJ_NAME", "OBJ_DESC"));
             $html_people->setCurrentBlock("BLOCK_CONTACT");
             $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($person["OBJ_NAME"]) . "/");
             if (is_object($person["OBJ_ICON"])) {
                 // TODO: Passt der link?
                 $icon_link = PATH_URL . "cached/get_document.php?id=" . $person["OBJ_ICON"]->get_id() . "&type=usericon";
             } else {
                 // TODO: Passt der link?
                 $icon_link = PATH_STYLE . "images/anonymous.jpg";
             }
             $html_people->setVariable("CONTACT_IMAGE", $icon_link);
             $html_people->setVariable("CONTACT_NAME", h($person["USER_FIRSTNAME"]) . " " . h($person["USER_FULLNAME"]));
             $html_people->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($person["OBJ_NAME"]));
             $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
             $html_people->setVariable("LABEL_SEND", gettext("Send"));
             //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
             //see if our candidate is already member in one of the other tutorials.
             $already_member_and_exclusive = false;
             if ($group instanceof \koala_group_tutorial) {
                 if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                     $course_learners_group = $group->steam_group_course_learners;
                     $subgroups = $course_learners_group->get_subgroups();
                     foreach ($subgroups as $sg) {
                         if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             if ($already_member_and_exclusive) {
                 $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><small><b>" . gettext("Attention: User already in tutorial") . " " . $in_group->get_name() . "<p /></b></small><input type=\"hidden\" name=\"confirmed\" value=\"true\"/><input type=\"submit\"  name=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm anyhow") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             } else {
                 $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             }
             $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
             $html_people->parse("BLOCK_CONTACT");
         }
         $html_people->parse("BLOCK_CONTACT_LIST");
         $content->setVariable("HTML_USER_LIST", $html_people->get());
     } else {
         $content->setVariable("LABEL_NO_REQUESTS", "<h3>" . gettext("No membership request found.") . "</h3>");
     }
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #11
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;
 }
Example #12
0
foreach ($users as $user) {
    array_push($ids, $user['id']);
}
User::createInstances($ids);
foreach ($ids as $id) {
    $user = User::getInstance($id);
    /**
     * get names of groups the user is a member of
     */
    $group = '';
    if ($user->isSuperUser()) {
        // if is super user, show in groups
        $group .= '<b>_superuser</b><br/>';
    }
    foreach ($user->groups() as $id) {
        $g = Group::getInstance($id);
        $group .= $g->name() . '<br/>';
    }
    $delete = '<a id="' . $user->id() . '" class="delete link"><span class="admin-menu-img" id="delete-img"' . ' title="Delete User" alt="Delete User"/></a>';
    $href = '<a href="users.php?page=edit-users&id=' . $user->id() . '" class="list-link">';
    $content .= '<tr>
			<td class="first">' . $href . $user->name() . '</a></td>
			<td>' . $href . $user->email() . '</a></td>
			<td>' . $href . $group . '</a></td>';
    if ($super) {
        $content .= '<td><a class="link loginas" user_id="' . $user->id() . '" hashstr="' . $user->password() . '">Login</a></td>';
    }
    $content .= '
			<td>' . $delete . '</td>
		</tr>';
}
Example #13
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
     $id = $path[0];
     $portal = \lms_portal::get_instance();
     $portal_user = $portal->get_user();
     try {
         $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE;
     } catch (\Exception $ex) {
         include "bad_link.php";
         exit;
     }
     $group_is_private = FALSE;
     if ($steam_group && is_object($steam_group)) {
         switch ((string) $steam_group->get_attribute("OBJ_TYPE")) {
             case "course":
                 $group = new \koala_group_course($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
                 break;
             default:
                 $group = new \koala_group_default($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . "groups/" . $group->get_id() . "/";
                 // Determine if group is public or private
                 $parent = $group->get_parent_group();
                 if ($parent->get_id() == STEAM_PRIVATE_GROUP) {
                     $group_is_private = TRUE;
                 }
                 break;
         }
     }
     if ($group_is_private) {
         if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) {
             throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS);
         }
     }
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
         header("location:../");
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Group::getInstance()->loadTemplate("list_users.template.html");
     $is_member = $group->is_member($user);
     //echo "is_member? " . $is_member;
     $privacy_deny_participants = $group->get_attribute("GROUP_PRIVACY");
     //echo "attribute: ''" . $privacy_deny_participants . "''";
     if ($privacy_deny_participants == PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS && !$is_member) {
         //echo "*** deny ***";
         //TODO
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", gettext("Participants are hidden."));
     } else {
         //echo "*** permit ***";
         $no_members = count($members);
         if ($no_members > 0) {
             switch (get_class($group)) {
                 case "koala_group_course":
                     $groupname = $group->get_course_id();
                     break;
                 default:
                     $groupname = $group->get_name();
                     break;
             }
             if (!USER_LIST_NO_PAGEING) {
                 $paginator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($groupname), gettext("%TOTAL members in %NAME")) . ")");
                 $start = $paginator["startIndex"];
                 $end = $start + 10 > $no_members ? $no_members : $start + 10;
                 $content->setVariable("PAGINATOR", $paginator["html"]);
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
             } else {
                 //if (count($members) > 10) {
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (Anzahl " . count($members) . ")");
                 $content->setCurrentBlock("BLOCK_FILTER");
                 $content->setVariable("HELP_TEXT", "Benutzer lassen sich einfacher finden, indem Sie den Filter verwenden. Tippen Sie einfach einen Teil des Benutzernamen oder der Benutzerkennung in das Textfeld.");
                 $content->setVariable('LABEL_FILTER', "<b>" . gettext('Filter') . "</b>");
                 $start = 0;
                 $end = count($members);
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $html = "";
                     foreach ($extensions as $extension) {
                         $html .= $extension->get_filter_html($portal, "filter_user", "extension_data");
                     }
                     $content->setCurrentBlock("BLOCK_EXTENSION_FILTER");
                     $content->setVariable("EXTENSION_FILTER", $html);
                     $content->parse("BLOCK_EXTENSION_FILTER");
                 }
                 $content->parse("BLOCK_FILTER");
                 //}
             }
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
             !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
             !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                 !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             }
             !COURSE_PARTICIPANTS_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
             $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
             $content->setVariable("END_HTML_FORM", "</form>");
             for ($i = $start; $i < $end; $i++) {
                 $member = $members[$i];
                 if ($member["USER_TRASHED"] === 1) {
                     continue;
                 }
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($member["OBJ_NAME"]) . "/");
                 // TODO: Passt der link?
                 $icon_link = $member["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . h($member["OBJ_ICON"]) . "&type=usericon&width=30&height=40";
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 $title = !empty($member["USER_ACADEMIC_TITLE"]) ? h($member["USER_ACADEMIC_TITLE"]) . " " : "";
                 $content->setVariable("CONTACT_NAME", $title . h($member["USER_FIRSTNAME"]) . " " . h($member["USER_FULLNAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($member["OBJ_NAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_SEND", gettext("Send"));
                 !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("FACULTY_AND_FOCUS", h($member["USER_PROFILE_FACULTY"]));
                 if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                     !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"remove[" . h($member["OBJ_NAME"]) . "]\" value=\"" . gettext("Remove") . "\"/></td>");
                 }
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $result = "";
                     foreach ($extensions as $extension) {
                         $result .= $extension->get_member_info(\steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $member["OBJ_NAME"]), $group);
                     }
                     $content->setVariable("EXTENSIONS_DATA", $result);
                 }
                 $member_desc = empty($member["OBJ_DESC"]) ? "student" : $member["OBJ_DESC"];
                 $status = secure_gettext($member_desc);
                 $content->setVariable("OBJ_DESC", h($status) . " " . ($i + 1));
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_NO_MEMBERS", gettext("No members found."));
         }
     }
     $html_handler_group->set_html_left($content->get());
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html_handler_group->get_html());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #14
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $group_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $user = \lms_steam::get_current_user();
     //TODO: Was soll dieses $em hier??
     //$em = \lms_steam::get_extensionmanager();
     if (!($steam_group = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group_id))) {
         include "bad_link.php";
         exit;
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception("Is not a group: " . $_GET["id"]);
     }
     $group = \koala_object::get_koala_object($steam_group);
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         $values = $_POST["values"];
         if (defined("LOG_DEBUGLOG")) {
             \logging::write_log(LOG_DEBUGLOG, "group_cancel\t" . $user->get_name() . " leaves " . $steam_group->get_identifier());
         }
         \logging::start_timer("leave_group");
         if ($group->remove_member($user)) {
             $group_name = $group->get_display_name();
             $short_confirmation = str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated."));
             $confirmation = str_replace("%NAME", $user->get_full_name(), gettext("Dear %NAME,")) . "\n\n" . $short_confirmation . "\n\n" . gettext("Your koaLA Team");
             \lms_steam::mail($user, "\"" . PLATFORM_NAME . " System\"<no_reply@" . STEAM_SERVER . ">", PLATFORM_NAME . ": " . str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated")), $confirmation);
             $cache = get_cache_function($user->get_name());
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $user->get_name());
             $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
             $_SESSION["confirmation"] = $short_confirmation;
             if (defined("LOG_DEBUGLOG")) {
                 \logging::append_log(LOG_DEBUGLOG, " runtime=" . \logging::print_timer("leave_group"));
             }
             header("Location: " . $values["return_to"]);
             exit;
         } else {
             throw new \Exception("Cannot delete membership.");
         }
         if (defined("LOG_DEBUGLOG")) {
             \logging::append_log(LOG_DEBUGLOG, "failed. runtime=" . \logging::print_timer("leave_group"));
         }
     }
     $content = \Group::getInstance()->loadTemplate("groups_cancel_membership.template.html");
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
         if (empty($_SESSION['confirmation'])) {
             // don't warn if we came here on successful membership cancel...
             if ($group instanceof \koala_group_course) {
                 $portal->set_problem_description(gettext("You are not member of this course."));
             } else {
                 $portal->set_problem_description(gettext("You are not member of this group."));
             }
         }
     } else {
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             if (empty($_SESSION['confirmation'])) {
                 // don't warn if we came here on successful membership cancel...
                 if ($group instanceof \koala_group_course) {
                     $portal->set_problem_description(gettext("You are not member of this course."));
                 } else {
                     $portal->set_problem_description(gettext("You are not member of this group."));
                 }
             }
         } else {
             $redirect = $_SERVER["HTTP_REFERER"];
             if ($group instanceof \koala_group_default && !$group->is_public()) {
                 $redirect = PATH_URL . "user/" . \lms_steam::get_current_user()->get_name() . "/groups/";
             }
             $content->setVariable("DELETE_BACK_LINK", $redirect);
             $content->setVariable("FORM_ACTION", PATH_URL . "group/cancelGroup/\t" . $group_id);
             $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure?"));
             $content->setVariable("INFO_CANCEL_MEMBERSHIP", str_replace("%NAME", $group->get_display_name(), gettext("You are going to cancel your membership in <b>'%NAME'</b>.")));
             $content->setVariable("BUTTON_SUBMIT", "<input type=\"submit\" name=\"values[delete]\"  value=\"" . gettext("Yes, cancel my membership") . "\"/>");
         }
     }
     /*
     $portal->set_page_main(
     								"",
     								$content->get(),
     								""
     								);
     $portal->show_html();
     */
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #15
0
 /**
  * Handle form action
  */
 protected function formAction()
 {
     switch ($this->s->action) {
         case "activate":
             if ($this->s->element != '') {
                 $group = Group::getInstance($this->s->element);
                 $rights = $group->rights;
                 if (current($rights) == '') {
                     $rights = array();
                 }
                 if ($this->vars['option'] == 'set' && !in_array($this->vars['right'], $rights)) {
                     $rights[] = $this->vars['right'];
                 } elseif ($this->vars['option'] == 'remove') {
                     foreach ($rights as $key => $right) {
                         if ($right == $this->vars['right']) {
                             unset($rights[$key]);
                         }
                     }
                 }
                 $group->rights = $rights;
                 if ($group->save()) {
                     return true;
                 }
             }
             Error::addWarning('Fehler: Es wurde kein Modul ausgewählt!');
             break;
         case 'create':
             $group = Group::getInstance();
             $group->name = $this->vars['name'];
             if ($group->save()) {
                 Error::addMessage('Die Benutzergruppe wurde erfolgreich angelegt!');
                 $this->form['reload'] = array('group' => array('groups'));
                 return true;
             }
         case 'delete':
             $group = Group::getInstance($this->s->element);
             $name = $group->name;
             if ($group->delete()) {
                 Error::addMessage('Die Gruppe ' . $name . ' wurde erfolgreich gelöscht!');
                 $this->form['reload'] = array('group' => array('groups'));
             }
             break;
         case 'reload':
             switch ($this->s->element) {
                 case 'groups':
                     // groups table
                     echo $this->listGroups();
                     break;
                 default:
                     Error::addError('Fehler: Element nicht gefunden!');
                     return false;
             }
             return true;
             break;
     }
     return false;
 }