Forums / Developer / Trigger on user login/logout - nearly working solution

Trigger on user login/logout - nearly working solution

Author Message

Simon Phillips

Monday 28 February 2005 3:33:22 pm

Hi,

With a modification to the kernel, I've got triggers activating on user login and logout. However, something strange seems to be happening when I attach a workflow to the trigger - the login/logout event doesn't succeed on the first try - as if the workflow has sent back a status to tell it to wait. This means that one has to login/logout twice in order to get it working.

My login trigger is defined as follows in the operation_definition file:

$OperationList['login'] = array( 'name' => 'login',
                                'default_call_method' => array( 'include_file' => 'extension/spauthintegrate/modules/spauthhooks.php',
                                                                'class' => 'spauthhooks' ),
                                'parameter_type' => 'standard',
                                'parameters' => array( array( 'name' => 'user_id',
                                                              'type' => 'integer',
                                                              'required' => true )),
                                'keys' => array( 'user_id' ),

                                'body' => array( array( 'type' => 'trigger',
                                                        'name' => 'post_login',
                                                        'keys' => array( 'user_id')
                                                        )
												) 
								);

This trigger is activated by the following code at the correct point in the ezUser class:

            include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
    		include_once( 'kernel/classes/eztrigger.php' );

    		$dummy=& eZOperationHandler::execute( 'user', 'login', array( 'user_id' => $userID));

The trigger is attached to a workflow with a single workflow event which returns the following status : EZ_WORKFLOW_TYPE_STATUS_ACCEPTED.

The workflow executes the first time one tries to log in/out, and the log in/out functionality executes the second time one tries. From what I can tell, my workflow status is correct; what could the problem be?

If I run a method instead of calling a trigger in the above user/login trigger code, it works fine - but I'd prefer to use a workflow for this due to the potential other uses for the ez community.

<b>Please help</b>!

Thanks,
Simon

Xavier Dutoit

Sunday 27 March 2005 4:15:17 am

Hi Simon,

As you might have seen, workflows aren't that used (nor documented) and the ez crew says they are going to improve them (3.7 ?).

I was wondering if you've been able to find a solution on your problem ? If yes, I'd love to see how you solved it.

Good luck.

Xavier

http://www.sydesy.com