static function removeByValue($value, $policyID = false) { if ($policyID) { $limitationIDList = array(); $limitations = eZPolicyLimitation::fetchByPolicyID($policyID, false); foreach ($limitations as $limitationArray) { $limitationIDList[] = $limitationArray['id']; } if (count($limitationIDList) > 0) { eZPersistentObject::removeObject(eZPolicyLimitationValue::definition(), array('limitation_id' => array($limitationIDList), "value" => $value)); return; } } eZPersistentObject::removeObject(eZPolicyLimitationValue::definition(), array("value" => $value)); }
/** * 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; }
$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'; } if (isset($policyID)) { $limitationList = eZPolicyLimitation::fetchByPolicyID($policyID); foreach ($limitationList as $limitation) { $limitationID = $limitation->attribute('id'); $limitationIdentifier = $limitation->attribute('identifier'); $limitationValues = eZPolicyLimitationValue::fetchList($limitationID); $valueList = array(); foreach ($limitationValues as $limitationValue) { $value = $limitationValue->attribute('value'); $valueList[] = $value; } $currentLimitationList[$limitationIdentifier] = $valueList; } } $tpl->setVariable('current_function', $currentFunction); $tpl->setVariable('function_limitations', $currentFunctionLimitations); $tpl->setVariable('no_limitations', $noLimitations); $tpl->setVariable('current_module', $currentModule); $tpl->setVariable('functions', $functionNames); $tpl->setVariable('node_list', $nodeList); $tpl->setVariable('subtree_list', $subtreeList);
function appendLimitation($identifier, $values) { $limitation = eZPolicyLimitation::create($this->ID, $identifier); $db = eZDB::instance(); $db->begin(); $limitation->store(); $limitationID = $limitation->attribute('id'); $limitations = array(); foreach ($values as $value) { $limitationValue = eZPolicyLimitationValue::create($limitationID, $value); $limitationValue->store(); if (isset($limitation->Values)) { $limitation->Values[] = $limitationValue; } } $db->commit(); if (isset($this->Limitations)) { $this->Limitations[] = $limitation; } return $limitation; }
function valueList() { if (!isset($this->Values)) { $values = eZPersistentObject::fetchObjectList(eZPolicyLimitationValue::definition(), null, array('limitation_id' => $this->attribute('id')), null, null, true); if ($this->LimitValue) { $values[] = new eZPolicyLimitationValue(array('id' => -1, 'value' => $this->LimitValue)); } $this->Values = $values; } return $this->Values; }