[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare Workflow - Agents Connector - business objects 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.bo_agent.inc.php 19830 2005-11-14 19:37:58Z regis_glc $ */ 12 13 14 /** 15 * * Agents abstraction library - business layer 16 * * 17 * * This allows the Workflow Engine to connect to various agents 18 * * Agents are external elements for the workflow. It could be 19 * * email systems, filesystems, calendars, what you want. 20 * * Use this class to make childrens like, for example in the 21 * * class.bo_agent_mail_smtp.inc.php for the mail_smtp susbsytem 22 * * 23 * * @package workflow 24 * * @author regis.leroy@glconseil.com 25 * * GPL 26 */ 27 28 29 class bo_agent 30 { 31 // the local error storage 32 var $error = Array(); 33 //the instance and activity object we are working with at runtime (references) 34 var $activity = null; 35 var $instance = null; 36 //the process object is used for process level configuration 37 var $process = null; 38 //store process level configuration 39 var $conf; 40 41 // define theses values in your child class ---------------------------------------------- 42 //agent title 43 var $title=''; 44 45 //agent description 46 var $description=''; 47 48 //agent help 49 var $help=''; 50 51 //derived so object. i.e.: for foo agent it is an so_agent_foo 52 var $so_agent; 53 54 // the agent id 55 var $agent_id; 56 57 /** 58 * the fields which are saved at admin time and just changed at runtime (without saving) 59 */ 60 var $fields = Array(); 61 62 /** 63 * the config fields which are at process level , key is the config option and value is the 64 * * default value 65 */ 66 var $ProcessConfigurationFieldsdefault = Array(); 67 68 /** 69 * the config fields which are at process level , key is the config option and value is an 70 * * associative array with keys: 71 * * * 'title' for an helper/title line, not a conf value in fact 72 * * * 'text' for a text input 73 * * * 'yesno' to select between true or false 74 * * * an array for a list of select key => value pairs 75 */ 76 var $showProcessConfigurationFieldsdefault = Array(); 77 //---------------------------------------------------------------------------------------- 78 79 function bo_agent() 80 { 81 82 } 83 84 //! return errors recorded by this object 85 /** 86 * * You should always call this function after failed operations on a workflow object to obtain messages 87 * * @param $as_array if true the result will be send as an array of errors or an empty array. Else, if you do not give any parameter 88 * * or give a false parameter you will obtain a single string which can be empty or will contain error messages with <br /> html tags. 89 */ 90 function get_error($as_array=false) 91 { 92 if ($as_array) 93 { 94 return $this->error; 95 } 96 $result_str = implode('<br />',$this->error); 97 $this->error= Array(); 98 return $result_str; 99 } 100 101 102 function getTitle() 103 { 104 return $this->title; 105 } 106 107 function getDescription() 108 { 109 return $this->description; 110 } 111 112 function getHelp() 113 { 114 return $this->help; 115 } 116 117 /** 118 * * Factory: Load the agent values stored somewhere in the agent object and retain the agent id 119 * * 120 * * @param $agent_id is the agent id 121 * * @param $really_load boolean, true by default, if false the data wont be loaded from database and 122 * * the only thing done by this function is storing the agent_id (usefull if you know you wont need actual data) 123 * * @return false if the agent cannot be loaded, true else 124 */ 125 function load($agent_id, $really_load=true) 126 { 127 $this->agent_id = $agent_id; 128 return true; 129 } 130 131 /** 132 * * Save the agent datas 133 * * 134 * * @return false if the agent cannot be saved, true else 135 */ 136 function save() 137 { 138 return true; 139 } 140 141 /** 142 * * Function called at runtime to permit association with the instance and the activity 143 * * we store references to theses objects 144 */ 145 function runtime(&$instance, &$activity) 146 { 147 $this->instance =& $instance; 148 $this->activity =& $activity; 149 } 150 151 /** 152 * * Return the agent fields in different forms 153 * * @param $result_type int : 154 * * 1 the result is an array containing the field names 155 * * 2 the result is an array containing fields names => value pairs 156 * * 3 the result is an array containing fields names => field array pairs, the field array is an associative array 157 * containing all infos about the field with $key => $value pairs. 158 * * @return an array, the form depends on the parameter $result_type 159 */ 160 function get($result_type) 161 { 162 switch ($result_type) 163 { 164 case 1: 165 return array_keys($this->fields); 166 break; 167 case 2: 168 $res = Array(); 169 foreach ($this->fields as $key => $value) 170 { 171 $res[$key] = html_entity_decode($value['value']); 172 } 173 return $res; 174 break; 175 default : 176 return $this->fields; 177 } 178 } 179 180 /** 181 * * Affect some values to some of the agent's fields 182 * * @param $datas is an array containing fields => value pairs 183 * * @return false if one or more value cannot be affected, true else 184 */ 185 function set(&$datas) 186 { 187 foreach ($datas as $key => $value) 188 { 189 if ( (isset($this->fields[$key])) && (is_array($this->fields[$key])) ) 190 { 191 $this->fields[$key]['value'] = htmlentities($value); 192 } 193 else 194 { 195 return false; 196 } 197 } 198 return true; 199 } 200 201 202 /** 203 * * this function tell the engine which process level options have to be set 204 * * 205 * * for the agent. Theses options will be initialized for all processes by the engine 206 * * and can be different for each process. 207 * * @return an array which can be empty 208 */ 209 function listProcessConfigurationFields() 210 { 211 return $this->showProcessConfigurationFields; 212 } 213 214 /** 215 * * This function retrieve process level configuration otpions set by the engine 216 * * for the agent. Theses conf values are cached locally for the object life duration 217 * * @param $wf_p_id is the process id 218 * * @param $force is false by default, if true we retrieve theses config values even if the $conf 219 * * local cache is already set 220 * * @return an associative array which can be empty 221 */ 222 function getProcessConfigurationFields($wf_p_id, $force=false) 223 { 224 if ($force || (!(isset($this->conf))) ) 225 { 226 if (!(isset($this->process))) 227 { 228 $this->process =& CreateObject('workflow.workflow_process'); 229 $this->process->getProcess($wf_p_id); 230 } 231 $this->conf = $this->process->getConfigValues($this->ProcessConfigurationFieldsdefault); 232 } 233 return $this->conf; 234 } 235 236 /** 237 * * this function lists activity level options avaible for the agent 238 * * 239 * * @return an associative array which can be empty 240 */ 241 function getAdminActivityOptions () 242 { 243 return (Array(Array())); 244 } 245 } 246 ?>
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 |