Пример #1
0
     $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));
 } else {
     $db->commit();
     $currentLimitationList = array();
     foreach ($currentFunctionLimitations as $currentFunctionLimitation) {
         $limitationName = $currentFunctionLimitation['name'];
         $currentLimitationList[$limitationName] = '-1';
Пример #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;
}
 function copy($limitationID)
 {
     $newValue = eZPolicyLimitationValue::createNew($limitationID, $this->attribute('value'));
 }