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


PHP CIBlockRights::userHasRightTo方法代码示例

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


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

示例1: canRead

 public function canRead($userId)
 {
     if (!Loader::includeModule("iblock")) {
         return false;
     }
     $iblockId = $this->entityId;
     return \CIBlockRights::userHasRightTo($iblockId, $iblockId, "element_read") || \CIBlockSectionRights::userHasRightTo($iblockId, 0, "section_element_bind");
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:8,代码来源:iblockworkflowconnector.php

示例2: checkPermission

 protected function checkPermission()
 {
     global $USER;
     $this->listPerm = CListPermissions::checkAccess($USER, $this->iblockTypeId, $this->iblockId, $this->socnetGroupId);
     if ($this->listPerm < 0) {
         switch ($this->listPerm) {
             case CListPermissions::WRONG_IBLOCK_TYPE:
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_WRONG_IBLOCK_TYPE'))));
                 break;
             case CListPermissions::WRONG_IBLOCK:
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_WRONG_IBLOCK'))));
                 break;
             case CListPermissions::LISTS_FOR_SONET_GROUP_DISABLED:
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_SONET_GROUP_DISABLED'))));
                 break;
             default:
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_UNKNOWN_ERROR'))));
                 break;
         }
     } elseif ($this->listPerm < CListPermissions::CAN_READ && !(CIBlockRights::userHasRightTo($this->iblockId, $this->iblockId, "element_read") || CIBlockSectionRights::userHasRightTo($this->iblockId, $this->sectionId, "section_element_bind"))) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:23,代码来源: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


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