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


PHP eZContentObjectTreeNode::getParentNodeIdListByContentObjectID方法代码示例

本文整理汇总了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;
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:52,代码来源:ezcontentobject.php

示例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" );
        }
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:41,代码来源:ezcontentobjecttreenode_test.php


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