ez.no / exponential / documentation / development / extensions / workflow events / unpublish
A very simple event is the unpublish event. This sets the object to unpublished. The event is placed in kernel/classes/workflowtypes/event/ezunpublish/ and the file is called ezunpublishtype.php.
kernel/classes/workflowtypes/event/ezunpublish/ezunpublishtype.php:
<?php include_once( 'kernel/classes/ezworkflowtype.php' ); define( "EZ_WORKFLOW_TYPE_UNPUBLISH_ID", "ezunpublish" ); class eZUnpublishType extends eZWorkflowEventType { /*! Constructor */ function eZUnpublishType() { $this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_UNPUBLISH_ID, "Unpublish" ); } function execute( &$process, &$event ) { $parameters = $process->attribute( 'parameter_list' ); $object =& eZContentObject::fetch( $parameters['object_id'] ); $version =& eZContentObjectVersion::fetchVersion( $parameters['version'], $parameters['object_id'] ); $version->unpublish(); return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; } } eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_UNPUBLISH_ID, "ezunpublishtype" ); ?>
In the same way as for the datatype the event inherit from a superclass (eZWorkflowEventType, placed inside kernel/classes/ezworkflowtype.php). The constructor calls the superclass with the identifier for the event and the name the event will get in the drop down in the admin interface.
The only virtual method we have to create is execute. This method is run each time the event is executed. The method takes two arguments, one is an object for the current process and the other is an object for the current event.
In the end of the file (outside the class definition) we have to register the event in the same way as for the datatype.
Log in or create a user account to comment.
Comments
Now it's a CRONJOB
Christiane Kloss
Thursday 24 March 2005 12:04:25 pm
There are some UnpublishSettings in content.ini:
Copy to content.ini.append...
[UnpublishSettings]
RootNodeList[]
ClassList[]
The classes to be unpublished have to have a datefield named 'unpublish_date', that will be checked.
Steps to create a new event
Xavier Dutoit
Monday 04 October 2004 8:12:18 am
workflow.ini
James Ward
Wednesday 16 June 2004 10:50:12 pm
>Step 5: Add the new event to the configuration
>Our new event must be configured in the appropriate configuration file.
>extension/myextension/settings/workflow.ini.append:
Does something similar need to be done here? If so, could someone please include it with this document?