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


PHP CUser::getUserGroup方法代码示例

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


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

示例1: getSecurityContextByUser

 /**
  * Gets security context (access provider) for user.
  * Attention! File/Folder can use anywhere and SecurityContext have to check rights anywhere (any module).
  * @param mixed $user User which use for check rights.
  * @return SecurityContext
  */
 public function getSecurityContextByUser($user)
 {
     if ($this->isCurrentUser($user)) {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         if (Loader::includeModule('socialnetwork') && \CSocnetUser::isCurrentUserModuleAdmin()) {
             return new FakeSecurityContext($user);
         }
         if (UserModel::isCurrentUserAdmin()) {
             return new FakeSecurityContext($user);
         }
     } else {
         $userId = UserModel::resolveUserId($user);
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         if ($userId && Loader::includeModule('socialnetwork') && \CSocnetUser::isUserModuleAdmin($userId)) {
             return new FakeSecurityContext($user);
         }
         try {
             if ($userId && ModuleManager::isModuleInstalled('bitrix24') && Loader::includeModule('bitrix24') && \CBitrix24::isPortalAdmin($userId)) {
                 return new FakeSecurityContext($user);
             } elseif ($userId) {
                 //Check user group 1 ('Admins')
                 $tmpUser = new \CUser();
                 $arGroups = $tmpUser->getUserGroup($userId);
                 if (in_array(1, $arGroups)) {
                     return new FakeSecurityContext($user);
                 }
             }
         } catch (\Exception $e) {
         }
     }
     return new DiskSecurityContext($user);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:38,代码来源:disk.php

示例2: processActionCheckDelegateResponsible

 protected function processActionCheckDelegateResponsible()
 {
     $this->checkRequiredPostParams(array('iblockId'));
     if (!Loader::includeModule('iblock')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK'))));
     }
     $this->iblockId = intval($this->request->getPost('iblockId'));
     $this->iblockTypeId = COption::GetOptionString('lists', 'livefeed_iblock_type_id');
     $this->checkPermission();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $rightObject = new CIBlockRights($this->iblockId);
     $rights = $rightObject->getRights();
     $rightsList = $rightObject->getRightsList(false);
     $idRight = array_search('iblock_full', $rightsList);
     $listUser = array();
     $nameTemplate = CSite::GetNameFormat(false);
     $count = 0;
     foreach ($rights as $right) {
         $res = strpos($right['GROUP_CODE'], 'U');
         if ($right['TASK_ID'] == $idRight && $res === 0) {
             $userId = substr($right['GROUP_CODE'], 1);
             $userGroups = CUser::getUserGroup($userId);
             if (!in_array(1, $userGroups)) {
                 $userQuery = CUser::getByID($userId);
                 if ($user = $userQuery->getNext()) {
                     $listUser[$count]['id'] = $right['GROUP_CODE'];
                     $listUser[$count]['name'] = CUser::formatName($nameTemplate, $user, false);
                 }
             }
         }
         $count++;
     }
     $this->sendJsonSuccessResponse(array('listUser' => $listUser));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:36,代码来源:ajax.php

示例3: CanUserOperateDocumentType

 function CanUserOperateDocumentType($operation, $userId, $documentType, $parameters = array())
 {
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     $parameters["IBlockId"] = intval(substr($documentType, strlen("iblock_")));
     $parameters['sectionId'] = !empty($parameters['sectionId']) ? (int) $parameters['sectionId'] : 0;
     if (!array_key_exists("IBlockRightsMode", $parameters)) {
         $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE");
     }
     if ($parameters["IBlockRightsMode"] === "E") {
         if ($operation === CBPCanUserOperateOperation::CreateWorkflow) {
             return CIBlockRights::userHasRightTo($parameters["IBlockId"], $parameters["IBlockId"], "iblock_rights_edit");
         } elseif ($operation === CBPCanUserOperateOperation::WriteDocument) {
             return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters["sectionId"], "section_element_bind");
         } elseif ($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow) {
             if (!array_key_exists("WorkflowId", $parameters)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow) {
                 return CIBlockRights::userHasRightTo($parameters["IBlockId"], 0, "element_read");
             }
             if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
                 return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters['sectionId'], "section_element_bind");
             }
             $userId = intval($userId);
             if (!array_key_exists("AllUserGroups", $parameters)) {
                 if (!array_key_exists("UserGroups", $parameters)) {
                     $parameters["UserGroups"] = CUser::getUserGroup($userId);
                 }
                 $parameters["AllUserGroups"] = $parameters["UserGroups"];
                 $parameters["AllUserGroups"][] = "Author";
             }
             if (!array_key_exists("DocumentStates", $parameters)) {
                 if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
                     $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]));
                 } else {
                     $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null);
                 }
             }
             if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
                 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
             } else {
                 return false;
             }
             $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"], true);
             if (!is_array($allowableOperations)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow && in_array("read", $allowableOperations) || $operation === CBPCanUserOperateOperation::StartWorkflow && in_array("write", $allowableOperations)) {
                 return true;
             }
             $chop = $operation === CBPCanUserOperateOperation::ViewWorkflow ? "element_read" : "section_element_bind";
             $tasks = self::getRightsTasks();
             foreach ($allowableOperations as $op) {
                 if (isset($tasks[$op])) {
                     $op = $tasks[$op]['ID'];
                 }
                 $ar = CTask::getOperations($op, true);
                 if (in_array($chop, $ar)) {
                     return true;
                 }
             }
         }
         return false;
     }
     if (!array_key_exists("IBlockPermission", $parameters)) {
         if (CModule::includeModule('lists')) {
             $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId);
         } else {
             $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId);
         }
     }
     if ($parameters["IBlockPermission"] <= "R") {
         return false;
     } elseif ($parameters["IBlockPermission"] >= "W") {
         return true;
     }
     $userId = intval($userId);
     if (!array_key_exists("AllUserGroups", $parameters)) {
         if (!array_key_exists("UserGroups", $parameters)) {
             $parameters["UserGroups"] = CUser::getUserGroup($userId);
         }
         $parameters["AllUserGroups"] = $parameters["UserGroups"];
         $parameters["AllUserGroups"][] = "Author";
     }
     if (!array_key_exists("DocumentStates", $parameters)) {
         $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null);
     }
     if (array_key_exists("WorkflowId", $parameters)) {
         if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
             $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
         } else {
             return false;
         }
     }
     $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"]);
     if (!is_array($allowableOperations)) {
         return false;
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:bizprocdocument.php

示例4: getProductDataToFillBasket


//.........这里部分代码省略.........
                 if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") {
                     $columnCode = str_replace("_VALUE", "", $key);
                     $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
                 }
             }
         }
         unset($arElement);
         if (isset($arProductData[$productId])) {
             $arElementInfo = $arProductData[$productId];
         }
         if (isset($arSku2Parent[$productId])) {
             $arParent = $arProductData[$arSku2Parent[$productId]];
         }
         if (!empty($arSku2Parent)) {
             foreach ($arUserColumns as $field) {
                 $fieldVal = $field . "_VALUE";
                 $parentId = $arSku2Parent[$productId];
                 if ((!isset($arElementInfo[$fieldVal]) || isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
                     $arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
                 }
             }
             if (strpos($arElementInfo["~XML_ID"], '#') === false) {
                 $arElementInfo["~XML_ID"] = $arParent['~XML_ID'] . '#' . $arElementInfo["~XML_ID"];
             }
         }
         $arElementInfo["MODULE"] = "catalog";
         $arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
         $arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];
         if ($arElementInfo["IBLOCK_ID"] > 0) {
             $arElementInfo["EDIT_PAGE_URL"] = \CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array("find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
         }
         static $buyersGroups = array();
         if (empty($buyersGroups[$userId])) {
             $buyersGroups[$userId] = \CUser::getUserGroup($userId);
         }
         $arBuyerGroups = $buyersGroups[$userId];
         // price
         $currentVatMode = \CCatalogProduct::getPriceVatIncludeMode();
         $currentUseDiscount = \CCatalogProduct::getUseDiscount();
         \CCatalogProduct::setUseDiscount(!$isSetItem);
         \CCatalogProduct::setPriceVatIncludeMode(true);
         \CCatalogProduct::setUsedCurrency(Sale\Internals\SiteCurrencyTable::getSiteCurrency($LID));
         $arPrice = \CCatalogProduct::getOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
         \CCatalogProduct::clearUsedCurrency();
         \CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
         \CCatalogProduct::setUseDiscount($currentUseDiscount);
         unset($currentUseDiscount, $currentVatMode);
         $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
         $arElementInfo['PRICE'] = $currentPrice;
         $arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
         $currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE'];
         $arProduct = array();
         if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId])) {
             $arProduct = $proxyCatalogProduct[$productId];
         } else {
             $rsProducts = \CCatalogProduct::getList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI'));
             if ($arProduct = $rsProducts->Fetch()) {
                 $proxyCatalogProduct[$productId] = $arProduct;
             }
         }
         if (empty($arProduct) || !is_array($arProduct)) {
             return array();
         }
         $balance = floatval($arProduct["QUANTITY"]);
         // sku props
         $arSkuData = array();
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:orderbasket.php

