testMail
y
1.1
y
This process tests the mail agent for egroupware
28/10/2005 [10:34:59]
<?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. * //*************************************************************************** ?>
display_please_wait_message
1
use_automatic_parsing
1
show_activity_title
1
show_instance_name
1
show_instance_owner
1
show_multiple_submit_as_select
0
show_activity_info_zone
1
draw_roles
1
mail_smtp_profile
default
View the Message
view This 'view' activity is there to give a nicer view in read-only mode on the message for all users of the process. We use the mail agent on it to prevent the owner (author of the message) that someones has consulted his message. 02/09/2005 [04:04:04] y n Validator MailUser mail_smtp wf_to %owner% wf_cc wf_bcc wf_from no-reply@nowhere.com wf_replyto wf_subject %user% has consulted your message wf_message %user% has consulted your message called %instance_name%. wf_send_mode 2 wf_agent_type mail_smtp `<?php $property_vars = array( 'MYDEST' => '', 'MYBODY' => '', 'REFUSAL' => '', ); //-------------------------------------- // // handling data on the form // //-------------------------------------- // init with the property foreach ($property_vars as $prop => $value) { $property_vars[$prop] = $instance->get($prop); } //-------------------------------------- // // handling results from the form // //-------------------------------------- //-------------------------------------- // // showing the form // //-------------------------------------- foreach ($property_vars as $prop => $value) { $template->set_var(array($prop => $property_vars[$prop])); } //we want to display the owner $this->display_owner = 1; //we want the history of the instance $this->display_history= true; // submit options we want $this->submit_array['__Cancel'] = lang('Close'); ?>` <table width="100%"> <tr class="th"> <td colspan="2">this a message made by {wf_owner}</td> </tr> </tr> <tr class="row_on"> <td> From:</td> <td>{wf_owner}</td> </tr> <tr class="row_on"> <td> To:</td> <td>{MYDEST}</td> </tr> <tr class="row_off"> <td> subject:</td> <td>{wf_instance_name}</td> </tr> <tr class="row_on"> <td> body:</td> <td> <textarea readonly="readonly" name="MYBODY" cols="76" rows="5">{MYBODY}</textarea></td> </tr> <tr class="row_on"> <td> in case of BaAad REFUSAL:</td> <td> {REFUSAL}</td> </tr> </table>
end
end default end activity 01/09/2005 [09:13:00] n y `<?php ?>`
Acknowledge user it was good
activity This automatic activity send an email to the user to prevent him his mail was sent 01/09/2005 [09:13:00] n y mail_smtp wf_to %owner% wf_cc wf_bcc wf_from %user% wf_replyto wf_subject Your mail was sent wf_message your mail for %property_MYDEST% was sent by the validator. %signature% wf_send_mode 2 wf_agent_type mail_smtp `<?php ?>`
Acknowledge user it was bad
activity Boo, the validator said the mail was bad, send an email to the owner, aka the user starting the process, to tell him it was bad 01/09/2005 [09:13:00] n y mail_smtp wf_to %owner% wf_cc wf_bcc wf_from %user% wf_replyto %user% wf_subject Your mail was not sent wf_message Your mail for %property_MYDEST% was NOT sent by the validator. here is his explanation: %property_REFUSAL% %signature% wf_send_mode 3 wf_agent_type mail_smtp `<?php ?>`
Send the message
activity This automatic activity will send the message that the user was asking for. 28/10/2005 [10:21:20] n y mail_smtp wf_to %property_MYDEST% wf_cc wf_bcc wf_from %owner% wf_replyto %owner% wf_subject %instance_name% wf_message %property_MYBODY% wf_send_mode 2 wf_agent_type mail_smtp `<?php ?>`
Validation
switch The Validator validate the mail and send it by completing the activity. He can as well invalidate the mail. 02/09/2005 [03:06:38] y y Validator MailUser `<?php //avoid empty property warning $instance->set('REFUSAL',''); $property_vars = array( 'MYDEST' => '', 'MYBODY' => '', 'REFUSAL' => '', ); //-------------------------------------- // // handling data on the form // //-------------------------------------- // init variables with POST and if POST is empty // init with the property foreach ($property_vars as $prop => $value) { $property_vars[$prop] = get_var($prop,'any',$instance->get($prop)); } //user commands **************** $ActBad = get_var('ActBad','POST',false); $ActGood = get_var('ActGood','POST',false); $ActLater = get_var('ActLater','POST',false); //-------------------------------------- // // handling results from the form // //-------------------------------------- $message = Array(); $checkforstaying = true; if (($ActBad) || ($ActGood) || ($ActLater)) { // saving properties // if they changed foreach ($property_vars as $prop => $value) { if ($value != ($instance->get($prop)) ) { $instance->set($prop,$value); } } if ($ActGood) { $checkforstaying = false; // going to next stage $instance->setNextActivity('Send the message'); //complete and send the message $instance->complete(); } if ($ActBad) { if($property_vars['REFUSAL']=='') { $message[]='You need to complete the REFUSAL to give some explanation of why it is baAad'; } else { $checkforstaying = false; // going to next stage $instance->setNextActivity('Acknowledge user it was bad'); //complete and sen the message $instance->complete(); } } elseif($ActLater) { $checkforstaying = false; //leave without complete() $GLOBALS['workflow']['__leave_activity']=true; } } //now if we do not leave... if ($checkforstaying) { //-------------------------------------- // // showing the form // //-------------------------------------- foreach ($property_vars as $prop => $value) { $template->set_var(array($prop => htmlentities($property_vars[$prop]))); } //some more form vars $template->set_var(array( 'message' => implode('<br />',$message), ) ); //we want to display the owner $this->display_owner = 1; // submit options we want $this->submit_array['ActBad'] = array(label => 'BaAad', confirm => 'Are you sure you want to reject it?'); $this->submit_array['ActGood'] = array(label => 'GoOod', confirm => 'this will send the email, you really want it, really?'); $this->submit_array['ActLater'] = 'Later, I need more reflexion'; //priority array $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - normal'), 3 => lang('3 - better'), 4 => lang('4 - urgent'), ); } ?>` <table width="100%"> <tr class="th"> <td colspan="2">Decide if this message is goOod or baAad. If you choose goOod he will be sent, else he wont, and {wf_owner} will be warned of your choice by email</td> </tr> </tr> <tr class="row_off"> <td>&nbsp;</td> <td>&nbsp;{message}</td> </tr> <tr class="row_on"> <td> From:</td> <td>{wf_owner}</td> </tr> <tr class="row_on"> <td> To:</td> <td>{MYDEST}</td> </tr> <tr class="row_off"> <td> subject:</td> <td>{wf_instance_name}</td> </tr> <tr class="row_on"> <td> body:</td> <td> <textarea readonly="readonly" name="MYBODY" cols="76" rows="5">{MYBODY}</textarea></td> </tr> <tr class="row_on"> <td> in case of BaAad REFUSAL:</td> <td> <input type="text" name="REFUSAL" value="{REFUSAL}" /></td> </tr> </table>
Send Automatic Mail to Validator
activity This automatic activity sends an email to people in validator role. This email contains a lot of tips for writing emails with this agent 01/09/2005 [09:13:00] n y Validator mail_smtp wf_to %roles% wf_cc wf_bcc wf_from %user% wf_replyto %user% wf_subject A mail needs your validation wf_message %owner% wanted to send an email to %property_MYDEST%. You need to check the message, the task is avaible %link_userinstance|here on the activity list%. and just to test links I think you should try to click on this %link_http://www.egroupware.org/|egroupware.org external site link%. or on this %link_/index.php?menuaction=workflow.ui_useractivities.form|local installation link%. And some other usefull links are: %link_viewinstance|the instance in default view mode%. %link_viewniceinstance|the instance in view activity%. %link_admininstance|the instance in admin mode%. We could as well use some defined tokens: instance name and id: %instance_name% (%instance_id%) activity name and id: %activity_name% (%activity_id%) process name, version and id: %process_name% v%process_version% (%process_id%) Last tip, if you want the \% character use the '\' charater to escape him. ===================================== %signature% wf_send_mode 3 wf_agent_type mail_smtp `<?php ?>`
Need to send an email
start This start activity let the User write an email and send an email to the Validator Role, the user email is not sent. To test some other functionnalities we send an email to the user after he finished this activity to tell him we are sending an email to the validator 01/09/2005 [09:13:00] y y MailUser mail_smtp wf_to %user% wf_cc wf_bcc wf_from no-reply@nowhere.com wf_replyto %user% wf_subject Your message is waiting for validation wf_message Your message for %property_MYDEST% is actually awaiting for validation by the validator. %signature% wf_send_mode 0 wf_agent_type mail_smtp `<?php // retrieve submit options **************** $ActSendtoValidation = get_var('ActSendtoValidation','POST',false); //retrieve the message $MYBODY = get_var('MYBODY','POST','write your message here'); $MYDEST = get_var('MYDEST','POST',''); //-------------------------------------- // // handling results from the form // //-------------------------------------- $checkforcomplete = false; $message = Array(); if ($ActSendtoValidation) { //do some checks if (($MYBODY=='') || ($MYBODY=='write your message here') || ($MYBODY=='hey, you NEED to write your message here!')) { //no need to work with an empty message, even if the SendtoValidation is set $MYBODY = 'hey, you NEED to write your message here!'; $message[] = 'you should write something in the message zone'; } elseif ($MYDEST=='') { //no need to work with an empty dest, even if the SendtoValidation is set $message[] = 'write an email in the To: field, please'; } elseif (get_var('wf_name','POST','')=='') { //empty subject for the message, baAad $message[] = 'write a subject for your message, please'; } else { $checkforcomplete = true; } } if ($checkforcomplete) { //save the instance property, we are in a start activity, //which is a pseudo instance //this means we cannot keep track of instance properties when looping on the form //but it is not meaning you cannot write instance properties //in fact they are just in memory and written in database when the complete() //is done. $instance->set('MYDEST',$MYDEST); $instance->set('MYBODY',$MYBODY); // going to next stage $instance->complete(); // the 'wf_name' and 'wf_priority' special properties are saved in // start_pos.php when completing //we use the name of the instance as the subject of the message } else { //-------------------------------------- // // let's run_activity show the form // //-------------------------------------- // submit options we want $this->submit_array['ActSendtoValidation'] = lang('Send to Validation'); //Special cancel value $this->submit_array['__Cancel'] = lang('Cancel'); //priority levels we want $this->priority_array = array( 1 => lang('1 - low'), 2 => lang('2 - normal'), 3 => lang('3 - hurry up'), 4 => lang('4 - I need It!'), ); //and default values and messages $template->set_var(array( 'MYDEST' => $MYDEST, 'MYBODY' => $MYBODY, 'message' => implode('<br />',$message), )); } ?>` <table width="100%"> <tr class="th"> <td colspan="2">this activity will begin a new test mail process, an instance will be created. Your message wont be sent. An email will be sent to the Validator and he will decide if your message can be sent or not. You will be warned of his decision.</td> </tr> <tr class="row_off"> <td>&nbsp;</td> <td>&nbsp;{message}</td> </tr> <tr class="row_on"> <td> To:</td> <td> <input type="text" name="MYDEST" value="{MYDEST}" /></td> </tr> <tr class="row_off"> <td> enter the subject of your message:</td> <td> <input type="text" name="wf_name" value="" /></td> </tr> <tr class="row_on"> <td> enter the body your message:</td> <td> <textarea name="MYBODY" cols="76" rows="5">{MYBODY}</textarea></td> </tr> </table>
Need to send an email
Send Automatic Mail to Validator
Send Automatic Mail to Validator
Validation
Validation
Acknowledge user it was bad
Validation
Send the message
Send the message
Acknowledge user it was good
Acknowledge user it was good
end
Acknowledge user it was bad
end