Changeset 16816
- Timestamp:
- 03/31/09 17:46:13 (4 years ago)
- Files:
-
- plugins/sfEzcWorkflowPlugin/trunk/lib/sfEzcWorkflowManager.class.php (modified) (7 diffs)
- plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/config/generator.yml (modified) (1 diff)
- plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/lib/PluginsfEzcWorkflowExecutionAdminActions.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfEzcWorkflowPlugin/trunk/lib/sfEzcWorkflowManager.class.php
r16637 r16816 13 13 class sfEzcWorkflowManager 14 14 { 15 const ANY_SF_NODE = 1; 16 const ANY_INPUT_NODE = 2; 17 const ANY_NODE = 3; 18 15 19 /** 16 20 * This action resume a sfPropelEzcWorkflowExecution suspended when a … … 27 31 { 28 32 $execution = new sfPropelEzcWorkflowExecution($execution_id); 29 self::validateWorkflowResumeRequest($execution, $variables, $action );33 self::validateWorkflowResumeRequest($execution, $variables, $action,self::ANY_SF_NODE); 30 34 $execution->resume($variables); 31 35 if ($execution->isSuspended()) … … 44 48 * resuming the workflow instance 45 49 * @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) 46 51 * @exception sfEzcWorkflowManagerException 47 52 * @return true if the request is valid, false otherwise 48 53 */ 49 54 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 ) 51 56 { 52 57 $active_nodes = $execution->getActivatedNodes(); … … 57 62 foreach( $active_nodes as $node ) 58 63 { 59 $sfNodefound = self::isNodeExecutableByUser($node,$action->getUser() );64 $sfNodefound = self::isNodeExecutableByUser($node,$action->getUser(),$type_nodes); 60 65 if ($sfNodefound) 61 66 { … … 70 75 * the corresponding action 71 76 * @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) 73 79 * @exception sfEzcWorkflowManagerException 74 80 */ 75 static public function doProcessRemainingNodes(ezcWorkflowExecution $execution, sfAction $action )81 static public function doProcessRemainingNodes(ezcWorkflowExecution $execution, sfAction $action, $type_nodes = self::ANY_SF_NODE ) 76 82 { 77 83 $waiting_for = $execution->getWaitingFor(); … … 84 90 foreach( $active_nodes as $node ) 85 91 { 86 if (!self::isNodeExecutableByUser($node,$action->getUser() ))92 if (!self::isNodeExecutableByUser($node,$action->getUser(),$type_nodes)) 87 93 { 88 94 continue; 89 95 } 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 } 91 104 } 92 105 }else{ … … 126 139 127 140 /** 128 * Validate if the user has rigths to execute the node141 * Validate if the user has rigths to execute 129 142 * @param ezcWorkflowNode $node Input node to check execution restrictions 130 143 * @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) 131 145 * @return boolean true if execution is granted, false otherwise 132 146 */ 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) 136 160 { 137 161 if ($node->isSecure()) plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/config/generator.yml
r16807 r16816 20 20 sfEzcWorkflow: {label: Workflow} 21 21 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 } 23 24 cancel: 24 25 label: Cancel plugins/sfEzcWorkflowPlugin/trunk/modules/sfEzcWorkflowExecutionAdmin/lib/PluginsfEzcWorkflowExecutionAdminActions.class.php
r13442 r16816 58 58 59 59 /** 60 * Validate an resume request and execute doResume 60 * Validate an resume request and execute doResume only InputFromSf node 61 61 */ 62 public function executeResume (sfWebRequest $request)62 public function executeResumeWeb(sfWebRequest $request) 63 63 { 64 64 $execution_id = $request->getParameter('id'); … … 69 69 $this->doResume($execution_id); 70 70 $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'); 71 96 }catch(Exception $e) 72 97 { … … 108 133 * Resume a workflow suspended by an ezcWorkflowNodeInputFromSf node 109 134 */ 110 public function doResume($execution_id )135 public function doResume($execution_id, $node_type = sfEzcWorkflowManager::ANY_SF_NODE) 111 136 { 112 137 $execution = sfEzcWorkflowManager::retrieveWorkflowExecutionById($execution_id); 113 sfEzcWorkflowManager::doProcessRemainingNodes($execution,$this );138 sfEzcWorkflowManager::doProcessRemainingNodes($execution,$this,$node_type); 114 139 } 115 140