本文整理汇总了PHP中group_user_access函数的典型用法代码示例。如果您正苦于以下问题:PHP group_user_access函数的具体用法?PHP group_user_access怎么用?PHP group_user_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了group_user_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
if ($group = self::get_group($instance)) {
require_once 'group.php';
$role = group_user_access($group->id);
if ($role || $group->public) {
$limit = 5;
$configdata = $instance->get('configdata');
if (!empty($configdata['limit'])) {
$limit = intval($configdata['limit']);
}
$foruminfo = get_records_sql_array('
SELECT
p.id, p.subject, p.body, p.poster, p.topic, t.forum, pt.subject AS topicname,
u.firstname, u.lastname, u.username, u.preferredname, u.email, u.profileicon, u.admin, u.staff, u.deleted, u.urlid
FROM
{interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic)
INNER JOIN {interaction_instance} i ON (i.id = t.forum)
INNER JOIN {interaction_forum_post} pt ON (pt.topic = p.topic AND pt.parent IS NULL)
INNER JOIN {usr} u ON p.poster = u.id
WHERE
i.group = ?
AND i.deleted = 0
AND t.deleted = 0
AND p.deleted = 0
ORDER BY
p.ctime DESC', array($group->id), 0, $limit);
if ($foruminfo) {
$userfields = array('firstname', 'lastname', 'username', 'preferredname', 'email', 'profileicon', 'admin', 'staff', 'deleted', 'urlid');
foreach ($foruminfo as $f) {
$f->author = (object) array('id' => $f->poster);
foreach ($userfields as $uf) {
$f->author->{$uf} = $f->{$uf};
unset($f->{$uf});
}
}
}
$smarty = smarty_core();
$smarty->assign('group', $group);
$smarty->assign('foruminfo', $foruminfo);
if ($instance->get_view()->get('type') == 'grouphomepage') {
return $smarty->fetch('blocktype:recentforumposts:latestforumposts.tpl');
}
return $smarty->fetch('blocktype:recentforumposts:recentforumposts.tpl');
}
}
return '';
}
示例2: notrude_form
/**
* Returns a form to mark a view as unobjectionable,
* if the user is allowed to do that.
*
* @returns array Form elements.
*/
function notrude_form()
{
global $USER, $view, $artefact;
$owner = $view->get('owner');
if (!($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)) || $view->get('group') && $USER->get('admin') || $view->get('group') && group_user_access($view->get('group'), $USER->get('id')) == 'admin')) {
return;
}
if ($artefact) {
$params = array('artefact', $artefact->get('id'));
} else {
$params = array('view', $view->get('id'));
}
$isrude = get_record_select('objectionable', 'objecttype = ? AND objectid = ? AND resolvedby IS NULL LIMIT 1', $params);
if (!$isrude) {
return;
}
return array('name' => 'notrude_form', 'class' => 'form-inline', 'method' => 'post', 'elements' => array('objection' => array('type' => 'hidden', 'value' => $isrude->id), 'text' => array('type' => 'html', 'class' => 'pbm', 'value' => get_string('viewobjectionableunmark', 'view')), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-default', 'value' => '<span class="icon icon-lg icon-times text-danger prs"></span> ' . get_string('notobjectionable'))));
}
示例3: notrude_form
/**
* Returns a form to mark a view as unobjectionable,
* if the user is allowed to do that.
*
* @returns array Form elements.
*/
function notrude_form()
{
global $USER, $view, $artefact;
$owner = $view->get('owner');
if (!($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)) || $view->get('group') && $USER->get('admin') || $view->get('group') && group_user_access($view->get('group'), $USER->get('id')) == 'admin')) {
return;
}
if ($artefact) {
$params = array('artefact', $artefact->get('id'));
} else {
$params = array('view', $view->get('id'));
}
$isrude = get_record_select('objectionable', 'objecttype = ? AND objectid = ? AND resolvedby IS NULL LIMIT 1', $params);
if (!$isrude) {
return;
}
return array('name' => 'notrude_form', 'method' => 'post', 'elements' => array('objection' => array('type' => 'hidden', 'value' => $isrude->id), 'text' => array('type' => 'html', 'value' => get_string('viewobjectionableunmark', 'view')), 'submit' => array('type' => 'submit', 'value' => get_string('notobjectionable'))));
}
示例4: groupadminsform_submit
function groupadminsform_submit(Pieform $form, $values)
{
global $SESSION, $group, $admins;
$newadmins = array_diff($values['admins'], $admins);
$demoted = array_diff($admins, $values['admins']);
db_begin();
if ($demoted) {
$demoted = join(',', array_map('intval', $demoted));
execute_sql("\n UPDATE {group_member}\n SET role = 'member'\n WHERE role = 'admin' AND \"group\" = ?\n AND member IN ({$demoted})", array($group->id));
}
$dbnow = db_format_timestamp(time());
foreach ($newadmins as $id) {
if (group_user_access($group->id, $id)) {
group_change_role($group->id, $id, 'admin');
} else {
group_add_user($group->id, $id, 'admin');
}
}
db_commit();
$SESSION->add_ok_msg(get_string('groupadminsupdated', 'admin'));
redirect(get_config('wwwroot') . 'admin/groups/groups.php');
}
示例5: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
if ($group = self::get_group($instance)) {
require_once 'group.php';
$role = group_user_access($group->id);
if ($role || $group->public) {
$limit = 5;
$configdata = $instance->get('configdata');
if (!empty($configdata['limit'])) {
$limit = intval($configdata['limit']);
}
$foruminfo = get_records_sql_array('
SELECT
p.id, p.subject, p.body, p.poster, p.topic, t.forum, pt.subject AS topicname
FROM
{interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic)
INNER JOIN {interaction_instance} i ON (i.id = t.forum)
INNER JOIN {interaction_forum_post} pt ON (pt.topic = p.topic AND pt.parent IS NULL)
WHERE
i.group = ?
AND i.deleted = 0
AND t.deleted = 0
AND p.deleted = 0
ORDER BY
p.ctime DESC', array($group->id), 0, $limit);
$smarty = smarty_core();
$smarty->assign('group', $group);
$smarty->assign('foruminfo', $foruminfo);
if ($instance->get_view()->get('type') == 'grouphomepage') {
return $smarty->fetch('blocktype:recentforumposts:latestforumposts.tpl');
}
return $smarty->fetch('blocktype:recentforumposts:recentforumposts.tpl');
}
}
return '';
}
示例6: param_integer
$userid = param_integer('userid');
$jointype = param_variable('jointype');
// Prevent group membership changing done by ordinary members, Tutors can only
// add members to group and cannot remove anyone. Group admins can do anything.
// With regard to invitation, both admins and tutors can invite people.
foreach (array_unique(array_merge($initialgroups, $resultgroups)) as $groupid) {
if (!group_user_access($groupid)) {
json_reply('local', get_string('accessdenied', 'error'));
break;
}
switch (group_user_access($groupid)) {
case 'member':
json_reply('local', get_string('accessdenied', 'error'));
break;
case 'tutor':
if ($usertype = group_user_access($groupid, $userid)) {
if ($usertype == 'member' && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
json_reply('local', get_string('cantremovemember', 'group'));
} elseif ($usertype != 'member' && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
json_reply('local', get_string('cantremoveuserisadmin', 'group'));
}
}
}
}
$groupdata = get_records_select_assoc('group', 'id IN (' . join(',', array_unique(array_merge($initialgroups, $resultgroups))) . ')');
if ($jointype == 'controlled') {
db_begin();
//remove group membership
if ($groupstoremove = array_diff($initialgroups, $resultgroups)) {
$groupstoremovemail = '';
foreach ($groupstoremove as $groupid) {
示例7: group_get_groupinfo_data
function group_get_groupinfo_data($group)
{
safe_require('artefact', 'file');
safe_require('interaction', 'forum');
$group->admins = group_get_admins(array($group->id));
$group->settingsdescription = group_display_settings($group);
if (get_config('allowgroupcategories')) {
$group->categorytitle = $group->category ? get_field('group_category', 'title', 'id', $group->category) : '';
}
if (group_can_list_members($group, group_user_access($group->id))) {
$group->membercount = count_records('group_member', 'group', $group->id);
}
$group->viewcount = count_records('view', 'group', $group->id);
$group->filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
$group->forumcounts = PluginInteractionForum::count_group_forums($group->id);
$group->topiccounts = PluginInteractionForum::count_group_topics($group->id);
$group->postcounts = PluginInteractionForum::count_group_posts($group->id);
return $group;
}
示例8: array
if (empty($c->author)) {
if (!isset($commenters[$c->authorname])) {
$commenters[$c->authorname] = array();
}
$commenters[$c->authorname]['commenter'] = $c->authorname;
$commenters[$c->authorname]['count'] = isset($commenters[$c->authorname]['count']) ? $commenters[$c->authorname]['count'] + 1 : 1;
if ($commenters[$c->authorname]['count'] == 1) {
$extcommenters++;
}
$extcomments++;
} else {
if (!isset($commenters[$c->author->id])) {
$commenters[$c->author->id] = array();
}
$commenters[$c->author->id]['commenter'] = (int) $c->author->id;
$commenters[$c->author->id]['member'] = group_user_access($group->id, $c->author->id);
$commenters[$c->author->id]['count'] = isset($commenters[$c->author->id]['count']) ? $commenters[$c->author->id]['count'] + 1 : 1;
if (empty($commenters[$c->author->id]['member'])) {
if ($commenters[$c->author->id]['count'] == 1) {
$extcommenters++;
}
$extcomments++;
} else {
if ($commenters[$c->author->id]['count'] == 1) {
$membercommenters++;
}
$membercomments++;
}
}
}
$data['id'] = (int) $data['id'];
示例9: define
*
*/
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');
$userid = param_integer('user');
define('GROUP', $groupid);
$group = group_current_group();
$user = get_record('usr', 'id', $userid, 'deleted', 0);
if (!$user) {
throw new UserNotFoundException(get_string('usernotfound', 'group', $userid));
}
if ($group->jointype != 'invite' || group_user_access($groupid) != 'admin') {
throw new AccessDeniedException(get_string('cannotinvitetogroup', 'group'));
}
if (record_exists('group_member', 'group', $groupid, 'member', $userid) || record_exists('group_member_invite', 'group', $groupid, 'member', $userid)) {
throw new UserException(get_string('useralreadyinvitedtogroup', 'group'));
}
define('TITLE', get_string('invitemembertogroup', 'group', display_name($userid), $group->name));
$roles = group_get_role_info($groupid);
foreach ($roles as $k => &$v) {
$v = $v->display;
}
safe_require('grouptype', $group->grouptype);
$form = pieform(array('name' => 'invitetogroup', 'autofocus' => false, 'method' => 'post', 'elements' => array('reason' => array('type' => 'textarea', 'cols' => 50, 'rows' => 4, 'title' => get_string('reason')), 'role' => array('type' => 'select', 'options' => $roles, 'title' => get_string('Role', 'group'), 'defaultvalue' => call_static_method('GroupType' . $group->grouptype, 'default_role')), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('invite', 'group'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'user/view.php?id=' . $userid))));
$smarty = smarty();
$smarty->assign('subheading', TITLE);
$smarty->assign('form', $form);
示例10: get_data
protected static function get_data($groupid, $editing = false)
{
global $USER;
if (!defined('GROUP')) {
define('GROUP', $groupid);
}
// get the currently requested group
$group = group_current_group();
$role = group_user_access($group->id);
if ($role) {
$bi = group_get_homepage_view_groupview_block($group->id);
$configdata = $bi->get('configdata');
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$limit = $limit > 0 ? $limit : 5;
// Get all views created in the group
$sort = array(array('column' => 'type=\'grouphomepage\'', 'desc' => true));
$data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, 0, true, $sort);
foreach ($data['groupviews']->data as &$view) {
if (!$editing && isset($view['template']) && $view['template']) {
$view['form'] = pieform(create_view_form(null, null, $view['id']));
}
}
// For group members, display a list of views that others have
// shared to the group
$data['sharedviews'] = View::get_sharedviews_data($limit, 0, $group->id);
foreach ($data['sharedviews']->data as &$view) {
if (!$editing && isset($view['template']) && $view['template']) {
$view['form'] = pieform(create_view_form($group, null, $view->id));
}
}
$data['sharedcollections'] = View::get_sharedcollections_data($limit, 0, $group->id);
if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
// Display a list of views submitted to the group
list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id);
$allsubmitted = array_merge(array_values($collections), array_values($views));
$data['allsubmitted'] = array('data' => array_slice($allsubmitted, 0, $limit), 'count' => count($allsubmitted), 'limit' => $limit, 'offset' => 0);
}
}
if ($group->submittableto) {
require_once 'pieforms/pieform.php';
// A user can submit more than one view to the same group, but no view can be
// submitted to more than one group.
// Display a list of views this user has submitted to this group, and a submission
// form containing drop-down of their unsubmitted views.
list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id);
$data['mysubmitted'] = array_merge(array_values($collections), array_values($views));
// Only render the submission form in viewing mode
if (!$editing) {
$data['group_view_submission_form'] = group_view_submission_form($group->id);
}
}
$data['group'] = $group;
return $data;
}
示例11: group_get_menu_tabs
/**
* 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;
}
$menu = array('info' => array('path' => 'groups/info', 'url' => 'group/view.php?id=' . $group->id, 'title' => get_string('About', 'group'), 'weight' => 20), 'members' => array('path' => 'groups/members', 'url' => 'group/members.php?id=' . $group->id, 'title' => get_string('Members', 'group'), 'weight' => 30));
if ($group->public || group_user_access($group->id)) {
$menu['forums'] = array('path' => 'groups/forums', 'url' => 'interaction/forum/index.php?group=' . $group->id, 'title' => get_string('nameplural', 'interaction.forum'), 'weight' => 40);
}
$menu['views'] = array('path' => 'groups/views', 'url' => 'view/groupviews.php?group=' . $group->id, 'title' => get_string('Views', 'group'), 'weight' => 50);
if (group_user_access($group->id)) {
safe_require('grouptype', $group->grouptype);
$artefactplugins = call_static_method('GroupType' . $group->grouptype, 'get_group_artefact_plugins');
if ($plugins = get_records_array('artefact_installed', 'active', 1)) {
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 (defined('MENUITEM')) {
$key = substr(MENUITEM, strlen('groups/'));
if ($key && isset($menu[$key])) {
$menu[$key]['selected'] = true;
}
}
return $menu;
}
示例12: add_user_to_autoadd_groups
/**
* Given a user, makes sure they have been added to all groups that are marked
* as ones that users should be auto-added to
*
* @param array $eventdata Event data passed from activity_occured, the key 'id' = userid
*/
function add_user_to_autoadd_groups($eventdata)
{
require_once 'group.php';
$userid = $eventdata['id'];
if ($autoaddgroups = get_column('group', 'id', 'usersautoadded', true)) {
foreach ($autoaddgroups as $groupid) {
if (!group_user_access($groupid, $userid)) {
group_add_user($groupid, $userid);
}
}
}
}
示例13: get_views_and_collections
/**
* Get all views for a (user,group,institution), grouping views
* into their collections. Empty collections not returned.
*
* @param mixed $owner integer userid or array of userids
* @param mixed $group integer groupid or array of groupids
* @param mixed $institution string institution name or array of institution names
* @param string $matchconfig record all matches with given config hash (see set_access)
* @param boolean $includeprofile include profile view
* @param integer $submittedgroup return only views & collections submitted to this group
* @param $string $sort Order to sort by (defaults to 'c.name, v.title')
*
* @return array, array
*/
function get_views_and_collections($owner = null, $group = null, $institution = null, $matchconfig = null, $includeprofile = true, $submittedgroup = null, $sort = null)
{
$excludelocked = $group && group_user_access($group) != 'admin';
// Anonymous public viewing of a group with 'Allow submissions' checked needs to avoid including the dummy root profile page.
if ($owner == '0') {
$includeprofile = false;
}
$sql = "\n SELECT v.id, v.type, v.title, v.accessconf, v.ownerformat, v.startdate, v.stopdate, v.template,\n v.owner, v.group, v.institution, v.urlid, v.submittedgroup, v.submittedhost, " . db_format_tsfield('v.submittedtime', 'submittedtime') . ", v.submittedstatus,\n c.id AS cid, c.name AS cname,\n c.submittedgroup AS csubmitgroup, c.submittedhost AS csubmithost, " . db_format_tsfield('c.submittedtime', 'csubmittime') . ", c.submittedstatus AS csubmitstatus\n FROM {view} v\n LEFT JOIN {collection_view} cv ON v.id = cv.view\n LEFT JOIN {collection} c ON cv.collection = c.id\n WHERE v.type IN ('portfolio'";
$sql .= $includeprofile ? ", 'profile') " : ') ';
$sql .= $excludelocked ? 'AND v.locked != 1 ' : '';
if (is_null($owner) && is_null($group) && is_null($institution)) {
$values = array();
} else {
list($ownersql, $values) = self::multiple_owner_sql((object) array('owner' => $owner, 'group' => $group, 'institution' => $institution));
$sql .= "AND v.{$ownersql} ";
}
if ($submittedgroup) {
$sql .= 'AND v.submittedgroup = ? ';
$values[] = (int) $submittedgroup;
}
if ($sort == null) {
$sql .= 'ORDER BY c.name, v.title';
} else {
$sql .= "ORDER BY {$sort}";
}
$records = get_records_sql_assoc($sql, $values);
$collections = array();
$views = array();
if (!$records) {
return array($collections, $views);
}
self::get_extra_view_info($records, false, false);
foreach ($records as &$r) {
$vid = $r['id'];
$cid = $r['cid'];
$v = array('id' => $vid, 'type' => $r['type'], 'name' => $r['displaytitle'], 'url' => $r['fullurl'], 'startdate' => $r['startdate'], 'stopdate' => $r['stopdate'], 'template' => $r['template'], 'owner' => $r['owner'], 'submittedgroup' => $r['submittedgroup'], 'submittedhost' => $r['submittedhost'], 'submittedtime' => $r['submittedtime'], 'submittedstatus' => $r['submittedstatus']);
if (isset($r['user'])) {
$v['ownername'] = display_name($r['user']);
$v['ownerurl'] = profile_url($r['user']);
}
// If filtering by submitted views, and the view is submitted, but the collection isn't,
// then ignore the collection and return the view by itself.
if ($cid && (!$submittedgroup || $r['csubmitgroup'] == $r['submittedgroup'])) {
if (!isset($collections[$cid])) {
$collections[$cid] = array('id' => $cid, 'name' => $r['cname'], 'url' => $r['fullurl'], 'owner' => $r['owner'], 'group' => $r['group'], 'institution' => $r['institution'], 'submittedgroup' => $r['csubmitgroup'], 'submittedhost' => $r['csubmithost'], 'submittedtime' => $r['csubmittime'], 'submittedstatus' => $r['csubmitstatus'], 'template' => $r['template'], 'views' => array());
if (isset($r['user'])) {
$collections[$cid]['ownername'] = $v['ownername'];
$collections[$cid]['ownerurl'] = $v['ownerurl'];
}
if ($matchconfig && $matchconfig == $r['accessconf']) {
$collections[$cid]['match'] = true;
}
}
$collections[$cid]['views'][$vid] = $v;
} else {
$views[$vid] = $v;
if ($matchconfig && $matchconfig == $r['accessconf']) {
$views[$vid]['match'] = true;
}
}
}
return array($collections, $views);
}
示例14: get_sharedviews_data
/**
* Get views which have been explicitly shared to a group and are
* not owned by the group
*/
public static function get_sharedviews_data($limit = 10, $offset = 0, $groupid)
{
global $USER;
$userid = $USER->get('id');
require_once get_config('libroot') . 'group.php';
if (!group_user_access($groupid)) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$from = '
FROM {view} v
INNER JOIN {view_access} a ON (a.view = v.id)
INNER JOIN {group_member} m ON (a.group = m.group AND (a.role = m.role OR a.role IS NULL))
WHERE a.group = ? AND m.member = ? AND (v.group IS NULL OR v.group != ?)';
$ph = array($groupid, $userid, $groupid);
$count = count_records_sql('SELECT COUNT(*) ' . $from, $ph);
$viewdata = get_records_sql_assoc('
SELECT v.id,v.title,v.startdate,v.stopdate,v.description,v.group,v.owner,v.ownerformat,v.institution ' . $from . '
ORDER BY v.title, v.id', $ph, $offset, $limit);
if ($viewdata) {
View::get_extra_view_info($viewdata, false);
} else {
$viewdata = array();
}
return (object) array('data' => array_values($viewdata), 'count' => $count);
}
示例15: can_see_attached_file
/**
* Given a post id & the id of an image artefact, check that the logged-in user
* has permission to see the image in the context of the post.
*/
public static function can_see_attached_file($file, $postid)
{
global $USER;
require_once 'group.php';
if (!$file instanceof ArtefactTypeImage) {
return false;
}
$post = get_record_sql('
SELECT
p.body, p.poster, g.id AS groupid, g.public
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic AND t.deleted = 0)
INNER JOIN {interaction_forum_post} fp ON (fp.parent IS NULL AND fp.topic = t.id)
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted = 0)
INNER JOIN {group} g ON (f.group = g.id AND g.deleted = 0)
WHERE p.id = ? AND p.deleted = 0', array($postid));
if (!$post) {
return false;
}
if (!$post->public && !group_user_access($post->groupid, $USER->get('id'))) {
return false;
}
// Check that the author of the post is allowed to publish the file
$poster = new User();
$poster->find_by_id($post->poster);
if (!$poster->can_publish_artefact($file)) {
return false;
}
// Load the post as an html fragment & make sure it has the image in it
$page = new DOMDocument();
libxml_use_internal_errors(true);
$success = $page->loadHTML($post->body);
libxml_use_internal_errors(false);
if (!$success) {
return false;
}
$xpath = new DOMXPath($page);
$srcstart = get_config('wwwroot') . 'artefact/file/download.php?file=' . $file->get('id') . '&';
$query = '//img[starts-with(@src,"' . $srcstart . '")]';
$elements = $xpath->query($query);
if ($elements->length < 1) {
return false;
}
return true;
}