コード例 #1
0
    public function setUp()
    {
        parent::setUp();

        $this->policy = eZPolicy::createNew(
            1, array( 'ModuleName' => 'foo', 'FunctionName' => 'bar' )
        );

        eZPolicyLimitation::createNew(
            $this->policy->attribute( 'id' ), 'Owner'
        );
    }
コード例 #2
0
/**
 * Applies the POST submitted limitations as found in the dropdowns
 * @param eZPolicy $policy
 * @param string $currentModule
 * @param string $currentFunction
 * @param array $currentFunctionLimitations
 *
 * @return bool True if limitations were found, false otherwise
 */
function processDropdownLimitations( &$policy, $currentModule, $currentFunction, $currentFunctionLimitations )
{
    $hasLimitation = false;

    $http = eZHTTPTool::instance();

    $db = eZDB::instance();
    $db->begin();

    foreach ( $currentFunctionLimitations as $functionLimitation )
    {
        if ( $http->hasPostVariable( $functionLimitation['name'] ) and
            $functionLimitation['name'] != 'Node' and
            $functionLimitation['name'] != 'Subtree' )
        {
            $limitationValueList = $http->postVariable( $functionLimitation['name'] );

            if ( !in_array('-1', $limitationValueList ) )
            {
                $hasLimitation = true;
                $policyLimitation = eZPolicyLimitation::createNew( $policy->attribute( 'id' ),
                                                                   $functionLimitation['name'] );
                foreach ( $limitationValueList as $limitationValue )
                {
                    eZPolicyLimitationValue::createNew( $policyLimitation->attribute( 'id' ), $limitationValue );
                }
            }
        }
    }

    $db->commit();

    return $hasLimitation;
}
コード例 #3
0
ファイル: edit.php プロジェクト: mugoweb/ezpublish-legacy
             $node = eZContentObjectTreeNode::fetch($nodeID);
             $nodeList[] = $node;
         }
     }
 }
 if ($http->hasPostVariable('SelectedNodeIDArray') and $http->postVariable('BrowseActionName') == 'FindLimitationSubtree' and !$http->hasPostVariable('BrowseCancelButton')) {
     $selectedSubtreeIDList = $http->postVariable('SelectedNodeIDArray');
     if ($http->hasSessionVariable('BrowsePolicyID')) {
         $policy = eZPolicy::fetch($http->sessionVariable('BrowsePolicyID'));
     } else {
         $policy = eZPolicy::createNew($roleID, array('ModuleName' => $currentModule, 'FunctionName' => $currentFunction, 'Limitation' => ''));
         $http->setSessionVariable('BrowsePolicyID', $policy->attribute('id'));
     }
     $subtreeLimitation = eZPolicyLimitation::fetchByIdentifier($policy->attribute('id'), 'Subtree');
     if ($subtreeLimitation == null) {
         $subtreeLimitation = eZPolicyLimitation::createNew($policy->attribute('id'), 'Subtree');
     }
     foreach ($selectedSubtreeIDList as $nodeID) {
         if (!in_array($nodeID, $subtreeIDList)) {
             $subtree = eZContentObjectTreeNode::fetch($nodeID);
             $pathString = $subtree->attribute('path_string');
             $policyLimitationValue = eZPolicyLimitationValue::createNew($subtreeLimitation->attribute('id'), $pathString);
             $subtreeList[] = $subtree;
         }
     }
 }
 if ($http->hasPostVariable('Limitation') && count($currentFunctionLimitations) == 0) {
     $currentModule = $http->postVariable('CurrentModule');
     $currentFunction = $http->postVariable('ModuleFunction');
     eZDebugSetting::writeDebug('kernel-role-edit', $currentModule, 'currentModule');
     $policy = eZPolicy::createNew($roleID, array('ModuleName' => $currentModule, 'FunctionName' => $currentFunction));
コード例 #4
0
ファイル: edit.php プロジェクト: nlenardou/ezpublish
             $node = eZContentObjectTreeNode::fetch($nodeID);
             $nodeList[] = $node;
         }
     }
 }
 if ($http->hasPostVariable('SelectedNodeIDArray') and $http->postVariable('BrowseActionName') == 'FindLimitationSubtree' and !$http->hasPostVariable('BrowseCancelButton')) {
     $selectedSubtreeIDList = $http->postVariable('SelectedNodeIDArray');
     if ($http->hasSessionVariable('BrowsePolicyID')) {
         $policy = eZPolicy::fetch($http->sessionVariable('BrowsePolicyID'));
     } else {
         $policy = eZPolicy::createNew($roleID, array('ModuleName' => $currentModule, 'FunctionName' => $currentFunction, 'Limitation' => ''));
         $http->setSessionVariable('BrowsePolicyID', $policy->attribute('id'));
     }
     $subtreeLimitation = eZPolicyLimitation::fetchByIdentifier($policy->attribute('id'), 'Subtree');
     if ($subtreeLimitation == null) {
         $subtreeLimitation = eZPolicyLimitation::createNew($policy->attribute('id'), 'Subtree', $currentModule, $currentFunction);
     }
     foreach ($selectedSubtreeIDList as $nodeID) {
         if (!in_array($nodeID, $subtreeIDList)) {
             $subtree = eZContentObjectTreeNode::fetch($nodeID);
             $pathString = $subtree->attribute('path_string');
             $policyLimitationValue = eZPolicyLimitationValue::createNew($subtreeLimitation->attribute('id'), $pathString);
             $subtreeList[] = $subtree;
         }
     }
 }
 if ($http->hasPostVariable('Limitation') && count($currentFunctionLimitations) == 0) {
     $currentModule = $http->postVariable('CurrentModule');
     $currentFunction = $http->postVariable('ModuleFunction');
     eZDebugSetting::writeDebug('kernel-role-edit', $currentModule, 'currentModule');
     $policy = eZPolicy::createNew($roleID, array('ModuleName' => $currentModule, 'FunctionName' => $currentFunction));
コード例 #5
0
ファイル: ezpolicylimitation.php プロジェクト: nfrp/ezpublish
 function copy($policyID)
 {
     $newParameter = eZPolicyLimitation::createNew($policyID, $this->attribute('identifier'));
     foreach ($this->attribute('values') as $value) {
         $value->copy($newParameter->attribute('id'));
     }
 }
コード例 #6
0
ファイル: policyedit.php プロジェクト: runelangseid/ezpublish
        $nodeLimitation = eZPolicyLimitation::createNew($policyID, "Node", $currentModule, $currentFunction);
    }
    foreach ($selectedNodeIDList as $nodeID) {
        if (!in_array($nodeID, $nodeIDList)) {
            $nodeLimitationValue = eZPolicyLimitationValue::createNew($nodeLimitation->attribute('id'), $nodeID);
            $node = eZContentObjectTreeNode::fetch($nodeID);
            $nodeList[] = $node;
        }
    }
}
if ($http->hasPostVariable("SelectedNodeIDArray") and $http->postVariable("BrowseActionName") == "FindLimitationSubtree" and !$http->hasPostVariable('BrowseCancelButton')) {
    $selectedSubtreeIDList = $http->postVariable("SelectedNodeIDArray");
    $db = eZDB::instance();
    $db->begin();
    if ($subtreeLimitation == null) {
        $subtreeLimitation = eZPolicyLimitation::createNew($policyID, "Subtree", $currentModule, $currentFunction);
    }
    foreach ($selectedSubtreeIDList as $nodeID) {
        if (!isset($subtreeIDList) or !in_array($nodeID, $subtreeIDList)) {
            $subtree = eZContentObjectTreeNode::fetch($nodeID);
            $pathString = $subtree->attribute('path_string');
            $policyLimitationValue = eZPolicyLimitationValue::createNew($subtreeLimitation->attribute('id'), $pathString);
            $subtreeList[] = $subtree;
        }
    }
    $db->commit();
}
$currentLimitationList = array();
foreach ($currentFunctionLimitations as $currentFunctionLimitation) {
    $currentLimitationList[$currentFunctionLimitation['name']] = "-1";
}