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


PHP eZUser::hasAccessTo方法代码示例

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


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

示例1: checkAccess

 public static function checkAccess(eZContentObject $contentobject, eZUser $user, $functionName, $originalClassID = false, $parentClassID = false, $returnAccessList = false, $language = false)
 {
     $classID = $originalClassID;
     $userID = $user->attribute('contentobject_id');
     $origFunctionName = $functionName;
     // Fetch the ID of the language if we get a string with a language code
     // e.g. 'eng-GB'
     $originalLanguage = $language;
     if (is_string($language) && strlen($language) > 0) {
         $language = eZContentLanguage::idByLocale($language);
     } else {
         $language = false;
     }
     // This will be filled in with the available languages of the object
     // if a Language check is performed.
     $languageList = false;
     // The 'move' function simply reuses 'edit' for generic access
     // but adds another top-level check below
     // The original function is still available in $origFunctionName
     if ($functionName == 'move') {
         $functionName = 'edit';
     }
     $accessResult = $user->hasAccessTo('content', $functionName);
     $accessWord = $accessResult['accessWord'];
     /*
     // Uncomment this part if 'create' permissions should become implied 'edit'.
     // Merges in 'create' policies with 'edit'
     if ( $functionName == 'edit' &&
          !in_array( $accessWord, array( 'yes', 'no' ) ) )
     {
         // Add in create policies.
         $accessExtraResult = $user->hasAccessTo( 'content', 'create' );
         if ( $accessExtraResult['accessWord'] != 'no' )
         {
             $accessWord = $accessExtraResult['accessWord'];
             if ( isset( $accessExtraResult['policies'] ) )
             {
                 $accessResult['policies'] = array_merge( $accessResult['policies'],
                                                          $accessExtraResult['policies'] );
             }
             if ( isset( $accessExtraResult['accessList'] ) )
             {
                 $accessResult['accessList'] = array_merge( $accessResult['accessList'],
                                                            $accessExtraResult['accessList'] );
             }
         }
     }
     */
     if ($origFunctionName == 'remove' or $origFunctionName == 'move') {
         $mainNode = $contentobject->attribute('main_node');
         // We do not allow these actions on objects placed at top-level
         // - remove
         // - move
         if ($mainNode and $mainNode->attribute('parent_node_id') <= 1) {
             return 0;
         }
     }
     if ($classID === false) {
         $classID = $contentobject->attribute('contentclass_id');
     }
     if ($accessWord == 'yes') {
         return 1;
     } else {
         if ($accessWord == 'no') {
             if ($functionName == 'edit') {
                 // Check if we have 'create' access under the main parent
                 if ($contentobject->attribute('current_version') == 1 && !$contentobject->attribute('status')) {
                     $mainNode = eZNodeAssignment::fetchForObject($contentobject->attribute('id'), $contentobject->attribute('current_version'));
                     $parentObj = $mainNode[0]->attribute('parent_contentobject');
                     $result = $parentObj->checkAccess('create', $contentobject->attribute('contentclass_id'), $parentObj->attribute('contentclass_id'), false, $originalLanguage);
                     return $result;
                 } else {
                     return 0;
                 }
             }
             if ($returnAccessList === false) {
                 return 0;
             } else {
                 return $accessResult['accessList'];
             }
         } else {
             $policies =& $accessResult['policies'];
             $access = 'denied';
             foreach (array_keys($policies) as $pkey) {
                 $limitationArray =& $policies[$pkey];
                 if ($access == 'allowed') {
                     break;
                 }
                 $limitationList = array();
                 if (isset($limitationArray['Subtree'])) {
                     $checkedSubtree = false;
                 } else {
                     $checkedSubtree = true;
                     $accessSubtree = false;
                 }
                 if (isset($limitationArray['Node'])) {
                     $checkedNode = false;
                 } else {
                     $checkedNode = true;
                     $accessNode = false;
//.........这里部分代码省略.........
开发者ID:rantoniazzi,项目名称:xrowmetadata,代码行数:101,代码来源:xrowsitemaptools.php


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