Beispiel #1
0
 static function createNew($policyID, $identifier)
 {
     $policyParameter = new eZPolicyLimitation(array());
     $policyParameter->setAttribute('policy_id', $policyID);
     $policyParameter->setAttribute('identifier', $identifier);
     $policyParameter->store();
     return $policyParameter;
 }
Beispiel #2
0
 function limitationList($useCache = true, $ignoreLimitIdentifier = false)
 {
     if (!isset($this->Limitations) || !$useCache) {
         $limitations = eZPersistentObject::fetchObjectList(eZPolicyLimitation::definition(), null, array('policy_id' => $this->attribute('id')), null, null, true);
         eZDebugSetting::writeDebug('kernel-policy-limitation', $limitations, "before policy limitations " . $this->ID);
         eZDebugSetting::writeDebug('kernel-policy-limitation', $this, "policy itself before before limitations check");
         if ($ignoreLimitIdentifier === false && isset($this->LimitIdentifier) && $this->LimitIdentifier) {
             $limitIdentifier = $this->attribute('limit_identifier');
             $limitValue = $this->attribute('limit_value');
             $limitationTouched = false;
             $checkEmptyLimitation = true;
             foreach ($limitations as $limitation) {
                 if ($limitation->attribute('identifier') == $limitIdentifier) {
                     if ($limitIdentifier == 'Subtree') {
                         $limitationTouched = true;
                         $values = $limitation->attribute('values');
                         foreach ($values as $limitationValue) {
                             $value = $limitationValue->attribute('value');
                             if (strpos($value, $limitValue) === 0) {
                                 $checkEmptyLimitation = false;
                                 eZDebugSetting::writeDebug('kernel-policy-limitation', $value, "Limitationvalue has been left in the limitation [limitValue={$limitValue}]");
                             } else {
                                 if (strpos($limitValue, $value) === 0) {
                                     $checkEmptyLimitation = false;
                                     $limitationValue->setAttribute('value', $limitValue);
                                     eZDebugSetting::writeDebug('kernel-policy-limitation', $value, "Limitationvalue has been exchanged to the value from cond assignment [limitValue={$limitValue}]");
                                 } else {
                                     eZDebugSetting::writeDebug('kernel-policy-limitation', $value, "Limitationvalue has been removed from limitation [limitValue={$limitValue}]");
                                     //exlude limitation value from limitation..
                                     unset($limitationValue);
                                 }
                             }
                         }
                         if ($checkEmptyLimitation) {
                             eZDebugSetting::writeDebug('kernel-policy-limitation', $this, 'The policy has been disabled');
                             $this->Disabled = true;
                             $this->Limitations = array();
                             return $this->Limitations;
                         }
                     }
                 }
             }
             if (!$limitationTouched) {
                 $policyLimitation = new eZPolicyLimitation(array('id' => -1, 'policy_id' => $this->attribute('id'), 'identifier' => $this->attribute('limit_identifier')));
                 $policyLimitation->setAttribute('limit_value', $this->attribute('limit_value'));
                 $limitations[] = $policyLimitation;
             }
         }
         eZDebugSetting::writeDebug('kernel-policy-limitation', $limitations, "policy limitations " . $this->ID);
         $this->Limitations = $limitations;
     }
     return $this->Limitations;
 }