Ejemplo n.º 1
0
function access_user_calendar($cal_can_xxx = '', $other_user, $cur_user = '', $type = '', $access = '')
{
    global $access_other_cals, $access_users, $login, $ADMIN_OVERRIDE_UAC, $is_admin;
    $admin_override = $is_admin && !empty($ADMIN_OVERRIDE_UAC) && $ADMIN_OVERRIDE_UAC == 'Y';
    if ($admin_override) {
        return $cal_can_xxx == 'email' || $cal_can_xxx == 'invite' ? 'Y' : CAN_DOALL;
    }
    $access_wt = $ret = $type_wt = 0;
    if (empty($cur_user) && empty($login)) {
        $cur_user = '******';
    }
    if (empty($cur_user) && !empty($login)) {
        $cur_user = $login;
    }
    if ($cur_user == $other_user) {
        if ($login == '__public__' && $cal_can_xxx == 'approve') {
            return 'N';
        }
        return $cal_can_xxx == 'email' || $cal_can_xxx == 'invite' ? 'Y' : CAN_DOALL;
    }
    assert('! empty ( $other_user )');
    assert('! empty ( $cur_user )');
    if (empty($access_other_cals)) {
        access_load_user_permissions();
    }
    $key1 = $cur_user . '.' . $other_user;
    $key2 = $cur_user . '.__default__';
    $key3 = '__default__.' . $other_user;
    $key4 = '__default__.__default__';
    if (isset($access_other_cals[$key1][$cal_can_xxx])) {
        $ret = $access_other_cals[$key1][$cal_can_xxx];
    } else {
        if (isset($access_other_cals[$key2][$cal_can_xxx])) {
            $ret = $access_other_cals[$key2][$cal_can_xxx];
        } else {
            if (isset($access_other_cals[$key3][$cal_can_xxx])) {
                $ret = $access_other_cals[$key3][$cal_can_xxx];
            } else {
                if (isset($access_other_cals[$key4][$cal_can_xxx])) {
                    $ret = $access_other_cals[$key4][$cal_can_xxx];
                }
            }
        }
    }
    // Check type and access levels.
    if (!empty($access) && !empty($type)) {
        if ($access == 'C') {
            $access_wt = CONF_WT;
        }
        if ($access == 'P') {
            $access_wt = PUBLIC_WT;
        }
        if ($access == 'R') {
            $access_wt = PRIVATE_WT;
        }
        if ($type == 'E' || $type == 'M') {
            $type_wt = EVENT_WT;
        }
        if ($type == 'J' || $type == 'O') {
            $type_wt = JOURNAL_WT;
        }
        if ($type == 'T' || $type == 'N') {
            $type_wt = TASK_WT;
        }
        $total_wt = $type_wt & $access_wt;
        $ret = $ret & $total_wt ? $ret : 0;
    }
    return $ret;
}
Ejemplo n.º 2
0
//} else
$otheruser = getPostValue('otheruser');
if ($otheruser == '__default__') {
    $otheruser_fullname = $defConfigStr;
    $otheruser_login = '******';
} elseif ($otheruser == '__public__') {
    $otheruser_fullname = translate('Public Access');
    $otheruser_login = '******';
}
if (!empty($otheruser)) {
    if ($allow_view_other) {
        user_load_variables($otheruser, 'otheruser_');
        // Turn off admin override so we see the users own settings.
        $ADMIN_OVERRIDE_UAC = 'N';
        // Now load all the data from webcal_access_user.
        $allPermissions = access_load_user_permissions(false);
        // Load default-default values if exist.
        if (!empty($allPermissions['__default__.__default__'])) {
            $op = $allPermissions['__default__.__default__'];
        }
        if ($is_admin) {
            // Load user-default values if exist.
            if (!empty($allPermissions[$guser . '.__default__'])) {
                $op = $allPermissions[$guser . '.__default__'];
            }
            // Load user-otheruser values if exist.
            if (!empty($allPermissions[$guser . '.' . $otheruser])) {
                $op = $allPermissions[$guser . '.' . $otheruser];
            }
        } else {
            // Load defualt-user values if exist.