Exemplo n.º 1
0
/**
 * Test if user is member of Group, via safe call to OG function.
 */
function _groupadmin_is_group_member($gid, $uid)
{
    return _groupadmin_checkfunc('og_is_group_member') ? og_is_group_member($gid, FALSE, $uid) : FALSE;
}
Exemplo n.º 2
0
/**
 * Check whether current user can perform tasks for given group.
 * We don't need to worry too much about performance here, as result
 * will normally be cached via _groupadmin_access() function.
 */
function _groupadmin_access_check($gid, $op)
{
    // Initial checks: make sure $gid is a valid Group node.
    if (!_groupadmin_checkfunc('og_is_group_type')) {
        return FALSE;
    }
    if (!og_is_group_type(_groupadmin_get_group($gid, 'type'))) {
        return FALSE;
    }
    global $user;
    $node = _groupadmin_get_group($gid);
    switch ($op) {
        case 'administrate':
            $required = 'admins';
            break;
        case 'show_all':
            $op = 'show_non-members';
            // don't break
        // don't break
        default:
            $required = _groupadmin_settings('l_' . $op);
    }
    $access = _groupadmin_user_has_role($node, $user, $required);
    return $access;
}