本文整理汇总了PHP中Group::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::getInstance方法的具体用法?PHP Group::getInstance怎么用?PHP Group::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDisplay
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));
}
示例2: frameResponse
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 {
//.........这里部分代码省略.........
示例3: frameResponse
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");
}
}
//.........这里部分代码省略.........
示例4: onIndex
/**
* 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;
}
}
}
示例5: frameResponse
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;
}
示例6: __construct
/**
* __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;
}
示例7: frameResponse
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");
//.........这里部分代码省略.........
示例8: frameResponse
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.")));
}
//.........这里部分代码省略.........
示例9: getAll
/**
* 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;
}
示例10: frameResponse
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());
//.........这里部分代码省略.........
示例11: frameResponse
//.........这里部分代码省略.........
} 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"));
示例12: foreach
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>';
}
示例13: frameResponse
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"];
//.........这里部分代码省略.........
示例14: frameResponse
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");
//.........这里部分代码省略.........
示例15: formAction
/**
* 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;
}