| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZWaitUntilDateType class 4 // 5 // Created on: <09-Jan-2003 15:01:18 sp> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezwaituntildatetype.php 30 */ 31 32 /*! 33 \class eZWaitUntilDateType ezwaituntildatetype.php 34 \brief The class eZWaitUntilDateType does 35 36 */ 37 include_once ( 'kernel/classes/workflowtypes/event/ezwaituntildate/ezwaituntildate.php' ); 38 define( "EZ_WORKFLOW_TYPE_WAIT_UNTIL_DATE_ID", "ezwaituntildate" ); 39 40 class eZWaitUntilDateType extends eZWorkflowEventType 41 { 42 /*! 43 Constructor 44 */ 45 function eZWaitUntilDateType() 46 { 47 $this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_WAIT_UNTIL_DATE_ID, ezi18n( 'kernel/workflow/event', "Wait until date" ) ); 48 $this->setTriggerTypes( array( 'content' => array( 'publish' => array( 'before', 49 'after' ) ) ) ); 50 } 51 52 function execute( &$process, &$event ) 53 { 54 $parameters = $process->attribute( 'parameter_list' ); 55 $object =& eZContentObject::fetch( $parameters['object_id'] ); 56 $version =& $object->version( $parameters['version'] ); 57 $objectAttributes = $version->attribute( 'contentobject_attributes' ); 58 $waitUntilDateObject =& $this->workflowEventContent( $event ); 59 $waitUntilDateEntryList = $waitUntilDateObject->attribute( 'classattribute_id_list' ); 60 $modifyPublishDate = $event->attribute( 'data_int1' ); 61 eZDebug::writeDebug( 'executing publish on time event' ); 62 // eZDebug::writeDebug( $waitUntilDateEntryList, 'executing publish on time event' ); 63 // eZDebug::writeDebug( $objectAttributes, 'publish on time event' ); 64 65 foreach ( array_keys( $objectAttributes ) as $key ) 66 { 67 $objectAttribute =& $objectAttributes[$key]; 68 $contentClassAttributeID = $objectAttribute->attribute( 'contentclassattribute_id' ); 69 // eZDebug::writeDebug( $waitUntilDateEntryList, "checking if $contentClassAttributeID in array:" ); 70 if ( in_array( $objectAttribute->attribute( 'contentclassattribute_id' ), $waitUntilDateEntryList ) ) 71 { 72 $dateTime =& $objectAttribute->attribute( 'content' ); 73 if ( get_class( $dateTime ) == 'ezdatetime' or 74 get_class( $dateTime ) == 'eztime' or 75 get_class( $dateTime ) == 'ezdate' ) 76 { 77 if ( time() < $dateTime->timeStamp() ) 78 { 79 $this->setInformation( "Event delayed until " . $dateTime->toString( true ) ); 80 $this->setActivationDate( $dateTime->timeStamp() ); 81 // eZDebug::writeDebug( $dateTime->toString(), 'executing publish on time event' ); 82 return EZ_WORKFLOW_TYPE_STATUS_DEFERRED_TO_CRON; 83 } 84 else if ( $dateTime->isValid() and $modifyPublishDate ) 85 { 86 $object->setAttribute( 'published', $dateTime->timeStamp() ); 87 $object->store(); 88 } 89 else 90 { 91 return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; 92 // return EZ_WORKFLOW_TYPE_STATUS_WORKFLOW_DONE; 93 } 94 } 95 else 96 { 97 return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; 98 // return EZ_WORKFLOW_TYPE_STATUS_WORKFLOW_DONE; 99 } 100 } 101 } 102 return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; 103 // return EZ_WORKFLOW_TYPE_STATUS_WORKFLOW_DONE; 104 } 105 106 function attributes() 107 { 108 return array_merge( array( 'contentclass_list', 109 'contentclassattribute_list', 110 'has_class_attributes' ), 111 eZWorkflowEventType::attributes() ); 112 } 113 114 function hasAttribute( $attr ) 115 { 116 return in_array( $attr, $this->attributes() ); 117 } 118 119 function &attribute( $attr ) 120 { 121 switch( $attr ) 122 { 123 case 'contentclass_list' : 124 { 125 $classList = eZContentClass::fetchList( EZ_CLASS_VERSION_STATUS_DEFINED, true ); 126 return $classList; 127 128 }break; 129 case 'contentclassattribute_list' : 130 { 131 // $postvarname = 'WorkflowEvent' . '_event_ezwaituntildate_' .'class_' . $workflowEvent->attribute( 'id' ); and $http->hasPostVariable( $postvarname ) 132 if ( isset ( $GLOBALS['eZWaitUntilDateSelectedClass'] ) ) 133 { 134 $classID = $GLOBALS['eZWaitUntilDateSelectedClass']; 135 } 136 else 137 { 138 // if nothing was preselected, we will use the first one: 139 // POSSIBLE ENHANCEMENT: in the common case, the contentclass_list fetch will be called twice 140 $classList = eZWaitUntilDateType::attribute( 'contentclass_list' ); 141 if ( isset( $classList[0] ) ) 142 $classID = $classList[0]->attribute( 'id' ); 143 else 144 $classID = false; 145 } 146 if ( $classID ) 147 { 148 $attributeList = eZContentClassAttribute::fetchListByClassID( $classID ); 149 } 150 else 151 $attributeList = array(); 152 return $attributeList; 153 }break; 154 case 'has_class_attributes' : 155 { 156 // for the backward compatability: 157 $hasClassAttribute = 1; 158 return $hasClassAttribute; 159 }break; 160 default: 161 return eZWorkflowEventType::attribute( $attr ); 162 } 163 } 164 165 function customWorkflowEventHTTPAction( &$http, $action, &$workflowEvent ) 166 { 167 $id = $workflowEvent->attribute( "id" ); 168 switch ( $action ) 169 { 170 case "new_classelement" : 171 { 172 $waitUntilDate =& $workflowEvent->content( ); 173 174 $classIDList = $http->postVariable( 'WorkflowEvent' . '_event_ezwaituntildate_' . 'class_' . $workflowEvent->attribute( 'id' ) ); 175 176 $classAttributeIDList = $http->postVariable( 'WorkflowEvent' . '_event_ezwaituntildate_' . 'classattribute_' . $workflowEvent->attribute( 'id' ) ); 177 178 179 $waitUntilDate->addEntry( $classAttributeIDList[0], $classIDList[0] ); 180 $workflowEvent->setContent( $waitUntilDate ); 181 }break; 182 case "remove_selected" : 183 { 184 $version = $workflowEvent->attribute( "version" ); 185 $postvarname = "WorkflowEvent" . "_data_waituntildate_remove_" . $workflowEvent->attribute( "id" ); 186 $arrayRemove = $http->postVariable( $postvarname ); 187 eZDebug::writeDebug( $arrayRemove, 'remove params 0' ); 188 189 foreach( $arrayRemove as $entryID ) 190 { 191 eZDebug::writeDebug( "$id - $entryID - $version ", 'remove params' ); 192 eZWaitUntilDate::removeEntry( $id, $entryID, $version ); 193 } 194 }break; 195 case "load_class_attribute_list" : 196 { 197 $postvarname = 'WorkflowEvent' . '_event_ezwaituntildate_' .'class_' . $workflowEvent->attribute( 'id' ); 198 if ( $http->hasPostVariable( $postvarname ) ) 199 { 200 $classIDList = $http->postVariable( 'WorkflowEvent' . '_event_ezwaituntildate_' .'class_' . $workflowEvent->attribute( 'id' ) ); 201 eZDebug::writeDebug($classIDList, "classIDLIst" ); 202 // $http->setSessionVariable( 'eZWaitUntilDateSelectedClass', $classIDList[0] ); 203 $GLOBALS['eZWaitUntilDateSelectedClass'] = $classIDList[0]; 204 } 205 else 206 { 207 eZDebug::writeDebug( "no class selected" ); 208 } 209 }break; 210 default : 211 { 212 eZDebug::writeError( "Unknown custom HTTP action: " . $action, "eZEnumType" ); 213 }break; 214 } 215 216 } 217 218 function fetchHTTPInput( &$http, $base, &$event ) 219 { 220 $modifyDateVariable = $base . "_data_waituntildate_modifydate_" . $event->attribute( "id" ); 221 if ( $http->hasPostVariable( $modifyDateVariable ) ) 222 { 223 $modifyDateValue = (int)$http->postVariable( $modifyDateVariable ); 224 $event->setAttribute( 'data_int1', $modifyDateValue ); 225 } 226 } 227 228 function &workflowEventContent( &$event ) 229 { 230 $id = $event->attribute( "id" ); 231 $version = $event->attribute( "version" ); 232 $waitUntilDate = new eZWaitUntilDate( $id, $version ); 233 return $waitUntilDate; 234 } 235 236 function storeEventData( &$event, $version ) 237 { 238 $waitUntilDate =& $event->content(); 239 $waitUntilDate->setVersion( $version ); 240 241 } 242 243 } 244 245 eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_WAIT_UNTIL_DATE_ID, "ezwaituntildatetype" ); 246 247 248 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |