本文整理汇总了PHP中eZContentObjectTreeNode::getParentNodeIdListByContentObjectID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::getParentNodeIdListByContentObjectID方法的具体用法?PHP eZContentObjectTreeNode::getParentNodeIdListByContentObjectID怎么用?PHP eZContentObjectTreeNode::getParentNodeIdListByContentObjectID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::getParentNodeIdListByContentObjectID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkGroupLimitationAccess
/**
* @param array $limitationValueList
* @param int $userID
* @param int|bool $contentObjectID
* @return string Returns "denied" or "allowed"
*/
function checkGroupLimitationAccess( $limitationValueList, $userID, $contentObjectID = false )
{
$access = 'denied';
if ( is_array( $limitationValueList ) && is_numeric( $userID ) )
{
if ( $contentObjectID !== false )
{
$contentObject = eZContentObject::fetch( $contentObjectID );
}
else
{
$contentObject = $this;
}
if ( is_object( $contentObject ) )
{
// limitation value == 1, means "self group"
if ( in_array( 1, $limitationValueList ) )
{
// no need to check groups if user ownes this object
$ownerID = $contentObject->attribute( 'owner_id' );
if ( $ownerID == $userID || $contentObject->attribute( 'id' ) == $userID )
{
$access = 'allowed';
}
else
{
// get parent node ids for 'user' and 'owner'
$groupList = eZContentObjectTreeNode::getParentNodeIdListByContentObjectID( array( $userID, $ownerID ), true );
// find group(s) which is common for 'user' and 'owner'
$commonGroup = array_intersect( $groupList[$userID], $groupList[$ownerID] );
if ( count( $commonGroup ) > 0 )
{
// ok, we have at least 1 common group
$access = 'allowed';
}
}
}
}
}
return $access;
}
示例2: testGetParentNodeIdListByContentObjectID
/**
* Unit test for eZContentObjectTreeNode::getParentNodeIDListByContentObjectID()
*
* @todo test with $onlyMainNode=true
* @todo test with $groupByObjectID=true
*/
public function testGetParentNodeIdListByContentObjectID()
{
// Create a few containers with a few children below each
$childrenIDArray = $childrenParentIDArray = array();
for ( $i = 0; $i < 3; $i++ )
{
$folder = new ezpObject( 'folder', 2 );
$folder->name = "Container #{$i} for " . __FUNCTION__;
$folder->publish();
$containerID = $folder->attribute( 'main_node_id' );
$containerIDArray[] = $containerID;
for ( $j = 0; $j < 5; $j++ )
{
$article = new ezpObject( 'article', $containerID );
$article->title = "Object #{$i}";
$article->publish();
$articleID = $article->attribute( 'id' );
$childrenIDArray[] = $articleID;
$childrenParentIDArray[$articleID] = $containerID;
}
}
// First test without grouping
$parentNodeIDArray = eZContentObjectTreeNode::getParentNodeIdListByContentObjectID(
$childrenIDArray, false );
$this->assertEquals( count( $childrenIDArray ), count( $parentNodeIDArray ),
"count of returned items doesn't match the parameters count" );
foreach( $parentNodeIDArray as $parentNodeID )
{
$this->assertTrue( in_array( $parentNodeID, $containerIDArray ),
"Returned parent_node_id $parentNodeID isn't in the list of created nodes" );
}
}