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 include_once( 'kernel/classes/workflowtypes/event/ezwaituntildate/ezwaituntildatevalue.php' );
00040
00041 class eZWaitUntilDate
00042 {
00043 function eZWaitUntilDate( $eventID, $eventVersion )
00044 {
00045 $this->WorkflowEventID = $eventID;
00046 $this->WorkflowEventVersion = $eventVersion;
00047 $this->Entries =& eZWaitUntilDateValue::fetchAllElements( $eventID, $eventVersion );
00048 }
00049
00050 function attributes()
00051 {
00052 return array( 'workflow_event_id',
00053 'workflow_event_version',
00054 'entry_list',
00055 'classattribute_id_list' );
00056 }
00057
00058 function hasAttribute( $attr )
00059 {
00060 return in_array( $attr, $this->attributes() );
00061 }
00062
00063 function &attribute( $attr )
00064 {
00065 switch ( $attr )
00066 {
00067 case "workflow_event_id" :
00068 {
00069 return $this->WorkflowEventID;
00070 }break;
00071 case "workflow_event_version" :
00072 {
00073 return $this->WorkflowEventVersion;
00074 }break;
00075 case "entry_list" :
00076 {
00077 return $this->Entries;
00078 }break;
00079 case 'classattribute_id_list' :
00080 {
00081 return $this->classAttributeIDList();
00082 }
00083 default :
00084 {
00085 eZDebug::writeError( "Attribute '$attr' does not exist", 'eZWaitUntilDate::attribute' );
00086 $retValue = null;
00087 return $retValue;
00088 }break;
00089 }
00090 }
00091 function removeWaitUntilDateEntries( $workflowEventID, $workflowEventVersion )
00092 {
00093 eZWaitUntilDateValue::removeAllElements( $workflowEventID, $workflowEventVersion );
00094 }
00095
00096
00097
00098 function addEntry( $contentClassAttributeID, $contentClassID = false )
00099 {
00100 if ( !isset( $contentClassAttributeID ) )
00101 {
00102 return;
00103 }
00104 if ( !$contentClassID )
00105 {
00106 $contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
00107 $contentClassID = $contentClassAttribute->attribute( 'contentclass_id' );
00108 }
00109
00110 foreach ( $this->Entries as $entrie )
00111 {
00112 if ( $entrie->attribute( 'contentclass_attribute_id' ) == $contentClassAttributeID and
00113 $entrie->attribute( 'contentclass_id' ) == $contentClassID )
00114 return;
00115 }
00116 $waitUntilDateValue = eZWaitUntilDateValue::create( $this->WorkflowEventID, $this->WorkflowEventVersion, $contentClassAttributeID, $contentClassID );
00117 $waitUntilDateValue->store();
00118 $this->Entries =& eZWaitUntilDateValue::fetchAllElements( $this->WorkflowEventID, $this->WorkflowEventVersion );
00119 }
00120
00121 function removeEntry( $workflowEventID, $id, $version )
00122 {
00123 eZDebug::writeDebug( "$workflowEventID - $id - $version ", 'remove params 2' );
00124
00125 eZWaitUntilDateValue::remove( $id, $version );
00126 $this->Entries =& eZWaitUntilDateValue::fetchAllElements( $workflowEventID, $version );
00127 }
00128
00129 function &classAttributeIDList()
00130 {
00131 $attributeIDList = array();
00132 foreach ( array_keys( $this->Entries ) as $key )
00133 {
00134 $entry =& $this->Entries[$key];
00135 $attributeIDList[] = $entry->attribute( 'contentclass_attribute_id' );
00136 }
00137 return $attributeIDList;
00138 }
00139
00140 function setVersion( $version )
00141 {
00142 if ( $version == 1 && count( $this->Entries ) == 0 )
00143 {
00144 $this->Entries = eZWaitUntilDateValue::fetchAllElements( $this->WorkflowEventID, 0 );
00145 for ( $i = 0; $i < count( $this->Entries ); $i++ )
00146 {
00147 $entry =& $this->Entries[$i];
00148 $entry->setAttribute( "workflow_event_version", 1 );
00149 $entry->store();
00150 }
00151 }
00152 if ( $version == 0 )
00153 {
00154 eZWaitUntilDateValue::removeAllElements( $this->WorkflowEventID, 0 );
00155 foreach( $this->Entries as $entry )
00156 {
00157 $id = $entry->attribute( "id" );
00158 $workflowEventID = $entry->attribute( "workflow_event_id" );
00159 $contentClassID = $entry->attribute( "contentclass_id" );
00160 $contentClassAttributeID = $entry->attribute( "contentclass_attribute_id" );
00161 $entryCopy = eZWaitUntilDateValue::createCopy( $id,
00162 $workflowEventID,
00163 0,
00164 $contentClassID,
00165 $contentClassAttributeID );
00166
00167 $entryCopy->store();
00168 }
00169 }
00170
00171 }
00172
00173
00174 var $WorkflowEventID;
00175 var $WorkflowEventVersion;
00176 var $Entries;
00177
00178 }
00179
00180
00181 ?>