TestJoin2
y
1.7
y
Testing join activities
19/11/2005 [12:57:34]
<?php //*************************************************************************** //* copyleft Regis dot Leroy at glconseil dot com * //* This program is free software; you can redistribute it and/or modify it * //* under the terms of the GNU General Public License as published by the * //* Free Software Foundation; either version 2 of the License, or (at your * //* option) any later version. * //*************************************************************************** ?>
draw_select_next_user
1
show_select_next_user
0
display_please_wait_message
1
use_automatic_parsing
1
show_activity_title
1
show_instance_name
1
show_instance_owner
0
show_multiple_submit_as_select
0
show_activity_info_zone
1
draw_roles
1
font_size
10
ownership_give_abort_right
0
ownership_give_exception_right
0
ownership_give_release_right
0
role_give_abort_right
1
role_give_release_right
1
role_give_exception_right
1
mail_smtp_profile
default
mail_smtp_debug
1
end
end default end activity 19/11/2005 [12:57:35] n y `<?php ?>`
Report
standalone standalone activity used to make a report of the tests 19/11/2005 [12:57:35] y n Role1 `<?php //! show all instances contained in the list to the table of instances function report_show_instances(&$mylist, &$template) { $template->set_block('template', 'block_instances_row', 'inst_row'); foreach ($mylist as $inst) { $template->set_var(array( 'head_inst_name' => tra('inst. name'), 'head_inst_priority' => tra('inst. priority'), 'head_status' => tra('status'), 'head_act_name' => tra('act. name'), 'head_user' => tra('user'), 'instance_name' => $inst['insname'], 'instance_priority' => $inst['wf_priority'], 'instance_status' => $inst['wf_status'].'/'.$inst['wf_act_status'], 'activity_name' => $inst['wf_name'], 'user' => $inst['wf_user'], )); $template->parse('inst_row', 'block_instances_row', true); } } //user commands **************** $ActClose = get_var('ActClose','post',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- if ($ActClose) { $GLOBALS['workflow']['__leave_activity']=true; } else { //-------------------------------------- // // showing the form // //-------------------------------------- // we want to retrieve a list of all instances ordered by priority $sort_mode='wf_priority__desc'; $wheres[] = '(gi.wf_p_id='.$GLOBALS['workflow']['wf_process_id'].')'; $wheres[] = "(gi.wf_status<>'aborted')"; $where = implode(' and ', $wheres); $inst_list = $this->GUI->gui_list_user_instances($GLOBALS['phpgw_info']['user']['account_id'], -1,-1, $sort_mode, '',$where); //_debug_array($inst_list['data']); report_show_instances($inst_list['data'], $this->wf_template); //Submit options we want //$this->submit_array['ActClose'] = lang('Close'); } ?>` <!--******************** ROWS ********************* --> <table width="100%"> <tr class="row_off"> <td colspan="4">Here, with a standalone activity, we have a view on all instances for this process</td> </tr> <tr class="th"> <td>{head_inst_priority}</td> <td>{head_inst_name}</td> <td>{head_status}</td> <td>{head_act_name}</td> <td>{head_user}</td> </tr> <!-- BEGIN block_instances_row --> <tr class="{row_class}"> <td>{instance_priority}</td> <td>{instance_name}</td> <td>{instance_status}</td> <td>{activity_name}</td> <td>{user}</td> </tr> <!-- END block_instances_row --> </table>
Automatik
activity non interactive auto-routed activity. add "Tagged" string at the end of PROPERTY_ONE and PROPERTY_TWO 19/11/2005 [12:57:35] n y `<?php ?>`
After-Join
activity Interactive activity after the join to check PROPERTY_ONE and PROPERTY_TWO values 19/11/2005 [12:57:35] y y Role1 `<?php $array_vars = array( 'PROPERTY_ONE' => '', 'PROPERTY_TWO' => '', 'EMPTY_ONE' => '', 'EMPTY_TWO' => '', 'EMPTY_COUNTER' => '', 'BUZZ' => '', ); //-------------------------------------- // // handling data on the form // //-------------------------------------- // init variables with POST and if POST is empty // init with the property foreach ($array_vars as $prop => $value) { $array_vars[$prop] = get_var($prop,'any',$instance->get($prop)); } //user commands **************** $ActNextStage = get_var('ActNextStage','POST',false); $ActClose = get_var('ActClose','POST',false); $ActNothing = get_var('ActNothing', 'POST',false); $ActSleep = get_var('ActSleep', 'POST',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- $leaveloop = false; if ($ActSleep) { // to test the please wait message // waiting 30 seconds... sleep(30); } if (($ActNextStage) || ($ActClose)) { // saving properties // if they changed $instance->setProperties($array_vars); if ($ActNextStage) { // going to next stage $leaveloop = $instance->complete(); } elseif($ActClose) { $leaveloop = true; $GLOBALS['workflow']['__leave_activity']=true; } } if (!($leaveloop)) { //-------------------------------------- // // showing the form // //-------------------------------------- foreach ($array_vars as $prop => $value) { $template->set_var(array($prop => htmlspecialchars($array_vars[$prop]))); } // submit options we want $this->submit_array['ActNextStage'] = lang('going to next stage'); $this->submit_array['ActClose'] = lang('Close and get back later'); $this->submit_array['ActSleep'] = lang('long loop for fun'); $this->submit_array['ActNothing'] = lang('little loop'); //special Cancel Value we wont get back here $this->submit_array['__Cancel'] = lang('Quit Without Saving'); //special Print mode button $this->enable_print_mode = true; //priority levels we want $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - medium'), 3 => lang('3 - medium but better'), 4 => lang('4 - high'), ); } ?>` <table width="100%"> <tr bgcolor="#DDDDDD"> <td bgcolor="#EEEEEE" width="25%"> <div align="right">PROPERTY ONE&nbsp;:</td> <td bgcolor="#E8F0F0" width="25%"> <div align="left"><input type="text" name="PROPERTY_ONE" value="{PROPERTY_ONE}" size="38"></div></td> </td> <td bgcolor="#EEEEEE" width="25%"> <div align="right">PROPERTY TWO&nbsp;:</div></td> <td bgcolor="#E8F0F0" width="25%"> <div align="left"><input type="text" name="PROPERTY_TWO" value="{PROPERTY_TWO}" size="38"></div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty PROPERTY ONE&nbsp;:</div></td> <td> <div align="left">{EMPTY_ONE}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">counter of empty PROPERTY TWO&nbsp;:</div></td> <td> <div align="left">{EMPTY_TWO}</div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty One or Two&nbsp;:</div></td> <td> <div align="left">{EMPTY_COUNTER}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">The Buzz&nbsp;:</div></td> <td> <div align="left">{BUZZ}</div></td> </tr> </table>
joiner
join Join activities from left and right and then permits a send to the end activity when both are Ok 19/11/2005 [12:57:35] n n Role1 Role3 `<?php ?>`
right branch
activity interactive activity on the right branch 19/11/2005 [12:57:35] y y Role2 mail_smtp wf_to %property_DEST%, %user%, Georges &lt;gege@hotmail.com&gt; wf_cc %roles% wf_bcc wf_from Bernard &lt;%user%&gt; wf_replyto %user% wf_subject test wf_message test 1 mail sent from %activity_name% for instance %instance_name% (%instance_id%). wf_send_mode 1 wf_agent_type mail_smtp `<?php $array_vars = array( 'PROPERTY_ONE' => '', 'PROPERTY_TWO' => '', 'EMPTY_ONE' => '', 'EMPTY_TWO' => '', 'EMPTY_COUNTER' => '', 'BUZZ' => '', ); //-------------------------------------- // // handling data on the form // //-------------------------------------- // init variables with POST and if POST is empty // init with the property foreach ($array_vars as $prop => $value) { $array_vars[$prop] = get_var($prop,'any',$instance->get($prop)); } _debug_array($array_vars); //user commands **************** $ActNextStage = get_var('ActNextStage','post',false); $ActClose = get_var('ActClose','post',false); $ActSave = get_var('ActSave','post',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- $leaveloop = false; if (($ActNextStage) || ($ActClose)) { // saving properties // if they changed foreach ($array_vars as $prop => $value) { if (($value === ($instance->get($prop))) ) { $instance->set($prop,$value); } } if ($ActNextStage) { // going to next stage $leaveloop = $instance->complete(); } elseif($ActClose) { $leaveloop = true; $GLOBALS['workflow']['__leave_activity']=true; } } if ($ActSave) { // saving properties // if they changed foreach ($array_vars as $prop => $value) { echo "<br> having $prop, was ".($instance->get($prop)). " is $value"; if (!($value === ($instance->get($prop)) )) { echo " ...saving $prop to $value"; $instance->set($prop,$value); } } } //showing the form if we are not leaving the loop if (!($leaveloop)) { //-------------------------------------- // // showing the form // //-------------------------------------- foreach ($array_vars as $prop => $value) { $template->set_var(array($prop => htmlspecialchars($array_vars[$prop]))); } //we want to display the owner $this->display_owner = 1; //we want to display the next_user $this->display_next_user =1; // submit options we want $this->submit_array['ActNextStage'] = lang('going to next stage'); $this->submit_array['ActClose'] = lang('Close and get back later'); //special Cancel Value we wont get back here $this->submit_array['__Cancel'] = lang('Quit Without Saving'); //A Save Button keeping on the form $this->submit_array['ActSave'] = lang('Save and stay on form'); //special Print mode button $this->enable_print_mode = true; //priority levels we want $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - medium'), 3 => lang('3 - medium but better'), 4 => lang('4 - high'), ); } ?>` <!--******************** PROPERTIES ********************* --> <table width="100%"> <tr class="th"> <td colspan="2">Here we are in the 'right branch' activity, we can change properties if we want</td> </tr> <tr class="row_on"> <td> <div align="right">PROPERTY ONE&nbsp;:</td> <td> <div align="left"><input type="text" name="PROPERTY_ONE" value="{PROPERTY_ONE}" size="38"></div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">PROPERTY TWO&nbsp;:</div></td> <td> <div align="left"><input type="text" name="PROPERTY_TWO" value="{PROPERTY_TWO}" size="38"></div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty PROPERTY ONE&nbsp;:</div></td> <td> <div align="left">{EMPTY_ONE}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">counter of empty PROPERTY TWO&nbsp;:</div></td> <td> <div align="left">{EMPTY_TWO}</div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty One or Two&nbsp;:</div></td> <td> <div align="left">{EMPTY_COUNTER}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">the BUZZ property&nbsp;:</div></td> <td> <div align="left"><input type="text" name="BUZZ" value="{BUZZ}" size="38"></div></td> </tr> </table>
Switch 1
switch This automatic switch will decide which way he will take by looking at PROPERTY_ONE. If this property is empty it will go t the Empty_one, else it goes to the joiner 19/11/2005 [12:57:35] n y `<?php $choose = $instance->get('PROPERTY_ONE'); if (empty($choose)) { if (!($instance->setNextActivity('Empty One'))) { $instance->setNextActivity('joiner'); } } else { $instance->setNextActivity('joiner'); } ?>`
lonely branch 1
activity another automatic activity somewhere 19/11/2005 [12:57:35] n y `<?php ?>`
Lonely branch II
activity yet another automatic lonely branch but this one need to be send manually 19/11/2005 [12:57:35] n n Role1 `<?php ?>`
Switch2
switch A second automatic switch. It decide which branch to choose by looking at PROPERTY_TWO. If the property is empty it take the instance to Empty Two, else it goes to the joiner 19/11/2005 [12:57:35] n y `<?php $choose = $instance->get('PROPERTY_TWO'); if (empty($choose)) { if (!($instance->setNextActivity('Empty Two'))) { $instance->setNextActivity('joiner'); } } else { $instance->setNextActivity('joiner'); } ?>`
Empty Counter
activity This automatic activity records a counter named EMPTY_COUNTER to remember how many times he has been launched for a given instance 19/11/2005 [12:57:35] n y `<?php $counter = $instance->get('EMPTY_COUNTER'); echo "<br> counter is actually:".$counter; $counter++; echo "<br> now is set it to:".$counter; $instance->set('EMPTY_COUNTER',$counter); ?>`
splitter2
split second splitter after the first one 19/11/2005 [12:57:35] n y `<?php ?>`
splitter
split splitt the workflow in 2 branches 19/11/2005 [12:57:35] n y `<?php ?>`
Empty One
activity This automatic activity does nothing but is there to test if someone goes there when PROPERTY_ONE is empty. 19/11/2005 [12:57:35] n y `<?php $counter = $instance->get('EMPTY_ONE'); $counter++; $instance->set('EMPTY_ONE',$counter); ?>`
Empty Two
activity This automatic activity does nothing but is there to test if someone goes there when PROPERTY_TWO is empty. 19/11/2005 [12:57:35] n y `<?php $counter = $instance->get('EMPTY_TWO'); $counter++; $instance->set('EMPTY_TWO',$counter); ?>`
left branch
activity interactive form activity on the left branch. contains a test on changing the owner. After Left branch is finished we rerun splitter2, giving a new Right branch for the instance. This make a second right branch! 19/11/2005 [12:57:35] y y Role1 `<?php $array_vars = array( 'PROPERTY_ONE' => '', 'PROPERTY_TWO' => '', 'EMPTY_ONE' => '', 'EMPTY_TWO' => '', 'EMPTY_COUNTER' => '', 'BUZZ' => '', ); //-------------------------------------- // // handling data on the form // //-------------------------------------- // init variables with POST and if POST is empty // init with the property foreach ($array_vars as $prop => $value) { $array_vars[$prop] = get_var($prop,'any',$instance->get($prop)); } //user commands **************** $ActNextStage = get_var('ActNextStage','post',false); $ActClose = get_var('ActClose','post',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- $leaveloop = false; if (($ActNextStage) || ($ActClose)) { // saving properties // if they changed $instance->setProperties($array_vars); if ($ActNextStage) { // going to next stage $leaveloop = $instance->complete(); } elseif($ActClose) { $leaveloop = true; $GLOBALS['workflow']['__leave_activity']=true; } } if (!($leaveloop)) { //-------------------------------------- // // showing the form // //-------------------------------------- foreach ($array_vars as $prop => $value) { $template->set_var(array($prop => htmlspecialchars($array_vars[$prop]))); } //we want to diplay the owner as well, and as a select //avaible users are people from Role1 and Role2 which have access to joiner //BUT if you have an user in Role3 which is in Role2 as well he wont be there //he would be there as a Role2 which is not allowed, you need the Role3 for it. $this->display_owner = array( 'role' => array('Role1','Role2'), 'activity' => 'joiner', ); //we want to select the next user for the Join sending $this->display_next_user = array( 'activity' => 'joiner', ); // submit options we want $this->submit_array['ActNextStage'] = lang('going to next stage'); $this->submit_array['ActClose'] = lang('Close and get back later'); //special Cancel Value we wont get back here $this->submit_array['__Cancel'] = lang('Quit Without Saving'); //special Print mode button $this->enable_print_mode = true; //priority levels we want $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - medium'), 3 => lang('3 - medium but better'), 4 => lang('4 - high'), ); } ?>` <!--******************** PROPERTIES ********************* --> <table width="100%"> <tr class="th"> <td colspan="2">Here we are in the 'left branch' activity, we can change properties if we want</td> </tr> <tr class="row_on"> <td> <div align="right">PROPERTY ONE&nbsp;:</td> <td> <div align="left"><input type="text" name="PROPERTY_ONE" value="{PROPERTY_ONE}" size="38"></div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">PROPERTY TWO&nbsp;:</div></td> <td> <div align="left"><input type="text" name="PROPERTY_TWO" value="{PROPERTY_TWO}" size="38"></div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty PROPERTY ONE&nbsp;:</div></td> <td> <div align="left">{EMPTY_ONE}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">counter of empty PROPERTY TWO&nbsp;:</div></td> <td> <div align="left">{EMPTY_TWO}</div></td> </tr> <tr class="row_on"> </td> <td> <div align="right">counter of empty One or Two&nbsp;:</div></td> <td> <div align="left">{EMPTY_COUNTER}</div></td> </tr> <tr class="row_off"> </td> <td> <div align="right">The BUZZ property in a textarea&nbsp;:</div></td> <td> <textarea>{BUZZ}</textarea></td> </tr> </table>
auto logger
activity log some infos about the state of this process after the start 19/11/2005 [12:57:35] n y `<?php // saving some properties to retain the state we have just after starting $value = $instance->getName(); $instance->set('auto_logger_NAME_START',$value); $value = $instance->getPriority(); $instance->set('auto_logger_PRIORITY_START',$value); $instance->set('auto_logger_USER_START',$GLOBALS['user']); //Setting the default values for the properties we will use later $init = array( 'PROPERTY_ONE' => 0, 'PROPERTY_TWO' => 0, 'EMPTY_ONE' => 0, 'EMPTY_TWO' => 0, 'EMPTY_COUNTER' => 0, 'BUZZ' => ' here is a quote " double single '."'' escaped \'".' escaped slash \\ and escaped quote\", trying to end an input zone "> and trying to end a textarea </textarea> as well.', ); $instance->setProperties($init); ?>`
start the test
start start activity for this test 19/11/2005 [12:57:34] y y Role1 Role3 `<?php // retrieve submit options **************** $ActNextStage = get_var('ActNextStage','post',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- $leaveloop = false; if ($ActNextStage) { // going to next stage $leaveloop = $instance->complete(); // the 'wf_name' and 'wf_priority' special properties are saved in // start_pos.php when completing } if (!$leaveloop) { //-------------------------------------- // // let's run_activity show the form // //-------------------------------------- // submit options we want $this->submit_array['ActNextStage'] = lang('Create this instance'); //Special cancel value $this->submit_array['__Cancel'] = lang('Cancel'); //priority levels we want $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - medium'), 3 => lang('3 - medium but better'), 4 => lang('4 - high'), ); // we want to select the owner //(0:empty,1:display,2:select all people having a role on the process) // could be an array as well to define other values, see left branch $this->display_owner = 2; // we want to select the next user //(0:empty,1:display,2:select all people having a role on the process) // could be an array as well to define other values, see left branch $this->display_next_user = 2; } ?>` <!--******************** SPECIAL START PROPERTIES ********************* --> <table width="100%"> <tr class="th"> <td colspan="2">this activity will begin a new test process, an instance will be created</td> </tr> <tr class="row_on"> <td> enter here a name for this test instance:</td> <td> <input type="text" name="wf_name" value=""</td> </tr> </table>
start the test
auto logger
auto logger
splitter
left branch
splitter2
splitter
left branch
splitter2
Switch 1
splitter
splitter2
splitter2
right branch
splitter
lonely branch 1
splitter2
Lonely branch II
splitter2
Switch2
Empty One
Empty Counter
Empty Two
Empty Counter
right branch
joiner
Switch 1
joiner
lonely branch 1
joiner
Lonely branch II
joiner
Switch 1
Empty One
Switch2
joiner
Empty Counter
joiner
Switch2
Empty Two
joiner
After-Join
After-Join
Automatik
Automatik
end