本文整理汇总了PHP中CIBlockElementRights::GetUserOperations方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElementRights::GetUserOperations方法的具体用法?PHP CIBlockElementRights::GetUserOperations怎么用?PHP CIBlockElementRights::GetUserOperations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElementRights
的用法示例。
在下文中一共展示了CIBlockElementRights::GetUserOperations方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CatalogRecurringCallback
function CatalogRecurringCallback($productID, $userID)
{
global $APPLICATION;
global $DB;
$productID = intval($productID);
if ($productID <= 0) {
return false;
}
$userID = intval($userID);
if ($userID <= 0) {
return false;
}
$arProduct = CCatalogProduct::GetByID($productID);
if (!$arProduct) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_PRODUCT")), "NO_PRODUCT");
return false;
}
if ($arProduct["PRICE_TYPE"] == "T") {
$arProduct = CCatalogProduct::GetByID($arProduct["TRIAL_PRICE_ID"]);
if (!$arProduct) {
$APPLICATION->ThrowException(str_replace("#TRIAL_ID#", $productID, str_replace("#ID#", $arProduct["TRIAL_PRICE_ID"], Loc::getMessage("I_NO_TRIAL_PRODUCT"))), "NO_PRODUCT_TRIAL");
return false;
}
}
$productID = intval($arProduct["ID"]);
if ($arProduct["PRICE_TYPE"] != "R") {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_NOT_SUBSCR")), "NO_IBLOCK_SUBSCR");
return false;
}
$dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if (!($arIBlockElement = $dbIBlockElement->GetNext())) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
$arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
if (empty($arUserRights)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
} elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
} else {
if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
}
$arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] != "Y") {
$APPLICATION->ThrowException(str_replace("#ID#", $arIBlockElement["IBLOCK_ID"], Loc::getMessage("I_CATALOG_NOT_SUBSCR")), "NOT_SUBSCRIPTION");
return false;
}
if ($arProduct["CAN_BUY_ZERO"] != "Y" && ($arProduct["QUANTITY_TRACE"] == "Y" && doubleval($arProduct["QUANTITY"]) <= 0)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_SOLD")), "PRODUCT_END");
return false;
}
$arUserGroups = CUser::GetUserGroup($userID);
$arUserGroups = array_values(array_unique($arUserGroups));
CCatalogDiscountSave::Disable();
$arPrice = CCatalogProduct::GetOptimalPrice($productID, 1, $arUserGroups, "Y");
if (empty($arPrice)) {
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, 1, $arUserGroups)) {
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $arUserGroups, "Y");
}
}
CCatalogDiscountSave::Enable();
if (empty($arPrice)) {
return false;
}
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
//SIGURD: logic change. see mantiss 5036.
// discount applied to a final price with VAT already included.
if (doubleval($arPrice['PRICE']['VAT_RATE']) > 0) {
$currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
}
$arDiscountList = array();
if (!empty($arPrice["DISCOUNT_LIST"])) {
$dblStartPrice = $currentPrice;
foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
switch ($arOneDiscount['VALUE_TYPE']) {
case CCatalogDiscount::TYPE_FIX:
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$currentDiscount = $arOneDiscount['VALUE'];
} else {
$currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
$currentPrice = $currentPrice - $currentDiscount;
break;
case CCatalogDiscount::TYPE_PERCENT:
$currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
if (0 < $arOneDiscount['MAX_DISCOUNT']) {
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
} else {
$dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
//.........这里部分代码省略.........
示例2: getProductAvailableQuantity
/**
* @param $productId
* @param null $userId
* @return bool
* @throws Main\ArgumentException
*/
public static function getProductAvailableQuantity($productId, $userId = null)
{
$adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
$userId = isset($userId) ? (int) $userId : 0;
if ($userId < 0) {
$userId = 0;
}
static $arUserCache = array();
if ($adminSection) {
if ($userId == 0) {
return false;
}
if (!isset($arUserCache[$userId])) {
$userIterator = Main\UserTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $userId)));
if ($userDat = $userIterator->fetch()) {
$userDat['ID'] = (int) $userDat['ID'];
$arUserCache[$userDat['ID']] = CUser::GetUserGroup($userDat['ID']);
} else {
return false;
}
}
$dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productId, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSION' => 'N'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if (!($arProduct = $dbIBlockElement->GetNext())) {
return false;
}
$iblockRights = null;
if (!($iblockRights = static::getHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID']))) {
if ($iblockRights = CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE')) {
static::setHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID'], $iblockRights);
}
}
if ($iblockRights == 'E') {
$proxyUserPermissionKey = $productId . "|" . $userId;
if (!($arUserRights = static::getHitCache('USER_RIGHT', $proxyUserPermissionKey))) {
if ($arUserRights = CIBlockElementRights::GetUserOperations($productId, $userId)) {
static::setHitCache('USER_RIGHT', $proxyUserPermissionKey, $arUserRights);
}
}
if (empty($arUserRights) || !isset($arUserRights['element_read'])) {
return false;
}
unset($arUserRights);
} else {
if (CIBlock::GetPermission($arProduct['IBLOCK_ID'], $userId) < 'R') {
return false;
}
}
} else {
$dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productId, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'R'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if (!($arProduct = $dbIBlockElement->GetNext())) {
return false;
}
}
$rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY'));
if ($arCatalogProduct = $rsProducts->Fetch()) {
return $arCatalogProduct['QUANTITY'];
}
return false;
}
示例3: OrderProduct
/**
* @param array $arParams
* @return array|false
*/
public static function OrderProduct($arParams)
{
$arParams['RENEWAL'] = (isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N');
$arParams['CHECK_QUANTITY'] = (isset($arParams['CHECK_QUANTITY']) && $arParams['CHECK_QUANTITY'] == 'N' ? 'N' : 'Y');
$arParams['CHECK_DISCOUNT'] = (isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y');
$arParams['USER_ID'] = (isset($arParams['USER_ID']) ? (int)$arParams['USER_ID'] : 0);
if ($arParams['USER_ID'] < 0)
$arParams['USER_ID'] = 0;
$arParams['SITE_ID'] = (isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false);
$strSiteID = $arParams['SITE_ID'];
$arParams['BASKET_ID'] = (string)(isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0');
if (isset($arParams['CURRENCY']))
$arParams['CURRENCY'] = CCurrency::checkCurrencyID($arParams['CURRENCY']);
if ($arParams['CURRENCY'] === false)
$arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);
global $USER;
$productID = (int)$arParams['PRODUCT_ID'];
$quantity = (float)$arParams['QUANTITY'];
$renewal = $arParams['RENEWAL'];
$intUserID = (int)$arParams['USER_ID'];
$arResult = array();
static $arUserCache = array();
if (0 < $intUserID)
{
if (!isset($arUserCache[$intUserID]))
{
$by = 'ID';
$order = 'DESC';
$rsUsers = CUser::GetList($by, $order, array("ID_EQUAL_EXACT"=>$intUserID),array('FIELDS' => array('ID')));
if ($arUser = $rsUsers->Fetch())
{
$arUser['ID'] = intval($arUser['ID']);
$arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
}
else
{
$intUserID = 0;
return $arResult;
}
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSION" => "N",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if(!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE"))
{
$arUserRights = CIBlockElementRights::GetUserOperations($productID,$intUserID);
if (empty($arUserRights))
{
return $arResult;
}
elseif (!is_array($arUserRights) || !array_key_exists('element_read',$arUserRights))
{
return $arResult;
}
}
else
{
if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID))
{
return $arResult;
}
}
}
else
{
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSIONS" => "Y",
"MIN_PERMISSION" => "R",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
//.........这里部分代码省略.........
示例4: OrderProduct
public static function OrderProduct($arParams)
{
if (!is_set($arParams, "RENEWAL") || $arParams["RENEWAL"] != "Y") {
$arParams["RENEWAL"] = "N";
}
if (!is_set($arParams, "USER_ID") || IntVal($arParams["USER_ID"]) <= 0) {
$arParams["USER_ID"] = 0;
}
if (!is_set($arParams["SITE_ID"])) {
$arParams["SITE_ID"] = false;
}
global $USER;
global $DB;
$productID = intval($arParams["PRODUCT_ID"]);
$quantity = doubleval($arParams["QUANTITY"]);
$renewal = $arParams["RENEWAL"] == "Y" ? "Y" : "N";
$strSiteID = $arParams["SITE_ID"];
$intUserID = intval($arParams["USER_ID"]);
if (0 > $intUserID) {
$intUserID = 0;
}
$arResult = array();
static $arUserCache = array();
if (0 < $intUserID) {
if (!array_key_exists($intUserID, $arUserCache)) {
$rsUsers = CUser::GetList($by = 'ID', $order = 'DESC', array("ID_EQUAL_EXACT" => $intUserID), array('FIELDS' => array('ID')));
if ($arUser = $rsUsers->Fetch()) {
$arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
} else {
$intUserID = 0;
return $arResult;
}
}
$dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSION" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if (!($arProduct = $dbIBlockElement->GetNext())) {
return $arResult;
}
if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE")) {
$arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID);
if (empty($arUserRights)) {
return $arResult;
} elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
return $arResult;
}
} else {
if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID)) {
return $arResult;
}
}
} else {
$dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if (!($arProduct = $dbIBlockElement->GetNext())) {
return $arResult;
}
}
if ($arCatalogProduct = CCatalogProduct::GetByID($productID)) {
if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) < doubleVal($quantity))) {
return $arResult;
}
} else {
return $arResult;
}
if (0 < $intUserID) {
$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
CCatalogDiscountSave::SetDiscountUserID($intUserID);
} else {
$arCoupons = CCatalogDiscountCoupon::GetCoupons();
}
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
if (empty($arPrice)) {
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())) {
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
}
}
if (empty($arPrice)) {
if (0 < $intUserID) {
CCatalogDiscountSave::ClearDiscountUserID();
}
return $arResult;
}
$boolDiscountVat = 'N' != COption::GetOptionString('catalog', 'discount_vat', 'Y');
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
if ($boolDiscountVat) {
if ('N' == $arPrice['PRICE']['VAT_INCLUDED']) {
$currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
}
} else {
if ('Y' == $arPrice['PRICE']['VAT_INCLUDED']) {
$currentPrice /= 1 + $arPrice['PRICE']['VAT_RATE'];
$arPrice['PRICE']['VAT_INCLUDED'] = 'N';
}
}
$arDiscountList = array();
$arCouponList = array();
if (!empty($arPrice["DISCOUNT_LIST"])) {
$dblStartPrice = $currentPrice;
foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
//.........这里部分代码省略.........
示例5: OrderProduct
/**
* @param array $arParams
* @return array|false
*/
public static function OrderProduct($arParams)
{
$adminSection = (defined('ADMIN_SECTION') && ADMIN_SECTION === true);
$arParams['RENEWAL'] = (isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N');
$arParams['CHECK_QUANTITY'] = (isset($arParams['CHECK_QUANTITY']) && $arParams['CHECK_QUANTITY'] == 'N' ? 'N' : 'Y');
$arParams['CHECK_DISCOUNT'] = (isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y');
$arParams['USER_ID'] = (isset($arParams['USER_ID']) ? (int)$arParams['USER_ID'] : 0);
if ($arParams['USER_ID'] < 0)
$arParams['USER_ID'] = 0;
$arParams['SITE_ID'] = (isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false);
$strSiteID = $arParams['SITE_ID'];
$arParams['BASKET_ID'] = (string)(isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0');
$arParams['CURRENCY'] = (isset($arParams['CURRENCY']) ? Currency\CurrencyManager::checkCurrencyID($arParams['CURRENCY']) : false);
if ($arParams['CURRENCY'] === false)
$arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);
global $USER;
$productID = (int)$arParams['PRODUCT_ID'];
$quantity = (float)$arParams['QUANTITY'];
$intUserID = (int)$arParams['USER_ID'];
$arResult = array();
if ($adminSection)
{
if ($intUserID == 0)
return $arResult;
$userGroups = self::getUserGroups($intUserID);
if (empty($userGroups))
return $arResult;
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
'ID' => $productID,
'ACTIVE' => 'Y',
'ACTIVE_DATE' => 'Y',
'CHECK_PERMISSION' => 'N'
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if (!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
if (CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE') == 'E')
{
$arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID);
if (empty($arUserRights) || !isset($arUserRights['element_read']))
return $arResult;
unset($arUserRights);
}
else
{
if (CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID) < 'R')
return $arResult;
}
}
else
{
$userGroups = $USER->GetUserGroupArray();
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
'ID' => $productID,
'ACTIVE' => 'Y',
'ACTIVE_DATE' => 'Y',
'CHECK_PERMISSIONS' => 'Y',
'MIN_PERMISSION' => 'R'
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if (!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
}
$rsProducts = CCatalogProduct::GetList(
array(),
array('ID' => $productID),
false,
false,
array(
'ID',
'CAN_BUY_ZERO',
'QUANTITY_TRACE',
'QUANTITY',
'WEIGHT',
'WIDTH',
'HEIGHT',
'LENGTH',
//.........这里部分代码省略.........
示例6: OrderProduct
public static function OrderProduct($arParams)
{
if (!is_set($arParams, "RENEWAL") || $arParams["RENEWAL"] != "Y")
$arParams["RENEWAL"] = "N";
if (!is_set($arParams, "USER_ID") || IntVal($arParams["USER_ID"]) <= 0)
$arParams["USER_ID"] = 0;
if (!is_set($arParams["SITE_ID"]))
$arParams["SITE_ID"] = false;
if (!is_set($arParams["CHECK_QUANTITY"]) || $arParams["CHECK_QUANTITY"] != "N")
$arParams["CHECK_QUANTITY"] = "Y";
global $USER;
$productID = intval($arParams["PRODUCT_ID"]);
$quantity = doubleval($arParams["QUANTITY"]);
$renewal = (($arParams["RENEWAL"] == "Y") ? "Y" : "N");
$strSiteID = $arParams["SITE_ID"];
$intUserID = intval($arParams["USER_ID"]);
if (0 > $intUserID)
$intUserID = 0;
$arResult = array();
static $arUserCache = array();
if (0 < $intUserID)
{
if (!isset($arUserCache[$intUserID]))
{
$by = 'ID';
$order = 'DESC';
$rsUsers = CUser::GetList($by, $order, array("ID_EQUAL_EXACT"=>$intUserID),array('FIELDS' => array('ID')));
if ($arUser = $rsUsers->Fetch())
{
$arUser['ID'] = intval($arUser['ID']);
$arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
}
else
{
$intUserID = 0;
return $arResult;
}
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSION" => "N",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if(!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE"))
{
$arUserRights = CIBlockElementRights::GetUserOperations($productID,$intUserID);
if (empty($arUserRights))
{
return $arResult;
}
elseif (!is_array($arUserRights) || !array_key_exists('element_read',$arUserRights))
{
return $arResult;
}
}
else
{
if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID))
{
return $arResult;
}
}
}
else
{
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"CHECK_PERMISSIONS" => "Y",
"MIN_PERMISSION" => "R",
),
false,
false,
array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')
);
if(!($arProduct = $dbIBlockElement->GetNext()))
return $arResult;
}
//.........这里部分代码省略.........
示例7: WDUFSetAccessToEdit
function WDUFSetAccessToEdit(&$files, $contextEntity)
{
global $USER;
if (!is_array($files)) {
return;
}
static $rootDataForCurrentUser = null;
if ($rootDataForCurrentUser === null && $USER->getId()) {
$rootDataForCurrentUser = CWebDavIblock::getRootSectionDataForUser($USER->getId());
}
$listIdFile = $iBlockCacheID = array();
foreach ($files as &$file) {
if (!empty($file['ID']) && !empty($file['NAME'])) {
if ($USER->getId() && !isset($file['IN_PERSONAL_LIB'])) {
$file['IN_PERSONAL_LIB'] = !CWebDavSymlinkHelper::isLink(CWebDavSymlinkHelper::ENTITY_TYPE_USER, $USER->getId(), array('ID' => $file['IBLOCK_SECTION_ID'], 'IBLOCK_ID' => $file['IBLOCK_ID']));
if (!$file['IN_PERSONAL_LIB']) {
$file['IN_PERSONAL_LIB'] = (bool) CWebDavSymlinkHelper::getLinkData(CWebDavSymlinkHelper::ENTITY_TYPE_USER, $USER->getId(), array('ID' => $file['IBLOCK_SECTION_ID'], 'IBLOCK_ID' => $file['IBLOCK_ID']));
}
if ($file['IN_PERSONAL_LIB']) {
$file['EXTERNAL_ID'] = "st{$rootDataForCurrentUser['IBLOCK_ID']}|{$rootDataForCurrentUser['SECTION_ID']}|f{$file['ID']}";
}
}
//file can may editable if in personal lib (local edit) or if office doc - in services
if (CWebDavEditDocGoogle::isEditable($file['NAME']) || !empty($file['IN_PERSONAL_LIB'])) {
$listIdFile[$file['ID']] = $file['ID'];
$iBlockCacheID[] = $file['IBLOCK_ID'];
}
}
}
unset($file);
if (empty($listIdFile)) {
return;
}
$obCache = new CPHPCache();
$cachePath = SITE_ID . "/webdav/inline";
//user - entity - id of files
$cacheID = md5('u' . (int) $USER->getId() . '_e' . $contextEntity . '_f' . implode('|', $listIdFile));
if ($obCache->InitCache(30 * 86400, $cacheID, $cachePath)) {
$vars = $obCache->GetVars();
$result = $vars["RESULT"];
}
if (empty($result) && $obCache->StartDataCache()) {
$result = array();
$rightsByElements = CIBlockElementRights::GetUserOperations($listIdFile);
foreach ($files as &$file) {
if (!isset($listIdFile[$file['ID']])) {
continue;
}
if (!empty($rightsByElements[$file['ID']]) && !empty($rightsByElements[$file['ID']]['element_edit'])) {
$file['EDITABLE'] = true;
$result[$file['ID']] = $file['ID'];
continue;
}
}
unset($file);
global $CACHE_MANAGER;
$CACHE_MANAGER->StartTagCache($cachePath);
foreach ($iBlockCacheID as $ibID) {
$CACHE_MANAGER->RegisterTag("iblock_id_" . $ibID);
}
$CACHE_MANAGER->EndTagCache();
$obCache->EndDataCache(array("RESULT" => $result));
} else {
foreach ($files as &$file) {
if (!isset($listIdFile[$file['ID']])) {
continue;
}
$file['EDITABLE'] = isset($result[$file['ID']]);
}
}
}