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