[ 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/src/common/ -> WfRuntime.php (source)

   1  <?php
   2  require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'Base.php');
   3  
   4  //!! WfRuntime
   5  //! A class to handle instances at runtime
   6  /*!
   7  * This class can be viewed by the user like an Instance, it is in fact more than an instance
   8  * as it handle concurrency and part of the core execution of the instance while avoiding
   9  * bad manipulation of the instance
  10  */
  11  class WfRuntime extends Base 
  12  {
  13    
  14    // processes config values cached for this object life duration
  15    // init is done at first use for the only process associated with this runtime object
  16    var $conf= Array();
  17    
  18    //instance and activity are the two most important object of the runtime
  19    var $activity = null;
  20    var $instance = null;
  21    var $instance_id = 0;
  22    var $activity_id = 0;
  23    //process object is used, for example, to retrieve the compiled code
  24    var $process = null;
  25    //workitems is a reference to $instance->workitems
  26    var $workitems = null;
  27    //activities is a reference to $instance->activities
  28    var $activities = null;
  29    //security Object
  30    var $security = null;
  31    //boolean, wether or not we are in a transaction
  32    var $transaction_in_progress = false; 
  33    //boolean, wether or not we are in debug mode 
  34    var $debug=false;
  35    //boolean, wether or not we are in automotic mode (i.e.: non-interactive), big impact on error handling
  36    var $auto_mode=false;
  37    
  38    /*!
  39    * @public
  40    * Constructor takes a PEAR::Db object
  41    */
  42    function WfRuntime(&$db) 
  43    {
  44      $this->child_name = 'WfRuntime';
  45      parent::Base($db);
  46      require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php');
  47      require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php');
  48      require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php');
  49      require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php');
  50      
  51      //first the activity is not set
  52      $this->activity = null;
  53      $this->instance =& new Instance($this->db);
  54      $this->process =& new Process($this->db);
  55      $this->security =& new WfSecurity($this->db); 
  56    }
  57  
  58    /*!
  59    * @private
  60    * Collect errors from all linked objects which could have been used by this object
  61    * Each child class should instantiate this function with her linked objetcs, calling get_error(true)
  62    * for example if you had a $this->process_manager created in the constructor you shoudl call
  63    * $this->error[] = $this->process_manager->get_error(false, $debug);
  64    * @param $debug is false by default, if true debug messages can be added to 'normal' messages
  65    * @param $prefix is a string appended to the debug message
  66    */
  67    function collect_errors($debug=false, $prefix = '')
  68    {
  69      parent::collect_errors($debug, $prefix);
  70      if (isset($this->instance) && !!($this->instance)) $this->error[] = $this->instance->get_error(false, $debug, $prefix);
  71      if (isset($this->process) && !!($this->process)) $this->error[] = $this->process->get_error(false, $debug, $prefix);
  72      if (isset($this->security) && !!($this->security)) $this->error[] = $this->security->get_error(false, $debug, $prefix);
  73      if (isset($this->activity) && !!($this->activity)) $this->error[] = $this->activity->get_error(false, $debug, $prefix);
  74    }
  75  
  76    /*!
  77    * @public
  78    * Call this function to end-up dying and giving a last message
  79    * @param $last_message is your last sentence
  80    * @param $include_errors is a false boolean by default, if true we'll include error messages
  81    * @param $debug is false by default, if true you will obtain more messages, if false you could obtain theses
  82    * @param $dying true by default, tells the engine to die or not
  83    * messages as well if this object has been placed in debug mode with setDebug(true)
  84    * recorded by this runtme object.
  85    * @return nothing, it die!
  86    */
  87    function fail($last_message, $include_errors = false, $debug=false, $dying=true)
  88    {
  89      $the_end = '';
  90      //see if local objects have been set to enforce it
  91      if ($this->debug) $debug = true;
  92      if ($this->auto_mode) $dying = false;
  93      
  94      if ($include_errors)
  95      {
  96        $the_end = $this->get_error(false, $debug).'<br />';
  97      }
  98      $the_end .= $last_message;
  99      if ($this->transaction_in_progress)
 100      {
 101        //we had a transaction actually, we mark a fail, this will force Rollback
 102        $this->db->FailTrans();
 103        $this->db->CompleteTrans();
 104      }
 105      if ($dying)
 106      {
 107        //this will make the session die
 108        galaxia_show_error($the_end, $dying);
 109      }
 110      else
 111      {
 112        //this will NOT BREAK the session!
 113        return $the_end;
 114      }
 115    }
 116  
 117    /*! 
 118    * @private
 119    * load the config values for the process associated with the runtime
 120    * config values are cached while this WfRuntime object stays alive
 121    * @param $arrayconf is a config array with default value i.e.:
 122    *    * key is the config option name
 123    *    * value is the config default value
 124    * @return a config array with values associated with the current process
 125    * for the asked config options and as well for som WfRuntime internal
 126    * config options
 127    */
 128    function &getConfigValues(&$arrayconf)
 129    {
 130      if (!(isset($this->process)))
 131      {
 132        $this->loadProcess();
 133      }
 134      $arrayconf['auto-release_on_leaving_activity'] = 1;  
 135      $this->conf =  $this->process->getConfigValues($arrayconf);
 136      return $this->conf;
 137    }
 138  
 139    /*!
 140    * @public
 141    * Load the instance, the activity and the process, allthings needed by the runtime engine
 142    * to  'execute' the activity
 143    * @param $activityId is the activity id, the activity we will run
 144    * @param $instanceId is the instance Id, can be empty for a start or standalone activity
 145    * @return true or false
 146    */
 147    function &LoadRuntime($activityId,$instanceId=0)
 148    {
 149      // load activity
 150      if (!($this->loadActivity($activityId, true, true)))
 151      {
 152        return false;
 153      }
 154      //interactive or non_interactive?
 155      $this->setAuto(!($this->activity->isInteractive()));
 156      //load instance
 157      if (!($this->loadInstance($instanceId)))
 158      {
 159        return false;
 160      }
 161      // load process
 162      if (!($this->loadProcess()))
 163      {
 164        return false;
 165      }
 166      
 167      //ensure the activity is not completed
 168      $this->instance->setActivityCompleted(false);
 169      
 170      //set the workitems and activities links
 171      $this->workitems =& $this->instance->workitems;
 172      $this->activities =& $this->instance->activities;
 173      return true;
 174    }
 175    
 176    /*!
 177    * @private
 178    * retrieve the process object associated with the activity
 179    * @param $pId is the process id of the process you want, if you do not give it we will try to
 180    * take it from the activity
 181    * @return a Process Object of the right type or false
 182    */
 183    function loadProcess($pId=0)
 184    {
 185      if ( (!(isset($this->process))) || ($this->process->getProcessId()==0))
 186      {
 187        if ( (empty($pId)) || (!($pId)) )
 188        {
 189          $pId = $this->activity->getProcessId();
 190          if ( (empty($pId)) || (!($pId)) )
 191          {
 192            //fail can return in auto mode or die
 193            $errors = $this->fail(tra('No Process indicated'),true, $this->debug, !($this->auto_mode));
 194            $this->error[] = $errors;
 195            return false;
 196          }
 197        }
 198        if ($this->debug) $this->error[] = 'loading process '.$pId;
 199        $this->process->getProcess($this->activity->getProcessId($pId));
 200      }
 201      return true;
 202    }
 203    
 204    function &getProcess()
 205    {
 206      return $this->process;
 207    }
 208    /*!
 209    * @private
 210    * retrieve the activity of the right type from a baseActivity Object
 211    * @param $activity_id is the activity_id you want
 212    * @param $with_roles will load the roles links on the object
 213    * @param $with_agents will load the agents links on the object
 214    * @return an Activity Object of the right type or false
 215    */
 216    function loadActivity($activity_id, $with_roles= true,$with_agents=false)
 217    {
 218      if ( (empty($activity_id)) || (!($activity_id)) )
 219      {
 220        //fail can return in auto mode or die
 221        $errors = $this->fail(tra('No activity indicated'),true, $this->debug, !($this->auto_mode));
 222        $this->error[] = $errors;
 223        return false;
 224      }
 225      $base_activity =& new BaseActivity($this->db);
 226      $this->activity =& $base_activity->getActivity($activity_id, $with_roles, $with_agents);
 227      if (!$this->activity)
 228      {
 229        $errors = $this->fail(tra('failed to load the activity'),true, $this->debug, !($this->auto_mode));
 230        $this->error[] = $errors;
 231        return false;
 232      }
 233      $this->activity_id = $activity_id;
 234      $this->error[] =  $base_activity->get_error();
 235      if ($this->debug) $this->error[] = 'loading activity '.$activity_id;
 236      return true;
 237    }
 238    
 239    function &getActivity()
 240    {
 241      return $this->activity;
 242    }
 243    
 244    /*!
 245    * @public
 246    * retrieve the instance which could be an empty object
 247    * @param $instanceId is the instance id
 248    * @return an Instance Object which can be empty or or string if something was turning bad
 249    */
 250    function loadInstance($instanceId)
 251    {
 252      $this->instance_id = $instanceId;
 253      $this->instance->getInstance($instanceId);
 254      if ( ($this->instance->getInstanceId()==0) 
 255        && (! (($this->activity->getType()=='standalone') || ($this->activity->getType()=='start') )) )
 256      {
 257        //fail can return in auto mode or die
 258        $errors = $this->fail(tra('no instance avaible'), true, $this->debug, !($this->auto_mode));
 259        $this->error[] = $errors;
 260        return false;
 261      }
 262      if ($this->debug) $this->error[] = 'loading instance '.$instanceId;
 263      return true;
 264    }
 265    
 266    /*!
 267    * @public
 268    * Perform necessary security checks at runtime before running an activity
 269    * This will as well lock the tables via the security object.
 270    * It should be launched in a transaction.
 271    * @return true if ok, false if the user has no runtime access
 272    * instance and activity are unsetted in case of false check
 273    */
 274    function checkUserRun()
 275    {
 276      if ($this->activity->getType()=='view')
 277      {
 278        //on view activities  the run action is a special action
 279        $action = 'viewrun';
 280      }
 281      else
 282      {
 283        $action = 'run';
 284      }
 285      //this will test the action rights and lock the necessary rows in tables in case of 'run'
 286      $result = $this->security->checkUserAction($this->activity_id,$this->instance_id,$action);
 287      $this->error[] =  $this->security->get_error(false, $this->debug);
 288      if ($result)
 289      {
 290        return true;
 291      }
 292      else
 293      {
 294        return false;
 295      }
 296    }
 297  
 298  
 299    /*!
 300    * @public
 301    * Perform necessary security checks at runtime
 302    * This will as well lock the tables via the security object.
 303    * It should be launched in a transaction.
 304    * @return true if ok, false if the user has no runtime access
 305    * instance and activity are unsetted in case of false check
 306    */
 307    function checkUserRelease()
 308    {
 309      //the first thing to scan if wether or not this process is configured for auto-release
 310      if ( (isset($this->conf['auto-release_on_leaving_activity'])) && ($this->conf['auto-release_on_leaving_activity']))
 311      {
 312        //this will test the release rights and lock the necessary rows in tables in case of 'release'
 313        $result = $this->security->checkUserAction($this->activity_id,$this->instance_id,'release');
 314        $this->error[] =  $this->security->get_error(false, $this->debug);
 315        if ($result)
 316        {
 317          //we are granted an access to release but there is a special bad case where
 318          //we are a user authorized at releasing instances owned by others and where
 319          //this instance is owned by another (for some quite complex reasons). 
 320          //we should not release this new user!!
 321          //Then this is auto-release, not a conscious act and so we will release only 
 322          //if we can still grab this instance (avoiding the bad case)
 323          
 324          //test grab before release
 325          if ($this->checkUserRun())
 326          {
 327            return true;
 328          }
 329        }
 330      }
 331      return false;
 332    }
 333    
 334    /*!
 335    * This will set/unset the WfRuntime in debug mode
 336    * @debug_mode is true by default, set it to false to disable debug mode
 337    */
 338    function setDebug($debug_mode=true)
 339    {
 340      $this->debug = $debug_mode;
 341    }
 342    
 343    /*!
 344    * This will set/unset the WfRuntime in automatic mode. i.e : executing
 345    * non-interactive or interactive activities. Automatic mode have big impacts
 346    * on error handling and on the way activities are executed
 347    * @auto_mode is true by default, set it to false to disable automatic mode
 348    */
 349    function setAuto($auto_mode=true)
 350    {
 351      $this->auto_mode = $auto_mode;
 352    }
 353    
 354    /*!
 355    * This function will start a transaction, call it before setActivityUser()
 356    */
 357    function StartRun()
 358    {
 359      $this->transaction_in_progress =true;
 360      $this->db->StartTrans();
 361    }
 362    
 363    /*!
 364    * This function ends the transactions started in StartRun()
 365    */
 366    function EndStartRun()
 367    {
 368      if ($this->transaction_in_progress) 
 369      {
 370        $this->db->CompleteTrans();
 371        $this->transaction_in_progress =false;
 372      }
 373    }
 374    
 375    /*!
 376    * For interactive activities this function will set the current user on the instance-activities table. 
 377    * This will prevent having several user using the same activity on the same intsance at the same time
 378    * But if you want this function to behave well you should call it after a checkUserRun or a checkUserRelease
 379    * and inside a transaction. Theses others function will ensure the table will be locked and the user
 380    * is really granted the action
 381    * @param $grab is true by default, if false the user will be set to '*', releasing the instance-activity record
 382    */
 383    function setActivityUser($grab=true)
 384    {
 385      if(isset($GLOBALS['user']) && !empty($this->instance->instanceId) && !empty($this->activity_id)) 
 386      {
 387        if ($this->activity->isInteractive())
 388        {// activity is interactive and we want the form, we'll try to grab the ticket on this instance-activity (or release)
 389          if ($grab)
 390          {
 391            $new_user = $GLOBALS['user'];
 392          }
 393          else
 394          {
 395            $new_user= '*';
 396          }
 397          if (!$this->instance->setActivityUser($this->activity_id,$new_user))
 398          {
 399             //fail can return in auto mode or die
 400             $errors = $this->fail(lang("You do not have the right to run this activity anymore, maybe a concurrent access problem, refresh your datas.", true, $this->debug, !($this->auto_mode)));
 401             $this->error[] = $errors;
 402             return false;
 403          }
 404        }// if activity is not interactive there's no need to grab the token
 405      }
 406      else
 407      {
 408        //fail can return in auto mode or die
 409        $errors= $this->fail(lang("We cannot run this activity, maybe this instance or this activity do not exists anymore.", true, $this->debug, !($this->auto_mode)));
 410        $this->error[] = $errors;
 411        return false;
 412      }    
 413    }
 414    
 415    /*!
 416    * Try to give some usefull info about the current runtime
 417    * @return an associative arrays with keys/values which could be usefull
 418    */
 419    function &getRuntimeInfo()
 420    {
 421      $result = Array();
 422  //    _debug_array($this->instance);
 423      if (isset($this->instance))
 424      {
 425        $result['instance_name'] = $this->instance->getName();
 426        $result['instance_owner'] = $this->instance->getOwner();
 427      }
 428      if (isset($this->activity))
 429      {
 430        $result['activity_name'] = $this->activity->getName();
 431        $result['activity_id'] = $this->activity_id;
 432        $result['activity_type'] = $this->activity->getType();
 433      }
 434      return $result;
 435    }
 436  
 437    /*!
 438    * This part of the runtime will be runned just after the "require_once ($source);" which is the inclusion
 439    * of compiled php file. We are in fact after all the "user code" part. We should decide what to do next
 440    * @param $debug is false by default
 441    * @return an array which must be analysed byr the application run class. It contains 2 keys
 442    *    * 'action' : value is a string is the action the run class should do
 443    *        * 'return' should return the result we just returned (in auto mode, to propagate infos)
 444    *        * 'loop' should just loop on the form, i.e.: do nothing
 445    *        * 'leaving' should show a page for the user leaving the activity (Cancel or Close without completing)
 446    *        * 'completed' should show a page for the user having completed the activity
 447    *    * 'engine_info' : value is an array is an array containing a lot of infos about what was done by the engine
 448    *        especially when completing the instance or when executing an automatic activity
 449    */
 450    function handle_postUserCode($debug=false)
 451    {
 452      $result = Array();
 453      
 454       // re-retrieve instance id which could have been modified by a complete
 455       $this->instance_id    = $this->instance->getInstanceId();
 456       
 457       //synchronised instance object with the database
 458       $this->instance->sync();
 459  
 460      // for interactive activities in non-auto mode:
 461      if (!($this->auto_mode) && $this->activity->isInteractive())
 462      {
 463        if ($this->instance->getActivityCompleted())
 464        {
 465          // activity is interactive and completed, 
 466          // we have to continue the workflow
 467          // and send any autorouted activity which could be after this one
 468          // this is not done in the $instance->complete() to let
 469          // xxx_pos.php code be executed before sending the instance
 470  
 471          $result['engine_info'] =& $this->instance->sendAutorouted($this->activity_id);
 472  
 473          // application should display completed page
 474          $result['action']='completed';
 475          return $result;
 476        }
 477        // it hasn't been completed
 478        else
 479        {
 480          if ($GLOBALS['workflow']['__leave_activity'])
 481          {
 482            // activity is interactive and the activity source set the 
 483            // $GLOBALS[workflow][__leave_activity] it's a 'cancel' mode.
 484            // we redirect the user to the leave activity page
 485            $result['action']='leaving';
 486            return $result;
 487          }
 488          else
 489          { 
 490            //the activity is not completed and the user doesn't want to leave
 491            // we loop on the form
 492            $result['action']='loop';
 493            return $result;
 494          }
 495        }
 496      }
 497      else
 498      { 
 499        // in auto mode or with non interactive activities we return engine info
 500        // and we collect our errors, we do not let them for other objects
 501        $this->collect_errors($debug);
 502        $result['engine_info']['debug'] = implode('<br />',array_filter($this->error));
 503        $result['engine_info']['info'] =& $this->getRuntimeInfo();
 504        $result['action'] = 'return';
 505        return $result;
 506      }
 507    }
 508  
 509    /*!
 510    * @public
 511    * Gets the the 'Activity Completed' status 
 512    */
 513    function getActivityCompleted()
 514    {
 515      return $this->instance->getActivityCompleted();
 516    }
 517  
 518    
 519    //----------- Instance public function mapping -------------------------------------------
 520    
 521    /*! 
 522    * Sets the next activity to be executed, if the current activity is
 523    * a switch activity the complete() method will use the activity setted
 524    * in this method as the next activity for the instance. 
 525    * Note that this method receives an activity name as argument (Not an Id)
 526    * and that it does not need the activityId like the instance method
 527    * @param $actname : name of the next activity
 528    */
 529    function setNextActivity($actname) 
 530    {
 531      return $this->instance->setNextActivity($this->activity_id,$actname);
 532    }
 533  
 534    /*!
 535    * This method can be used to set the user that must perform the next 
 536    * activity of the process. this effectively "assigns" the instance to
 537    * some user.
 538    * @param $user is the next user id
 539    */
 540    function setNextUser($user) 
 541    {
 542      return $this->instance->setNextUser($user);
 543    }
 544  
 545    /*!
 546    * This method can be used to get the user that must perform the next 
 547    * activity of the process. This can be empty if no setNextUser() was done before.
 548    * It wont return the default user but only the user which was assigned by a setNextUser.
 549    */
 550    function getNextUser() 
 551    {
 552      return $this->instance->getNextUser();
 553    }
 554   
 555    /*!
 556    * Sets the name of this instance.
 557    * @param $value is the new name of the instance
 558    */
 559    function setName($value) 
 560    {
 561      return $this->instance->setName($value);
 562    }
 563  
 564    /*!
 565    * Get the name of this instance.
 566    */
 567    function getName() {
 568      return $this->instance->getName();
 569    }
 570  
 571    /*!
 572    * Sets the category of this instance.
 573    */
 574    function setCategory($value) 
 575    {
 576      return $this->instance->setcategory($value);
 577    }
 578  
 579    /*!
 580    * Get the category of this instance.
 581    */
 582    function getCategory() 
 583    {
 584      return $this->instance->getCategory();
 585    }
 586    
 587    /*! 
 588    * Sets a property in this instance. This method is used in activities to
 589    * set instance properties.
 590    * all property names are normalized for security reasons and to avoid localisation
 591    * problems (A->z, digits and _ for spaces). If you have several set to call look
 592    * at the setProperties function. Each call to this function has an impact on database
 593    * @param $name is the property name (it will be normalized)
 594    * @value is the value you want for this property
 595    * @return true if it was ok
 596    */
 597    function set($name,$value) 
 598    {
 599      return $this->instance->set($name,$value);
 600    }
 601    
 602    /*!
 603    * Sets several properties in this instance. This method is used in activities to
 604    * set instance properties. Use this method if you have several properties to set
 605    * as it will avoid
 606    * all property names are normalized for security reasons and to avoid localisation
 607    * problems (A->z, digits and _ for spaces). If you have several set to call look
 608    * at the setProperties function. Each call to this function has an impact on database
 609    * @param $properties_array is an associative array containing for each record the
 610    * property name as the key and the property value as the value. You do not need the complete
 611    * porperty array, you can give only the knew or updated properties.
 612    * @return true if it was ok
 613    */
 614    function setProperties($properties_array)
 615    {
 616       return $this->instance->setProperties($properties_array);
 617    }
 618  
 619    
 620    /*! 
 621    * Gets the value of an instance property.
 622    * @param $name is the name of the instance
 623    * @return false if the property was not found, but an error message is stored
 624    * in the instance object
 625    */
 626    function get($name) 
 627    {
 628      return $this->instance->get($name);
 629    }
 630    
 631    /*! 
 632    * Returns an array of assocs describing the activities where the instance
 633    * is present, can be more than one activity if the instance was "splitted"
 634    */
 635    function getActivities() 
 636    {
 637      return $this->instance->getActivities();
 638    }
 639    
 640    /*! 
 641    * Gets the instance status can be
 642    * 'completed', 'active', 'aborted' or 'exception'
 643    */
 644    function getStatus() 
 645    {
 646      return $this->instance->getStatus();
 647    }
 648    
 649    /*! 
 650    * Sets the instance status , the value can be:
 651    * @param $status is the status you want, it can be:
 652    * 'completed', 'active', 'aborted' or 'exception'
 653    * @return true or false
 654    */
 655    function setStatus($status) 
 656    {
 657      return $this->instance->setStatus($status);
 658    }
 659    
 660    /*!
 661    * Gets the instance priority, it's an integer
 662    */
 663    function getPriority()
 664    {
 665      return $this->instance->getPriority();
 666    } 
 667  
 668    /*!
 669    * Sets the instance priority,
 670    * @param $priority should be an integer
 671    */
 672    function setPriority($priority)
 673    {
 674      return $this->instance->setPriority($priority);
 675    }
 676     
 677    /*!
 678    * Returns the instanceId
 679    */
 680    function getInstanceId() 
 681    {
 682      return $this->instance->getInstanceId();
 683    }
 684    
 685    /*! 
 686    Returns the processId for this instance
 687    */
 688    function getProcessId() {
 689      return $this->instance->getProcessId();
 690    }
 691    
 692    /*! 
 693    * Returns the owner of the instance
 694    */
 695    function getOwner() 
 696    {
 697      return $this->instance->getOwner();
 698    }
 699    
 700    /*! 
 701    * Sets the instance owner
 702    * @user is the user id of the owner
 703    */
 704    function setOwner($user) 
 705    {
 706      return $this->instance->setOwner($user);
 707    }
 708    
 709    /*!
 710    * Returns the user that must execute or is already executing an activity
 711    * where the instance is present.
 712    * @param $activityId is the activity id
 713    * @return false if the activity was not found for the instance, else return the user id
 714    * or '*' if no user is defined yet.
 715    */  
 716    function getActivityUser($activityId) 
 717    {
 718      return $this->instance->getActivityUser($activityId);
 719    }
 720    
 721    /*!
 722    * Sets the status of the instance in some activity
 723    * @param $activityId is the activity id
 724    * @param $status is the new status, it can be 'running' or 'completed'
 725    * @return false if no activity was found for the instance
 726    */  
 727    function setActivityStatus($activityId,$status) 
 728    {
 729      return $this->instance->setActivityStatus($activityId,$status);
 730    }
 731    
 732    
 733    /*!
 734    * Gets the status of the instance in some activity, can be
 735    * 'running' or 'completed'
 736    * @param $activityId is the activity id
 737    */
 738    function getActivityStatus($activityId) 
 739    {
 740      return $this->instance->getActivityStatus($activityId);
 741    }
 742    
 743    /*!
 744    * Resets the start time of the activity indicated to the current time.
 745    * @param $activityId is the activity id
 746    */
 747    function setActivityStarted($activityId) 
 748    {
 749      return $this->instance->setActivityStarted($activityId);
 750    }
 751    
 752    /*!
 753    * Gets the Unix timstamp of the starting time for the given activity.
 754    * @param $activityId is the activity id
 755    */
 756    function getActivityStarted($activityId) 
 757    {
 758      return $this->instance->getActivityStarted($activityId);
 759    }
 760    
 761    /*!
 762    * Gets the time where the instance was started 
 763    * @return a Unix timestamp
 764    */
 765    function getStarted() 
 766    {
 767      return $this->instance->getStarted();
 768    }
 769    
 770    /*!
 771    * Gets the end time of the instance (when the process was completed)
 772    */
 773    function getEnded() 
 774    {
 775      return $this->instance->getEnded();
 776    }
 777    
 778    
 779    //! Completes an activity
 780    /*!
 781    * YOU MUST NOT CALL complete() for non-interactive activities since
 782    * the engine does automatically complete automatic activities after
 783    * executing them.
 784    * @return true or false, if false it means the complete was not done for some internal reason
 785    * consult get_error() for more informations
 786    */
 787    function complete() 
 788    {
 789      if (!($this->activity->isInteractive()))
 790      {
 791        $this->error[] = tra('interactive activities should not call the complete() method');
 792        return false;
 793      }
 794      
 795      return $this->instance->complete($this->activity_id);
 796    }
 797  
 798    /*!
 799    * Aborts an activity and terminates the whole instance. We still create a workitem to keep track
 800    * of where in the process the instance was aborted
 801    */
 802    function abort() 
 803    {
 804      return $this->instance->abort();
 805    }
 806    
 807    /*! 
 808    * Gets a comment for this instance 
 809    * @param $cId is the comment id
 810    */
 811    function get_instance_comment($cId) 
 812    {
 813      return $this->instance->get_instance_comment($cId);
 814    }
 815    
 816    /*! 
 817    * Inserts or updates an instance comment
 818    */
 819    function replace_instance_comment($cId, $activityId, $activity, $user, $title, $comment) 
 820    {
 821      return $this->instance->replace_instance_comment($cId, $activityId, $activity, $user, $title, $comment);
 822    }
 823    
 824    /*!
 825    * Removes an instance comment
 826    * @param $cId is the comment id
 827    */
 828    function remove_instance_comment($cId) 
 829    {
 830      return $this->instance->remove_instance_comment($cId);
 831    }
 832   
 833    /*!
 834    * Lists instance comments
 835    */
 836    function get_instance_comments() 
 837    {
 838      return $this->instance->get_instance_comments();
 839    }
 840  }
 841  
 842  
 843  ?>


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