Unpublish

Unpublish event

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.

Comments

Now it's a CRONJOB

Unpublish is a standard cronjob since 3.4(?).

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

workflow.ini

From the creating a new event document I noticed:

>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?

Log in or create a user account to comment.

Contents

Development

Extensions
    Translation
    Introduction to extensions
    Building an Exponential module
    Design extension
    Datatypes
    Workflow events
       Introduction to events
       Unpublish
       Wrapping event
       Creating a new event
    Module
    Template operator
    Template function
Exponential datamodel
Exponential tuning and stability
Importing attribute data
Kernel
Libraries
Scripting
Standards
System overview
Test Suite
Using Doxygen to create API documenta...


Created

10/07/2003
10:13:59 am
by Jo Henrik Endrerud

Last updated

10/07/2003
10:13:59 am
by Jo Henrik Endrerud

Authors

Jo Henrik Endrerud



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.