function addmembers_submit(Pieform $form, $values) { global $SESSION, $group, $USER; if (empty($values['users'])) { redirect(get_config('wwwroot') . 'group/suggest.php?id=' . GROUP); } require_once 'activity.php'; $groupurl = group_homepage_url($group, false); activity_occurred('maharamessage', array('users' => $values['users'], 'subject' => '', 'message' => '', 'strings' => (object) array('subject' => (object) array('key' => 'suggestgroupnotificationsubject', 'section' => 'group', 'args' => array(display_name($USER))), 'message' => (object) array('key' => 'suggestgroupnotificationmessage', 'section' => 'group', 'args' => array(display_name($USER), hsc($group->name), get_config('sitename')))), 'url' => $groupurl, 'urltext' => hsc($group->name))); $SESSION->add_ok_msg(get_string('recommendationssent', 'group', count($values['users']))); redirect(get_config('wwwroot') . $groupurl); }
function addmembers_submit(Pieform $form, $values) { global $SESSION, $group, $USER, $friends; if (empty($values['users'])) { redirect(get_config('wwwroot') . 'group/inviteusers.php?id=' . GROUP . ($friends ? '&friends=1' : '')); } db_begin(); foreach ($values['users'] as $userid) { group_invite_user($group, $userid, $USER->get('id'), 'member', true); } db_commit(); $SESSION->add_ok_msg(get_string('invitationssent', 'group', count($values['users']))); if ($friends) { redirect(group_homepage_url($group)); } redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP); }
function returnto() { global $view, $collection, $group, $returnto; // Deteremine the best place to return to if ($returnto === 'group') { $goto = group_homepage_url($group, false); } else { if ($returnto === 'view') { if (!empty($collection)) { $goto = $collection->get_url(false); } else { $goto = $view->get_url(false); } } else { $goto = 'view/index.php'; } } return $goto; }
<?php }?> <?php if ((is_string($tmp=(isset($this->scope["sbdata"]["groups"]) ? $this->scope["sbdata"]["groups"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <li id="groups"><a href="<?php echo (is_string($tmp=$this->scope["WWWROOT"]) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?>group/mygroups.php"><?php echo Dwoo_Plugin_str($this, "mygroups", 'mahara', null, null, null, null, null);?>:</a> <ul> <?php $_fh4_data = (is_string($tmp=(isset($this->scope["sbdata"]["groups"]) ? $this->scope["sbdata"]["groups"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp); if ($this->isArray($_fh4_data) === true) { foreach ($_fh4_data as $this->scope['group']) { /* -- foreach start output */ ?> <li><a href="<?php echo group_homepage_url((is_string($tmp=(isset($this->scope["group"]) ? $this->scope["group"] : null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp));?>"><?php echo (is_string($tmp=$this->readVarInto(array ( 1 => array ( 0 => '->', ), 2 => array ( 0 => 'name', ), 3 => array ( 0 => '', 1 => '', ),), $this->scope["group"], false)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?></a><?php if ((is_string($tmp=$this->readVarInto(array ( 1 => array ( 0 => '->', ), 2 => array ( 0 => 'role', ), 3 => array ( 0 => '', 1 => '', ),), (isset($this->scope["group"]) ? $this->scope["group"]:null), true)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp) == 'admin') { ?> (<?php echo Dwoo_Plugin_str($this, 'Admin', 'group', null, null, null, null, null);?>)<?php }?></li> <?php /* -- foreach end output */ } }?> </ul> <span class="tiny"><?php echo (is_string($tmp=$this->scope["sbdata"]["grouplimitstr"]) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?></span> </li> <?php }?> <?php if ((is_string($tmp=(isset($this->scope["sbdata"]["views"]) ? $this->scope["sbdata"]["views"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?>
$view->set_edit_nav(); $state = get_string('editcontent', 'view'); if ($view->get('type') == 'profile') { $profile = true; $title = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true)); define('TITLE', $title); } else { if ($view->get('type') == 'dashboard') { $dashboard = true; $title = get_string('usersdashboard', 'mahara', display_name($view->get('owner'), null, true)); define('TITLE', $title); } else { if ($view->get('type') == 'grouphomepage') { $title = get_string('grouphomepage', 'view'); if ($view->get('owner') != "0") { $groupurl = group_homepage_url(get_record('group', 'id', $view->get('group')), false); } define('TITLE', $title); } else { if ($new) { define('TITLE', get_string('notitle', 'view')); } else { define('TITLE', $view->get('title')); $editabletitle = true; } } } } // Make the default category the first tab if none is set $category = ''; if (param_exists('c')) {
$ownerformatoptions = array(FORMAT_NAME_FIRSTNAME => sprintf($formatstring, get_string('firstname'), $USER->get('firstname')), FORMAT_NAME_LASTNAME => sprintf($formatstring, get_string('lastname'), $USER->get('lastname')), FORMAT_NAME_FIRSTNAMELASTNAME => sprintf($formatstring, get_string('fullname'), full_name())); $displayname = display_name($USER); if ($displayname !== '') { $ownerformatoptions[FORMAT_NAME_DISPLAYNAME] = sprintf($formatstring, get_string('preferredname'), $displayname); } $studentid = (string) get_field('artefact', 'title', 'owner', $USER->get('id'), 'artefacttype', 'studentid'); if ($studentid !== '') { $ownerformatoptions[FORMAT_NAME_STUDENTID] = sprintf($formatstring, get_string('studentid'), $studentid); } // Clean urls are only available for portfolio views owned by groups or users who already // have their own clean profiles or group homepages. if ($urlallowed = get_config('cleanurls') && $view->get('type') == 'portfolio' && !$institution) { if ($group) { $groupdata = get_record('group', 'id', $group); if ($urlallowed = !is_null($groupdata->urlid) && strlen($groupdata->urlid)) { $cleanurlbase = group_homepage_url($groupdata) . '/'; } } else { $userurlid = $USER->get('urlid'); if ($urlallowed = !is_null($userurlid) && strlen($userurlid)) { $cleanurlbase = profile_url($USER) . '/'; } } } $editview = array('name' => 'editview', 'method' => 'post', 'autofocus' => 'title', 'autoselect' => $new ? 'title' : null, 'plugintype' => 'core', 'pluginname' => 'view', 'elements' => array('id' => array('type' => 'hidden', 'value' => $view->get('id')), 'new' => array('type' => 'hidden', 'value' => $new), 'title' => array('type' => 'text', 'title' => get_string('title', 'view'), 'defaultvalue' => $view->get('title'), 'rules' => array('required' => true)), 'urlid' => array('type' => 'text', 'title' => get_string('viewurl', 'view'), 'prehtml' => '<span class="description">' . (isset($cleanurlbase) ? $cleanurlbase : '') . '</span> ', 'description' => get_string('viewurldescription', 'view') . ' ' . get_string('cleanurlallowedcharacters'), 'defaultvalue' => $new ? null : $view->get('urlid'), 'rules' => array('maxlength' => 100, 'regex' => get_config('cleanurlvalidate')), 'ignore' => !$urlallowed || $new), 'description' => array('type' => 'wysiwyg', 'title' => get_string('description', 'view'), 'rows' => 10, 'cols' => 70, 'defaultvalue' => $view->get('description'), 'rules' => array('maxlength' => 65536)), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $view->get('tags'), 'help' => true))); if ($group) { $grouproles = $USER->get('grouproles'); if ($grouproles[$group] == 'admin') { $editview['elements']['locked'] = array('type' => 'switchbox', 'title' => get_string('Locked', 'view'), 'description' => get_string('lockedgroupviewdesc', 'view'), 'defaultvalue' => $view->get('locked'), 'disabled' => $view->get('type') == 'grouphomepage'); } }
/** * Returns a datastructure describing the tabs that appear on a group page * * @param object $group Database record of group to get tabs for * @return array */ function group_get_menu_tabs() { static $menu; $group = group_current_group(); if (!$group) { return null; } $role = group_user_access($group->id); $menu = array('info' => array('path' => 'groups/info', 'url' => group_homepage_url($group, false), 'title' => get_string('About', 'group'), 'weight' => 20)); if (group_can_list_members($group, $role)) { $menu['members'] = array('path' => 'groups/members', 'url' => 'group/members.php?id=' . $group->id, 'title' => get_string('Members', 'group'), 'weight' => 30); } if ($interactionplugins = plugins_installed('interaction')) { foreach ($interactionplugins as $plugin) { safe_require('interaction', $plugin->name); $plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'group_menu_items', $group); $menu = array_merge($menu, $plugin_menu); } } $menu['subnav'] = array('class' => 'group'); $menu['views'] = array('path' => 'groups/views', 'url' => 'view/groupviews.php?group=' . $group->id, 'title' => get_string('Views', 'group'), 'weight' => 50); $menu['collections'] = array('path' => 'groups/collections', 'url' => 'collection/index.php?group=' . $group->id, 'title' => get_string('Collections', 'group'), 'weight' => 60); if (group_role_can_edit_views($group, $role)) { $menu['share'] = array('path' => 'groups/share', 'url' => 'group/shareviews.php?group=' . $group->id, 'title' => get_string('share', 'view'), 'weight' => 70); } if ($role) { safe_require('grouptype', $group->grouptype); $artefactplugins = call_static_method('GroupType' . $group->grouptype, 'get_group_artefact_plugins'); if ($plugins = plugins_installed('artefact')) { foreach ($plugins as &$plugin) { if (!in_array($plugin->name, $artefactplugins)) { continue; } safe_require('artefact', $plugin->name); $plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'group_tabs', $group->id); $menu = array_merge($menu, $plugin_menu); } } } if (group_role_can_access_report($group, $role)) { $menu['report'] = array('path' => 'groups/report', 'url' => 'group/report.php?group=' . $group->id, 'title' => get_string('report', 'group'), 'weight' => 70); } if (defined('MENUITEM')) { $key = substr(MENUITEM, strlen('groups/')); if ($key && isset($menu[$key])) { $menu[$key]['selected'] = true; } } // Sort the menu items by weight uasort($menu, function ($a, $b) { // Only items with a "weight" component need to get sorted. Ones without weight can go first. if (!array_key_exists('weight', $a)) { return -1; } if (!array_key_exists('weight', $b)) { return 1; } $aweight = $a['weight']; $bweight = $b['weight']; if ($aweight == $bweight) { return 0; } return $aweight < $bweight ? -1 : 1; }); return $menu; }
/** * Get all views & collections for a (user,group), grouped * by their accesslists as defined by the accessconf column * * @param integer $owner * @param integer $group * * @return array */ public static function get_accesslists($owner = null, $group = null, $institution = null) { require_once 'institution.php'; if (!is_null($owner) && !is_array($owner) && $owner > 0) { $ownerobj = new User(); $ownerobj->find_by_id($owner); } $data = array(); list($data['collections'], $data['views']) = self::get_views_and_collections($owner, $group, $institution); // Remember one representative viewid in each collection $viewindex = array(); // Add strings to describe startdate/stopdate access overrides foreach ($data['collections'] as &$c) { $view = current($c['views']); $viewindex[$view['id']] = array('type' => 'collections', 'id' => $c['id']); $c['access'] = self::access_override_description($view); $c['viewid'] = $view['id']; } foreach ($data['views'] as &$v) { $viewindex[$v['id']] = array('type' => 'views', 'id' => $v['id']); $v['access'] = self::access_override_description($v); $v['viewid'] = $v['id']; } if (empty($viewindex)) { return $data; } // Get view_access records, apart from those with visible = 0 (system access records) $accessgroups = get_records_sql_array(' SELECT va.*, g.grouptype, g.name, g.urlid FROM {view_access} va LEFT OUTER JOIN {group} g ON (g.id = va.group AND g.deleted = 0) WHERE va.view IN (' . join(',', array_keys($viewindex)) . ') AND va.visible = 1 ORDER BY va.view, va.accesstype, g.grouptype, va.role, g.name, va.group, va.usr', array()); if (!$accessgroups) { return $data; } if (!function_exists('is_probationary_user')) { require_once get_config('libroot') . 'antispam.php'; } foreach ($accessgroups as $access) { // remove 'Public' from the list if the owner isn't allowed to have them if ($access->accesstype == 'public' && (get_config('allowpublicviews') != 1 || isset($ownerobj) && !$ownerobj->institution_allows_public_views() || isset($ownerobj) && is_probationary_user($ownerobj->id))) { continue; } $vi = $viewindex[$access->view]; // Just count secret urls. if ($access->token) { if (!isset($data[$vi['type']][$vi['id']]['secreturls'])) { $data[$vi['type']][$vi['id']]['secreturls'] = 0; } $data[$vi['type']][$vi['id']]['secreturls']++; continue; } $key = null; if ($access->usr) { $access->accesstype = 'user'; $access->id = $access->usr; } else { if ($access->group) { $access->accesstype = 'group'; $access->id = $access->group; if ($access->role) { $access->roledisplay = get_string($access->role, 'grouptype.' . $access->grouptype); } $access->groupurl = group_homepage_url((object) array('id' => $access->group, 'urlid' => $access->urlid)); } else { if ($access->institution) { $access->accesstype = 'institution'; $access->id = $access->institution; $access->name = institution_display_name($access->institution); } else { $key = $access->accesstype; } } } if ($key) { if (!isset($data[$vi['type']][$vi['id']]['accessgroups'][$key])) { $data[$vi['type']][$vi['id']]['accessgroups'][$key] = (array) $access; } } else { $data[$vi['type']][$vi['id']]['accessgroups'][] = (array) $access; } } return $data; }
function releaseview_submit() { global $USER, $SESSION, $view, $collection, $submittedgroup, $releasecollection; if ($releasecollection) { if (is_object($submittedgroup) && $submittedgroup->allowarchives) { $collection->pendingrelease($USER); $SESSION->add_ok_msg(get_string('collectionreleasedpending', 'group')); } else { $collection->release($USER); $SESSION->add_ok_msg(get_string('collectionreleasedsuccess', 'group')); } } else { if (is_object($submittedgroup) && $submittedgroup->allowarchives) { $view->pendingrelease($USER); $SESSION->add_ok_msg(get_string('viewreleasedpending', 'group')); } else { $view->release($USER); $SESSION->add_ok_msg(get_string('viewreleasedsuccess', 'group')); } } if ($submittedgroup) { // The tutor might not have access to the view any more; send // them back to the group page. redirect(group_homepage_url($submittedgroup)); } redirect($view->get_url()); }
* @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'groups'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; require_once 'group.php'; $groupid = param_integer('id'); define('GROUP', $groupid); $group = get_record_sql("SELECT g.*\n FROM {group} g\n INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')\n WHERE g.id = ?\n AND g.deleted = 0", array($USER->get('id'), $groupid)); if (!$group) { throw new AccessDeniedException(get_string('cantdeletegroup', 'group')); } define('TITLE', get_string('deletespecifiedgroup', 'group', $group->name)); $form = pieform(array('name' => 'deletegroup', 'renderer' => 'div', 'autofocus' => false, 'method' => 'post', 'elements' => array('submit' => array('type' => 'submitcancel', 'class' => 'btn-default', 'value' => array(get_string('yes'), get_string('no')), 'goto' => group_homepage_url($group))))); $smarty = smarty(); $smarty->assign('subheading', TITLE); $smarty->assign('message', get_string('groupconfirmdelete', 'group')); $smarty->assign('form', $form); $smarty->display('group/delete.tpl'); function deletegroup_submit(Pieform $form, $values) { global $SESSION, $USER, $groupid; group_delete($groupid); $SESSION->add_ok_msg(get_string('deletegroup', 'group')); redirect('/group/mygroups.php'); }
function institution_view_stats_table($limit, $offset, &$institutiondata) { global $USER; if ($institutiondata['views'] != 0) { $count = count_records_select('view', 'id IN (' . join(',', array_fill(0, $institutiondata['views'], '?')) . ') AND type != ?', array_merge($institutiondata['viewids'], array('dashboard'))); } else { $count = 0; } $pagination = build_pagination(array('id' => 'stats_pagination', 'url' => get_config('wwwroot') . 'admin/users/statistics.php?institution=' . $institutiondata['name'] . '&type=views', 'jsonscript' => 'admin/users/statistics.json.php', 'datatable' => 'statistics_table', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'extradata' => array('institution' => $institutiondata['name']), 'setlimit' => true)); $result = array('count' => $count, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']); if ($count < 1) { return $result; } $viewdata = get_records_sql_assoc("SELECT\n v.id, v.title, v.owner, v.group, v.institution, v.visits, v.type, v.ownerformat, v.urlid\n FROM {view} v\n WHERE v.id IN (" . join(',', array_fill(0, $institutiondata['views'], '?')) . ") AND v.type != ?\n ORDER BY v.visits DESC, v.title, v.id", array_merge($institutiondata['viewids'], array('dashboard')), $offset, $limit); require_once 'view.php'; require_once 'group.php'; View::get_extra_view_info($viewdata, false, false); safe_require('artefact', 'comment'); $comments = ArtefactTypeComment::count_comments(array_keys($viewdata)); foreach ($viewdata as &$v) { $v = (object) $v; if ($v->owner) { $v->ownername = display_name($v->user); $v->ownerurl = profile_url($v->user); } else { $v->ownername = $v->sharedby; if ($v->group) { $v->ownerurl = group_homepage_url($v->groupdata); } else { if ($v->institution && $v->institution != 'mahara') { $v->ownerurl = get_config('wwwroot') . 'institution/index.php?institution=' . $v->institution; } } } $v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0; } $csvfields = array('title', 'displaytitle', 'fullurl', 'owner', 'group', 'institution', 'ownername', 'ownerurl', 'visits', 'type', 'comments'); $USER->set_download_file(generate_csv($viewdata, $csvfields), 'viewstatistics.csv', 'text/csv'); $result['csv'] = true; $smarty = smarty_core(); $smarty->assign('data', $viewdata); $smarty->assign('offset', $offset); $result['tablerows'] = $smarty->fetch('admin/viewstats.tpl'); return $result; }
function addmember_submit(Pieform $form, $values) { global $USER, $SESSION, $userid; $group = get_record('group', 'id', $values['group']); $ctitle = $group->name; $adduser = get_record('usr', 'id', $userid); try { group_add_user($values['group'], $userid, 'member'); $lang = get_user_language($userid); require_once get_config('libroot') . 'activity.php'; activity_occurred('maharamessage', array('users' => array($userid), 'subject' => get_string_from_language($lang, 'addedtogroupsubject', 'group'), 'message' => get_string_from_language($lang, 'addedtogroupmessage', 'group', display_name($USER, $adduser), $ctitle), 'url' => group_homepage_url($group, false), 'urltext' => $ctitle)); $SESSION->add_ok_msg(get_string('useradded', 'group')); } catch (SQLException $e) { $SESSION->add_error_msg(get_string('adduserfailed', 'group')); } redirect(profile_url($adduser)); }
/** * Generate sitemap(s) and an index * * @return bool */ public function generate() { // check that the sitemaps directory exists and create it if it doesn't check_dir_exists($this->directory, true); // this is used by PluginInteractionForum::get_active_topics $USER = new User(); // create a new sitemap $this->create_sitemap(); // get a list of public groups $publicgroups = get_records_select_array('group', 'public = 1 AND deleted = 0'); if (!empty($publicgroups)) { foreach ($publicgroups as $group) { if (isset($group->mtime) && $this->check_date($group->mtime)) { // each group gets a url entry $groupurl = group_homepage_url($group); $groupurl = utf8_encode(htmlspecialchars($groupurl, ENT_QUOTES, 'UTF-8')); $grouplastmod = format_date(strtotime($group->mtime), 'strftimew3cdate'); $this->add_url($groupurl, $grouplastmod); } // build a list of forums in each public group $forums = get_forum_list($group->id); $forumids = array(); foreach ($forums as $forum) { $forumids[] = $forum->id; } // active topics within the specified forums (public only) $activetopics = PluginInteractionForum::get_active_topics(0, 0, 0, $forumids); foreach ($activetopics['data'] as $topic) { if (isset($topic->mtime) && $this->check_date($topic->mtime) || isset($topic->ctime) && $this->check_date($topic->ctime)) { $forumurl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topic->id; $forumurl = utf8_encode(htmlspecialchars($forumurl, ENT_QUOTES, 'UTF-8')); // mtime will be set if the last post has been edited if (isset($topic->mtime) && strtotime($topic->mtime) !== FALSE) { $forumlastmod = format_date(strtotime($topic->mtime), 'strftimew3cdate'); } else { $forumlastmod = format_date(strtotime($topic->ctime), 'strftimew3cdate'); } $this->add_url($forumurl, $forumlastmod); } } } } // views shared with the public // grouphomepage type views are handled above $types = array('portfolio'); $views = View::view_search(null, null, null, null, null, 0, true, null, $types); if (!empty($views->data)) { foreach ($views->data as $view) { if (isset($view['mtime']) && $this->check_date($view['mtime'])) { $viewurl = utf8_encode(htmlspecialchars($view['fullurl'], ENT_QUOTES, 'UTF-8')); $viewlastmod = format_date(strtotime($view['mtime']), 'strftimew3cdate'); $this->add_url($viewurl, $viewlastmod); } } } // add the urlset and print the xml out // only if the urlset has any children if ($this->currenturlset->hasChildNodes()) { $this->save_sitemap(true); } return true; }
foreach ($blocks as $b) { if (!isset($data[$b->artefact]->views)) { $data[$b->artefact]->views = array(); } if (!isset($data[$b->artefact]->views[$b->view])) { $data[$b->artefact]->views[$b->view] = array('view' => $b->view, 'viewtitle' => $b->viewtitle, 'fullurl' => $viewdata[$b->view]['fullurl']); // Add the view owner's name if it's not the same as the note owner. This will either // be a group artefact inside an individual's view, or it's an institution/site artefact. if (!empty($params['group']) && $b->owner || !empty($params['institution']) && $params['institution'] != $b->institution) { if ($b->owner) { $ownername = display_default_name($viewdata[$b->view]['user']); $ownerurl = profile_url($viewdata[$b->view]['user']); } else { if ($b->group) { $ownername = $viewdata[$b->view]['groupdata']['name']; $ownerurl = group_homepage_url($viewdata[$b->view]['groupdata']); } else { if ($b->institution == 'mahara') { $ownername = get_config('sitename'); } else { $ownername = $b->institutionname; $ownerurl = get_config('wwwroot') . 'institution/index.php?institution=' . $b->institution; } } } $data[$b->artefact]->views[$b->view]['ownername'] = $ownername; $data[$b->artefact]->views[$b->view]['ownerurl'] = $ownerurl; } } if (!isset($data[$b->artefact]->blocks)) { $data[$b->artefact]->blocks = array();
$page = 1; } $offset = ($page - 1) * $limit; switch ($type) { case 'friend': $data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id'), 'friends' => true)); break; case 'user': $data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id'))); break; case 'group': require_once 'group.php'; $data = search_group($query, $limit, $offset, ''); $roles = get_records_array('grouptype_roles'); $data['roles'] = array(); foreach ($roles as $r) { $data['roles'][$r->grouptype][] = array('name' => $r->role, 'display' => get_string($r->role, 'grouptype.' . $r->grouptype)); } foreach ($data['data'] as &$r) { $r->url = group_homepage_url($r); } break; default: $data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id'), 'friends' => true)); break; } $more = $data['count'] > $limit * $page; $data['error'] = false; $data['message'] = ''; $data['more'] = $more; json_reply(false, $data);
/** * Returns a datastructure describing the tabs that appear on a group page * * @param object $group Database record of group to get tabs for * @return array */ function group_get_menu_tabs() { static $menu; $group = group_current_group(); if (!$group) { return null; } $role = group_user_access($group->id); $menu = array('info' => array('path' => 'groups/info', 'url' => group_homepage_url($group, false), 'title' => get_string('About', 'group'), 'weight' => 20)); if (group_can_list_members($group, $role)) { $menu['members'] = array('path' => 'groups/members', 'url' => 'group/members.php?id=' . $group->id, 'title' => get_string('Members', 'group'), 'weight' => 30); } if ($interactionplugins = plugins_installed('interaction')) { foreach ($interactionplugins as $plugin) { safe_require('interaction', $plugin->name); $plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'group_menu_items', $group); $menu = array_merge($menu, $plugin_menu); } } $menu['views'] = array('path' => 'groups/views', 'url' => 'view/groupviews.php?group=' . $group->id, 'title' => get_string('Views', 'group'), 'weight' => 50); $menu['collections'] = array('path' => 'groups/collections', 'url' => 'collection/index.php?group=' . $group->id, 'title' => get_string('Collections', 'group'), 'weight' => 60); if (group_role_can_edit_views($group, $role)) { $menu['share'] = array('path' => 'groups/share', 'url' => 'group/shareviews.php?group=' . $group->id, 'title' => get_string('share', 'view'), 'weight' => 70); } if ($role) { safe_require('grouptype', $group->grouptype); $artefactplugins = call_static_method('GroupType' . $group->grouptype, 'get_group_artefact_plugins'); if ($plugins = plugins_installed('artefact')) { foreach ($plugins as &$plugin) { if (!in_array($plugin->name, $artefactplugins)) { continue; } safe_require('artefact', $plugin->name); $plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'group_tabs', $group->id); $menu = array_merge($menu, $plugin_menu); } } } if (group_role_can_access_report($group, $role)) { $menu['report'] = array('path' => 'groups/report', 'url' => 'group/report.php?group=' . $group->id, 'title' => get_string('report', 'group'), 'weight' => 70); } if (defined('MENUITEM')) { $key = substr(MENUITEM, strlen('groups/')); if ($key && isset($menu[$key])) { $menu[$key]['selected'] = true; } } return $menu; }
public function submitted_to() { if ($this->submittedgroup) { $record = get_record('group', 'id', $this->submittedgroup, null, null, null, null, 'id, name, urlid'); $record->url = group_homepage_url($record); } else { if ($this->submittedhost) { $record = get_record('host', 'wwwroot', $this->submittedhost, null, null, null, null, 'wwwroot, name'); $record->url = $record->wwwroot; } else { throw new SystemException("Collection with id " . $this->id . " has not been submitted"); } } return $record; }
function editgroup_submit(Pieform $form, $values) { global $USER, $SESSION, $group_data, $publicallowed; $values['public'] = isset($values['public']) ? $values['public'] : 0; $values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0; $newvalues = array('name' => $group_data->name == $values['name'] ? $values['name'] : trim($values['name']), 'description' => $values['description'], 'grouptype' => $values['grouptype'], 'category' => empty($values['category']) ? null : intval($values['category']), 'open' => intval($values['open']), 'controlled' => intval($values['controlled']), 'request' => intval($values['request']), 'usersautoadded' => intval($values['usersautoadded']), 'public' => $publicallowed ? intval($values['public']) : 0, 'viewnotify' => intval($values['viewnotify']), 'submittableto' => intval($values['submittableto']), 'allowarchives' => intval(!empty($values['allowarchives']) ? $values['allowarchives'] : 0), 'editroles' => $values['editroles'], 'hidden' => intval($values['hidden']), 'hidemembers' => intval(!empty($values['hidemembersfrommembers']) || !empty($values['hidemembers'])), 'hidemembersfrommembers' => intval($values['hidemembersfrommembers']), 'groupparticipationreports' => intval($values['groupparticipationreports']), 'invitefriends' => intval($values['invitefriends']), 'suggestfriends' => intval($values['suggestfriends']), 'editwindowstart' => db_format_timestamp($values['editwindowstart']), 'editwindowend' => db_format_timestamp($values['editwindowend']), 'sendnow' => intval($values['sendnow']), 'feedbacknotify' => intval($values['feedbacknotify'])); if (get_config('cleanurls') && isset($values['urlid']) && '' !== (string) $values['urlid']) { $newvalues['urlid'] = $values['urlid']; } db_begin(); if (!$group_data->id) { $newvalues['members'] = array($USER->get('id') => 'admin'); $group_data->id = group_create($newvalues); $USER->reset_grouproles(); } // Now update the description with any embedded image info $newvalues['description'] = EmbeddedImage::prepare_embedded_images($newvalues['description'], 'group', $group_data->id, $group_data->id); $newvalues['id'] = $group_data->id; unset($newvalues['members']); group_update((object) $newvalues); $SESSION->add_ok_msg(get_string('groupsaved', 'group')); db_commit(); // Reload $group_data->urlid or else the redirect will fail if (get_config('cleanurls') && (!isset($values['urlid']) || $group_data->urlid != $values['urlid'])) { $group_data->urlid = get_field('group', 'urlid', 'id', $group_data->id); } redirect(group_homepage_url($group_data)); }
function get_groups_for_user($username) { global $REMOTEWWWROOT, $USER; list($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT); if (!$user) { return false; } require_once 'group.php'; $USER->reanimate($user->id, $authinstance->instanceid); $groupdata = group_get_associated_groups($USER->get('id'), 'all', null, null); $data = new stdclass(); $data->data = array(); $data->count = $groupdata['count']; $data->displayname = display_name($user); if ($data->count) { foreach ($groupdata['groups'] as $g) { $groupurl = group_homepage_url($g, false); $record = array(); $record['id'] = $g->id; $record['name'] = $g->name; $record['description'] = $g->description; $record['public'] = $g->public; $record['jointype'] = $g->jointype; $record['grouptype'] = $g->grouptype; $record['membershiptype'] = $g->membershiptype; $record['role'] = $g->role; $record['url'] = '/' . $groupurl; $record['fullurl'] = get_config('wwwroot') . $groupurl; $data->data[] = $record; } } return $data; }
/** * Given a list of artefact ids, return a name and url for the thing that * owns each artefact, suitable for display. * * @param array $ids list of artefact ids * * @return array list of StdClass objects, each containing a name & url property */ function artefact_get_owner_info($ids) { $data = get_records_sql_assoc(' SELECT a.id AS aid, a.owner, a.group, a.institution, u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.urlid, g.name AS groupname, g.urlid as groupurlid, i.displayname FROM {artefact} a LEFT JOIN {usr} u ON a.owner = u.id LEFT JOIN {group} g ON a.group = g.id LEFT JOIN {institution} i ON a.institution = i.name WHERE a.id IN (' . join(',', array_fill(0, count($ids), '?')) . ')', $ids); $wwwroot = get_config('wwwroot'); foreach ($data as &$d) { if ($d->institution == 'mahara') { $name = get_config('sitename'); $url = $wwwroot; } else { if ($d->institution) { $name = $d->displayname; $url = $wwwroot . 'institution/index.php?institution=' . $d->institution; } else { if ($d->group) { $name = $d->groupname; $url = group_homepage_url((object) array('id' => $d->group, 'urlid' => $d->groupurlid)); } else { $name = display_name($d); $url = profile_url($d); } } } $d = (object) array('name' => $name, 'url' => $url); } return $data; }
public static function get_active_topics($limit, $offset, $category, $forumids = array()) { global $USER; if (is_postgres()) { $lastposts = ' SELECT DISTINCT ON (topic) topic, id, poster, subject, body, ctime FROM {interaction_forum_post} p WHERE p.deleted = 0 ORDER BY topic, ctime DESC'; } else { if (is_mysql()) { $lastposts = ' SELECT topic, id, poster, subject, body, ctime FROM ( SELECT topic, id, poster, subject, body, ctime FROM {interaction_forum_post} WHERE deleted = 0 ORDER BY ctime DESC ) temp1 GROUP BY topic'; } } $values = array(); $from = ' FROM {interaction_forum_topic} t JOIN {interaction_instance} f ON t.forum = f.id JOIN {group} g ON f.group = g.id'; // user is not anonymous if ($USER->get('id') > 0) { $from .= ' JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ?) '; $values[] = $USER->get('id'); } $from .= ' JOIN {interaction_forum_post} first ON (first.topic = t.id AND first.parent IS NULL) JOIN (' . $lastposts . ' ) last ON last.topic = t.id'; $where = ' WHERE g.deleted = 0 AND f.deleted = 0 AND t.deleted = 0'; if (!empty($category)) { $where .= ' AND g.category = ?'; $values[] = (int) $category; } if (!empty($forumids)) { $where .= ' AND f.id IN (' . join(',', array_fill(0, count($forumids), '?')) . ')'; $values = array_merge($values, $forumids); } $result = array('count' => count_records_sql('SELECT COUNT(*) ' . $from . $where, $values), 'limit' => $limit, 'offset' => $offset, 'data' => array()); if (!$result['count']) { return $result; } $select = ' SELECT t.id, t.forum AS forumid, f.title AS forumname, g.id AS groupid, g.name AS groupname, g.urlid, first.subject AS topicname, first.poster AS firstpostby, last.id AS postid, last.poster, last.subject, last.body, last.ctime, edits.ctime as mtime, COUNT(posts.id) AS postcount'; $from .= ' LEFT JOIN {interaction_forum_post} posts ON posts.topic = t.id LEFT JOIN {interaction_forum_edit} edits ON edits.post = last.id'; $sort = ' GROUP BY t.id, t.forum, f.title, g.id, g.name, g.urlid, first.subject, first.poster, last.id, last.poster, last.subject, last.body, last.ctime, edits.ctime ORDER BY last.ctime DESC'; $result['data'] = get_records_sql_array($select . $from . $where . $sort, $values, $offset, $limit); foreach ($result['data'] as &$r) { $r->groupurl = group_homepage_url((object) array('id' => $r->groupid, 'urlid' => $r->urlid)); } return $result; }
public function render_exception() { global $USER, $SESSION; if (defined('GROUP') && $USER->is_logged_in()) { $roles = $USER->get('grouproles'); if (!isset($roles[GROUP])) { $group = group_current_group(); if ($group->jointype == 'open' || get_record('group_member_invite', 'group', GROUP, 'member', $USER->get('id'))) { $message = get_string('notmembermayjoin', 'group', $group->name); // Error code equals 1 if we have objection=1 in url if ($this->getCode() == '1') { $message .= ' ' . get_string('accessdeniedobjection', 'error'); } $SESSION->add_error_msg($message); $next = substr($_SERVER['REQUEST_URI'], strlen(get_mahara_install_subdirectory()) - 1); $goto = group_homepage_url($group); $goto .= (strpos($goto, '?') ? '&' : '?') . 'next=' . urlencode($next); redirect($goto); } if ($group->request && !get_record('group_member_request', 'group', GROUP, 'member', $USER->get('id'))) { $SESSION->add_error_msg(get_string('notamember', 'group')); redirect(get_config('wwwroot') . 'group/requestjoin.php?id=' . GROUP . '&returnto=view'); } } } header("HTTP/1.0 403 Forbidden", true); return parent::render_exception(); }
$_fh0_data = (is_string($tmp=(isset($this->scope["views"]) ? $this->scope["views"] : null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp); if ($this->isArray($_fh0_data) === true) { foreach ($_fh0_data as $this->scope['view']) { /* -- foreach start output */ ?> <div class="<?php echo $this->classCall('cycle', array('default', 'r0,r1', true, true, ',', null, false));?> listrow"> <h3 class="title"><a href="<?php echo (is_string($tmp=$this->scope["view"]["fullurl"]) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?>"><?php echo (is_string($tmp=$this->scope["view"]["title"]) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?></a></h3> <div class="detail"><?php echo preg_replace('#<[^>]*>#', ' ', str_shorten_html((isset($this->scope["view"]["description"]) ? $this->scope["view"]["description"]:null), 100, true));?></div> <?php if ((is_string($tmp=(isset($this->scope["view"]["sharedby"]) ? $this->scope["view"]["sharedby"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <div class="groupuserdate"> <?php if ((is_string($tmp=(isset($this->scope["view"]["group"]) ? $this->scope["view"]["group"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp) && (is_string($tmp=(isset($this->scope["loggedin"]) ? $this->scope["loggedin"] : null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <a href="<?php echo group_homepage_url((is_string($tmp=(isset($this->scope["view"]["groupdata"]) ? $this->scope["view"]["groupdata"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp));?>"><?php echo (is_string($tmp=$this->scope["view"]["sharedby"]) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp);?></a> <?php } elseif ((is_string($tmp=(isset($this->scope["view"]["owner"]) ? $this->scope["view"]["owner"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp) && (is_string($tmp=(isset($this->scope["loggedin"]) ? $this->scope["loggedin"] : null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <?php if ((is_string($tmp=(isset($this->scope["view"]["anonymous"]) ? $this->scope["view"]["anonymous"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <?php if ((is_string($tmp=(isset($this->scope["view"]["staff_or_admin"]) ? $this->scope["view"]["staff_or_admin"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)) { ?> <?php echo $this->assignInScope((is_string($tmp=(isset($this->scope["view"]["sharedby"]) ? $this->scope["view"]["sharedby"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp), 'realauthor');?> <?php echo $this->assignInScope(profile_url((is_string($tmp=(isset($this->scope["view"]["user"]) ? $this->scope["view"]["user"]:null)) ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)), 'realauthorlink');?> <?php }?>