示例#1
0
/**
* Implementation of hook_menu_alter().
* If enabled, remove the standard "add users" tab.
*/
function groupadmin_menu_alter(&$items)
{
    //drupal_set_message(print_r($items, 1));
    //foreach ($items as $key => $value)  drupal_set_message($key);
    if (_groupadmin_settings('x_remove_standard_link')) {
        unset($items['og/users/%node/add_user']);
    }
}
/**
 * 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;
}