[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/workflow/inc/engine/ -> config.egw.inc.php (source)

   1  <?php
   2  
   3  /**
   4   * Configuration of the Galaxia Workflow Engine for E-Groupware
   5   */
   6  
   7  // Common prefix used for all database table names, e.g. galaxia_
   8  if (!defined('GALAXIA_TABLE_PREFIX')) {
   9          define('GALAXIA_TABLE_PREFIX', 'egw_wf_');
  10  }
  11  
  12  // Directory containing the Galaxia library, e.g. this directory
  13  if (!defined('GALAXIA_LIBRARY')) {
  14          define('GALAXIA_LIBRARY', dirname(__FILE__));
  15  }
  16  
  17  // Specify how error messages should be shown
  18  if (!function_exists('galaxia_show_error')) {
  19      /**
  20      * Show error messages from the engine
  21      * @param $msg is the message to show
  22      * @param $dying is true by default and will launch a terminal die command
  23      * @param $log is trru by default and will emit a PHP WARNING if set to true
  24      * if not set to false.
  25      */
  26  	function galaxia_show_error($msg, $dying = true, $log=true)
  27      {
  28          $final_message = htmlspecialchars("Galaxia Workflow Error: $msg");
  29          if ($log)
  30          {
  31              trigger_error($final_message, E_USER_WARNING);
  32          }
  33          if ($dying)
  34          {
  35              die($final_message);
  36          }
  37          else
  38          {
  39              echo("<br>$final_message");
  40          }
  41      }
  42  }
  43  
  44  
  45  // filesystem Operations
  46  $GLOBALS['egw']->vfs = createobject('phpgwapi.vfs');
  47  
  48  // check if basedir exists
  49  $test=$GLOBALS['egw']->vfs->get_real_info(array('string' => '/', 'relatives' => array(RELATIVE_NONE), 'relative' => False));
  50  if($test[mime_type]!='Directory')
  51  {
  52      galaxia_show_error(lang('Base directory does not exist, please ask adminstrator to check the global configuration'),false, true);
  53  }
  54  
  55  // check if /workflow  exists
  56  $test = @$GLOBALS['egw']->vfs->get_real_info(array('string' => '/workflow', 'relatives' => array(RELATIVE_NONE), 'relative' => False));
  57  if($test[mime_type]!='Directory')
  58  {
  59      // if not, create it
  60      $GLOBALS['egw']->vfs->override_acl = 1;
  61      $GLOBALS['egw']->vfs->mkdir(array(
  62          'string' => '/workflow',
  63          'relatives' => array(RELATIVE_NONE)
  64      ));
  65      $GLOBALS['egw']->vfs->override_acl = 0;
  66  
  67      // test one more time
  68      $test = $GLOBALS['egw']->vfs->get_real_info(array('string' => '/workflow', 'relatives' => array(RELATIVE_NONE), 'relative' => False));
  69      if($test[mime_type]!='Directory')
  70      {
  71          galaxia_show_error(lang('/workflow directory does not exist and could not be created, please ask adminstrator to check the global configuration'), false, true);
  72      }
  73  }
  74              
  75  // Directory where the Galaxia processes will be stored, e.g. /workflow on the vfs
  76  if (!defined('GALAXIA_PROCESSES'))
  77  {
  78          // Note: this directory must be writeable by the webserver !
  79          define('GALAXIA_PROCESSES', $GLOBALS['egw']->vfs->basedir.SEP.'workflow');
  80  }
  81  
  82  // Directory where a *copy* of the Galaxia activity templates will be stored, e.g. templates
  83  // Define as '' if you don't want to copy templates elsewhere
  84  if (!defined('GALAXIA_TEMPLATES')) {
  85          // Note: this directory must be writeable by the webserver !
  86          define('GALAXIA_TEMPLATES', '');
  87  }
  88  
  89  // Default header to be added to new activity templates
  90  if (!defined('GALAXIA_TEMPLATE_HEADER')) {
  91          define('GALAXIA_TEMPLATE_HEADER', '');
  92  }
  93  
  94  // File where the ProcessManager logs for Galaxia will be saved, e.g. lib/Galaxia/log/pm.log
  95  // Define as '' if you don't want to use logging
  96  if (!defined('GALAXIA_LOGFILE')) {
  97          // Note: this file must be writeable by the webserver !
  98          //define('GALAXIA_LOGFILE', GALAXIA_LIBRARY . '/log/pm.log');
  99          define('GALAXIA_LOGFILE',  $GLOBALS['egw']->vfs->basedir.SEP.'workflow'.SEP.'galaxia.log');
 100  }
 101  
 102  // Directory containing the GraphViz 'dot' and 'neato' programs, in case
 103  // your webserver can't find them via its PATH environment variable
 104  if (!defined('GRAPHVIZ_BIN_DIR')) {
 105          define('GRAPHVIZ_BIN_DIR', '');
 106          //define('GRAPHVIZ_BIN_DIR', 'd:/wintools/ATT/GraphViz/bin');
 107  }
 108  
 109  // language function
 110  function tra($msg, $m1='', $m2='', $m3='', $m4='')
 111  {
 112      return lang($msg, $m1, $m2, $m3, $m4);
 113  }
 114  
 115  
 116  //define the list of agents avaible with your Galaxia installation
 117  if (!function_exists('galaxia_get_agents_list'))
 118  {
 119      /**
 120       * * This function list the agents avaible with your galaxia installation. The name of an agent
 121       * * is his unique identifier, the priority is an execution order priority
 122      *  * @return an associative array of agents description, each row is an agent description
 123      *  * containing a 'wf_agent_type' key and a 'wf_agent_priority' key
 124       */
 125  	function galaxia_get_agents_list()
 126      {
 127          $res = array(
 128              array(
 129                  'wf_agent_type' => 'mail_smtp', 
 130                  'wf_agent_priority' => 1,
 131              )
 132          );
 133          return  $res;
 134      }
 135  }
 136  
 137  
 138  
 139  if (!function_exists('galaxia_user_can_admin_process'))
 140  {
 141      //! Specify if the user has special admin rights on processes
 142      /**
 143      *  * @return true if the actual user has access to the processes administration. 
 144      *  * ie. he can edit/activate/deactivate/create/destroy processes and activities
 145      *  * warning: dangerous rights, this user can do whatever PHP can do...
 146       */
 147  	function galaxia_user_can_admin_process()
 148      {
 149              return  (($GLOBALS['egw']->acl->check('run',1,'admin')) ||  ($GLOBALS['egw']->acl->check('admin_workflow',1,'workflow')));
 150      }
 151  }
 152  
 153  if (!function_exists('galaxia_user_can_admin_instance'))
 154  {
 155      //! Specify if the user has special admin rights on instances
 156      /**
 157      *  * @return true if the actual user has access to the instance administration
 158      *  * ie. he can edit and modify all properties, members, assigned users of an instance whatever the state of the instance is
 159      *  * warning: this is clearly an administrator right
 160       */
 161  	function galaxia_user_can_admin_instance()
 162      {
 163          return  (($GLOBALS['egw']->acl->check('run',1,'admin')) ||  ($GLOBALS['egw']->acl->check('admin_instance_workflow',1,'workflow')));
 164      }
 165  }
 166  
 167  
 168  if (!function_exists('galaxia_user_can_clean_instances'))
 169  {
 170      //! Specify if the user has special cleanup rights on ALL instances
 171      /**
 172      *  * @return true if the actual user is granted access to the 'clean instances' and 'clean all instances for a process' functions
 173      *  * warning: theses are dangerous functions!
 174       */
 175  	function galaxia_user_can_clean_instances()
 176      {
 177          return  (($GLOBALS['egw']->acl->check('run',1,'admin')) ||  ($GLOBALS['egw']->acl->check('cleanup_workflow',1,'workflow')));
 178      }
 179  }
 180  
 181  if (!function_exists('galaxia_user_can_clean_aborted_instances'))
 182  {
 183      //! Specify if the actual user has special cleanup rights on aborted instances
 184      /**
 185      *  * @return true if the user is granted access to the 'clean aborted instances' functions
 186       */
 187  	function galaxia_user_can_clean_aborted_instances()
 188      {
 189          return  ((!$GLOBALS['egw']->acl->check('run',1,'admin')) ||  (!$GLOBALS['egw']->acl->check('cleanup_aborted_workflow',1,'workflow')));
 190      }
 191  }
 192  
 193  if (!function_exists('galaxia_user_can_monitor'))
 194  {
 195      //! Specify if the user has special monitors rights
 196      /**
 197      *  * @return true if the actual user has access to the monitor screens (this is not sufficient for cleanup access)
 198       */
 199  	function galaxia_user_can_monitor()
 200      {
 201          return  (($GLOBALS['egw']->acl->check('run',1,'admin')) ||  ($GLOBALS['egw']->acl->check('monitor_workflow',1,'workflow')));
 202      }
 203  }
 204  
 205      if (!function_exists('galaxia_retrieve_user_groups')) 
 206      {
 207          /*!
 208          * Specify how to retrieve an array containing all groups id for a given user
 209          * if the user is in no group this function should return false
 210          * @param $user is the current user id
 211          * @return an arry of integers, the groups ids the user is member of, or false if the user is not
 212          * the member of any group
 213          */
 214  		function galaxia_retrieve_user_groups($user=0) 
 215          {
 216              $user_groups=Array();
 217              if (!($user == $GLOBALS['egw_info']['user']['account_id'])) 
 218              {
 219                  //we are asking groups membership for another user than the actually loaded in memory.
 220                  $other_account =& CreateObject('phpgwapi.accounts',$user,'u');
 221                  $memberships = $other_account->membership($user);
 222                  unset($other_account);
 223              }
 224              else
 225              {
 226                  // we are asking groups membership for the actual user
 227                  // in egroupware we retrieve the already loaded in memory group list.
 228                  $memberships = $GLOBALS['egw']->accounts->membership();
 229              }
 230              foreach((array)$memberships as $key => $value)
 231              {
 232                  if (!( (is_null($value)) || ($value=='') )) $user_groups[]=($value['account_id']);
 233              }
 234              if (empty($user_groups)) return false;
 235              return $user_groups;
 236          }
 237      }
 238  
 239  
 240      if (!function_exists('galaxia_retrieve_group_users')) 
 241      {
 242          //! Specify how to retrieve an array containing all users id for a given group id
 243          /**
 244          *  * @param $group the group id
 245          *  * @param $add_names false by default, if true we add user names in the result
 246          *  * return an array with all users id or an associative array with names associated with ids if $add_names is true
 247           */
 248  		function galaxia_retrieve_group_users($group, $add_names=false) 
 249          {
 250              $members = $GLOBALS['egw']->accounts->member($group);
 251              foreach((array)$members as $key => $value)
 252              {
 253                  if ($add_names)
 254                  {
 255                      $group_users[$value['account_id']] = $value['account_name'];
 256                  }
 257                  else
 258                  {
 259                      $group_users[]=($value['account_id']);
 260                  }
 261              }
 262              
 263              return $group_users;
 264          }
 265      }
 266      
 267      if (!function_exists('galaxia_retrieve_running_user'))
 268  {
 269      //! returns the actual user running this PHP code
 270      /**
 271      *  * @return the user id of the actual running user. 
 272       */
 273  	function galaxia_retrieve_running_user()
 274      {
 275              return ($GLOBALS['egw_info']['user']['account_id']);
 276      }
 277  }
 278  
 279  
 280      if (!function_exists('galaxia_retrieve_name')) 
 281      {
 282          //! Specify how to retrieve the name of an user with is Id
 283          /**
 284          *  * @param $user the user or group id
 285          *  * return the name of the user
 286           */
 287  		function galaxia_retrieve_name($user) 
 288          {
 289              $username = $GLOBALS['egw']->accounts->id2name($user);
 290              return $username;
 291          }
 292      }
 293       
 294  // Specify how to execute a non-interactive activity (for use in src/API/Instance.php)
 295  if (!function_exists('galaxia_execute_activity')) {
 296          /**
 297           * * This function will execute automatic (non-interactive) activities for the engine
 298          *  * @param $activityId (default 0) is the activity_id it should run
 299          *  * @param $iid (default 0) is the instance id it should run for
 300          *  * @param $auto is true by default
 301          *  * @return AN ARRAY, or at least true or false. This array can contain :
 302          *    * a key 'failure' with an error string the engine will retrieve in instance error messages in case of
 303          *    failure (this will mark your execution as Bad), 
 304          *    * a key 'debug' with a debug string the engine will retrieve in instance error messages,
 305           */
 306  		function galaxia_execute_activity($activityId = 0, $iid = 0, $auto = 1)
 307          {
 308              // This way we create a new run_activity instance for the next activity
 309              $run_activity =& CreateObject('workflow.run_activity.go');
 310              $data = $run_activity->go($activityId, $iid, $auto);
 311              return $data;
 312          }
 313  }
 314  
 315  /*
 316      Specify how to obtain stored config values
 317      Parameter: an array containing pairs of (variables_names => default values)
 318      For an unknown variable name it will return default_value and this
 319      default value will be the NEW STORED value. If no default value is
 320      given we assume it's a false.
 321      WARNING: you should cast your result if you bet its' an integer
 322      as it is maybe stored as a string. But 1 and 0 special values are
 323      handled correctly as ints (bools).
 324  */
 325  if (!function_exists('galaxia_get_config_values')) 
 326  {
 327  	function galaxia_get_config_values($parameters=array())
 328      {
 329              $config =& CreateObject('phpgwapi.config');
 330              $config->read_repository();
 331  
 332              $result_array = array();
 333              foreach ($parameters as $config_var => $default_value)
 334              {
 335                  $config_value = $config->config_data[$config_var];
 336                  if(isset($config_value))
 337                  { //we add something in the config store, we take it
 338                      if ($config_value=='False')
 339                      {
 340                          $result_array[$config_var]=0;
 341                      }
 342                      elseif ($config_value=='True')
 343                      {
 344                          $result_array[$config_var]=1;
 345                      }
 346                      else
 347                      {
 348                          $result_array[$config_var] = $config_value;
 349                      }
 350                  }
 351                  else
 352                  {
 353                      //we had no value stored yet, so we store it now
 354          //boolean warning: egw'config class is not storing false values if it is 0
 355                      //we have to map theses int...
 356                      $stored_value= (string)$default_value;
 357                      if ($stored_value=='1')
 358                      {
 359                          $stored_value='True';
 360                      }
 361                      elseif ($stored_value=='0')
 362                      {
 363                          $stored_value='False';
 364                      }
 365  
 366                      $config->value($config_var,$stored_value);
 367                      $config->save_repository();
 368                      // take the not casted variable
 369                      $result_array[$config_var] = $default_value;
 370                  }
 371              }
 372              unset($config);
 373              return $result_array;
 374      }
 375  }
 376  
 377  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7