Custom workflow event before publishing

Author Message

James Ranson

Thursday 19 October 2006 11:43:06 pm

I am attempting to develop an extension that contains a custom workflow event. The event should occur before publishing and prompt the user for some extra information.

The template appears as expected, but when I submit the form, I am brought back to the editing page. When the execute() function was written to return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_RETURN, it was impossible to actually publish the entry, because it kept looping between the edit form and the event form.

It's probably just something simple, but I'm new to this and would appreciate some help. Thanks.

<?php

define("EZ_WORKFLOW_TYPE_CUSTOMPAY", "custompay");

class customPayType extends eZWorkflowEventType
{
        function customPayType()
        {
                $this->eZWorkflowEventType(EZ_WORKFLOW_TYPE_CUSTOMPAY, "Custom Payment Page");
        }
        function execute(&$process, &$event) 
        {
                $http =& eZHTTPTool::instance();
                if ($http->hasPostVariable("cc_type") && $http->hasPostVariable("cc_number"))
                {
                        return EZ_WORKFLOW_TYPE_STATUS_WORKFLOW_DONE;
                }
                $process->Template = array('templateName' => 'design:workflow/eventtype/result/event_custompay.tpl',
                                'templateVars' => array('request_uri' => eZSys::requestUri(),
                                                                                'event' => $event));
                return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE;
        }
}

eZWorkflowEventType::registerType(EZ_WORKFLOW_TYPE_CUSTOMPAY, "custompaytype");

?>

Template:

<form method="post">
<label>Credit Card Type: </label><input type="text" name="cc_type"/><br/>
<label>Credit Card Number: </label><input type="text" name="cc_number"/><br/>
<input type="submit" class="button">
</form>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.