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


PHP ca_users::getTypeAccessLevel方法代码示例

本文整理汇总了PHP中ca_users::getTypeAccessLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_users::getTypeAccessLevel方法的具体用法?PHP ca_users::getTypeAccessLevel怎么用?PHP ca_users::getTypeAccessLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_users的用法示例。


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

示例1: caCanRead

/**
 * Determines if the specified item (and optionally a specific bundle in that item) are readable by the user
 *
 * @param int $pn_user_id
 * @param mixed $pm_table A table name or number
 * @param mixed $pm_id A primary key value of the row, or an array of values to check. If a single integer value is provided then a boolean result will be returned; if an array of values is provided then an array will be returned with all ids that are readable
 * @param string $ps_bundle_name An optional bundle to check access for
 *
 * @return If $pm_id is an integer return true if user has read access, otherwise false if the user does not have access; if $pm_id is an array of ids, returns an array with all ids the are readable; returns null if one or more parameters are invalid
 */
function caCanRead($pn_user_id, $pm_table, $pm_id, $ps_bundle_name = null, $pa_options = null)
{
    $pb_return_as_array = caGetOption('returnAsArray', $pa_options, false);
    $t_user = new ca_users($pn_user_id, true);
    if (!$t_user->getPrimaryKey()) {
        return null;
    }
    $o_dm = Datamodel::load();
    $ps_table_name = is_numeric($pm_table) ? $o_dm->getTableName($pm_table) : $pm_table;
    if (!is_array($pm_id)) {
        $pm_id = array($pm_id);
    }
    if ($ps_bundle_name) {
        if ($t_user->getBundleAccessLevel($ps_table_name, $ps_bundle_name) < __CA_BUNDLE_ACCESS_READONLY__) {
            return sizeof($pm_id) == 1 && !$pb_return_as_array ? false : array();
        }
    }
    if (!($t_instance = $o_dm->getInstanceByTableName($ps_table_name, true))) {
        return null;
    }
    $vb_do_type_access_check = (bool) $t_instance->getAppConfig()->get('perform_type_access_checking');
    $vb_do_item_access_check = (bool) $t_instance->getAppConfig()->get('perform_item_level_access_checking');
    list($ps_table_name, $ps_bundle_name) = caTranslateBundlesForAccessChecking($ps_table_name, $ps_bundle_name);
    if (!($qr_res = caMakeSearchResult($ps_table_name, $pm_id))) {
        return null;
    }
    $va_return_values = array();
    while ($qr_res->nextHit()) {
        $vn_id = $qr_res->getPrimaryKey();
        // Check type restrictions
        if ($vb_do_type_access_check) {
            $vn_type_access = $t_user->getTypeAccessLevel($ps_table_name, $qr_res->get("{$ps_table_name}.type_id"));
            if ($vn_type_access < __CA_BUNDLE_ACCESS_READONLY__) {
                continue;
            }
        }
        // Check item level restrictions
        if ($vb_do_item_access_check) {
            $vn_item_access = $t_instance->checkACLAccessForUser($t_user, $vn_id);
            if ($vn_item_access < __CA_ACL_READONLY_ACCESS__) {
                continue;
            }
        }
        $va_return_values[] = $vn_id;
    }
    if (sizeof($pm_id) == 1 && !$pb_return_as_array) {
        return sizeof($va_return_values) > 0 ? true : false;
    }
    return $va_return_values;
}
开发者ID:samrahman,项目名称:providence,代码行数:60,代码来源:accessHelpers.php

示例2: caCanRead

/**
 * Determines if the specified item (and optionally a specific bundle in that item) are readable by the user
 *
 * @param int $pn_user_id
 * @param mixed $pm_table A table name or number
 * @param int $pn_id The primary key value of the row
 * @param string $ps_bundle_name An optional bundle to check access for
 *
 * @return True if user has read access, otherwise false if the user does not have access or null if one or more parameters are invalid
 */
function caCanRead($pn_user_id, $pm_table, $pn_id, $ps_bundle_name = null)
{
    $o_dm = Datamodel::load();
    $ps_table_name = is_numeric($pm_table) ? $o_dm->getTableName($pm_table) : $pm_table;
    if (!($t_instance = $o_dm->getInstanceByTableName($ps_table_name, true))) {
        return null;
    }
    if (!$t_instance->load($pn_id)) {
        return null;
    }
    $t_user = new ca_users($pn_user_id);
    if (!$t_user->getPrimaryKey()) {
        return null;
    }
    list($ps_table_name, $ps_bundle_name) = caTranslateBundlesForAccessChecking($ps_table_name, $ps_bundle_name);
    // Check type restrictions
    if ((bool) $t_instance->getAppConfig()->get('perform_type_access_checking')) {
        $vn_type_access = $t_user->getTypeAccessLevel($ps_table_name, $t_instance->getTypeID());
        if ($vn_type_access < __CA_BUNDLE_ACCESS_READONLY__) {
            return false;
        }
    }
    // Check item level restrictions
    if ((bool) $t_instance->getAppConfig()->get('perform_item_level_access_checking')) {
        $vn_item_access = $t_instance->checkACLAccessForUser($t_user);
        if ($vn_item_access < __CA_ACL_READONLY_ACCESS__) {
            return false;
        }
    }
    if ($ps_bundle_name) {
        if ($t_user->getBundleAccessLevel($ps_table_name, $ps_bundle_name) < __CA_BUNDLE_ACCESS_READONLY__) {
            return false;
        }
    }
    return true;
}
开发者ID:ffarago,项目名称:pawtucket2,代码行数:46,代码来源:accessHelpers.php


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