示例5: loadDiscountByUserGroups

 /**
  * Load from database discount id for user groups.
  *
  * @return void
  * @throws Main\ArgumentException
  */
 protected function loadDiscountByUserGroups()
 {
     if (!array_key_exists('USER_ID', $this->orderData)) {
         return;
     }
     $userGroups = \CUser::getUserGroup($this->orderData['USER_ID']);
     Main\Type\Collection::normalizeArrayValuesByInt($userGroups);
     $cacheKey = md5('U' . implode('_', $userGroups));
     if (!isset($this->discountByUserCache[$cacheKey])) {
         $discountCache = array();
         $groupDiscountIterator = Internals\DiscountGroupTable::getList(array('select' => array('DISCOUNT_ID'), 'filter' => array('@GROUP_ID' => $userGroups, '=ACTIVE' => 'Y'), 'order' => array('DISCOUNT_ID' => 'ASC')));
         while ($groupDiscount = $groupDiscountIterator->fetch()) {
             $groupDiscount['DISCOUNT_ID'] = (int) $groupDiscount['DISCOUNT_ID'];
             if ($groupDiscount['DISCOUNT_ID'] > 0) {
                 $discountCache[$groupDiscount['DISCOUNT_ID']] = $groupDiscount['DISCOUNT_ID'];
             }
         }
         unset($groupDiscount, $groupDiscountIterator);
         if (!empty($discountCache)) {
             $this->discountByUserCache[$cacheKey] = $discountCache;
         }
         unset($discountCache);
     }
     $this->discountIds = $this->discountByUserCache[$cacheKey];
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:discount.php

示例6: calculateFull

 /**
  * Calculate discount by new order.
  *
  * @return Result
  */
 protected function calculateFull()
 {
     $result = new Result();
     $this->discountIds = array();
     if (!$this->isMixedBasket()) {
         $this->fillEmptyDiscountResult();
     } else {
         $this->discountResult['ORDER'] = array();
     }
     $order = $this->getOrder();
     $basket = $order->getBasket();
     /** @var BasketItem $basketItem */
     foreach ($basket as $basketItem) {
         $code = $basketItem->getBasketCode();
         if ($this->isCustomPriceByCode($code)) {
             if (array_key_exists($code, $this->basketDiscountList)) {
                 unset($this->basketDiscountList[$code]);
             }
         } else {
             if (!isset($this->basketDiscountList[$code])) {
                 $this->basketDiscountList[$code] = $basketItem->getField('DISCOUNT_LIST');
                 if ($this->basketDiscountList[$code] === null) {
                     unset($this->basketDiscountList[$code]);
                 }
             }
         }
     }
     unset($code, $basketItem, $basket);
     $this->resetBasketPrices();
     if ($this->isMixedBasket()) {
         DiscountCouponsManager::clearApply(false);
         $basketDiscountResult = $this->calculateMixedBasketDiscount();
     } else {
         DiscountCouponsManager::clearApply();
         $basketDiscountResult = $this->calculateFullBasketDiscount();
     }
     if (!$basketDiscountResult->isSuccess()) {
         $result->addErrors($basketDiscountResult->getErrors());
         unset($basketDiscountResult);
         return $result;
     }
     unset($basketDiscountResult);
     $this->roundBasketPrices();
     $codeList = array_keys($this->orderData['BASKET_ITEMS']);
     switch (self::getApplyMode()) {
         case self::APPLY_MODE_DISABLE:
             foreach ($codeList as &$code) {
                 if (isset($this->basketDiscountList[$code]) && !empty($this->basketDiscountList[$code])) {
                     $this->orderData['BASKET_ITEMS'][$code]['LAST_DISCOUNT'] = 'Y';
                 }
             }
             unset($code);
             break;
         case self::APPLY_MODE_LAST:
             foreach ($codeList as &$code) {
                 if (!isset($this->basketDiscountList[$code]) || empty($this->basketDiscountList[$code])) {
                     continue;
                 }
                 $lastDiscount = end($this->basketDiscountList[$code]);
                 if (!empty($lastDiscount['LAST_DISCOUNT']) && $lastDiscount['LAST_DISCOUNT'] == 'Y') {
                     $this->orderData['BASKET_ITEMS'][$code]['LAST_DISCOUNT'] = 'Y';
                 }
             }
             unset($code);
             break;
         case self::APPLY_MODE_ADD:
             break;
     }
     unset($codeList);
     $userGroups = \CUser::getUserGroup($this->orderData['USER_ID']);
     Main\Type\Collection::normalizeArrayValuesByInt($userGroups);
     $cacheKey = md5('U' . implode('_', $userGroups));
     if (!isset($this->discountByUserCache[$cacheKey])) {
         $discountCache = array();
         $groupDiscountIterator = Internals\DiscountGroupTable::getList(array('select' => array('DISCOUNT_ID'), 'filter' => array('@GROUP_ID' => $userGroups, '=ACTIVE' => 'Y')));
         while ($groupDiscount = $groupDiscountIterator->fetch()) {
             $groupDiscount['DISCOUNT_ID'] = (int) $groupDiscount['DISCOUNT_ID'];
             if ($groupDiscount['DISCOUNT_ID'] > 0) {
                 $discountCache[$groupDiscount['DISCOUNT_ID']] = $groupDiscount['DISCOUNT_ID'];
             }
         }
         unset($groupDiscount, $groupDiscountIterator);
         if (!empty($discountCache)) {
             Main\Type\Collection::normalizeArrayValuesByInt($discountCache);
             $this->discountByUserCache[$cacheKey] = $discountCache;
         }
         unset($discountCache);
     }
     if (!empty($this->discountByUserCache[$cacheKey])) {
         $this->discountIds = $this->discountByUserCache[$cacheKey];
     }
     if (empty($this->discountIds)) {
         $this->discountIds = null;
     } else {
         $this->getDiscountModules();
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:discount.php


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