[903] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * @package Galaxia |
---|
| 4 | * @author Mauricio Luiz Viani - viani@celepar.pr.gov.br |
---|
| 5 | * @licence |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | // Common prefix used for all database table names, e.g. galaxia_ |
---|
| 9 | if (!defined('GALAXIA_TABLE_PREFIX')) { |
---|
| 10 | define('GALAXIA_TABLE_PREFIX', 'egw_wf_'); |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | // Directory containing the Galaxia library, e.g. this directory |
---|
| 14 | if (!defined('GALAXIA_LIBRARY')) { |
---|
| 15 | define('GALAXIA_LIBRARY', dirname(__FILE__)); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | // Directory where the Galaxia processes will be stored, e.g. /workflow on the vfs |
---|
| 19 | if (!defined('GALAXIA_PROCESSES')) |
---|
| 20 | { |
---|
| 21 | // Note: this directory must be writeable by the webserver ! |
---|
| 22 | define('GALAXIA_PROCESSES', $_SESSION['phpgw_info']['workflow']['vfs_basedir'].SEP.'workflow'); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | // Directory where a *copy* of the Galaxia activity templates will be stored, e.g. templates |
---|
| 26 | // Define as '' if you don't want to copy templates elsewhere |
---|
| 27 | if (!defined('GALAXIA_TEMPLATES')) { |
---|
| 28 | // Note: this directory must be writeable by the webserver ! |
---|
| 29 | define('GALAXIA_TEMPLATES', ''); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | // Default header to be added to new activity templates |
---|
| 33 | if (!defined('GALAXIA_TEMPLATE_HEADER')) { |
---|
| 34 | define('GALAXIA_TEMPLATE_HEADER', ''); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // File where the ProcessManager logs for Galaxia will be saved, e.g. lib/Galaxia/log/pm.log |
---|
| 38 | // Define as '' if you don't want to use logging |
---|
| 39 | if (!defined('GALAXIA_LOGFILE')) { |
---|
| 40 | // Note: this file must be writeable by the webserver ! |
---|
| 41 | //define('GALAXIA_LOGFILE', GALAXIA_LIBRARY . '/log/pm.log'); |
---|
| 42 | define('GALAXIA_LOGFILE', $_SESSION['phpgw_info']['workflow']['vfs_basedir'].SEP.'workflow'.SEP.'galaxia.log'); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | // Directory containing the GraphViz 'dot' and 'neato' programs, in case |
---|
| 46 | // your webserver can't find them via its PATH environment variable |
---|
| 47 | if (!defined('GRAPHVIZ_BIN_DIR')) { |
---|
| 48 | define('GRAPHVIZ_BIN_DIR', ''); |
---|
| 49 | //define('GRAPHVIZ_BIN_DIR', 'd:/wintools/ATT/GraphViz/bin'); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | // language function |
---|
| 53 | function tra($msg, $m1='', $m2='', $m3='', $m4='') |
---|
| 54 | { |
---|
| 55 | $frase = $msg."*"; |
---|
| 56 | |
---|
| 57 | if (isset($_SESSION['phpgw_info']['workflow']['lang'][$msg])) |
---|
| 58 | { |
---|
| 59 | $frase = $_SESSION['phpgw_info']['workflow']['lang'][$msg]; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $sub_array = array('%1', '%2', '%3', '%4'); |
---|
| 63 | $new_array = array($m1, $m2, $m3, $m4); |
---|
| 64 | |
---|
| 65 | return str_replace($sub_array, $new_array, $frase); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | //define the list of agents avaible with your Galaxia installation |
---|
| 69 | if (!function_exists('galaxia_get_agents_list')) |
---|
| 70 | { |
---|
| 71 | /** |
---|
| 72 | * * This function list the agents avaible with your galaxia installation. The name of an agent |
---|
| 73 | * * is his unique identifier, the priority is an execution order priority |
---|
| 74 | * * @return an associative array of agents description, each row is an agent description |
---|
| 75 | * * containing a 'wf_agent_type' key and a 'wf_agent_priority' key |
---|
| 76 | */ |
---|
| 77 | function galaxia_get_agents_list() |
---|
| 78 | { |
---|
| 79 | $res = array( |
---|
| 80 | array( |
---|
| 81 | 'wf_agent_type' => 'mail_smtp', |
---|
| 82 | 'wf_agent_priority' => 1, |
---|
| 83 | ) |
---|
| 84 | ); |
---|
| 85 | return $res; |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | if (!function_exists('galaxia_user_can_admin_process')) |
---|
| 91 | { |
---|
| 92 | //! Specify if the user has special admin rights on processes |
---|
| 93 | /** |
---|
| 94 | * * @return true if the actual user has access to the processes administration. |
---|
| 95 | * * ie. he can edit/activate/deactivate/create/destroy processes and activities |
---|
| 96 | * * warning: dangerous rights, this user can do whatever PHP can do... |
---|
| 97 | */ |
---|
| 98 | function galaxia_user_can_admin_process() |
---|
| 99 | { |
---|
| 100 | return $_SESSION['phpgw_info']['workflow']['user_can_admin_process']; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | if (!function_exists('galaxia_user_can_admin_instance')) |
---|
| 105 | { |
---|
| 106 | //! Specify if the user has special admin rights on instances |
---|
| 107 | /** |
---|
| 108 | * * @return true if the actual user has access to the instance administration |
---|
| 109 | * * ie. he can edit and modify all properties, members, assigned users of an instance whatever the state of the instance is |
---|
| 110 | * * warning: this is clearly an administrator right |
---|
| 111 | */ |
---|
| 112 | function galaxia_user_can_admin_instance() |
---|
| 113 | { |
---|
| 114 | return $_SESSION['phpgw_info']['workflow']['user_can_admin_instance']; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | if (!function_exists('galaxia_user_can_clean_instances')) |
---|
| 120 | { |
---|
| 121 | //! Specify if the user has special cleanup rights on ALL instances |
---|
| 122 | /** |
---|
| 123 | * * @return true if the actual user is granted access to the 'clean instances' and 'clean all instances for a process' functions |
---|
| 124 | * * warning: theses are dangerous functions! |
---|
| 125 | */ |
---|
| 126 | function galaxia_user_can_clean_instances() |
---|
| 127 | { |
---|
| 128 | return $_SESSION['phpgw_info']['workflow']['user_can_clean_instances']; |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | if (!function_exists('galaxia_user_can_clean_aborted_instances')) |
---|
| 133 | { |
---|
| 134 | //! Specify if the actual user has special cleanup rights on aborted instances |
---|
| 135 | /** |
---|
| 136 | * * @return true if the user is granted access to the 'clean aborted instances' functions |
---|
| 137 | */ |
---|
| 138 | function galaxia_user_can_clean_aborted_instances() |
---|
| 139 | { |
---|
| 140 | return $_SESSION['phpgw_info']['workflow']['user_can_clean_aborted_instances']; |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | if (!function_exists('galaxia_user_can_monitor')) |
---|
| 145 | { |
---|
| 146 | //! Specify if the user has special monitors rights |
---|
| 147 | /** |
---|
| 148 | * * @return true if the actual user has access to the monitor screens (this is not sufficient for cleanup access) |
---|
| 149 | */ |
---|
| 150 | function galaxia_user_can_monitor() |
---|
| 151 | { |
---|
| 152 | return $_SESSION['phpgw_info']['workflow']['user_can_monitor']; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | if (!function_exists('galaxia_retrieve_user_groups')) |
---|
| 157 | { |
---|
| 158 | /*! |
---|
| 159 | * Specify how to retrieve an array containing all groups id for a given user |
---|
| 160 | * if the user is in no group this function should return false |
---|
| 161 | * @param $user is the current user id |
---|
| 162 | * @return an arry of integers, the groups ids the user is member of, or false if the user is not |
---|
| 163 | * the member of any group |
---|
| 164 | */ |
---|
| 165 | function galaxia_retrieve_user_groups($user = 0) |
---|
| 166 | { |
---|
| 167 | $memberships = array(); |
---|
| 168 | |
---|
| 169 | $loadGroups = ($user != $_SESSION['phpgw_info']['workflow']['account_id']) || (is_null($_SESSION['phpgw_info']['workflow']['user_groups'])); |
---|
| 170 | if ($loadGroups) |
---|
| 171 | { |
---|
| 172 | $memberships = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($user); |
---|
| 173 | if ($user == $_SESSION['phpgw_info']['workflow']['account_id']) |
---|
| 174 | $_SESSION['phpgw_info']['workflow']['user_groups'] = $memberships; |
---|
| 175 | } |
---|
| 176 | else |
---|
| 177 | $memberships = $_SESSION['phpgw_info']['workflow']['user_groups']; // we are asking groups membership for the actual user in egroupware we retrieve the already loaded in memory group list. |
---|
| 178 | |
---|
| 179 | if (empty($memberships)) |
---|
| 180 | return false; |
---|
| 181 | |
---|
| 182 | return $memberships; |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | |
---|
| 187 | if (!function_exists('galaxia_retrieve_group_users')) |
---|
| 188 | { |
---|
| 189 | //! Specify how to retrieve an array containing all users id for a given group id |
---|
| 190 | /** |
---|
| 191 | * * @param $group the group id |
---|
| 192 | * * @param $add_names false by default, if true we add user names in the result |
---|
| 193 | * * return an array with all users id or an associative array with names associated with ids if $add_names is true |
---|
| 194 | */ |
---|
| 195 | function galaxia_retrieve_group_users($group, $add_names = false) |
---|
| 196 | { |
---|
| 197 | /* get information regarding the members of the group */ |
---|
| 198 | $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); |
---|
| 199 | $members = $ldap->getGroupUsers($group); |
---|
| 200 | |
---|
| 201 | /* checl for error in the LDAP query */ |
---|
| 202 | if ($members === false) |
---|
| 203 | return false; |
---|
| 204 | |
---|
| 205 | /* format the output as requested */ |
---|
| 206 | $group_users = array(); |
---|
| 207 | foreach($members as $member) |
---|
| 208 | if ($add_names) |
---|
| 209 | $group_users[$member['account_id']] = $member['account_name']; |
---|
| 210 | else |
---|
| 211 | $group_users[] = $member['account_id']; |
---|
| 212 | |
---|
| 213 | return $group_users; |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | if (!function_exists('galaxia_retrieve_running_user')) |
---|
| 218 | { |
---|
| 219 | //! returns the actual user running this PHP code |
---|
| 220 | /** |
---|
| 221 | * * @return the user id of the actual running user. |
---|
| 222 | */ |
---|
| 223 | function galaxia_retrieve_running_user() |
---|
| 224 | { |
---|
| 225 | return $_SESSION['phpgw_info']['workflow']['account_id']; |
---|
| 226 | } |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | if (!function_exists('galaxia_retrieve_name')) |
---|
| 231 | { |
---|
| 232 | //! Specify how to retrieve the name of an user with is Id |
---|
| 233 | /** |
---|
| 234 | * * @param $user the user or group id |
---|
| 235 | * * return the name of the user |
---|
| 236 | */ |
---|
| 237 | function galaxia_retrieve_name($user) |
---|
| 238 | { |
---|
| 239 | $username = $GLOBALS['ajax']->ldap->id2name($user); |
---|
| 240 | return $username; |
---|
| 241 | } |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | /* |
---|
| 245 | Specify how to obtain stored config values |
---|
| 246 | Parameter: an array containing pairs of (variables_names => default values) |
---|
| 247 | For an unknown variable name it will return default_value and this |
---|
| 248 | default value will be the NEW STORED value. If no default value is |
---|
| 249 | given we assume it's a false. |
---|
| 250 | WARNING: you should cast your result if you bet its' an integer |
---|
| 251 | as it is maybe stored as a string. But 1 and 0 special values are |
---|
| 252 | handled correctly as ints (bools). |
---|
| 253 | */ |
---|
| 254 | if (!function_exists('galaxia_get_config_values')) |
---|
| 255 | { |
---|
| 256 | function galaxia_get_config_values($parameters=array()) |
---|
| 257 | { |
---|
| 258 | $config = new ajax_config(); |
---|
| 259 | $config->read_repository(); |
---|
| 260 | |
---|
| 261 | $result_array = array(); |
---|
| 262 | foreach ($parameters as $config_var => $default_value) |
---|
| 263 | { |
---|
| 264 | $config_value = $config->config_data[$config_var]; |
---|
| 265 | if(isset($config_value)) |
---|
| 266 | { //we add something in the config store, we take it |
---|
| 267 | if ($config_value=='False') |
---|
| 268 | { |
---|
| 269 | $result_array[$config_var]=0; |
---|
| 270 | } |
---|
| 271 | elseif ($config_value=='True') |
---|
| 272 | { |
---|
| 273 | $result_array[$config_var]=1; |
---|
| 274 | } |
---|
| 275 | else |
---|
| 276 | { |
---|
| 277 | $result_array[$config_var] = $config_value; |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | else |
---|
| 281 | { |
---|
| 282 | //we had no value stored yet, so we store it now |
---|
| 283 | //boolean warning: egw'config class is not storing false values if it is 0 |
---|
| 284 | //we have to map theses int... |
---|
| 285 | $stored_value= (string)$default_value; |
---|
| 286 | if ($stored_value=='1') |
---|
| 287 | { |
---|
| 288 | $stored_value='True'; |
---|
| 289 | } |
---|
| 290 | elseif ($stored_value=='0') |
---|
| 291 | { |
---|
| 292 | $stored_value='False'; |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | $config->value($config_var,$stored_value); |
---|
| 296 | $config->save_repository(); |
---|
| 297 | // take the not casted variable |
---|
| 298 | $result_array[$config_var] = $default_value; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | unset($config); |
---|
| 302 | return $result_array; |
---|
| 303 | } |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | ?> |
---|