00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 include_once( "kernel/classes/ezpersistentobject.php" );
00041
00042 class eZPolicyLimitationValue extends eZPersistentObject
00043 {
00044
00045
00046
00047 function eZPolicyLimitationValue( $row )
00048 {
00049 $this->eZPersistentObject( $row );
00050 }
00051
00052
00053 function definition()
00054 {
00055 return array( "fields" => array( "id" => array( 'name' => 'ID',
00056 'datatype' => 'integer',
00057 'default' => 0,
00058 'required' => true ),
00059 'limitation_id' => array( 'name' => 'LimitationID',
00060 'datatype' => 'integer',
00061 'default' => 0,
00062 'required' => true,
00063 'foreign_class' => 'eZPolicyLimitation',
00064 'foreign_attribute' => 'id',
00065 'multiplicity' => '1..*' ),
00066 'value' => array( 'name' => 'Value',
00067 'datatype' => 'text',
00068 'default' => '',
00069 'required' => true ) ),
00070 "keys" => array( "id" ),
00071 "increment_key" => "id",
00072 "sort" => array( "value" => "asc" ),
00073 "class_name" => "eZPolicyLimitationValue",
00074 "name" => "ezpolicy_limitation_value" );
00075 }
00076
00077
00078
00079
00080
00081
00082 function createNew( $limitationID, $value )
00083 {
00084 $limitationValue = new eZPolicyLimitationValue( array() );
00085 $limitationValue->setAttribute( 'limitation_id', $limitationID );
00086 $limitationValue->setAttribute( 'value', $value );
00087 $limitationValue->store();
00088
00089 return $limitationValue;
00090 }
00091
00092
00093
00094
00095
00096
00097 function create( $limitationID, $value )
00098 {
00099 $row = array( 'id' => null,
00100 'limitation_id' => $limitationID,
00101 'value' => $value );
00102 return new eZPolicyLimitationValue( $row );
00103 }
00104
00105
00106
00107
00108
00109 function copy( $limitationID )
00110 {
00111 $newValue = eZPolicyLimitationValue::createNew( $limitationID, $this->attribute( 'value' ) );
00112 }
00113
00114 function fetchList( $limitationID, $asObject = true )
00115 {
00116 return eZPersistentObject::fetchObjectList( eZPolicyLimitationValue::definition(),
00117 null,
00118 array( 'limitation_id' => $limitationID ),
00119 null,
00120 null,
00121 $asObject );
00122 }
00123
00124
00125
00126
00127
00128 function removeByValue( $value, $policyID = false )
00129 {
00130 if ( $policyID )
00131 {
00132 $limitationIDList = array();
00133 $limitations = eZPolicyLimitation::fetchByPolicyID( $policyID, false );
00134 foreach ( $limitations as $limitationArray )
00135 {
00136 $limitationIDList[] = $limitationArray['id'];
00137 }
00138 if ( count( $limitationIDList ) > 0 )
00139 {
00140 eZPersistentObject::removeObject( eZPolicyLimitationValue::definition(),
00141 array( 'limitation_id' => array( $limitationIDList ),
00142 "value" => $value ) );
00143 return;
00144 }
00145 }
00146 eZPersistentObject::removeObject( eZPolicyLimitationValue::definition(),
00147 array( "value" => $value ) );
00148 }
00149
00150 }
00151
00152 ?>