Development

Changeset 16816

You must first sign up to be able to contribute.

Changeset 16816

Show
Ignore:
Timestamp:
03/31/09 17:46:13 (4 years ago)
Author:
cinxgler
Message:

Allows to resume workflow suspended waiting for input or not.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfEzcWorkflowPlugin/trunk/lib/sfEzcWorkflowManager.class.php

    r16637 r16816  
    1313class sfEzcWorkflowManager 
    1414{ 
     15  const ANY_SF_NODE = 1; 
     16  const ANY_INPUT_NODE = 2; 
     17  const ANY_NODE = 3; 
     18 
    1519  /** 
    1620   * This action resume a sfPropelEzcWorkflowExecution suspended when a 
     
    2731  { 
    2832    $execution = new sfPropelEzcWorkflowExecution($execution_id); 
    29     self::validateWorkflowResumeRequest($execution, $variables, $action); 
     33    self::validateWorkflowResumeRequest($execution, $variables, $action,self::ANY_SF_NODE); 
    3034    $execution->resume($variables); 
    3135    if ($execution->isSuspended()) 
     
    4448   *                                        resuming the workflow instance 
    4549   * @param sfAction             $action Action which call this method 
     50   * @param integer              $type_nodes   says what nodes can be resumed (sf input, any input, any node) 
    4651   * @exception sfEzcWorkflowManagerException 
    4752   * @return true if the request is valid, false otherwise 
    4853   */ 
    4954   
    50   static public function validateWorkflowResumeRequest(ezcWorkflowExecution $execution, $variables,sfAction $action
     55  static public function validateWorkflowResumeRequest(ezcWorkflowExecution $execution, $variables,sfAction $action, $type_nodes = self::ANY_SF_NODE
    5156  { 
    5257    $active_nodes = $execution->getActivatedNodes(); 
     
    5762    foreach( $active_nodes as $node ) 
    5863    { 
    59       $sfNodefound = self::isNodeExecutableByUser($node,$action->getUser()); 
     64      $sfNodefound = self::isNodeExecutableByUser($node,$action->getUser(),$type_nodes); 
    6065      if ($sfNodefound) 
    6166      { 
     
    7075   * the corresponding action 
    7176   * @param ezcWorkflowExecution $execution 
    72    * @param sfAction             $action     Action which call this method 
     77   * @param sfAction             $action        Action which call this method 
     78   * @param integer              $type_nodes   says what nodes can be resumed (sf input, any input, any node) 
    7379   * @exception sfEzcWorkflowManagerException 
    7480   */ 
    75   static public function doProcessRemainingNodes(ezcWorkflowExecution $execution, sfAction $action
     81  static public function doProcessRemainingNodes(ezcWorkflowExecution $execution, sfAction $action, $type_nodes = self::ANY_SF_NODE
    7682  { 
    7783    $waiting_for = $execution->getWaitingFor(); 
     
    8490      foreach( $active_nodes as $node ) 
    8591      { 
    86         if (!self::isNodeExecutableByUser($node,$action->getUser())) 
     92        if (!self::isNodeExecutableByUser($node,$action->getUser(),$type_nodes)) 
    8793        { 
    8894          continue; 
    8995        } 
    90         $action->redirect($node->getActionUri().'?sf_ezc_wf_execution_id='.$execution->getId()); 
     96        if ($node instanceof ezcWorkflowNodeInputFromSf) 
     97        { 
     98          $action->redirect($node->getActionUri().'?sf_ezc_wf_execution_id='.$execution->getId()); 
     99        } 
     100        else 
     101        { 
     102          $execution->resume(); 
     103        } 
    91104      } 
    92105    }else{ 
     
    126139   
    127140  /** 
    128    * Validate if the user has rigths to execute the node 
     141   * Validate if the user has rigths to execute 
    129142   * @param ezcWorkflowNode $node Input node to check execution restrictions 
    130143   * @param sfUser               $user User who wants to execute the node 
     144   * @param integer              $type_nodes   says what nodes can be resumed (sf input, any input, any node) 
    131145   * @return boolean true if execution is granted, false otherwise 
    132146   */ 
    133   static public function isNodeExecutableByUser(ezcWorkflowNode $node, sfUser $user) 
    134   { 
    135     if ($node instanceof ezcWorkflowNodeInputFromSf) 
     147  static public function isNodeExecutableByUser(ezcWorkflowNode $node, sfUser $user, $type_nodes) 
     148  { 
     149    if (($type_nodes == self::ANY_NODE ) && $node instanceof ezcWorkflowNode) 
     150    { 
     151      return true; 
     152    } 
     153     
     154    if (($type_nodes == self::ANY_NODE || $type_nodes == self::ANY_INPUT_NODE) && $node instanceof ezcWorkflowNodeInput) 
     155    { 
     156      return true; 
     157    } 
     158 
     159    if (($type_nodes == self::ANY_NODE || $type_nodes == self::ANY_INPUT_NODE || $type_nodes == self::ANY_SF_NODE ) && $node instanceof ezcWorkflowNodeInputFromSf) 
    136160    { 
    137161      if ($node->isSecure()) 
  • plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/config/generator.yml

    r16807 r16816  
    2020          sfEzcWorkflow: {label: Workflow} 
    2121        object_actions: 
    22           resume:   { label: Resume, action: Resume } 
     22          resume_sf:   { label: Resume sf nodes, action: ResumeWeb } 
     23          resume_any:   { label: Resume any nodes, action: ResumeAny } 
    2324          cancel: 
    2425            label: Cancel 
  • plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/lib/PluginsfEzcWorkflowExecutionAdminActions.class.php

    r13442 r16816  
    5858   
    5959  /** 
    60    * Validate an resume request and execute doResume 
     60   * Validate an resume request and execute doResume only InputFromSf node 
    6161   */ 
    62   public function executeResume(sfWebRequest $request) 
     62  public function executeResumeWeb(sfWebRequest $request) 
    6363  { 
    6464    $execution_id = $request->getParameter('id'); 
     
    6969        $this->doResume($execution_id); 
    7070        $this->getUser()->setFlash('error', 'There isn\'t any ezcWorkflowNodeInputFromSf node waiting for being executed'); 
     71      }catch(Exception $e) 
     72      { 
     73        $this->getUser()->setFlash('error', 'The workflow could\'nt be resumed : '. get_class($e).': '.$e->getMessage()); 
     74      } 
     75    } 
     76    else 
     77    { 
     78      $this->getUser()->setFlash('error', 'The workflow instance is invalid.'); 
     79    } 
     80    $this->redirect('@sfEzcWorkflowExecutionAdmin'); 
     81  } 
     82 
     83 
     84  /** 
     85   * Validate an resume request and execute doResume any type of node 
     86   */ 
     87  public function executeResumeAny(sfWebRequest $request) 
     88  { 
     89    $execution_id = $request->getParameter('id'); 
     90    if ( $execution_id > 0) 
     91    { 
     92      try 
     93      { 
     94        $this->doResume($execution_id, sfEzcWorkflowManager::ANY_NODE); 
     95        $this->getUser()->setFlash('notice', 'Workflow resumed sucessfully'); 
    7196      }catch(Exception $e) 
    7297      { 
     
    108133   * Resume a workflow suspended by an ezcWorkflowNodeInputFromSf node 
    109134   */ 
    110   public function doResume($execution_id
     135  public function doResume($execution_id, $node_type = sfEzcWorkflowManager::ANY_SF_NODE
    111136  { 
    112137    $execution = sfEzcWorkflowManager::retrieveWorkflowExecutionById($execution_id); 
    113     sfEzcWorkflowManager::doProcessRemainingNodes($execution,$this); 
     138    sfEzcWorkflowManager::doProcessRemainingNodes($execution,$this,$node_type); 
    114139  } 
    115140