Ignore:
Timestamp:
05/26/10 10:12:22 (14 years ago)
Author:
viani
Message:

Ticket #950 - Merged 2589:2838 /trunk/workflow/ em /sandbox/workflow/trunk/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/trunk/inc/engine/src/common/WfRuntime.php

    r2372 r2858  
    66 * as it handle concurrency and part of the core execution of the instance while avoiding 
    77 * bad manipulation of the instance 
    8  *  
     8 * 
    99 * @package Galaxia 
    10  * @license http://www.gnu.org/copyleft/gpl.html GPL  
     10 * @license http://www.gnu.org/copyleft/gpl.html GPL 
    1111 */ 
    12 class WfRuntime extends Base  
    13 {   
     12class WfRuntime extends Base 
     13{ 
    1414  /** 
    1515   * @var array processes config values cached for this object life duration, init is done at first use for the only process associated with this runtime object 
    1616   * @access public 
    1717   */ 
    18   var $conf= Array();   
     18  var $conf= Array(); 
    1919  /** 
    2020   * @var object $activity 
    21    * @access public  
     21   * @access public 
    2222   */ 
    2323  var $activity = null; 
    2424  /** 
    2525   * @var object $instance 
    26    * @access public  
     26   * @access public 
    2727   */ 
    2828  var $instance = null; 
    2929  /** 
    3030   * @var int $instance_id 
    31    * @access public  
    32    */ 
    33   var $instance_id = 0;   
     31   * @access public 
     32   */ 
     33  var $instance_id = 0; 
    3434  /** 
    3535   * @var int $activity_id 
    36    * @access public  
     36   * @access public 
    3737   */ 
    3838  var $activity_id = 0; 
    3939  /** 
    4040   * @var object $process Retrieve process information 
    41    * @access public  
     41   * @access public 
    4242   */ 
    4343  var $process = null; 
    4444  /** 
    4545   * @var object $workitems  Reference to $instance->workitems 
    46    * @access public  
     46   * @access public 
    4747   */ 
    4848  var $workitems = null; 
    4949  /** 
    5050   * @var object $activities Reference to $instance->activities 
    51    * @access public  
    52    */   
     51   * @access public 
     52   */ 
    5353  var $activities = null; 
    5454  /** 
    5555   * @var object $security Security object 
    56    * @access public  
    57    */   
     56   * @access public 
     57   */ 
    5858  var $security = null; 
    5959  /** 
    6060   * @var bool $transaction_in_progress Transaction state 
    61    * @access public  
    62    */   
    63   var $transaction_in_progress = false;  
     61   * @access public 
     62   */ 
     63  var $transaction_in_progress = false; 
    6464  /** 
    6565   * @var bool $debug Debug state 
    66    * @access public  
    67    */    
     66   * @access public 
     67   */ 
    6868  var $debug=false; 
    6969  /** 
    7070   * @var bool $auto_mode Automatic mode state, non-interactive for instance, big impact on error handling 
    71    * @access public  
    72    */   
     71   * @access public 
     72   */ 
    7373  var $auto_mode=false; 
    7474 
     
    8181  /** 
    8282   * Constructor 
    83    *  
     83   * 
    8484   * @param object &$db ADOdb 
    8585   * @return object WfRuntime instance 
    8686   * @access public 
    8787   */ 
    88   function WfRuntime()  
     88  function WfRuntime() 
    8989  { 
    9090    $this->child_name = 'WfRuntime'; 
     
    101101   * Collect errors from all linked objects which could have been used by this object 
    102102   * Each child class should instantiate this function with her linked objetcs, calling get_error(true) 
    103    *  
     103   * 
    104104   * @param bool $debug false by default, if true debug messages can be added to 'normal' messages 
    105105   * @param string $prefix appended to the debug message 
    106    * @return void  
     106   * @return void 
    107107   * @access private 
    108108   */ 
     
    118118  /** 
    119119   * Ends-up dying and giving a last message 
    120    *  
     120   * 
    121121   * @param string $last_message last sentence 
    122122   * @param bool $include_errors false by default, if true we'll include error messages 
     
    134134    if ($this->debug) $debug = true; 
    135135    if ($this->auto_mode) $dying = false; 
    136      
     136 
    137137    if ($include_errors) 
    138138    { 
     
    161161   * Loads the config values for the process associated with the runtime 
    162162   * config values are cached while this WfRuntime object stays alive 
    163    *  
     163   * 
    164164   * @param array $arrayconf Config array with default value, where key is config option name and value is default value 
    165    * @access private  
     165   * @access private 
    166166   * @return array Values associated with the current process for the asked config options and as well for som WfRuntime internal config options 
    167167   */ 
     
    172172      $this->loadProcess(); 
    173173    } 
    174     $arrayconf['auto-release_on_leaving_activity'] = 1;   
     174    $arrayconf['auto-release_on_leaving_activity'] = 1; 
    175175    $this->conf =  $this->process->getConfigValues($arrayconf); 
    176176    return $this->conf; 
     
    179179  /** 
    180180   * Loads instance, the activity and the process, needed by the runtime engine to 'execute' the activity 
    181    *  
     181   * 
    182182   * @param int $activityId activity id, the activity we will run 
    183183   * @param int $instanceId instance Id, can be empty for a start or standalone activity 
    184    * @return bool  
     184   * @return bool 
    185185   * @access public 
    186186   */ 
     
    204204      return false; 
    205205    } 
    206      
     206 
    207207    //ensure the activity is not completed 
    208208    $this->instance->setActivityCompleted(false); 
    209209        $this->instance->activityID = $activityId; 
    210      
     210 
    211211    //set the workitems and activities links 
    212212    $this->workitems =& $this->instance->workitems; 
     
    214214    return true; 
    215215  } 
    216    
     216 
    217217  /** 
    218218   * Retrieves the process object associated with the activity 
    219    *  
     219   * 
    220220   * @param int $pId Process id of the process you want, if you do not give it we will try to take it from the activity 
    221221   * @return mixed Process object of the right type or false 
     
    242242    return true; 
    243243  } 
    244    
     244 
    245245  /** 
    246246   * Gets current process instance 
    247    *  
     247   * 
    248248   * @return object Process instance 
    249249   * @access public 
     
    256256  /** 
    257257   * Retrieves the activity of the right type from a baseActivity Object 
    258    *  
     258   * 
    259259   * @param int $activity_id activity_id you want 
    260260   * @param bool $with_roles will load the roles links on the object 
     
    285285    return true; 
    286286  } 
    287    
     287 
    288288  /** 
    289289   * Gets current activity instance 
    290    *  
     290   * 
    291291   * @return object Activity instance 
    292292   * @access public 
    293    */   
     293   */ 
    294294  function &getActivity() 
    295295  { 
    296296    return $this->activity; 
    297297  } 
    298    
     298 
    299299  /** 
    300300   * Gets the instance which could be an empty object 
    301    *  
     301   * 
    302302   * @param int $instanceId is the instance id 
    303303   * @return mixed Instance object which can be empty or string if something was turning bad 
     
    308308    $this->instance_id = $instanceId; 
    309309    $this->instance->getInstance($instanceId); 
    310     if ( ($this->instance->getInstanceId()==0)  
     310    if ( ($this->instance->getInstanceId()==0) 
    311311      && (! (($this->activity->getType()=='standalone') || ($this->activity->getType()=='start') )) ) 
    312312    { 
     
    319319    return true; 
    320320  } 
    321    
     321 
    322322  /** 
    323323   * Perform necessary security checks at runtime before running an activity 
    324324   * This will as well lock the tables via the security object 
    325325   * It should be launched in a transaction 
    326    *  
     326   * 
    327327   * @return bool true if ok, false if the user has no runtime access 
    328328   * @access public 
     
    356356   * This will as well lock the tables via the security object 
    357357   * It should be launched in a transaction 
    358    *  
     358   * 
    359359   * @return bool true if ok, false if the user has no runtime access instance and activity are unsetted in case of false check 
    360360   * @access public 
     
    372372        //we are granted an access to release but there is a special bad case where 
    373373        //we are a user authorized at releasing instances owned by others and where 
    374         //this instance is owned by another (for some quite complex reasons).  
     374        //this instance is owned by another (for some quite complex reasons). 
    375375        //we should not release this new user!! 
    376         //Then this is auto-release, not a conscious act and so we will release only  
     376        //Then this is auto-release, not a conscious act and so we will release only 
    377377        //if we can still grab this instance (avoiding the bad case) 
    378          
     378 
    379379        //test grab before release 
    380380        if ($this->checkUserRun()) 
     
    386386    return false; 
    387387  } 
    388    
     388 
    389389  /** 
    390390   * Sets/unsets the WfRuntime in debug mode 
    391    *  
     391   * 
    392392   * @param bool $debug_mode true by default, set it to false to disable debug mode 
    393393   * @access public 
    394    * @return void  
     394   * @return void 
    395395   */ 
    396396  function setDebug($debug_mode=true) 
     
    398398    $this->debug = $debug_mode; 
    399399  } 
    400    
     400 
    401401  /** 
    402402   * Sets/unsets the WfRuntime in automatic mode. i.e : executing 
    403403   * non-interactive or interactive activities. Automatic mode have big impacts 
    404404   * on error handling and on the way activities are executed 
    405    *  
     405   * 
    406406   * @param bool $auto_mode true by default, set it to false to disable automatic mode 
    407407   * @access public 
    408    * @return void  
     408   * @return void 
    409409   */ 
    410410  function setAuto($auto_mode=true) 
     
    412412    $this->auto_mode = $auto_mode; 
    413413  } 
    414    
     414 
    415415  /** 
    416416   * This function will start a transaction, call it before setActivityUser() 
    417    *  
    418    * @access public 
    419    * @return void  
     417   * 
     418   * @access public 
     419   * @return void 
    420420   */ 
    421421  function StartRun() 
     
    424424    $this->db->StartTrans(); 
    425425  } 
    426    
     426 
    427427  /** 
    428428   * This function ends the transactions started in StartRun() 
    429    *  
     429   * 
    430430   * @access public 
    431431   * @return void 
     
    433433  function EndStartRun() 
    434434  { 
    435     if ($this->transaction_in_progress)  
     435    if ($this->transaction_in_progress) 
    436436    { 
    437437      $this->db->CompleteTrans(); 
     
    439439    } 
    440440  } 
    441    
    442   /** 
    443    * For interactive activities this function will set the current user on the instance-activities table.  
     441 
     442  /** 
     443   * For interactive activities this function will set the current user on the instance-activities table. 
    444444   * This will prevent having several user using the same activity on the same intsance at the same time 
    445445   * But if you want this function to behave well you should call it after a checkUserRun or a checkUserRelease 
    446446   * and inside a transaction. Theses others function will ensure the table will be locked and the user 
    447447   * is really granted the action 
    448    *  
     448   * 
    449449   * @param bool $grab true by default, if false the user will be set to '*', releasing the instance-activity record 
    450450   * @access public 
    451    * @return bool  
     451   * @return bool 
    452452   */ 
    453453  function setActivityUser($grab=true) 
    454454  { 
    455     if(isset($GLOBALS['user']) && !empty($this->instance->instanceId) && !empty($this->activity_id))  
     455    if(isset($GLOBALS['user']) && !empty($this->instance->instanceId) && !empty($this->activity_id)) 
    456456    { 
    457457      if ($this->activity->isInteractive()) 
     
    480480      $this->error[] = $errors; 
    481481      return false; 
    482     }     
    483   } 
    484    
     482    } 
     483  } 
     484 
    485485  /** 
    486486   * Tries to give some usefull info about the current runtime 
    487    *  
     487   * 
    488488   * @return array associative arrays with keys/values which could be usefull 
    489489   * @access public 
     
    510510   * This part of the runtime will be runned just after the activity code inclusion. 
    511511   * We are in fact after all the "user code" part. We should decide what to do next 
    512    *  
     512   * 
    513513   * @param bool $debug false by default 
    514514   * @return array an array which must be analysed by the application run class. It contains 2 keys 
     
    525525  { 
    526526    $result = Array(); 
    527      
     527 
    528528     // re-retrieve instance id which could have been modified by a complete 
    529529     $this->instance_id = $this->instance->getInstanceId(); 
    530       
     530 
    531531     //synchronised instance object with the database 
    532532     $this->instance->sync(); 
     
    537537      if ($this->instance->getActivityCompleted()) 
    538538      { 
    539         // activity is interactive and completed,  
     539        // activity is interactive and completed, 
    540540        // we have to continue the workflow 
    541541        // and send any autorouted activity which could be after this one 
     
    554554        if ($GLOBALS['workflow']['__leave_activity']) 
    555555        { 
    556           // activity is interactive and the activity source set the  
     556          // activity is interactive and the activity source set the 
    557557          // $GLOBALS[workflow][__leave_activity] it's a 'cancel' mode. 
    558558          // we redirect the user to the leave activity page 
     
    561561        } 
    562562        else 
    563         {  
     563        { 
    564564          //the activity is not completed and the user doesn't want to leave 
    565565          // we loop on the form 
     
    570570    } 
    571571    else 
    572     {  
     572    { 
    573573      // in auto mode or with non interactive activities we return engine info 
    574574      // and we collect our errors, we do not let them for other objects 
     
    583583  /** 
    584584   * Gets the the 'Activity Completed' status 
    585    *  
    586    * @access public 
    587    * @return string  
     585   * 
     586   * @access public 
     587   * @return string 
    588588   */ 
    589589  function getActivityCompleted() 
     
    592592  } 
    593593 
    594    
     594 
    595595  //----------- Instance public function mapping ------------------------------------------- 
    596    
     596 
    597597  /** 
    598598   * Sets the next activity to be executed, if the current activity is 
    599599   * a switch activity the complete() method will use the activity setted 
    600    * in this method as the next activity for the instance.  
     600   * in this method as the next activity for the instance. 
    601601   * Note that this method receives an activity name as argument (Not an Id) 
    602602   * and that it does not need the activityId like the instance method 
    603    *  
     603   * 
    604604   * @param string $actname name of the next activity 
    605605   * @return bool 
    606606   * @access public 
    607607   */ 
    608   function setNextActivity($actname)  
     608  function setNextActivity($actname) 
    609609  { 
    610610    return $this->instance->setNextActivity($this->activity_id,$actname); 
     
    612612 
    613613  /** 
    614    * Sets the user that must perform the next  
     614   * Sets the user that must perform the next 
    615615   * activity of the process. this effectively "assigns" the instance to 
    616616   * some user 
    617    *  
     617   * 
    618618   * @param int $user the next user id 
    619619   * @param string $activityName The name of the activity that the user will be able to executed. '*' means the next activity. 
    620    * @return bool  
     620   * @return bool 
    621621   * @access public 
    622622   */ 
     
    631631 
    632632  /** 
    633    * Sets the user role that must perform the next  
     633   * Sets the user role that must perform the next 
    634634   * activity of the process. this effectively "assigns" the instance to 
    635635   * some user 
    636    *  
     636   * 
    637637   * @param string $roleName the next activity role 
    638638   * @param string $activityName The name of the activity that the role will be able to executed. '*' means the next activity. 
     
    655655 
    656656  /** 
    657    * Gets the user that must perform the next activity of the process.  
     657   * Gets the user that must perform the next activity of the process. 
    658658   * This can be empty if no setNextUser() was done before. 
    659659   * It wont return the default user but only the user which was assigned by a setNextUser 
    660    *  
    661    * @return int  
    662    * @access public 
    663    */ 
    664   function getNextUser()  
     660   * 
     661   * @return int 
     662   * @access public 
     663   */ 
     664  function getNextUser() 
    665665  { 
    666666    return $this->instance->getNextUser(); 
    667667  } 
    668   
     668 
    669669  /** 
    670670   * Sets the name of this instance. 
    671    *  
     671   * 
    672672   * @param string $value new name of the instance 
    673    * @return bool  
    674    * @access public 
    675    */ 
    676   function setName($value)  
     673   * @return bool 
     674   * @access public 
     675   */ 
     676  function setName($value) 
    677677  { 
    678678    return $this->instance->setName($value); 
     
    681681  /** 
    682682   * Gets the name of this instance 
    683    *  
    684    * @return string  
     683   * 
     684   * @return string 
    685685   * @access public 
    686686   */ 
     
    691691  /** 
    692692   * Sets the category of this instance 
    693    *  
     693   * 
    694694   * @param string $value 
    695695   * @return bool 
    696696   * @access public 
    697697   */ 
    698   function setCategory($value)  
     698  function setCategory($value) 
    699699  { 
    700700    return $this->instance->setcategory($value); 
     
    703703  /** 
    704704   * Gets category of this instance 
    705    *  
    706    * @return string  
    707    * @access public 
    708    */ 
    709   function getCategory()  
     705   * 
     706   * @return string 
     707   * @access public 
     708   */ 
     709  function getCategory() 
    710710  { 
    711711    return $this->instance->getCategory(); 
    712712  } 
    713    
     713 
    714714  /** 
    715715   * Sets a property in this instance. This method is used in activities to 
     
    718718   * problems (A->z, digits and _ for spaces). If you have several set to call look 
    719719   * at the setProperties function. Each call to this function has an impact on database 
    720    *  
     720   * 
    721721   * @param string $name property name (it will be normalized) 
    722722   * @param mixed $value value for this property 
    723    * @return bool  
    724    * @access public 
    725    */ 
    726   function set($name,$value)  
     723   * @return bool 
     724   * @access public 
     725   */ 
     726  function set($name,$value) 
    727727  { 
    728728    return $this->instance->set($name,$value); 
    729729  } 
    730    
     730 
    731731  /** 
    732732   * Unsets a property in this instance. This method is used in activities to 
     
    734734   * All property names are normalized for security reasons and to avoid localisation 
    735735   * problems (A->z, digits and _ for spaces). Each call to this function has an impact on database 
    736    *  
     736   * 
    737737   * @param string $name property name (it will be normalized) 
    738738   * @return bool true if it was ok 
    739739   * @access public 
    740740   */ 
    741   function clear($name)  
     741  function clear($name) 
    742742  { 
    743743    return $this->instance->clear($name); 
     
    749749   * All property names are normalized for security reasons and to avoid localisation 
    750750   * problems (A->z, digits and _ for spaces) 
    751    *  
     751   * 
    752752   * @param string $name property name (it will be normalized) 
    753753   * @return bool true if it exists and false otherwise 
     
    766766   * problems (A->z, digits and _ for spaces). If you have several set to call look 
    767767   * at the setProperties function. Each call to this function has an impact on database 
    768    *  
     768   * 
    769769   * @param array $properties_array associative array containing for each record the 
    770770   * property name as the key and the property value as the value. You do not need the complete 
     
    780780  /** 
    781781   * Gets the value of an instance property 
    782    *  
     782   * 
    783783   * @param string $name name of the instance 
    784784   * @param string $defaultValue 
     
    793793  /** 
    794794   * Describes the activities where the instance is present, can be more than one activity if the instance was "splitted" 
    795    *  
     795   * 
    796796   * @access public 
    797797   * @return array Vector of assocs 
    798798   */ 
    799   function getActivities()  
     799  function getActivities() 
    800800  { 
    801801    return $this->instance->getActivities(); 
    802802  } 
    803    
     803 
    804804  /** 
    805805   * Gets the instance status can be 'completed', 'active', 'aborted' or 'exception' 
    806    *  
     806   * 
    807807   * @access public 
    808808   * @return string Instance status 
    809809   */ 
    810   function getStatus()  
     810  function getStatus() 
    811811  { 
    812812    return $this->instance->getStatus(); 
    813813  } 
    814    
     814 
    815815  /** 
    816816   * Sets the instance status 
    817    *  
     817   * 
    818818   * @param $status Desired status, it can be: 'completed', 'active', 'aborted' or 'exception' 
    819819   * @return bool 
    820820   * @access public 
    821821   */ 
    822   function setStatus($status)  
     822  function setStatus($status) 
    823823  { 
    824824    return $this->instance->setStatus($status); 
    825825  } 
    826    
     826 
    827827  /** 
    828828   * Gets the instance priority 
    829    *  
    830    * @access public 
    831    * @return int  
     829   * 
     830   * @access public 
     831   * @return int 
    832832   */ 
    833833  function getPriority() 
    834834  { 
    835835    return $this->instance->getPriority(); 
    836   }  
     836  } 
    837837 
    838838  /** 
    839839   * Sets the instance priority 
    840    *  
     840   * 
    841841   * @param int $priority 
    842842   * @access public 
    843    * @return bool  
     843   * @return bool 
    844844   */ 
    845845  function setPriority($priority) 
     
    847847    return $this->instance->setPriority($priority); 
    848848  } 
    849     
     849 
    850850  /** 
    851851   * Returns the instance id 
    852    *  
    853    * @return int  
    854    * @access public 
    855    */ 
    856   function getInstanceId()  
     852   * 
     853   * @return int 
     854   * @access public 
     855   */ 
     856  function getInstanceId() 
    857857  { 
    858858    return $this->instance->getInstanceId(); 
    859859  } 
    860    
     860 
    861861  /** 
    862862   * Returns the process id for this instance 
    863    *  
    864    * @return int  
    865    * @access public  
     863   * 
     864   * @return int 
     865   * @access public 
    866866   */ 
    867867  function getProcessId() { 
    868868    return $this->instance->getProcessId(); 
    869869  } 
    870    
     870 
    871871  /** 
    872872   * Returns the owner of the instance 
    873    *  
    874    * @return string  
    875    * @access public 
    876    */ 
    877   function getOwner()  
     873   * 
     874   * @return string 
     875   * @access public 
     876   */ 
     877  function getOwner() 
    878878  { 
    879879    return $this->instance->getOwner(); 
    880880  } 
    881    
     881 
    882882  /** 
    883883   * Sets the instance owner 
    884    *  
    885    * @param string $user  
    886    * @access public 
    887    * @return bool   
    888    */ 
    889   function setOwner($user)  
     884   * 
     885   * @param string $user 
     886   * @access public 
     887   * @return bool 
     888   */ 
     889  function setOwner($user) 
    890890  { 
    891891    return $this->instance->setOwner($user); 
    892892  } 
    893    
     893 
    894894  /** 
    895895   * Returns the user that must execute or is already executing an activity where the instance is present 
    896    *  
     896   * 
    897897   * @param int $activityId 
    898898   * @return bool False if the activity was not found for the instance, else return the user id or '*' if no user is defined yet 
    899899   * @access public 
    900    */   
    901   function getActivityUser($activityId)  
     900   */ 
     901  function getActivityUser($activityId) 
    902902  { 
    903903    return $this->instance->getActivityUser($activityId); 
    904904  } 
    905    
     905 
    906906  /** 
    907907   * Sets the status of the instance in some activity 
    908    *  
     908   * 
    909909   * @param int $activityId Activity id 
    910910   * @param string $status New status, it can be 'running' or 'completed' 
    911911   * @return bool False if no activity was found for the instance 
    912912   * @access public 
    913    */   
    914   function setActivityStatus($activityId,$status)  
     913   */ 
     914  function setActivityStatus($activityId,$status) 
    915915  { 
    916916    return $this->instance->setActivityStatus($activityId,$status); 
    917917  } 
    918    
    919    
    920   /** 
    921    * Gets the status of the instance in some activity  
    922    *  
    923    * @param int $activityId  
     918 
     919 
     920  /** 
     921   * Gets the status of the instance in some activity 
     922   * 
     923   * @param int $activityId 
    924924   * @return string 'running' or 'completed' 
    925925   * @access public 
    926926   */ 
    927   function getActivityStatus($activityId)  
     927  function getActivityStatus($activityId) 
    928928  { 
    929929    return $this->instance->getActivityStatus($activityId); 
    930930  } 
    931    
     931 
    932932  /** 
    933933   * Resets the start time of the activity indicated to the current time 
    934    *  
     934   * 
    935935   * @param int $activityId 
    936    * @return bool  
    937    * @access public 
    938    */ 
    939   function setActivityStarted($activityId)  
     936   * @return bool 
     937   * @access public 
     938   */ 
     939  function setActivityStarted($activityId) 
    940940  { 
    941941    return $this->instance->setActivityStarted($activityId); 
    942942  } 
    943    
     943 
    944944  /** 
    945945   * Gets the Unix timstamp of the starting time for the given activity 
    946    *  
     946   * 
    947947   * @param int $activityId 
    948    * @return int  
    949    * @access public 
    950    */ 
    951   function getActivityStarted($activityId)  
     948   * @return int 
     949   * @access public 
     950   */ 
     951  function getActivityStarted($activityId) 
    952952  { 
    953953    return $this->instance->getActivityStarted($activityId); 
    954954  } 
    955    
     955 
    956956  /** 
    957957   * Gets the time where the instance was started 
    958    *  
    959    * @return int  
    960    * @access public 
    961    */ 
    962   function getStarted()  
     958   * 
     959   * @return int 
     960   * @access public 
     961   */ 
     962  function getStarted() 
    963963  { 
    964964    return $this->instance->getStarted(); 
    965965  } 
    966    
     966 
    967967  /** 
    968968   * Gets the end time of the instance (when the process was completed) 
    969    *  
    970    * @return int  
    971    * @access public  
    972    */ 
    973   function getEnded()  
     969   * 
     970   * @return int 
     971   * @access public 
     972   */ 
     973  function getEnded() 
    974974  { 
    975975    return $this->instance->getEnded(); 
    976976  } 
    977    
    978    
     977 
     978 
    979979  /** 
    980980   * Completes an activity. 
     
    982982   * the engine does automatically complete automatic activities after 
    983983   * executing them 
    984    *  
     984   * 
    985985   * @return bool True or false, if false it means the complete was not done for some internal reason 
    986986   * consult get_error() for more informations 
    987987   * @access public 
    988988   */ 
    989   function complete()  
     989  function complete() 
    990990  { 
    991991    if (!($this->activity->isInteractive())) 
     
    994994      return false; 
    995995    } 
    996      
     996 
    997997    return $this->instance->complete($this->activity_id); 
    998998  } 
     
    10011001   * Aborts an activity and terminates the whole instance. We still create a workitem to keep track 
    10021002   * of where in the process the instance was aborted 
    1003    *  
    1004    * @return bool  
    1005    * @access public 
    1006    */ 
    1007   function abort()  
     1003   * 
     1004   * @return bool 
     1005   * @access public 
     1006   */ 
     1007  function abort() 
    10081008  { 
    10091009    return $this->instance->abort(); 
    10101010  } 
    1011    
     1011 
    10121012  /** 
    10131013   * Gets a comment for this instance 
    1014    *  
     1014   * 
    10151015   * @param int $cId Comment id 
    1016    * @return string  
    1017    * @access public 
    1018    */ 
    1019   function get_instance_comment($cId)  
     1016   * @return string 
     1017   * @access public 
     1018   */ 
     1019  function get_instance_comment($cId) 
    10201020  { 
    10211021    return $this->instance->get_instance_comment($cId); 
    10221022  } 
    1023    
     1023 
    10241024  /** 
    10251025   * Inserts or updates an instance comment 
    1026    *  
     1026   * 
    10271027   * @param int $cId Commend id 
    1028    * @param int $activityId  
    1029    * @param object $activity  
     1028   * @param int $activityId 
     1029   * @param object $activity 
    10301030   * @param int $user User id 
    10311031   * @param string $title Comment's title 
    10321032   * @param string $comment Comment's contents 
    1033    * @return bool  
    1034    * @access public 
    1035    */ 
    1036   function replace_instance_comment($cId, $activityId, $activity, $user, $title, $comment)  
     1033   * @return bool 
     1034   * @access public 
     1035   */ 
     1036  function replace_instance_comment($cId, $activityId, $activity, $user, $title, $comment) 
    10371037  { 
    10381038    return $this->instance->replace_instance_comment($cId, $activityId, $activity, $user, $title, $comment); 
    10391039  } 
    1040    
     1040 
    10411041  /** 
    10421042   * Removes an instance comment 
    1043    *  
     1043   * 
    10441044   * @param int $cId Comment id 
    1045    * @return bool  
    1046    * @access public 
    1047    */ 
    1048   function remove_instance_comment($cId)  
     1045   * @return bool 
     1046   * @access public 
     1047   */ 
     1048  function remove_instance_comment($cId) 
    10491049  { 
    10501050    return $this->instance->remove_instance_comment($cId); 
    10511051  } 
    1052   
     1052 
    10531053  /** 
    10541054   * Lists instance comments 
    1055    *  
    1056    * @return array  
    1057    * @access public 
    1058    */ 
    1059   function get_instance_comments()  
     1055   * 
     1056   * @return array 
     1057   * @access public 
     1058   */ 
     1059  function get_instance_comments() 
    10601060  { 
    10611061    return $this->instance->get_instance_comments(); 
     
    10871087    $workflow = $GLOBALS['workflow']; 
    10881088    unset($_REQUEST['iid']); 
    1089     $run_activity = Factory::getInstance('run_activity'); 
     1089    $run_activity = Factory::newInstance('run_activity'); 
    10901090    $run_activity->runtime->instance->parentInstanceId = $this->instance_id; 
    10911091    $run_activity->runtime->instance->parentActivityId = $this->activity_id; 
Note: See TracChangeset for help on using the changeset viewer.