Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
64.85% |
238 / 367 |
|
41.10% |
30 / 73 |
CRAP | |
0.00% |
0 / 7 |
SeedDMS_Core_Workflow | |
80.82% |
118 / 146 |
|
36.84% |
7 / 19 |
78.12 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getID | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
getInitState | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setInitState | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
getTransitions | |
85.71% |
12 / 14 |
|
0.00% |
0 / 1 |
5.07 | |||
getStates | |
90.00% |
9 / 10 |
|
0.00% |
0 / 1 |
5.03 | |||
getTransition | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
getNextTransitions | |
84.62% |
11 / 13 |
|
0.00% |
0 / 1 |
5.09 | |||
getPreviousTransitions | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
4.01 | |||
getTransitionsByStates | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
4.01 | |||
removeTransition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addTransition | |
60.00% |
12 / 20 |
|
0.00% |
0 / 1 |
8.30 | |||
isUsed | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
penetrate | |
80.00% |
8 / 10 |
|
0.00% |
0 / 1 |
5.20 | |||
checkForCycles | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
remove | |
61.11% |
11 / 18 |
|
0.00% |
0 / 1 |
6.47 | |||
SeedDMS_Core_Workflow_State | |
68.66% |
46 / 67 |
|
50.00% |
7 / 14 |
44.24 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getID | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
getMaxTime | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setMaxTime | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getPreCondFunc | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPreCondFunc | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getDocumentStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDocumentStatus | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
isUsed | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
getTransitions | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
4.01 | |||
remove | |
70.00% |
7 / 10 |
|
0.00% |
0 / 1 |
3.24 | |||
SeedDMS_Core_Workflow_Action | |
60.00% |
24 / 40 |
|
50.00% |
4 / 8 |
32.38 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getID | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
isUsed | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
getTransitions | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
20 | |||
remove | |
70.00% |
7 / 10 |
|
0.00% |
0 / 1 |
3.24 | |||
SeedDMS_Core_Workflow_Transition | |
38.82% |
33 / 85 |
|
31.25% |
5 / 16 |
236.06 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getID | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getWorkflow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setWorkflow | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getState | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setState | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getNextState | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNextState | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setAction | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getMaxTime | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setMaxTime | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getUsers | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
5.01 | |||
getGroups | |
64.29% |
9 / 14 |
|
0.00% |
0 / 1 |
6.14 | |||
remove | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
SeedDMS_Core_Workflow_Transition_User | |
83.33% |
5 / 6 |
|
75.00% |
3 / 4 |
4.07 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTransition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
SeedDMS_Core_Workflow_Transition_Group | |
0.00% |
0 / 8 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
setDMS | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTransition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getGroup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getNumOfUsers | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
SeedDMS_Core_Workflow_Log | |
80.00% |
12 / 15 |
|
57.14% |
4 / 7 |
7.39 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
setDMS | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTransition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getWorkflow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getComment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Implementation of the workflow object in the document management system |
4 | * |
5 | * @category DMS |
6 | * @package SeedDMS_Core |
7 | * @license GPL 2 |
8 | * @version @version@ |
9 | * @author Uwe Steinmann <uwe@steinmann.cx> |
10 | * @copyright Copyright (C) 2012 Uwe Steinmann |
11 | * @version Release: @package_version@ |
12 | */ |
13 | |
14 | /** |
15 | * Class to represent an workflow in the document management system |
16 | * |
17 | * @category DMS |
18 | * @package SeedDMS_Core |
19 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
20 | * @copyright Copyright (C) 2012 Uwe Steinmann |
21 | * @version Release: @package_version@ |
22 | */ |
23 | class SeedDMS_Core_Workflow { /* {{{ */ |
24 | /** |
25 | * @var integer id of workflow |
26 | * |
27 | * @access protected |
28 | */ |
29 | var $_id; |
30 | |
31 | /** |
32 | * @var string name of the workflow |
33 | * |
34 | * @access protected |
35 | */ |
36 | var $_name; |
37 | |
38 | /** |
39 | * @var SeedDMS_Core_Workflow_State initial state of the workflow |
40 | * |
41 | * @access protected |
42 | */ |
43 | var $_initstate; |
44 | |
45 | /** |
46 | * @var SeedDMS_Core_Workflow_Transition[] name of the workflow state |
47 | * |
48 | * @access protected |
49 | */ |
50 | var $_transitions; |
51 | |
52 | /** |
53 | * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to |
54 | * |
55 | * @access protected |
56 | */ |
57 | var $_dms; |
58 | |
59 | /** |
60 | * SeedDMS_Core_Workflow constructor. |
61 | * @param int $id |
62 | * @param string $name |
63 | * @param SeedDMS_Core_Workflow_State $initstate |
64 | */ |
65 | function __construct($id, $name, $initstate) { /* {{{ */ |
66 | $this->_id = $id; |
67 | $this->_name = $name; |
68 | $this->_initstate = $initstate; |
69 | $this->_transitions = null; |
70 | $this->_dms = null; |
71 | } /* }}} */ |
72 | |
73 | /** |
74 | * @param SeedDMS_Core_DMS $dms |
75 | */ |
76 | function setDMS($dms) { /* {{{ */ |
77 | $this->_dms = $dms; |
78 | } /* }}} */ |
79 | |
80 | /** |
81 | * @return int |
82 | */ |
83 | function getID() { return $this->_id; } |
84 | |
85 | /** |
86 | * @return string |
87 | */ |
88 | function getName() { return $this->_name; } |
89 | |
90 | /** |
91 | * @param $newName |
92 | * @return bool |
93 | */ |
94 | function setName($newName) { /* {{{ */ |
95 | $db = $this->_dms->getDB(); |
96 | |
97 | $queryStr = "UPDATE `tblWorkflows` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; |
98 | $res = $db->getResult($queryStr); |
99 | if (!$res) |
100 | return false; |
101 | |
102 | $this->_name = $newName; |
103 | return true; |
104 | } /* }}} */ |
105 | |
106 | /** |
107 | * @return SeedDMS_Core_Workflow_State |
108 | */ |
109 | function getInitState() { return $this->_initstate; } |
110 | |
111 | /** |
112 | * @param SeedDMS_Core_Workflow_State $state |
113 | * @return bool |
114 | */ |
115 | function setInitState($state) { /* {{{ */ |
116 | $db = $this->_dms->getDB(); |
117 | |
118 | $queryStr = "UPDATE `tblWorkflows` SET `initstate` = ".$state->getID()." WHERE `id` = " . $this->_id; |
119 | $res = $db->getResult($queryStr); |
120 | if (!$res) |
121 | return false; |
122 | |
123 | $this->_initstate = $state; |
124 | return true; |
125 | } /* }}} */ |
126 | |
127 | /** |
128 | * @return SeedDMS_Core_Workflow_Transition[]|bool |
129 | */ |
130 | function getTransitions() { /* {{{ */ |
131 | $db = $this->_dms->getDB(); |
132 | |
133 | if($this->_transitions) |
134 | return $this->_transitions; |
135 | |
136 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `workflow`=".$this->_id; |
137 | $resArr = $db->getResultArray($queryStr); |
138 | if (is_bool($resArr) && $resArr == false) |
139 | return false; |
140 | |
141 | $wkftransitions = array(); |
142 | for ($i = 0; $i < count($resArr); $i++) { |
143 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this, $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
144 | $wkftransition->setDMS($this->_dms); |
145 | $wkftransitions[$resArr[$i]["id"]] = $wkftransition; |
146 | } |
147 | |
148 | $this->_transitions = $wkftransitions; |
149 | |
150 | return $this->_transitions; |
151 | } /* }}} */ |
152 | |
153 | /** |
154 | * Get all states this workflow at some point may reach |
155 | * |
156 | * It basically iterates through all transistions and makes a unique |
157 | * list of the start and end state. |
158 | * |
159 | * @return array list of states |
160 | */ |
161 | function getStates() { /* {{{ */ |
162 | /** @noinspection PhpUnusedLocalVariableInspection */ |
163 | $db = $this->_dms->getDB(); |
164 | |
165 | if(!$this->_transitions) |
166 | $this->getTransitions(); |
167 | |
168 | $states = array(); |
169 | foreach($this->_transitions as $transition) { |
170 | if(!isset($states[$transition->getState()->getID()])) |
171 | $states[$transition->getState()->getID()] = $transition->getState(); |
172 | if(!isset($states[$transition->getNextState()->getID()])) |
173 | $states[$transition->getNextState()->getID()] = $transition->getNextState(); |
174 | } |
175 | |
176 | return $states; |
177 | } /* }}} */ |
178 | |
179 | /** |
180 | * Get the transition by its id |
181 | * |
182 | * @param integer $id id of transition |
183 | * @return bool|SeedDMS_Core_Workflow_Transition |
184 | */ |
185 | function getTransition($id) { /* {{{ */ |
186 | /** @noinspection PhpUnusedLocalVariableInspection */ |
187 | $db = $this->_dms->getDB(); |
188 | |
189 | if(!$this->_transitions) |
190 | $this->getTransitions(); |
191 | |
192 | if($this->_transitions[$id]) |
193 | return $this->_transitions[$id]; |
194 | |
195 | return false; |
196 | } /* }}} */ |
197 | |
198 | /** |
199 | * Get the transitions that can be triggered while being in the given state |
200 | * |
201 | * @param SeedDMS_Core_Workflow_State $state current workflow state |
202 | * @return SeedDMS_Core_Workflow_Transition[]|bool |
203 | */ |
204 | function getNextTransitions($state) { /* {{{ */ |
205 | $db = $this->_dms->getDB(); |
206 | |
207 | if(!$state) |
208 | return false; |
209 | |
210 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `workflow`=".$this->_id." AND `state`=".$state->getID(); |
211 | $resArr = $db->getResultArray($queryStr); |
212 | if (is_bool($resArr) && $resArr == false) |
213 | return false; |
214 | |
215 | $wkftransitions = array(); |
216 | for ($i = 0; $i < count($resArr); $i++) { |
217 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this, $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
218 | $wkftransition->setDMS($this->_dms); |
219 | $wkftransitions[$i] = $wkftransition; |
220 | } |
221 | |
222 | return $wkftransitions; |
223 | } /* }}} */ |
224 | |
225 | /** |
226 | * Get the transitions that lead to the given state |
227 | * |
228 | * @param SeedDMS_Core_Workflow_State $state current workflow state |
229 | * @return SeedDMS_Core_Workflow_Transition[]|bool |
230 | */ |
231 | function getPreviousTransitions($state) { /* {{{ */ |
232 | $db = $this->_dms->getDB(); |
233 | |
234 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `workflow`=".$this->_id." AND `nextstate`=".$state->getID(); |
235 | $resArr = $db->getResultArray($queryStr); |
236 | if (is_bool($resArr) && $resArr == false) |
237 | return false; |
238 | |
239 | $wkftransitions = array(); |
240 | for ($i = 0; $i < count($resArr); $i++) { |
241 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this, $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
242 | $wkftransition->setDMS($this->_dms); |
243 | $wkftransitions[$i] = $wkftransition; |
244 | } |
245 | |
246 | return $wkftransitions; |
247 | } /* }}} */ |
248 | |
249 | /** |
250 | * Get all transitions from one state into another state |
251 | * |
252 | * @param SeedDMS_Core_Workflow_State $state state to start from |
253 | * @param SeedDMS_Core_Workflow_State $nextstate state after transition |
254 | * @return SeedDMS_Core_Workflow_Transition[]|bool |
255 | */ |
256 | function getTransitionsByStates($state, $nextstate) { /* {{{ */ |
257 | $db = $this->_dms->getDB(); |
258 | |
259 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `workflow`=".$this->_id." AND `state`=".$state->getID()." AND `nextstate`=".$nextstate->getID(); |
260 | $resArr = $db->getResultArray($queryStr); |
261 | if (is_bool($resArr) && $resArr == false) |
262 | return false; |
263 | |
264 | $wkftransitions = array(); |
265 | for ($i = 0; $i < count($resArr); $i++) { |
266 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this, $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
267 | $wkftransition->setDMS($this->_dms); |
268 | $wkftransitions[$i] = $wkftransition; |
269 | } |
270 | |
271 | return $wkftransitions; |
272 | } /* }}} */ |
273 | |
274 | /** |
275 | * Remove a transition from a workflow |
276 | * Deprecated! User SeedDMS_Core_Workflow_Transition::remove() instead. |
277 | * |
278 | * @param SeedDMS_Core_Workflow_Transition $transition |
279 | * @return boolean true if no error occured, otherwise false |
280 | */ |
281 | function removeTransition($transition) { /* {{{ */ |
282 | return $transition->remove(); |
283 | } /* }}} */ |
284 | |
285 | /** |
286 | * Add new transition to workflow |
287 | * |
288 | * @param SeedDMS_Core_Workflow_State $state |
289 | * @param SeedDMS_Core_Workflow_Action $action |
290 | * @param SeedDMS_Core_Workflow_State $nextstate |
291 | * @param SeedDMS_Core_User[] $users |
292 | * @param SeedDMS_Core_Group[] $groups |
293 | * @return SeedDMS_Core_Workflow_Transition|bool instance of new transition |
294 | */ |
295 | function addTransition($state, $action, $nextstate, $users, $groups) { /* {{{ */ |
296 | $db = $this->_dms->getDB(); |
297 | |
298 | $db->startTransaction(); |
299 | $queryStr = "INSERT INTO `tblWorkflowTransitions` (`workflow`, `state`, `action`, `nextstate`) VALUES (".$this->_id.", ".$state->getID().", ".$action->getID().", ".$nextstate->getID().")"; |
300 | if (!$db->getResult($queryStr)) { |
301 | $db->rollbackTransaction(); |
302 | return false; |
303 | } |
304 | |
305 | /* force reloading all transitions otherwise getTransition() will fail if two |
306 | * transitions are added in a row, without reloading the workflow |
307 | */ |
308 | $this->_transitions = array(); |
309 | $transition = $this->getTransition($db->getInsertID('tblWorkflowTransitions')); |
310 | |
311 | foreach($users as $user) { |
312 | $queryStr = "INSERT INTO `tblWorkflowTransitionUsers` (`transition`, `userid`) VALUES (".$transition->getID().", ".$user->getID().")"; |
313 | if (!$db->getResult($queryStr)) { |
314 | $db->rollbackTransaction(); |
315 | return false; |
316 | } |
317 | } |
318 | |
319 | foreach($groups as $group) { |
320 | $queryStr = "INSERT INTO `tblWorkflowTransitionGroups` (`transition`, `groupid`, `minusers`) VALUES (".$transition->getID().", ".$group->getID().", 1)"; |
321 | if (!$db->getResult($queryStr)) { |
322 | $db->rollbackTransaction(); |
323 | return false; |
324 | } |
325 | } |
326 | |
327 | $db->commitTransaction(); |
328 | return $transition; |
329 | } /* }}} */ |
330 | |
331 | /** |
332 | * Check if workflow is currently used by any document |
333 | * |
334 | * @return boolean true if workflow is used, otherwise false |
335 | */ |
336 | function isUsed() { /* {{{ */ |
337 | $db = $this->_dms->getDB(); |
338 | |
339 | $queryStr = "SELECT * FROM `tblWorkflowDocumentContent` WHERE `workflow`=".$this->_id; |
340 | $resArr = $db->getResultArray($queryStr); |
341 | if (is_array($resArr) && count($resArr) == 0) |
342 | return false; |
343 | return true; |
344 | } /* }}} */ |
345 | |
346 | /** |
347 | * @param SeedDMS_Core_Workflow_State[] $laststates |
348 | * @return SeedDMS_Core_Workflow_State[]|bool |
349 | */ |
350 | private function penetrate($laststates) { |
351 | $state = end($laststates); |
352 | $transitions = $this->getNextTransitions($state); |
353 | foreach($transitions as $transition) { |
354 | $nextstate = $transition->getNextState(); |
355 | /* Check if nextstate is already in list of previous states */ |
356 | foreach($laststates as $laststate) { |
357 | if($laststate->getID() == $nextstate->getID()) |
358 | return array_merge($laststates, array($nextstate)); |
359 | } |
360 | if($ret = $this->penetrate(array_merge($laststates, array($nextstate)))) |
361 | return $ret; |
362 | } |
363 | return false; |
364 | } |
365 | |
366 | /** |
367 | * Check if workflow contains cycles |
368 | * |
369 | * @return boolean list of states if workflow contains cycles, otherwise false |
370 | */ |
371 | function checkForCycles() { /* {{{ */ |
372 | /** @noinspection PhpUnusedLocalVariableInspection */ |
373 | $db = $this->_dms->getDB(); |
374 | |
375 | $initstate = $this->getInitState(); |
376 | |
377 | return $this->penetrate(array($initstate)); |
378 | } /* }}} */ |
379 | |
380 | /** |
381 | * Remove the workflow and all its transitions |
382 | * Do not remove actions and states of the workflow |
383 | * |
384 | * @return boolean true on success or false in case of an error |
385 | * false is also returned if the workflow is currently in use |
386 | */ |
387 | function remove() { /* {{{ */ |
388 | $db = $this->_dms->getDB(); |
389 | |
390 | if($this->isUsed()) |
391 | return false; |
392 | |
393 | $db->startTransaction(); |
394 | |
395 | $queryStr = "DELETE FROM `tblWorkflowTransitions` WHERE `workflow` = " . $this->_id; |
396 | if (!$db->getResult($queryStr)) { |
397 | $db->rollbackTransaction(); |
398 | return false; |
399 | } |
400 | |
401 | $queryStr = "DELETE FROM `tblWorkflowMandatoryWorkflow` WHERE `workflow` = " . $this->_id; |
402 | if (!$db->getResult($queryStr)) { |
403 | $db->rollbackTransaction(); |
404 | return false; |
405 | } |
406 | |
407 | // Delete workflow itself |
408 | $queryStr = "DELETE FROM `tblWorkflows` WHERE `id` = " . $this->_id; |
409 | if (!$db->getResult($queryStr)) { |
410 | $db->rollbackTransaction(); |
411 | return false; |
412 | } |
413 | |
414 | $db->commitTransaction(); |
415 | |
416 | return true; |
417 | } /* }}} */ |
418 | |
419 | } /* }}} */ |
420 | |
421 | /** |
422 | * Class to represent a workflow state in the document management system |
423 | * |
424 | * @category DMS |
425 | * @package SeedDMS_Core |
426 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
427 | * @copyright Copyright (C) 2012 Uwe Steinmann |
428 | * @version Release: @package_version@ |
429 | */ |
430 | class SeedDMS_Core_Workflow_State { /* {{{ */ |
431 | /** |
432 | * @var integer id of workflow state |
433 | * |
434 | * @access protected |
435 | */ |
436 | var $_id; |
437 | |
438 | /** |
439 | * @var string name of the workflow state |
440 | * |
441 | * @access protected |
442 | */ |
443 | var $_name; |
444 | |
445 | /** |
446 | * @var int maximum of seconds allowed in this state |
447 | * |
448 | * @access protected |
449 | */ |
450 | var $_maxtime; |
451 | |
452 | /** |
453 | * @var int maximum of seconds allowed in this state |
454 | * |
455 | * @access protected |
456 | */ |
457 | var $_precondfunc; |
458 | |
459 | /** |
460 | * @var int matching documentstatus when this state is reached |
461 | * |
462 | * @access protected |
463 | */ |
464 | var $_documentstatus; |
465 | |
466 | /** |
467 | * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to |
468 | * |
469 | * @access protected |
470 | */ |
471 | var $_dms; |
472 | |
473 | /** |
474 | * SeedDMS_Core_Workflow_State constructor. |
475 | * @param $id |
476 | * @param $name |
477 | * @param $maxtime |
478 | * @param $precondfunc |
479 | * @param $documentstatus |
480 | */ |
481 | function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) { |
482 | $this->_id = $id; |
483 | $this->_name = $name; |
484 | $this->_maxtime = $maxtime; |
485 | $this->_precondfunc = $precondfunc; |
486 | $this->_documentstatus = $documentstatus; |
487 | $this->_dms = null; |
488 | } |
489 | |
490 | /** |
491 | * @param $dms |
492 | */ |
493 | function setDMS($dms) { |
494 | $this->_dms = $dms; |
495 | } |
496 | |
497 | /** |
498 | * @return int |
499 | */ |
500 | function getID() { return $this->_id; } |
501 | |
502 | /** |
503 | * @return string |
504 | */ |
505 | function getName() { return $this->_name; } |
506 | |
507 | /** |
508 | * @param string $newName |
509 | * @return bool |
510 | */ |
511 | function setName($newName) { /* {{{ */ |
512 | $db = $this->_dms->getDB(); |
513 | |
514 | $queryStr = "UPDATE `tblWorkflowStates` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; |
515 | $res = $db->getResult($queryStr); |
516 | if (!$res) |
517 | return false; |
518 | |
519 | $this->_name = $newName; |
520 | return true; |
521 | } /* }}} */ |
522 | |
523 | /** |
524 | * @return int maximum |
525 | */ |
526 | function getMaxTime() { return $this->_maxtime; } |
527 | |
528 | /** |
529 | * @param $maxtime |
530 | * @return bool |
531 | */ |
532 | function setMaxTime($maxtime) { /* {{{ */ |
533 | $db = $this->_dms->getDB(); |
534 | |
535 | $queryStr = "UPDATE `tblWorkflowStates` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id; |
536 | $res = $db->getResult($queryStr); |
537 | if (!$res) |
538 | return false; |
539 | |
540 | $this->_maxtime = $maxtime; |
541 | return true; |
542 | } /* }}} */ |
543 | |
544 | /** |
545 | * @return int maximum |
546 | */ |
547 | function getPreCondFunc() { return $this->_precondfunc; } |
548 | |
549 | /** |
550 | * @param $precondfunc |
551 | * @return bool |
552 | */ |
553 | function setPreCondFunc($precondfunc) { /* {{{ */ |
554 | $db = $this->_dms->getDB(); |
555 | |
556 | $queryStr = "UPDATE `tblWorkflowStates` SET `precondfunc` = ".$db->qstr($precondfunc)." WHERE id = " . $this->_id; |
557 | $res = $db->getResult($queryStr); |
558 | if (!$res) |
559 | return false; |
560 | |
561 | /** @noinspection PhpUndefinedVariableInspection */ |
562 | $this->_maxtime = $maxtime; /* @todo fix me */ |
563 | return true; |
564 | } /* }}} */ |
565 | |
566 | /** |
567 | * Get the document status which is set when this state is reached |
568 | * |
569 | * The document status uses the define states S_REJECTED and S_RELEASED |
570 | * Only those two states will update the document status |
571 | * |
572 | * @return integer document status |
573 | */ |
574 | function getDocumentStatus() { return $this->_documentstatus; } |
575 | |
576 | /** |
577 | * @param $docstatus |
578 | * @return bool |
579 | */ |
580 | function setDocumentStatus($docstatus) { /* {{{ */ |
581 | $db = $this->_dms->getDB(); |
582 | |
583 | $queryStr = "UPDATE `tblWorkflowStates` SET `documentstatus` = ".intval($docstatus)." WHERE id = " . $this->_id; |
584 | $res = $db->getResult($queryStr); |
585 | if (!$res) |
586 | return false; |
587 | |
588 | $this->_documentstatus = $docstatus; |
589 | return true; |
590 | } /* }}} */ |
591 | |
592 | /** |
593 | * Check if workflow state is currently used by any workflow transition |
594 | * |
595 | * @return boolean true if workflow is used, otherwise false |
596 | */ |
597 | function isUsed() { /* {{{ */ |
598 | $db = $this->_dms->getDB(); |
599 | |
600 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `state`=".$this->_id. " OR `nextstate`=".$this->_id; |
601 | $resArr = $db->getResultArray($queryStr); |
602 | if (is_array($resArr) && count($resArr) == 0) |
603 | return false; |
604 | return true; |
605 | } /* }}} */ |
606 | |
607 | /** |
608 | * Return workflow transitions the status is being used in |
609 | * |
610 | * @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error |
611 | */ |
612 | function getTransitions() { /* {{{ */ |
613 | $db = $this->_dms->getDB(); |
614 | |
615 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `state`=".$this->_id. " OR `nextstate`=".$this->_id; |
616 | $resArr = $db->getResultArray($queryStr); |
617 | if (is_array($resArr) && count($resArr) == 0) |
618 | return false; |
619 | |
620 | $wkftransitions = array(); |
621 | for ($i = 0; $i < count($resArr); $i++) { |
622 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this->_dms->getWorkflow($resArr[$i]["workflow"]), $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
623 | $wkftransition->setDMS($this->_dms); |
624 | $wkftransitions[$resArr[$i]["id"]] = $wkftransition; |
625 | } |
626 | |
627 | return $wkftransitions; |
628 | } /* }}} */ |
629 | |
630 | /** |
631 | * Remove the workflow state |
632 | * |
633 | * @return boolean true on success or false in case of an error |
634 | * false is also returned if the workflow state is currently in use |
635 | */ |
636 | function remove() { /* {{{ */ |
637 | $db = $this->_dms->getDB(); |
638 | |
639 | if($this->isUsed()) |
640 | return false; |
641 | |
642 | $db->startTransaction(); |
643 | |
644 | // Delete workflow state itself |
645 | $queryStr = "DELETE FROM `tblWorkflowStates` WHERE `id` = " . $this->_id; |
646 | if (!$db->getResult($queryStr)) { |
647 | $db->rollbackTransaction(); |
648 | return false; |
649 | } |
650 | |
651 | $db->commitTransaction(); |
652 | |
653 | return true; |
654 | } /* }}} */ |
655 | |
656 | } /* }}} */ |
657 | |
658 | /** |
659 | * Class to represent a workflow action in the document management system |
660 | * |
661 | * @category DMS |
662 | * @package SeedDMS_Core |
663 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
664 | * @copyright Copyright (C) 2012 Uwe Steinmann |
665 | * @version Release: @package_version@ |
666 | */ |
667 | class SeedDMS_Core_Workflow_Action { /* {{{ */ |
668 | /** |
669 | * @var integer id of workflow action |
670 | * |
671 | * @access protected |
672 | */ |
673 | var $_id; |
674 | |
675 | /** |
676 | * @var string name of the workflow action |
677 | * |
678 | * @access protected |
679 | */ |
680 | var $_name; |
681 | |
682 | /** |
683 | * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to |
684 | * |
685 | * @access protected |
686 | */ |
687 | var $_dms; |
688 | |
689 | /** |
690 | * SeedDMS_Core_Workflow_Action constructor. |
691 | * @param $id |
692 | * @param $name |
693 | */ |
694 | function __construct($id, $name) { |
695 | $this->_id = $id; |
696 | $this->_name = $name; |
697 | $this->_dms = null; |
698 | } |
699 | |
700 | /** |
701 | * @param $dms |
702 | */ |
703 | function setDMS($dms) { |
704 | $this->_dms = $dms; |
705 | } |
706 | |
707 | /** |
708 | * @return int |
709 | */ |
710 | function getID() { return $this->_id; } |
711 | |
712 | /** |
713 | * @return string name |
714 | */ |
715 | function getName() { return $this->_name; } |
716 | |
717 | /** |
718 | * @param $newName |
719 | * @return bool |
720 | */ |
721 | function setName($newName) { /* {{{ */ |
722 | $db = $this->_dms->getDB(); |
723 | |
724 | $queryStr = "UPDATE `tblWorkflowActions` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; |
725 | $res = $db->getResult($queryStr); |
726 | if (!$res) |
727 | return false; |
728 | |
729 | $this->_name = $newName; |
730 | return true; |
731 | } /* }}} */ |
732 | |
733 | /** |
734 | * Check if workflow action is currently used by any workflow transition |
735 | * |
736 | * @return boolean true if workflow action is used, otherwise false |
737 | */ |
738 | function isUsed() { /* {{{ */ |
739 | $db = $this->_dms->getDB(); |
740 | |
741 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `action`=".$this->_id; |
742 | $resArr = $db->getResultArray($queryStr); |
743 | if (is_array($resArr) && count($resArr) == 0) |
744 | return false; |
745 | return true; |
746 | } /* }}} */ |
747 | |
748 | /** |
749 | * Return workflow transitions the action is being used in |
750 | * |
751 | * @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error |
752 | */ |
753 | function getTransitions() { /* {{{ */ |
754 | $db = $this->_dms->getDB(); |
755 | |
756 | $queryStr = "SELECT * FROM `tblWorkflowTransitions` WHERE `action`=".$this->_id; |
757 | $resArr = $db->getResultArray($queryStr); |
758 | if (is_array($resArr) && count($resArr) == 0) |
759 | return false; |
760 | |
761 | $wkftransitions = array(); |
762 | for ($i = 0; $i < count($resArr); $i++) { |
763 | $wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this->_dms->getWorkflow($resArr[$i]["workflow"]), $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]); |
764 | $wkftransition->setDMS($this->_dms); |
765 | $wkftransitions[$resArr[$i]["id"]] = $wkftransition; |
766 | } |
767 | |
768 | return $wkftransitions; |
769 | } /* }}} */ |
770 | |
771 | /** |
772 | * Remove the workflow action |
773 | * |
774 | * @return boolean true on success or false in case of an error |
775 | * false is also returned if the workflow action is currently in use |
776 | */ |
777 | function remove() { /* {{{ */ |
778 | $db = $this->_dms->getDB(); |
779 | |
780 | if($this->isUsed()) |
781 | return false; |
782 | |
783 | $db->startTransaction(); |
784 | |
785 | // Delete workflow state itself |
786 | $queryStr = "DELETE FROM `tblWorkflowActions` WHERE `id` = " . $this->_id; |
787 | if (!$db->getResult($queryStr)) { |
788 | $db->rollbackTransaction(); |
789 | return false; |
790 | } |
791 | |
792 | $db->commitTransaction(); |
793 | |
794 | return true; |
795 | } /* }}} */ |
796 | |
797 | } /* }}} */ |
798 | |
799 | /** |
800 | * Class to represent a workflow transition in the document management system |
801 | * |
802 | * @category DMS |
803 | * @package SeedDMS_Core |
804 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
805 | * @copyright Copyright (C) 2012 Uwe Steinmann |
806 | * @version Release: @package_version@ |
807 | */ |
808 | class SeedDMS_Core_Workflow_Transition { /* {{{ */ |
809 | /** |
810 | * @var integer id of workflow transition |
811 | * |
812 | * @access protected |
813 | */ |
814 | var $_id; |
815 | |
816 | /** |
817 | * @var SeedDMS_Core_Workflow workflow this transition belongs to |
818 | * |
819 | * @access protected |
820 | */ |
821 | var $_workflow; |
822 | |
823 | /** |
824 | * @var SeedDMS_Core_Workflow_State of the workflow transition |
825 | * |
826 | * @access protected |
827 | */ |
828 | var $_state; |
829 | |
830 | /** |
831 | * @var SeedDMS_Core_Workflow_State next state of the workflow transition |
832 | * |
833 | * @access protected |
834 | */ |
835 | var $_nextstate; |
836 | |
837 | /** |
838 | * @var SeedDMS_Core_Workflow_Action of the workflow transition |
839 | * |
840 | * @access protected |
841 | */ |
842 | var $_action; |
843 | |
844 | /** |
845 | * @var integer maximum of seconds allowed until this transition must be triggered |
846 | * |
847 | * @access protected |
848 | */ |
849 | var $_maxtime; |
850 | |
851 | /** |
852 | * @var SeedDMS_Core_User[] of users allowed to trigger this transaction |
853 | * |
854 | * @access protected |
855 | */ |
856 | var $_users; |
857 | |
858 | /** |
859 | * @var SeedDMS_Core_Group[] of groups allowed to trigger this transaction |
860 | * |
861 | * @access protected |
862 | */ |
863 | var $_groups; |
864 | |
865 | /** |
866 | * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to |
867 | * |
868 | * @access protected |
869 | */ |
870 | var $_dms; |
871 | |
872 | /** |
873 | * SeedDMS_Core_Workflow_Transition constructor. |
874 | * @param $id |
875 | * @param $workflow |
876 | * @param $state |
877 | * @param $action |
878 | * @param $nextstate |
879 | * @param $maxtime |
880 | */ |
881 | function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) { |
882 | $this->_id = $id; |
883 | $this->_workflow = $workflow; |
884 | $this->_state = $state; |
885 | $this->_action = $action; |
886 | $this->_nextstate = $nextstate; |
887 | $this->_maxtime = $maxtime; |
888 | $this->_dms = null; |
889 | } |
890 | |
891 | /** |
892 | * @param $dms |
893 | */ |
894 | function setDMS($dms) { |
895 | $this->_dms = $dms; |
896 | } |
897 | |
898 | /** |
899 | * @return int |
900 | */ |
901 | function getID() { return $this->_id; } |
902 | |
903 | /** |
904 | * @return SeedDMS_Core_Workflow |
905 | */ |
906 | function getWorkflow() { return $this->_workflow; } |
907 | |
908 | /** |
909 | * @param SeedDMS_Core_Workflow $newWorkflow |
910 | * @return bool |
911 | */ |
912 | function setWorkflow($newWorkflow) { /* {{{ */ |
913 | $db = $this->_dms->getDB(); |
914 | |
915 | $queryStr = "UPDATE `tblWorkflowTransitions` SET `workflow` = ".$newWorkflow->getID()." WHERE `id` = " . $this->_id; |
916 | $res = $db->getResult($queryStr); |
917 | if (!$res) |
918 | return false; |
919 | |
920 | $this->_workflow = $newWorkflow; |
921 | return true; |
922 | } /* }}} */ |
923 | |
924 | |
925 | /** |
926 | * @return SeedDMS_Core_Workflow_State |
927 | */ |
928 | function getState() { return $this->_state; } |
929 | |
930 | /** |
931 | * @param SeedDMS_Core_Workflow_State $newState |
932 | * @return bool |
933 | */ |
934 | function setState($newState) { /* {{{ */ |
935 | $db = $this->_dms->getDB(); |
936 | |
937 | $queryStr = "UPDATE `tblWorkflowTransitions` SET `state` = ".$newState->getID()." WHERE `id` = " . $this->_id; |
938 | $res = $db->getResult($queryStr); |
939 | if (!$res) |
940 | return false; |
941 | |
942 | $this->_state = $newState; |
943 | return true; |
944 | } /* }}} */ |
945 | |
946 | /** |
947 | * @return SeedDMS_Core_Workflow_State |
948 | */ |
949 | function getNextState() { return $this->_nextstate; } |
950 | |
951 | /** |
952 | * @param SeedDMS_Core_Workflow_State $newNextState |
953 | * @return bool |
954 | */ |
955 | function setNextState($newNextState) { /* {{{ */ |
956 | $db = $this->_dms->getDB(); |
957 | |
958 | $queryStr = "UPDATE `tblWorkflowTransitions` SET `nextstate` = ".$newNextState->getID()." WHERE `id` = " . $this->_id; |
959 | $res = $db->getResult($queryStr); |
960 | if (!$res) |
961 | return false; |
962 | |
963 | $this->_nextstate = $newNextState; |
964 | return true; |
965 | } /* }}} */ |
966 | |
967 | /** |
968 | * @return SeedDMS_Core_Workflow_Action |
969 | */ |
970 | function getAction() { return $this->_action; } |
971 | |
972 | /** |
973 | * @param SeedDMS_Core_Workflow_Action $newAction |
974 | * @return bool |
975 | */ |
976 | function setAction($newAction) { /* {{{ */ |
977 | $db = $this->_dms->getDB(); |
978 | |
979 | $queryStr = "UPDATE `tblWorkflowTransitions` SET `action` = ".$newAction->getID()." WHERE `id` = " . $this->_id; |
980 | $res = $db->getResult($queryStr); |
981 | if (!$res) |
982 | return false; |
983 | |
984 | $this->_action = $newAction; |
985 | return true; |
986 | } /* }}} */ |
987 | |
988 | /** |
989 | * @return int |
990 | */ |
991 | function getMaxTime() { return $this->_maxtime; } |
992 | |
993 | /** |
994 | * @param $maxtime |
995 | * @return bool |
996 | */ |
997 | function setMaxTime($maxtime) { /* {{{ */ |
998 | $db = $this->_dms->getDB(); |
999 | |
1000 | $queryStr = "UPDATE `tblWorkflowTransitions` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id; |
1001 | $res = $db->getResult($queryStr); |
1002 | if (!$res) |
1003 | return false; |
1004 | |
1005 | $this->_maxtime = $maxtime; |
1006 | return true; |
1007 | } /* }}} */ |
1008 | |
1009 | /** |
1010 | * Get all users allowed to trigger this transition |
1011 | * |
1012 | * @return SeedDMS_Core_User[]|bool list of users |
1013 | */ |
1014 | function getUsers() { /* {{{ */ |
1015 | $db = $this->_dms->getDB(); |
1016 | |
1017 | if($this->_users) |
1018 | return $this->_users; |
1019 | |
1020 | $queryStr = "SELECT * FROM `tblWorkflowTransitionUsers` WHERE `transition`=".$this->_id; |
1021 | $resArr = $db->getResultArray($queryStr); |
1022 | if (is_bool($resArr) && $resArr == false) |
1023 | return false; |
1024 | |
1025 | $users = array(); |
1026 | for ($i = 0; $i < count($resArr); $i++) { |
1027 | $user = new SeedDMS_Core_Workflow_Transition_User($resArr[$i]['id'], $this, $this->_dms->getUser($resArr[$i]['userid'])); |
1028 | $user->setDMS($this->_dms); |
1029 | $users[$i] = $user; |
1030 | } |
1031 | |
1032 | $this->_users = $users; |
1033 | |
1034 | return $this->_users; |
1035 | } /* }}} */ |
1036 | |
1037 | /** |
1038 | * Get all users allowed to trigger this transition |
1039 | * |
1040 | * @return SeedDMS_Core_Group[]|bool list of users |
1041 | */ |
1042 | function getGroups() { /* {{{ */ |
1043 | $db = $this->_dms->getDB(); |
1044 | |
1045 | if($this->_groups) |
1046 | return $this->_groups; |
1047 | |
1048 | $queryStr = "SELECT * FROM `tblWorkflowTransitionGroups` WHERE `transition`=".$this->_id; |
1049 | $resArr = $db->getResultArray($queryStr); |
1050 | if (is_bool($resArr) && $resArr == false) |
1051 | return false; |
1052 | |
1053 | $groups = array(); |
1054 | for ($i = 0; $i < count($resArr); $i++) { |
1055 | $group = new SeedDMS_Core_Workflow_Transition_Group($resArr[$i]['id'], $this, $this->_dms->getGroup($resArr[$i]['groupid']), $resArr[$i]['minusers']); |
1056 | $group->setDMS($this->_dms); |
1057 | $groups[$i] = $group; |
1058 | } |
1059 | |
1060 | $this->_groups = $groups; |
1061 | |
1062 | return $this->_groups; |
1063 | } /* }}} */ |
1064 | |
1065 | /** |
1066 | * Remove the workflow transition |
1067 | * |
1068 | * @return boolean true on success or false in case of an error |
1069 | * false is also returned if the workflow action is currently in use |
1070 | */ |
1071 | function remove() { /* {{{ */ |
1072 | $db = $this->_dms->getDB(); |
1073 | |
1074 | $db->startTransaction(); |
1075 | |
1076 | // Delete workflow transition itself |
1077 | $queryStr = "DELETE FROM `tblWorkflowTransitions` WHERE `id` = " . $this->_id; |
1078 | if (!$db->getResult($queryStr)) { |
1079 | $db->rollbackTransaction(); |
1080 | return false; |
1081 | } |
1082 | |
1083 | $db->commitTransaction(); |
1084 | |
1085 | return true; |
1086 | } /* }}} */ |
1087 | |
1088 | } /* }}} */ |
1089 | |
1090 | /** |
1091 | * Class to represent a user allowed to trigger a workflow transition |
1092 | * |
1093 | * @category DMS |
1094 | * @package SeedDMS_Core |
1095 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
1096 | * @copyright Copyright (C) 2012 Uwe Steinmann |
1097 | * @version Release: @package_version@ |
1098 | */ |
1099 | class SeedDMS_Core_Workflow_Transition_User { /* {{{ */ |
1100 | /** |
1101 | * @var integer id of workflow transition |
1102 | * |
1103 | * @access protected |
1104 | */ |
1105 | var $_id; |
1106 | |
1107 | /** |
1108 | * @var object reference to the transtion this user belongs to |
1109 | * |
1110 | * @access protected |
1111 | */ |
1112 | var $_transition; |
1113 | |
1114 | /** |
1115 | * @var object user allowed to trigger a transition |
1116 | * |
1117 | * @access protected |
1118 | */ |
1119 | var $_user; |
1120 | |
1121 | /** |
1122 | * @var object reference to the dms instance this attribute belongs to |
1123 | _Core_Workflow_Transition_Group |
1124 | * @access protected |
1125 | */ |
1126 | var $_dms; |
1127 | |
1128 | /** |
1129 | * SeedDMS_Core_Workflow_Transition_User constructor. |
1130 | * @param $id |
1131 | * @param $transition |
1132 | * @param $user |
1133 | */ |
1134 | function __construct($id, $transition, $user) { |
1135 | $this->_id = $id; |
1136 | $this->_transition = $transition; |
1137 | $this->_user = $user; |
1138 | } |
1139 | |
1140 | /** |
1141 | * @param $dms |
1142 | */ |
1143 | function setDMS($dms) { /* {{{ */ |
1144 | $this->_dms = $dms; |
1145 | } /* }}} */ |
1146 | |
1147 | /** |
1148 | * Get the transtion itself |
1149 | * |
1150 | * @return object group |
1151 | */ |
1152 | function getTransition() { /* {{{ */ |
1153 | return $this->_transition; |
1154 | } /* }}} */ |
1155 | |
1156 | /** |
1157 | * Get the user who is allowed to trigger the transition |
1158 | * |
1159 | * @return object user |
1160 | */ |
1161 | function getUser() { /* {{{ */ |
1162 | return $this->_user; |
1163 | } /* }}} */ |
1164 | } /* }}} */ |
1165 | |
1166 | /** |
1167 | * Class to represent a group allowed to trigger a workflow transition |
1168 | * |
1169 | * @category DMS |
1170 | * @package SeedDMS_Core |
1171 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
1172 | * @copyright Copyright (C) 2012 Uwe Steinmann |
1173 | * @version Release: @package_version@ |
1174 | */ |
1175 | class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */ |
1176 | /** |
1177 | * @var integer id of workflow transition |
1178 | * |
1179 | * @access protected |
1180 | */ |
1181 | var $_id; |
1182 | |
1183 | /** |
1184 | * @var object reference to the transtion this group belongs to |
1185 | * |
1186 | * @access protected |
1187 | */ |
1188 | var $_transition; |
1189 | |
1190 | /** |
1191 | * @var integer number of users how must trigger the transition |
1192 | * |
1193 | * @access protected |
1194 | */ |
1195 | var $_numOfUsers; |
1196 | |
1197 | /** |
1198 | * @var object group of users |
1199 | * |
1200 | * @access protected |
1201 | */ |
1202 | var $_group; |
1203 | |
1204 | /** |
1205 | * @var object reference to the dms instance this attribute belongs to |
1206 | * |
1207 | * @access protected |
1208 | */ |
1209 | var $_dms; |
1210 | |
1211 | /** |
1212 | * SeedDMS_Core_Workflow_Transition_Group constructor. |
1213 | * @param $id |
1214 | * @param $transition |
1215 | * @param $group |
1216 | * @param $numOfUsers |
1217 | */ |
1218 | function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */ |
1219 | $this->_id = $id; |
1220 | $this->_transition = $transition; |
1221 | $this->_group = $group; |
1222 | $this->_numOfUsers = $numOfUsers; |
1223 | } /* }}} */ |
1224 | |
1225 | /** |
1226 | * @param $dms |
1227 | */ |
1228 | function setDMS($dms) { /* {{{ */ |
1229 | $this->_dms = $dms; |
1230 | } /* }}} */ |
1231 | |
1232 | /** |
1233 | * Get the transtion itself |
1234 | * |
1235 | * @return object group |
1236 | */ |
1237 | function getTransition() { /* {{{ */ |
1238 | return $this->_transition; |
1239 | } /* }}} */ |
1240 | |
1241 | /** |
1242 | * Get the group whose user are allowed to trigger the transition |
1243 | * |
1244 | * @return object group |
1245 | */ |
1246 | function getGroup() { /* {{{ */ |
1247 | return $this->_group; |
1248 | } /* }}} */ |
1249 | |
1250 | /** |
1251 | * Returns the number of users of this group needed to trigger the transition |
1252 | * |
1253 | * @return integer number of users |
1254 | */ |
1255 | function getNumOfUsers() { /* {{{ */ |
1256 | return $this->_numOfUsers; |
1257 | } /* }}} */ |
1258 | |
1259 | } /* }}} */ |
1260 | |
1261 | /** |
1262 | * Class to represent a group allowed to trigger a workflow transition |
1263 | * |
1264 | * @category DMS |
1265 | * @package SeedDMS_Core |
1266 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx> |
1267 | * @copyright Copyright (C) 2012 Uwe Steinmann |
1268 | * @version Release: @package_version@ |
1269 | */ |
1270 | class SeedDMS_Core_Workflow_Log { /* {{{ */ |
1271 | /** |
1272 | * @var integer id of workflow log |
1273 | * |
1274 | * @access protected |
1275 | */ |
1276 | var $_id; |
1277 | |
1278 | /** |
1279 | * @var object document this log entry belongs to |
1280 | * |
1281 | * @access protected |
1282 | */ |
1283 | var $_document; |
1284 | |
1285 | /** |
1286 | * @var integer version of document this log entry belongs to |
1287 | * |
1288 | * @access protected |
1289 | */ |
1290 | var $_version; |
1291 | |
1292 | /** |
1293 | * @var object workflow |
1294 | * |
1295 | * @access protected |
1296 | */ |
1297 | var $_workflow; |
1298 | |
1299 | /** |
1300 | * @var object user initiating this log entry |
1301 | * |
1302 | * @access protected |
1303 | */ |
1304 | var $_user; |
1305 | |
1306 | /** |
1307 | * @var object transition |
1308 | * |
1309 | * @access protected |
1310 | */ |
1311 | var $_transition; |
1312 | |
1313 | /** |
1314 | * @var string date |
1315 | * |
1316 | * @access protected |
1317 | */ |
1318 | var $_date; |
1319 | |
1320 | /** |
1321 | * @var string comment |
1322 | * |
1323 | * @access protected |
1324 | */ |
1325 | var $_comment; |
1326 | |
1327 | /** |
1328 | * @var object reference to the dms instance this attribute belongs to |
1329 | * |
1330 | * @access protected |
1331 | */ |
1332 | var $_dms; |
1333 | |
1334 | /** |
1335 | * SeedDMS_Core_Workflow_Log constructor. |
1336 | * @param $id |
1337 | * @param $document |
1338 | * @param $version |
1339 | * @param $workflow |
1340 | * @param $user |
1341 | * @param $transition |
1342 | * @param $date |
1343 | * @param $comment |
1344 | */ |
1345 | function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) { |
1346 | $this->_id = $id; |
1347 | $this->_document = $document; |
1348 | $this->_version = $version; |
1349 | $this->_workflow = $workflow; |
1350 | $this->_user = $user; |
1351 | $this->_transition = $transition; |
1352 | $this->_date = $date; |
1353 | $this->_comment = $comment; |
1354 | $this->_dms = null; |
1355 | } |
1356 | |
1357 | /** |
1358 | * @param $dms |
1359 | */ |
1360 | function setDMS($dms) { /* {{{ */ |
1361 | $this->_dms = $dms; |
1362 | } /* }}} */ |
1363 | |
1364 | /** |
1365 | * @return object |
1366 | */ |
1367 | function getTransition() { /* {{{ */ |
1368 | return $this->_transition; |
1369 | } /* }}} */ |
1370 | |
1371 | /** |
1372 | * @return object |
1373 | */ |
1374 | function getWorkflow() { /* {{{ */ |
1375 | return $this->_workflow; |
1376 | } /* }}} */ |
1377 | |
1378 | /** |
1379 | * @return object |
1380 | */ |
1381 | function getUser() { /* {{{ */ |
1382 | return $this->_user; |
1383 | } /* }}} */ |
1384 | |
1385 | /** |
1386 | * @return string |
1387 | */ |
1388 | function getComment() { /* {{{ */ |
1389 | return $this->_comment; |
1390 | } /* }}} */ |
1391 | |
1392 | /** |
1393 | * @return string |
1394 | */ |
1395 | function getDate() { /* {{{ */ |
1396 | return $this->_date; |
1397 | } /* }}} */ |
1398 | |
1399 | } /* }}} */ |
1400 | ?> |