| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare Workflow - Mail SMTP Agent Connector - interface layer * 4 * ------------------------------------------------------------------------ * 5 * This program is free software; you can redistribute it and/or modify it * 6 * under the terms of the GNU General Public License as published * 7 * by the Free Software Foundation; either version 2 of the License, or * 8 * any later version. * 9 \**************************************************************************/ 10 11 /* $Id: class.ui_agent_mail_smtp.inc.php 19830 2005-11-14 19:37:58Z regis_glc $ */ 12 13 14 /** 15 * * Mail-SMTP Agent : interface layer 16 * * 17 * * This class connects the workflow agents calls to the mail_smtp agent business layer 18 * * 19 * * @package workflow 20 * * @author regis.leroy@glconseil.com 21 * * GPL 22 */ 23 24 require_once(dirname(__FILE__) . SEP . 'class.ui_agent.inc.php'); 25 26 class ui_agent_mail_smtp extends ui_agent 27 { 28 29 function ui_agent_mail_smtp() 30 { 31 parent::ui_agent(); 32 $this->agent_type = 'mail_smtp'; 33 $this->bo_agent =& CreateObject('workflow.bo_agent_mail_smtp'); 34 } 35 36 37 function showAdminActivityOptions ($template_block_name) 38 { 39 $admin_name = 'admin_agent_'.$this->agent_type; 40 $this->t->set_file($admin_name, $admin_name . '.tpl'); 41 $this->t->set_block($admin_name, 'block_ag_config_option_input', 'ag_option_input'); 42 $this->t->set_block($admin_name, 'block_ag_config_option_textarea', 'ag_option_textarea'); 43 $this->t->set_block($admin_name, 'block_ag_config_option_select_option', 'ag_option_select_option'); 44 $this->t->set_block($admin_name, 'block_ag_config_option_select', 'ag_option_select'); 45 $options =& $this->bo_agent->getAdminActivityOptions(); 46 foreach ($options as $option_name => $option_conf) 47 { 48 if ($option_conf['type'] == 'text') 49 { 50 $size = $option_conf['size']; 51 if ( (!($size)) || ($size > 80)) $size = 80; 52 $this->t->set_var(array( 53 'ag_config_name_i' => "wf_agent[".$this->agent_type."][".$option_name."]", 54 'ag_config_label_i' => $option_conf['label'], 55 'ag_config_value_i' => $option_conf['value'], 56 'ag_config_size_i' => 'size="'.$size.'"', 57 )); 58 $this->t->parse('ag_option_input','block_ag_config_option_input',true); 59 } 60 if ($option_conf['type'] == 'textarea') 61 { 62 $this->t->set_var(array( 63 'ag_config_name_t' => "wf_agent[".$this->agent_type."][".$option_name."]", 64 'ag_config_label_t' => $option_conf['label'], 65 'ag_config_value_t' => $option_conf['value'], 66 )); 67 $this->t->parse('ag_option_textarea','block_ag_config_option_textarea',true); 68 } 69 if ($option_conf['type'] == 'select') 70 { 71 $this->t->set_var(array( 72 'ag_config_name_s' => "wf_agent[".$this->agent_type."][".$option_name."]", 73 'ag_config_label_s' => $option_conf['label'], 74 )); 75 foreach($option_conf['values'] as $key => $value) 76 { 77 $this->t->set_var(array( 78 'ag_config_value_s_key' => $key, 79 'ag_config_value_s_value' => $value, 80 'ag_config_value_s_selected' => ($option_conf['value']==$key)? 'selected': '', 81 )); 82 $this->t->parse('ag_option_select_option','block_ag_config_option_select_option',true); 83 } 84 $this->t->parse('ag_option_select','block_ag_config_option_select',true); 85 } 86 } 87 //show the shared part handled by parent object 88 parent::showAdminActivityOptions('shared_part'); 89 $this->translate_template($admin_name); 90 $this->t->parse($template_block_name, $admin_name); 91 } 92 93 /** 94 * * Function called by the running object (run_activity) after the activity_pre code 95 * * and before the user code. This code is runned only if the $GLOBALS['workflow']['__leave_activity'] 96 * * IS NOT set (i.e.: the user is not cancelling his form in case of interactive activity) 97 * * WARNING : on interactive queries the user code is parsed several times and this function is called 98 * * each time you reach the begining of the code, this means at least the first time when you show the form 99 * * and every time you loop on the form + the last time when you complete the code (if the user did not cancel). 100 * * @return true or false, if false the $this->error array should contains error messages 101 */ 102 function run_activity_pre() 103 { 104 //load agent data from database 105 $this->bo_agent->init(); 106 107 //this will send an email only if the configuration says to do so 108 if (!($this->bo_agent->send_start())) 109 { 110 $this->error[] = lang('Smtp Agent has detected some errors when sending email at the beginning of the activity'); 111 $ok = false; 112 } 113 else 114 { 115 $ok = true; 116 } 117 $this->error[] = $this->bo_agent->get_error(); 118 if ($this->bo_agent->debugmode) echo '<br />START: Mail agent in DEBUG mode:'.implode('<br />',$this->error); 119 return $ok; 120 } 121 122 /** 123 * * Function called by the running object (run_activity) after the activity_pre code 124 * * and before the user code. This code is runned only if the $GLOBALS['workflow']['__leave_activity'] 125 * * IS set (i.e.: the user is cancelling his form in case of interactive activity) 126 * * @return true or false, if false the $this->error array should contains error messages 127 */ 128 function run_leaving_activity_pre() 129 { 130 //actually we never send emails when cancelling 131 return true; 132 } 133 134 /** 135 * * Function called by the running object (run_activity) after the user code 136 * * and after the activity_pos code. This code is runned only if the $GLOBALS['__activity_completed'] 137 * * IS set (i.e.: the user has completing the activity) 138 * * @return true or false, if false the $this->error array should contains error messages 139 */ 140 function run_activity_completed_pos() 141 { 142 //this will send an email only if the configuration says to do so 143 if (!($this->bo_agent->send_completed())) 144 { 145 $this->error[] = lang('Smtp Agent has detected some errors when sending email after completion of the activity'); 146 $ok = false; 147 } 148 else 149 { 150 $ok = true; 151 } 152 $this->error[] = $this->bo_agent->get_error(); 153 if ($this->bo_agent->debugmode) echo '<br />COMPLETED: Mail agent in DEBUG mode:'.implode('<br />',$this->error); 154 return $ok; 155 } 156 157 /** 158 * * Function called by the running object (run_activity) after the user code 159 * * and after the activity_pos code. This code is runned only if the $GLOBALS['__activity_completed'] 160 * * IS NOT set (i.e.: the user is not yet completing the activity) 161 * * WARNING : on interactive queries the user code is parsed several times and this function is called 162 * * each time you reach the end of the code without completing, this means at least the first time 163 * * and every time you loop on the form. 164 * * This function can call two types of mail sending 165 * * * sending email on POST queries (usefull for interactive forms), retrieving POSTed values 166 * * * sending email at each reach of the end of the code (usefull for automatic activities which 167 * * completes only after execution of user code (sending after completion is not possible). And we 168 * * musn't retrieve POSTed values in this case because it can concerns previous non-automatic activities 169 * * @return true or false, if false the $this->error array should contains error messages 170 */ 171 function run_activity_pos() 172 { 173 if ($this->bo_agent->sendOnPosted()) 174 {//First case, POSTed emails, we will try to see if there are some POSTed infos 175 //form settings POSTED with wf_agent_mail_smtp['xxx'] values 176 $this->retrieve_form_settings(); 177 if (!(isset($this->agent_values['submit_send']))) 178 { 179 return true; 180 } 181 else 182 { 183 //erase agent data with the POSTed values 184 $this->bo_agent->set($this->agent_values); 185 186 //this will send an email only if the configuration says to do so 187 if (!($this->bo_agent->send_post())) 188 { 189 $this->error[] = lang('Smtp Agent has detected some errors when sending email on demand whith this activity'); 190 $ok = false; 191 } 192 else 193 { 194 $ok = true; 195 } 196 $this->error[] = $this->bo_agent->get_error(); 197 if ($this->bo_agent->debugmode) echo '<br />POST: Mail agent in DEBUG mode:'.implode('<br />',$this->error); 198 return $ok; 199 } 200 } 201 else 202 {//Second case , not about POSTed values, the bo_agent will see himself he he need 203 // to do something on end of the user code 204 //this will send an email only if the configuration says to do so 205 if (!($this->bo_agent->send_end())) 206 { 207 $this->error[] = lang('Smtp Agent has detected some errors when sending email at the end of this activity'); 208 $ok = false; 209 } 210 else 211 { 212 $ok = true; 213 } 214 $this->error[] = $this->bo_agent->get_error(); 215 if ($this->bo_agent->debugmode) echo '<br />END: Mail agent in DEBUG mode:'.implode('<br />',$this->error); 216 return $ok; 217 } 218 } 219 220 } 221 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |