当前位置: 首页>>代码示例>>PHP>>正文


PHP group_get_user_groups函数代码示例

本文整理汇总了PHP中group_get_user_groups函数的典型用法代码示例。如果您正苦于以下问题:PHP group_get_user_groups函数的具体用法?PHP group_get_user_groups怎么用?PHP group_get_user_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了group_get_user_groups函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render_instance

 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $sort = !empty($configdata['sort']) ? $configdata['sort'] : null;
     $limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null;
     $view = $instance->get_view();
     $baseurl = $view->get('type') == 'dashboard' ? $view->get_url() . '?id=' . $view->get('id') : $view->get_url();
     $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
     $userid = $view->get('owner');
     if (!$userid) {
         return '';
     }
     $smarty = smarty_core();
     require_once 'group.php';
     // Group stuff
     if (!empty($limit)) {
         list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, 0);
     } else {
         $usergroups = group_get_user_groups($userid, null, $sort);
         $count = count($usergroups);
     }
     foreach ($usergroups as $group) {
         $group->roledisplay = get_string($group->role, 'grouptype.' . $group->grouptype);
     }
     $groups = array('data' => $usergroups, 'count' => $count, 'limit' => $limit, 'offset' => 0);
     $pagination = array('baseurl' => $baseurl, 'id' => 'mygroups_pagination', 'datatable' => 'usergroupstable', 'jsonscript' => 'blocktype/mygroups/mygroups.json.php', 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group'));
     self::render_items($groups, 'blocktype:mygroups:mygroupslist.tpl', $configdata, $pagination);
     $smarty->assign('USERGROUPS', $groups);
     $smarty->assign('userid', $userid);
     return $smarty->fetch('blocktype:mygroups:mygroups.tpl');
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:31,代码来源:lib.php

示例2: pieform_element_filebrowser_configure_tabs

function pieform_element_filebrowser_configure_tabs($viewowner, $prefix)
{
    if ($viewowner['type'] == 'institution' && $viewowner['id'] == 'mahara') {
        // No filebrowser tabs for site views
        return null;
    }
    $tabs = array();
    $subtabs = array();
    $upload = null;
    $selectedsubtab = null;
    if ($viewowner['type'] == 'institution') {
        $selectedtab = param_variable($prefix . '_owner', 'institution');
        $upload = $selectedtab == 'institution';
        $tabs['institution'] = get_string('institutionfiles', 'admin');
    } else {
        if ($viewowner['type'] == 'group') {
            $selectedtab = param_variable($prefix . '_owner', 'group');
            $upload = $selectedtab == 'group';
            $tabs['user'] = get_string('myfiles', 'artefact.file');
            $tabs['group'] = get_string('groupfiles', 'artefact.file');
        } else {
            // $viewowner['type'] == 'user'
            global $USER;
            $selectedtab = param_variable($prefix . '_owner', 'user');
            $upload = $selectedtab == 'user';
            $tabs['user'] = get_string('myfiles', 'artefact.file');
            if ($groups = $USER->get('grouproles')) {
                $tabs['group'] = get_string('groupfiles', 'artefact.file');
                require_once get_config('libroot') . 'group.php';
                $groups = group_get_user_groups($USER->get('id'));
                if ($selectedtab == 'group') {
                    if (!($selectedsubtab = (int) param_variable($prefix . '_ownerid', 0))) {
                        $selectedsubtab = $groups[0]->id;
                    }
                    foreach ($groups as &$g) {
                        $subtabs[$g->id] = $g->name;
                    }
                }
            }
            if ($institutions = $USER->get('institutions')) {
                $tabs['institution'] = get_string('institutionfiles', 'admin');
                $institutions = get_records_select_array('institution', 'name IN (' . join(',', array_map('db_quote', array_keys($institutions))) . ')');
                if ($selectedtab == 'institution') {
                    if (!($selectedsubtab = param_variable($prefix . '_ownerid', ''))) {
                        $selectedsubtab = $institutions[0]->name;
                    }
                    $selectedsubtab = hsc($selectedsubtab);
                    foreach ($institutions as &$i) {
                        $subtabs[$i->name] = $i->displayname;
                    }
                }
            }
        }
    }
    $tabs['site'] = get_string('sitefiles', 'admin');
    return array('tabs' => $tabs, 'subtabs' => $subtabs, 'owner' => $selectedtab, 'ownerid' => $viewowner['type'] == 'group' ? $viewowner['id'] : $selectedsubtab, 'upload' => $upload);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:57,代码来源:filebrowser.php

示例3: getGroupsList

 private function getGroupsList()
 {
     $list = array();
     foreach (group_get_user_groups($this->user->get('id')) as $group) {
         $list[$group->role][] = $group->id;
         $list['member'][] = $group->id;
     }
     return $list;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:9,代码来源:lib.php

示例4: group_get_user_admintutor_groups

function group_get_user_admintutor_groups()
{
    $groups = array();
    foreach (group_get_user_groups() as $g) {
        if ($g->role == 'admin' || $g->see_submitted_views) {
            $groups[] = $g;
        }
    }
    return $groups;
}
开发者ID:vohung96,项目名称:mahara,代码行数:10,代码来源:group.php

示例5: profile_sideblock

/**
 * creates the profile sideblock
 */
function profile_sideblock()
{
    global $USER, $SESSION;
    safe_require('notification', 'internal');
    require_once 'group.php';
    require_once 'institution.php';
    $data = array('id' => $USER->get('id'), 'myname' => display_name($USER, null, true), 'username' => $USER->get('username'), 'url' => profile_url($USER), 'profileiconurl' => get_config('wwwroot') . 'artefact/file/profileicons.php');
    $authinstance = $SESSION->get('mnetuser') ? $SESSION->get('authinstance') : $USER->get('authinstance');
    if ($authinstance) {
        $authobj = AuthFactory::create($authinstance);
        if ($authobj->authname == 'xmlrpc') {
            $peer = get_peer($authobj->wwwroot);
            if ($SESSION->get('mnetuser')) {
                $data['mnetloggedinfrom'] = get_string('youhaveloggedinfrom1', 'auth.xmlrpc', $authobj->wwwroot, $peer->name);
            } else {
                $data['peer'] = array('name' => $peer->name, 'wwwroot' => $peer->wwwroot);
            }
        }
    }
    $invitedgroups = get_records_sql_array('SELECT g.*, gmi.ctime, gmi.reason
             FROM {group} g
             JOIN {group_member_invite} gmi ON gmi.group = g.id
             WHERE gmi.member = ? AND g.deleted = ?', array($USER->get('id'), 0));
    $data['invitedgroups'] = $invitedgroups ? count($invitedgroups) : 0;
    $data['invitedgroupsmessage'] = $data['invitedgroups'] == 1 ? get_string('invitedgroup') : get_string('invitedgroups');
    $data['pendingfriends'] = count_records('usr_friend_request', 'owner', $USER->get('id'));
    $data['pendingfriendsmessage'] = $data['pendingfriends'] == 1 ? get_string('pendingfriend') : get_string('pendingfriends');
    // Check if we want to limit the displayed groups by the account setting
    $limitto = null;
    $limit = $USER->get_account_preference('groupsideblockmaxgroups');
    if (isset($limit) && is_numeric($limit)) {
        $limitto = intval($limit);
    }
    $sort = null;
    if ($sortorder = $USER->get_account_preference('groupsideblocksortby')) {
        $sort = $sortorder;
    }
    if ($limitto === null) {
        $data['groups'] = group_get_user_groups($USER->get('id'), null, $sort);
        $total = count($data['groups']);
    } else {
        if ($limitto === 0) {
            $data['groups'] = null;
        } else {
            list($data['groups'], $total) = group_get_user_groups($USER->get('id'), null, $sort, $limitto);
        }
    }
    $limitstr = '';
    if (!empty($limitto) && $limitto < $total) {
        switch ($sort) {
            case 'earliest':
                $limitstr = get_string('numberofmygroupsshowingearliest', 'blocktype.mygroups', $limitto, $total);
                break;
            case 'latest':
                $limitstr = get_string('numberofmygroupsshowinglatest', 'blocktype.mygroups', $limitto, $total);
                break;
            default:
                $limitstr = get_string('numberofmygroupsshowing', 'blocktype.mygroups', $limitto, $total);
                break;
        }
    }
    $data['grouplimitstr'] = $limitstr;
    $data['views'] = get_records_sql_array('SELECT v.id, v.title, v.urlid, v.owner
        FROM {view} v
        INNER JOIN {view_tag} vt ON (vt.tag = ? AND vt.view = v.id)
        WHERE v.owner = ?
        ORDER BY v.title', array(get_string('profile'), $USER->get('id')));
    if ($data['views']) {
        require_once 'view.php';
        foreach ($data['views'] as $v) {
            $view = new View(0, (array) $v);
            $view->set('dirty', false);
            $v->fullurl = $view->get_url();
        }
    }
    $data['artefacts'] = get_records_sql_array('SELECT a.id, a.artefacttype, a.title
         FROM {artefact} a
         INNER JOIN {artefact_tag} at ON (a.id = at.artefact AND tag = ?)
         WHERE a.owner = ?
         ORDER BY a.title', array(get_string('profile'), $USER->get('id')));
    if (!empty($data['artefacts'])) {
        // check if we have any blogposts and fetch their blog id if we do
        foreach ($data['artefacts'] as $key => $value) {
            if ($value->artefacttype == 'blogpost') {
                $value->blogid = get_field('artefact', 'parent', 'id', $value->id);
            }
        }
    }
    return $data;
}
开发者ID:kienv,项目名称:mahara,代码行数:93,代码来源:mahara.php

示例6: param_integer

$id = param_integer('id');
$blockid = param_integer('block');
$view = new View($id);
if (!can_view_view($view)) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$bi = new Blockinstance($blockid);
$configdata = $bi->get('configdata');
$sort = !empty($configdata['sort']) ? $configdata['sort'] : null;
$limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null;
$baseurl = $bi->get_view()->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $bi->get('id');
$userid = $bi->get_view()->get('owner');
if (!$userid) {
    json_reply(true, get_string('accessdenied', 'error'));
}
$smarty = smarty_core();
// Group stuff
if (!empty($limit)) {
    list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, $offset);
} else {
    $usergroups = group_get_user_groups($userid, null, $sort);
    $count = count($usergroups);
}
foreach ($usergroups as $group) {
    $group->roledisplay = get_string($group->role, 'grouptype.' . $group->grouptype);
}
$groups = array('data' => $usergroups, 'count' => $count, 'limit' => $limit, 'offset' => $offset);
$pagination = array('baseurl' => $baseurl, 'id' => 'mygroups_pagination', 'datatable' => 'usergroupstable', 'jsonscript' => 'blocktype/mygroups/mygroups.json.php', 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group'));
PluginBlocktypeMygroups::render_items($groups, 'blocktype:mygroups:mygroupslist.tpl', $configdata, $pagination);
json_reply(false, array('data' => $groups));
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:mygroups.json.php

示例7: array

$remoteusermessage = false;
$remoteuseracceptform = false;
$remoteusernewfriendform = false;
$remoteuserfriendscontrol = false;
$remoteuserrelationship = false;
if (!empty($loggedinid) && $loggedinid != $userid) {
    $invitedlist = array();
    // Groups admin'ed by the logged in user that the displayed user has been invited to
    $requestedlist = array();
    // Groups admin'ed by the logged in user that the displayed user has requested membership of
    // Get all groups where either:
    // - the logged in user is an admin, or
    // - the logged in user has a role which is allowed to assess submitted views, or
    // - the logged in user is a member & is allowed to invite friends (when the displayed user is a friend)
    $groups = array();
    foreach (group_get_user_groups() as $g) {
        if ($g->role == 'admin' || $g->see_submitted_views || $is_friend && $g->invitefriends) {
            $groups[] = $g;
        }
    }
    if ($groups) {
        $invitelist = array();
        // List of groups the displayed user can be invited to join
        $controlledlist = array();
        // List of groups the displayed user can be directly added to
        foreach ($groups as $group) {
            if (array_key_exists($group->id, $allusergroups)) {
                if ($allusergroups[$group->id]->type == 'invite') {
                    $invitedlist[$group->id] = $group->name;
                } else {
                    if ($allusergroups[$group->id]->type == 'request') {
开发者ID:rboyatt,项目名称:mahara,代码行数:31,代码来源:view.php

示例8: profile_sideblock

/**
 * creates the profile sideblock
 */
function profile_sideblock()
{
    global $USER, $SESSION;
    safe_require('notification', 'internal');
    require_once 'group.php';
    require_once 'institution.php';
    $data = array('id' => $USER->get('id'), 'myname' => display_name($USER, null, true), 'username' => $USER->get('username'), 'url' => profile_url($USER), 'profileiconurl' => get_config('wwwroot') . 'artefact/file/profileicons.php');
    $authinstance = $SESSION->get('mnetuser') ? $SESSION->get('authinstance') : $USER->get('authinstance');
    if ($authinstance) {
        $authobj = AuthFactory::create($authinstance);
        if ($authobj->authname == 'xmlrpc') {
            $peer = get_peer($authobj->wwwroot);
            if ($SESSION->get('mnetuser')) {
                $data['mnetloggedinfrom'] = get_string('youhaveloggedinfrom', 'auth.xmlrpc', $authobj->wwwroot, institution_display_name($peer->institution));
            } else {
                $data['peer'] = array('name' => $peer->name, 'wwwroot' => $peer->wwwroot);
            }
        }
    }
    $invitedgroups = get_records_sql_array('SELECT g.*, gmi.ctime, gmi.reason
             FROM {group} g
             JOIN {group_member_invite} gmi ON gmi.group = g.id
             WHERE gmi.member = ? AND g.deleted = ?', array($USER->get('id'), 0));
    $data['invitedgroups'] = $invitedgroups ? count($invitedgroups) : 0;
    $data['invitedgroupsmessage'] = $data['invitedgroups'] == 1 ? get_string('invitedgroup') : get_string('invitedgroups');
    $data['pendingfriends'] = count_records('usr_friend_request', 'owner', $USER->get('id'));
    $data['pendingfriendsmessage'] = $data['pendingfriends'] == 1 ? get_string('pendingfriend') : get_string('pendingfriends');
    $data['groups'] = group_get_user_groups($USER->get('id'));
    $data['views'] = get_records_sql_array('SELECT v.id, v.title, v.urlid, v.owner
        FROM {view} v
        INNER JOIN {view_tag} vt ON (vt.tag = ? AND vt.view = v.id)
        WHERE v.owner = ?
        ORDER BY v.title', array(get_string('profile'), $USER->get('id')));
    if ($data['views']) {
        require_once 'view.php';
        foreach ($data['views'] as $v) {
            $view = new View(0, (array) $v);
            $view->set('dirty', false);
            $v->fullurl = $view->get_url();
        }
    }
    $data['artefacts'] = get_records_sql_array('SELECT a.id, a.artefacttype, a.title
         FROM {artefact} a
         INNER JOIN {artefact_tag} at ON (a.id = at.artefact AND tag = ?)
         WHERE a.owner = ?
         ORDER BY a.title', array(get_string('profile'), $USER->get('id')));
    return $data;
}
开发者ID:nanda555,项目名称:TestAppFromAWS,代码行数:51,代码来源:mahara.php

示例9: pieform_element_viewacl

/**
 * Provides an element to manage a view ACL
 *
 * @param array    $element The element to render
 * @param Pieform  $form    The form to render the element for
 * @return string           The HTML for the element
 */
function pieform_element_viewacl(Pieform $form, $element)
{
    global $USER, $SESSION, $LANGDIRECTION;
    $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
    $smarty = smarty_core();
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
    $value = $form->get_value($element);
    // Look for the presets and split them into two groups
    require_once get_config('libroot') . 'antispam.php';
    $public = false;
    if (is_probationary_user()) {
        $public = false;
    } else {
        if (get_config('allowpublicviews') && $USER->institution_allows_public_views()) {
            $public = true;
        } else {
            if (get_config('allowpublicprofiles') && $element['viewtype'] == 'profile') {
                $public = true;
            }
        }
    }
    $allpresets = array('public', 'loggedin', 'friends');
    $allowedpresets = array();
    $loggedinindex = 0;
    if ($public) {
        $allowedpresets[] = 'public';
        $loggedinindex = 1;
    }
    $allowedpresets[] = 'loggedin';
    if ($form->get_property('userview')) {
        $allowedpresets[] = 'friends';
    }
    $accesslist = array();
    if ($value) {
        foreach ($value as $item) {
            if (is_array($item)) {
                if ($item['type'] == 'public') {
                    $item['publicallowed'] = (int) $public;
                }
                if (in_array($item['type'], $allpresets)) {
                    $item['name'] = get_string($item['type'] == 'loggedin' ? 'registeredusers' : $item['type'], 'view');
                    $item['preset'] = true;
                } else {
                    $item['name'] = pieform_render_viewacl_getvaluebytype($item['type'], $item['id']);
                }
                if ($strlen($item['name']) > 30) {
                    $item['shortname'] = str_shorten_text($item['name'], 30, true);
                }
                // only show access that is still current. Expired access will be deleted if the form is saved
                if ($form->is_submitted() || empty($item['stopdate']) || time() <= strtotime($item['stopdate'])) {
                    $accesslist[] = $item;
                }
            }
        }
    }
    $defaultaccesslist = $accesslist ? 0 : 1;
    $myinstitutions = array();
    foreach ($USER->get('institutions') as $i) {
        $myinstitutions[] = array('type' => 'institution', 'id' => $i->institution, 'start' => null, 'end' => null, 'name' => hsc($i->displayname), 'preset' => false);
    }
    foreach ($allowedpresets as &$preset) {
        $preset = array('type' => $preset, 'id' => $preset, 'start' => null, 'end' => null, 'name' => get_string($preset == 'loggedin' ? 'registeredusers' : $preset, 'view'), 'preset' => true);
    }
    $allgroups = array('type' => 'allgroups', 'id' => 'allgroups', 'start' => null, 'end' => null, 'name' => get_string('allmygroups', 'group'), 'preset' => true);
    $mygroups = array();
    foreach (group_get_user_groups($USER->get('id')) as $g) {
        $group = array('type' => 'group', 'id' => $g->id, 'start' => null, 'end' => null, 'name' => $g->name, 'preset' => false);
        if ($strlen($g->name) > 30) {
            $group['shortname'] = str_shorten_text($g->name, 30, true);
        }
        $mygroups[] = $group;
    }
    $faves = array();
    foreach (get_user_favorites($USER->get('id')) as $u) {
        $fave = array('type' => 'user', 'id' => $u->id, 'start' => null, 'end' => null, 'name' => $u->name, 'preset' => false);
        if ($strlen($u->name) > 30) {
            $fave['shortname'] = str_shorten_text($u->name, 30, true);
        }
        $faves[] = $fave;
    }
    require_once get_config('libroot') . 'pieforms/pieform/elements/calendar.php';
    $options = array('dateFormat' => get_string('calendar_dateFormat', 'langconfig'), 'timeFormat' => get_string('calendar_timeFormat', 'langconfig'), 'stepHour' => 1, 'stepMinute' => 5);
    $options = pieform_element_calendar_get_lang_strings($options, $LANGDIRECTION);
    $datepickeroptionstr = '';
    foreach ($options as $key => $option) {
        if (is_numeric($option)) {
            $datepickeroptionstr .= $key . ': ' . $option . ',';
        } else {
            if (is_array($option)) {
                foreach ($option as $k => $v) {
                    if (!is_numeric($v)) {
                        if (preg_match('/^\'(.*)\'$/', $v, $match)) {
//.........这里部分代码省略.........
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:viewacl.php

示例10: profile_sideblock

/**
 * creates the profile sideblock
 */
function profile_sideblock()
{
    global $USER, $SESSION;
    safe_require('notification', 'internal');
    require_once 'group.php';
    $data = array('id' => $USER->get('id'), 'myname' => display_name($USER, null, true), 'username' => $USER->get('username'), 'profileicon' => $USER->get('profileicon') ? $USER->get('profileicon') : 0);
    if ($SESSION->get('mnetuser')) {
        $authinstance = $SESSION->get('authinstance');
        if ($authinstance) {
            $authobj = AuthFactory::create($authinstance);
            $peer = get_peer($authobj->wwwroot);
            $data['mnetloggedinfrom'] = get_string('youhaveloggedinfrom', 'auth.xmlrpc', $authobj->wwwroot, $peer->name);
        }
    }
    $data['unreadnotifications'] = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
    $data['unreadnotificationsmessage'] = $data['unreadnotifications'] == 1 ? get_string('unreadmessage') : get_string('unreadmessages');
    $invitedgroups = get_records_sql_array('SELECT g.*, gmi.ctime, gmi.reason
             FROM {group} g
             JOIN {group_member_invite} gmi ON gmi.group = g.id
             WHERE gmi.member = ? AND g.deleted = ?', array($USER->get('id'), 0));
    $data['invitedgroups'] = $invitedgroups ? count($invitedgroups) : 0;
    $data['invitedgroupsmessage'] = $data['invitedgroups'] == 1 ? get_string('invitedgroup') : get_string('invitedgroups');
    $data['pendingfriends'] = count_records('usr_friend_request', 'owner', $USER->get('id'));
    $data['pendingfriendsmessage'] = $data['pendingfriends'] == 1 ? get_string('pendingfriend') : get_string('pendingfriends');
    $data['groups'] = group_get_user_groups($USER->get('id'));
    $data['views'] = get_records_sql_array('SELECT v.id, v.title
        FROM {view} v
        INNER JOIN {view_tag} vt ON (vt.tag = ? AND vt.view = v.id)
        WHERE v.owner = ?
        ORDER BY v.title', array(get_string('profile'), $USER->get('id')));
    $data['artefacts'] = get_records_sql_array('SELECT a.id, a.artefacttype, a.title
         FROM {artefact} a
         INNER JOIN {artefact_tag} at ON (a.id = at.artefact AND tag = ?)
         WHERE a.owner = ?
         ORDER BY a.title', array(get_string('profile'), $USER->get('id')));
    return $data;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:40,代码来源:mahara.php


注:本文中的group_get_user_groups函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。