當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。