本文整理匯總了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;
//.........這裏部分代碼省略.........