Forums / Developer / Workflow .. befor read wan`t work normaly !?

Workflow .. befor read wan`t work normaly !?

Author Message

Selmah Maxim

Monday 19 May 2003 8:40:58 am

what i need that the user befor read the data page workflow will check the published date, and the the end date of this data page.

coz of this i put the workflow content,read, befor, now when i click the dead data page the workflow work, and redirect me to another page, but when i make refresh i got the data page ?!
what the worng here ?

here is my workflow data :

______________________________________

<?php

include_once("kernel/classes/ezcontentobjecttreenode.php");

define( "EZ_WORKFLOW_TYPE_CHECK_EXP_ID", "checkexp" );

class CheckExpType extends eZWorkflowEventType
{

function CheckExpType()
{
$this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_CHECK_EXP_ID, "Check Exp." );
}

function execute( &$process, &$event )
{

$parameters =& $process->attribute( 'parameter_list' );

$node =& eZContentObjectTreeNode::fetch( $parameters['node_id'] );
$data_map = $node->attribute("data_map");
$Object = $node->attribute("object");

 

// enum value
$enumAttribute = $data_map[ 'registeration_period' ];


if($enumAttribute != null )
{
$enumObj = $enumAttribute->attribute( 'content' );
$enumobjectList = $enumObj->attribute( 'enumobject_list' );
$selectedEnumValue = $enumobjectList[0]->attribute( 'enumvalue' );

//
foreach ($Object as $Name=>$Value)
{
if("$Name" == "ID") $Data[$Name] = $Value;
if("$Name" == "ClassID") $Data[$Name]= $Value;
if("$Name" == "Published") $Data[$Name] = $Value;
if("$Name" == "CurrentVersion") $Data[$Name] = $Value;
}

$ActiveTo = $Data[Published]+$selectedEnumValue;
$Now = strtotime("now");

// get the company_status value //
$CompanyStatus = $data_map[ 'company_status' ];
$CompanyStatusValue = $CompanyStatus->attribute( 'content' );
$CompanyStatusValueID = $CompanyStatus->attribute( 'id' );


$db =& eZDb::instance();

$query = "select * from ezcontentobject_attribute where id='$CompanyStatusValueID' ";
$status = $db->arrayQuery($query);

if($ActiveTo <= $Now)
{
$query = "update ezcontentobject_attribute set data_int ='0' where id='$CompanyStatusValueID' ";
$db->query($query);
$process->Template = array( 'templateName' => 'design:' . 'data_not_active' . '.tpl',
'templateVars' => array( 'return_uri' => $requestUri,
'user_name' => $userName ) );
return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE;
}

elseif($status[0][data_int] == 0)
{
$process->Template = array( 'templateName' => 'design:' . 'data_not_active' . '.tpl',
'templateVars' => array( 'return_uri' => $requestUri,
'user_name' => $userName ) );
return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE;
}
} // End : $enumAttribute != null //
}// End : execute


}

eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_CHECK_EXP_ID, "checkexptype" );

?>
___________________

Any help please ?

Selmah Maxim

Monday 19 May 2003 9:33:56 am

ahhhhaa ... found it .. thx for help :)

_______

if($ActiveTo <= $Now)
{
$query = "update ezcontentobject_attribute set data_int ='0' where id='$CompanyStatusValueID' ";
$db->query($query);
$process->Template = array( 'templateName' => 'design:' . 'data_not_active' . '.tpl');
return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT;

}

elseif($status[0][data_int] == 0)
{
$process->Template = array( 'templateName' => 'design:' . 'data_not_active' . '.tpl');
return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT;
}
_______________

but what u think which is faster for browesing, to but in cron job or like this ?
do u have idea, or any way to view for the admin the not active data pages ?