New workflow event causes workflow view crash

Author Message

Eirik Alfstad Johansen

Wednesday 14 January 2004 4:20:12 am

Hi,

Trying to create a new workflow event, I get the error "Page can not be displayed" (generated by IE) when I click the "New workflow" button in the workflowlist view of the workflow module, which I'm guessing is due to some error in the code syntax. Here's the content of the ezcreateaccounttype.php file:

<?php

include_once( 'kernel/classes/ezworkflowtype.php' );
include_once( "kernel/classes/ezorder.php" );

define( "EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID", "ezcreateaccount" );

class eZCreateAccountType extends eZWorkflowEventType
{
/*!
Constructor
*/
function eZCreateAccountType()
{
$this->eZCreateAccountType( EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID, "Create account" );
}

function execute( &$process, &$event )
{
// order fetch parameters
$offset = 0;
$limit = 1;
$sortField = 'created';
$sortOrder = 'asc';

// fetch most recent order in an array
$orderArray =& eZOrder::active( true, $offset, $limit, $sortField, $sortOrder );

// for each order id (only one)
foreach($orderArray as $k => $v) {
$order_id = $v['order_nr'];
}

// fetch order
$order = eZOrder::fetch($order_id);

// save data used by account creation process
$address = $order[account_information][address];

// email me the order address to make sure it's A-OK
mail('[email protected]', 'Adressen er ' . $address, 'Body', 'From: [email protected]');

return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
}
}

eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID, "ezcreateaccounttype" );

?>

And here's the content of the workflow.ini.append.php file:

[EventSettings]
ExtensionDirectories[]=createaccount
AvailableEventTypes[]=event_ezcreateaccount

Any idea what I could be doing wrong?

Thanks in advance !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Balazs Halasy

Wednesday 14 January 2004 4:25:35 am

Did you check that this only happens when you add the actual extension that contains the new event? If so then there is definetively something wrong with your code.. try to cut it down to the bare minimum and work (add more and more logic) towards the goal. Having too many lines within a new event is not a good idea cause it is hard to see if it actually works or not.

Balazs

Eirik Alfstad Johansen

Wednesday 14 January 2004 6:03:29 am

OK, I've stripped it down to the bare basics, and still the page isn't displayed. Here's the code again.

include_once( 'kernel/classes/ezworkflowtype.php' );

define( "EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID", "ezcreateaccount" );

class eZCreateAccountType extends eZWorkflowEventType
{
/*!
Constructor
*/
function eZCreateAccountType()
{
$this->eZCreateAccountType( EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID, "Create account" );
}

function execute( &$process, &$event )
{
return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
}
}

eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_CREATEACCOUNT_ID, "ezcreateaccounttype" );

Am I missing something very basic, here?

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Eirik Alfstad Johansen

Wednesday 14 January 2004 6:07:12 am

Never mind, I located the bug. I was trying to do

$this->eZCreateAccountType

in the constructor when what I should've done was

$this->eZWorkflowEventType

Thanks anyways !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

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