| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 67.23% covered (warning) | 67.23% | 158 / 235 | 52.17% covered (warning) | 52.17% | 12 / 23 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
SeedDMS_Core_Group | 67.23% covered (warning) | 67.23% | 158 / 235 | 52.17% covered (warning) | 52.17% | 12 / 23 | 389.74 | 0.00% covered (danger) | 0.00% | 0 / 1
__construct | 100.00% covered (success) | 100.00% | 4 / 4 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
getInstance | 92.86% covered (success) | 92.86% | 13 / 14 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6.01 |
getAllInstances | 85.71% covered (warning) | 85.71% | 12 / 14 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6.10 |
__toString | 0.00% covered (danger) | 0.00% | 0 / 1 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
isType | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
setDMS | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
getDMS | 0.00% covered (danger) | 0.00% | 0 / 1 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
getID | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
getName | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
setName | 100.00% covered (success) | 100.00% | 9 / 9 | 100.00% covered (success) | 100.00% | 1 / 1 | 3 |
getComment | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 1 / 1 | 1 |
setComment | 100.00% covered (success) | 100.00% | 6 / 6 | 100.00% covered (success) | 100.00% | 1 / 1 | 2 |
getUsers | 100.00% covered (success) | 100.00% | 15 / 15 | 100.00% covered (success) | 100.00% | 1 / 1 | 5 |
getManagers | 92.86% covered (success) | 92.86% | 13 / 14 | 0.00% covered (danger) | 0.00% | 0 / 1 | 4.01 |
addUser | 100.00% covered (success) | 100.00% | 6 / 6 | 100.00% covered (success) | 100.00% | 1 / 1 | 3 |
removeUser | 100.00% covered (success) | 100.00% | 6 / 6 | 100.00% covered (success) | 100.00% | 1 / 1 | 2 |
isMember | 69.23% covered (warning) | 69.23% | 9 / 13 | 0.00% covered (danger) | 0.00% | 0 / 1 | 11.36 |
toggleManager | 100.00% covered (success) | 100.00% | 6 / 6 | 100.00% covered (success) | 100.00% | 1 / 1 | 4 |
remove | 0.00% covered (danger) | 0.00% | 0 / 48 | 0.00% covered (danger) | 0.00% | 0 / 1 | 156 |
getReviewStatus | 91.30% covered (success) | 91.30% | 21 / 23 | 0.00% covered (danger) | 0.00% | 0 / 1 | 8.04 |
getApprovalStatus | 90.91% covered (success) | 90.91% | 20 / 22 | 0.00% covered (danger) | 0.00% | 0 / 1 | 8.05 |
getWorkflowStatus | 0.00% covered (danger) | 0.00% | 0 / 14 | 0.00% covered (danger) | 0.00% | 0 / 1 | 56 |
getNotifications | 92.86% covered (success) | 92.86% | 13 / 14 | 0.00% covered (danger) | 0.00% | 0 / 1 | 5.01 |

1 | <?php
2 | declare(strict_types=1);
3 |
4 | /**
5 | * Implementation of the group 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) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
13 | * 2010-2024 Uwe Steinmann
14 | * @version Release: @package_version@
15 | */
16 |
17 | /**
18 | * Class to represent a user group in the document management system
19 | *
20 | * @category DMS
21 | * @package SeedDMS_Core
22 | * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
23 | * @copyright Copyright (C) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
24 | * 2010-2024 Uwe Steinmann
25 | * @version Release: @package_version@
26 | */
27 | class SeedDMS_Core_Group { /* {{{ */
28 | /**
29 | * The id of the user group
30 | *
31 | * @var integer
32 | */
33 | protected $_id;
34 |
35 | /**
36 | * The name of the user group
37 | *
38 | * @var string
39 | */
40 | protected $_name;
41 |
42 | /**
43 | * @var SeedDMS_Core_User[]
44 | */
45 | protected $_users;
46 |
47 | /**
48 | * The comment of the user group
49 | *
50 | * @var string
51 | */
52 | protected $_comment;
53 |
54 | /**
55 | * Back reference to DMS this user group belongs to
56 | *
57 | * @var SeedDMS_Core_DMS
58 | */
59 | protected $_dms;
60 |
61 | public function __construct($id, $name, $comment) { /* {{{ */
62 | $this->_id = $id;
63 | $this->_name = $name;
64 | $this->_comment = $comment;
65 | $this->_dms = null;
66 | } /* }}} */
67 |
68 | /**
69 | * Return an instance of a group object
70 | *
71 | * @param string|integer $id Id, name of group, depending
72 | * on the 3rd parameter.
73 | * @param SeedDMS_Core_DMS $dms instance of dms
74 | * @param string $by search by group name if set to 'name'.
75 | * Search by Id of group if left empty.
76 | * @return SeedDMS_Core_Group|bool instance of class SeedDMS_Core_Group if group was
77 | * found, null if group was not found, false in case of error
78 | */
79 | public static function getInstance($id, $dms, $by = '') { /* {{{ */
80 | $db = $dms->getDB();
81 |
82 | switch ($by) {
83 | case 'name':
84 | $queryStr = "SELECT * FROM `tblGroups` WHERE `name` = ".$db->qstr($id);
85 | break;
86 | default:
87 | $queryStr = "SELECT * FROM `tblGroups` WHERE `id` = " . (int) $id;
88 | }
89 |
90 | $resArr = $db->getResultArray($queryStr);
91 | if (is_bool($resArr) && $resArr == false)
92 | return false;
93 | elseif (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
94 | return null;
95 |
96 | $resArr = $resArr[0];
97 |
98 | $group = new self($resArr["id"], $resArr["name"], $resArr["comment"]);
99 | $group->setDMS($dms);
100 | return $group;
101 | } /* }}} */
102 |
103 | /**
104 | * Get all groups
105 | *
106 | * @param $orderby set to `name` for odering by name
107 | * @param SeedDMS_Core_DMS $dms
108 | * @return SeedDMS_Core_Group[]|bool list of groups or false in case of an error
109 | */
110 | public static function getAllInstances($orderby, $dms) { /* {{{ */
111 | $db = $dms->getDB();
112 |
113 | switch ($orderby) {
114 | case 'name':
115 | $queryStr = "SELECT * FROM `tblGroups` ORDER BY `name`";
116 | break;
117 | default:
118 | $queryStr = "SELECT * FROM `tblGroups` order by `id`";
119 | }
120 | $resArr = $db->getResultArray($queryStr);
121 |
122 | if (is_bool($resArr) && $resArr == false)
123 | return false;
124 |
125 | $groups = array();
126 | for ($i = 0; $i < count($resArr); $i++) {
127 | $group = new self($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
128 | $group->setDMS($dms);
129 | $groups[$i] = $group;
130 | }
131 |
132 | return $groups;
133 | } /* }}} */
134 |
135 | /**
136 | * Cast to string
137 | *
138 | * @return string
139 | */
140 | public function __toString() { /* {{{ */
141 | return $this->_name;
142 | } /* }}} */
143 |
144 | /**
145 | * Check if this object is of type 'group'.
146 | *
147 | * @param string $type type of object
148 | */
149 | public function isType($type) { /* {{{ */
150 | return $type == 'group';
151 | } /* }}} */
152 |
153 | /**
154 | * @param SeedDMS_Core_DMS $dms
155 | */
156 | public function setDMS($dms) { /* {{{ */
157 | $this->_dms = $dms;
158 | } /* }}} */
159 |
160 | /**
161 | * @return SeedDMS_Core_DMS $dms
162 | */
163 | public function getDMS() {
164 | return $this->_dms;
165 | }
166 |
167 | /**
168 | * Return internal id of group
169 | *
170 | * @return int
171 | */
172 | public function getID() { return $this->_id; }
173 |
174 | /**
175 | * Return name of group
176 | *
177 | * @return string
178 | */
179 | public function getName() { return $this->_name; }
180 |
181 | /**
182 | * Set new name of group
183 | *
184 | * @param $newName new name
185 | * @return bool true on success, otherwise false
186 | */
187 | public function setName($newName) { /* {{{ */
188 | $newName = trim($newName);
189 | if (!$newName)
190 | return false;
191 |
192 | $db = $this->_dms->getDB();
193 |
194 | $queryStr = "UPDATE `tblGroups` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
195 | if (!$db->getResult($queryStr))
196 | return false;
197 |
198 | $this->_name = $newName;
199 | return true;
200 | } /* }}} */
201 |
202 | /**
203 | * Return comment of group
204 | *
205 | * @return string
206 | */
207 | public function getComment() { return $this->_comment; }
208 |
209 | /**
210 | * Set new comment of group
211 | *
212 | * @param $newComment
213 | * @return bool true on success, otherwise false
214 | */
215 | public function setComment($newComment) { /* {{{ */
216 | $db = $this->_dms->getDB();
217 |
218 | $queryStr = "UPDATE `tblGroups` SET `comment` = ".$db->qstr($newComment)." WHERE `id` = " . $this->_id;
219 | if (!$db->getResult($queryStr))
220 | return false;
221 |
222 | $this->_comment = $newComment;
223 | return true;
224 | } /* }}} */
225 |
226 | /**
227 | * Get all users which are members of the group
228 | *
229 | * @return SeedDMS_Core_User[]|bool
230 | */
231 | public function getUsers() { /* {{{ */
232 | $db = $this->_dms->getDB();
233 |
234 | if (!isset($this->_users)) {
235 | $queryStr = "SELECT `tblUsers`.* FROM `tblUsers` ".
236 | "LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` ".
237 | "WHERE `tblGroupMembers`.`groupID` = '". $this->_id ."'";
238 | $resArr = $db->getResultArray($queryStr);
239 | if (is_bool($resArr) && $resArr == false)
240 | return false;
241 |
242 | $this->_users = array();
243 |
244 | $classname = $this->_dms->getClassname('user');
245 | foreach ($resArr as $row) {
246 | /** @var SeedDMS_Core_User $user */
247 | $user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']);
248 | $user->setDMS($this->_dms);
249 | array_push($this->_users, $user);
250 | }
251 | }
252 | return $this->_users;
253 | } /* }}} */
254 |
255 | /**
256 | * Get all users which are managers of the group
257 | *
258 | * @return SeedDMS_Core_User[]|bool
259 | */
260 | public function getManagers() { /* {{{ */
261 | $db = $this->_dms->getDB();
262 |
263 | $queryStr = "SELECT `tblUsers`.* FROM `tblUsers` ".
264 | "LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` ".
265 | "WHERE `tblGroupMembers`.`groupID` = '". $this->_id ."' AND `tblGroupMembers`.`manager` = 1";
266 | $resArr = $db->getResultArray($queryStr);
267 | if (is_bool($resArr) && $resArr == false)
268 | return false;
269 |
270 | $managers = array();
271 |
272 | $classname = $this->_dms->getClassname('user');
273 | foreach ($resArr as $row) {
274 | /** @var SeedDMS_Core_User $user */
275 | $user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']);
276 | $user->setDMS($this->_dms);
277 | array_push($managers, $user);
278 | }
279 | return $managers;
280 | } /* }}} */
281 |
282 | /**
283 | * Add user as member
284 | *
285 | * @param SeedDMS_Core_User $user
286 | * @param bool $asManager if set, user will be a manager of the group
287 | * @return bool
288 | */
289 | public function addUser($user, $asManager = false) { /* {{{ */
290 | $db = $this->_dms->getDB();
291 |
292 | $queryStr = "INSERT INTO `tblGroupMembers` (`groupID`, `userID`, `manager`) VALUES (".$this->_id.", ".$user->getID(). ", " . ($asManager?"1":"0") ." )";
293 | $res = $db->getResult($queryStr);
294 |
295 | if (!$res) return false;
296 |
297 | unset($this->_users);
298 | return true;
299 | } /* }}} */
300 |
301 | /**
302 | * Remove users as a member of the group
303 | *
304 | * @param SeedDMS_Core_User $user
305 | * @return bool
306 | */
307 | public function removeUser($user) { /* {{{ */
308 | $db = $this->_dms->getDB();
309 |
310 | $queryStr = "DELETE FROM `tblGroupMembers` WHERE `groupID` = ".$this->_id." AND `userID` = ".$user->getID();
311 | $res = $db->getResult($queryStr);
312 |
313 | if (!$res) return false;
314 | unset($this->_users);
315 | return true;
316 | } /* }}} */
317 |
318 | /**
319 | * Check if user is member of group
320 | *
321 | * @param SeedDMS_Core_User $user user to be checked
322 | * @param boolean $asManager also check whether user is manager of group if
323 | * set to true, otherwise does not care about manager status
324 | * @return boolean true if user is member, otherwise false
325 | */
326 | public function isMember($user, $asManager = false) { /* {{{ */
327 | if (isset($this->_users)&&!$asManager) {
328 | foreach ($this->_users as $usr)
329 | if ($usr->getID() == $user->getID())
330 | return true;
331 | return false;
332 | }
333 |
334 | $db = $this->_dms->getDB();
335 | $queryStr = "SELECT * FROM `tblGroupMembers` WHERE `groupID` = " . $this->_id . " AND `userID` = " . $user->getID();
336 | if ($asManager)
337 | $queryStr .= " AND `manager` = 1";
338 |
339 | $resArr = $db->getResultArray($queryStr);
340 |
341 | if (is_bool($resArr) && $resArr == false) return false;
342 | if (count($resArr) != 1) return false;
343 |
344 | return true;
345 | } /* }}} */
346 |
347 | /**
348 | * Toggle manager status of user
349 | *
350 | * @param SeedDMS_Core_User $user
351 | * @return boolean true if operation was successful, otherwise false
352 | */
353 | public function toggleManager($user) { /* {{{ */
354 | $db = $this->_dms->getDB();
355 |
356 | if (!$this->isMember($user)) return false;
357 |
358 | if ($this->isMember($user, true)) $queryStr = "UPDATE `tblGroupMembers` SET `manager` = 0 WHERE `groupID` = ".$this->_id." AND `userID` = ".$user->getID();
359 | else $queryStr = "UPDATE `tblGroupMembers` SET `manager` = 1 WHERE `groupID` = ".$this->_id." AND `userID` = ".$user->getID();
360 |
361 | if (!$db->getResult($queryStr)) return false;
362 | return true;
363 | } /* }}} */
364 |
365 | /**
366 | * Delete user group
367 | *
368 | * This method deletes the user group and all its references, like access
369 | * control lists, notifications, etc.
370 | *
371 | * @param SeedDMS_Core_User $user the user doing the removal (needed for entry in
372 | * review log.
373 | * @return boolean true on success or false in case of an error
374 | */
375 | public function remove($user) { /* {{{ */
376 | $db = $this->_dms->getDB();
377 |
378 | $db->startTransaction();
379 |
380 | $queryStr = "DELETE FROM `tblGroupMembers` WHERE `groupID` = " . $this->_id;
381 | if (!$db->getResult($queryStr)) {
382 | $db->rollbackTransaction();
383 | return false;
384 | }
385 | $queryStr = "DELETE FROM `tblACLs` WHERE `groupID` = " . $this->_id;
386 | if (!$db->getResult($queryStr)) {
387 | $db->rollbackTransaction();
388 | return false;
389 | }
390 | $queryStr = "DELETE FROM `tblNotify` WHERE `groupID` = " . $this->_id;
391 | if (!$db->getResult($queryStr)) {
392 | $db->rollbackTransaction();
393 | return false;
394 | }
395 | $queryStr = "DELETE FROM `tblMandatoryReviewers` WHERE `reviewerGroupID` = " . $this->_id;
396 | if (!$db->getResult($queryStr)) {
397 | $db->rollbackTransaction();
398 | return false;
399 | }
400 | $queryStr = "DELETE FROM `tblMandatoryApprovers` WHERE `approverGroupID` = " . $this->_id;
401 | if (!$db->getResult($queryStr)) {
402 | $db->rollbackTransaction();
403 | return false;
404 | }
405 | $queryStr = "DELETE FROM `tblWorkflowTransitionGroups` WHERE `groupid` = " . $this->_id;
406 | if (!$db->getResult($queryStr)) {
407 | $db->rollbackTransaction();
408 | return false;
409 | }
410 | $queryStr = "DELETE FROM `tblGroups` WHERE `id` = " . $this->_id;
411 | if (!$db->getResult($queryStr)) {
412 | $db->rollbackTransaction();
413 | return false;
414 | }
415 |
416 | // TODO : update document status if reviewer/approver has been deleted
417 |
418 |
419 | $reviewStatus = $this->getReviewStatus();
420 | foreach ($reviewStatus as $r) {
421 | $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
422 | "VALUES ('". $r["reviewID"] ."', '-2', 'Review group removed from process', ".$db->getCurrentDatetime().", '". $user->getID() ."')";
423 | $res = $db->getResult($queryStr);
424 | if (!$res) {
425 | $db->rollbackTransaction();
426 | return false;
427 | }
428 | }
429 |
430 | $approvalStatus = $this->getApprovalStatus();
431 | foreach ($approvalStatus as $a) {
432 | $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
433 | "VALUES ('". $a["approveID"] ."', '-2', 'Approval group removed from process', ".$db->getCurrentDatetime().", '". $user->getID() ."')";
434 | $res = $db->getResult($queryStr);
435 | if (!$res) {
436 | $db->rollbackTransaction();
437 | return false;
438 | }
439 | }
440 |
441 | $db->commitTransaction();
442 |
443 | return true;
444 | } /* }}} */
445 |
446 | public function getReviewStatus($documentID = null, $version = null) { /* {{{ */
447 | $db = $this->_dms->getDB();
448 |
449 | if (!$db->createTemporaryTable("ttreviewid")) {
450 | return false;
451 | }
452 |
453 | $status = array();
454 |
455 | // See if the group is assigned as a reviewer.
456 | $queryStr = "SELECT `tblDocumentReviewers`.*, `tblDocumentReviewLog`.`status`, ".
457 | "`tblDocumentReviewLog`.`comment`, `tblDocumentReviewLog`.`date`, ".
458 | "`tblDocumentReviewLog`.`userID` ".
459 | "FROM `tblDocumentReviewers` ".
460 | "LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
461 | "LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
462 | "WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
463 | ($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
464 | ($version == null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
465 | "AND `tblDocumentReviewers`.`type`='1' ".
466 | "AND `tblDocumentReviewers`.`required`='". $this->_id ."' ".
467 | "ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
468 | $resArr = $db->getResultArray($queryStr);
469 | if (is_bool($resArr) && $resArr == false)
470 | return false;
471 | if (count($resArr)>0) {
472 | foreach ($resArr as $res)
473 | $status[] = $res;
474 | }
475 | return $status;
476 | } /* }}} */
477 |
478 | public function getApprovalStatus($documentID = null, $version = null) { /* {{{ */
479 | $db = $this->_dms->getDB();
480 |
481 | if (!$db->createTemporaryTable("ttapproveid")) {
482 | return false;
483 | }
484 |
485 | $status = array();
486 |
487 | // See if the group is assigned as an approver.
488 | $queryStr = "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
489 | "`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
490 | "`tblDocumentApproveLog`.`userID` ".
491 | "FROM `tblDocumentApprovers` ".
492 | "LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
493 | "LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
494 | "WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
495 | ($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
496 | ($version == null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
497 | "AND `tblDocumentApprovers`.`type`='1' ".
498 | "AND `tblDocumentApprovers`.`required`='". $this->_id ."' ";
499 | $resArr = $db->getResultArray($queryStr);
500 | if (is_bool($resArr) && $resArr == false)
501 | return false;
502 | if (count($resArr)>0) {
503 | foreach ($resArr as $res)
504 | $status[] = $res;
505 | }
506 |
507 | return $status;
508 | } /* }}} */
509 |
510 | /**
511 | * Get a list of documents with a workflow
512 | *
513 | * @param int $documentID optional document id for which to retrieve the
514 | * reviews
515 | * @param int $version optional version of the document
516 | * @return bool|array list of all workflows
517 | */
518 | public function getWorkflowStatus($documentID = null, $version = null) { /* {{{ */
519 | $db = $this->_dms->getDB();
520 |
521 | $queryStr = 'select distinct d.*, c.`groupid` from `tblWorkflowTransitions` a left join `tblWorkflows` b on a.`workflow`=b.`id` left join `tblWorkflowTransitionGroups` c on a.`id`=c.`transition` left join `tblWorkflowDocumentContent` d on b.`id`=d.`workflow` where d.`document` is not null and a.`state`=d.`state` and c.`groupid`='.$this->_id;
522 | if ($documentID) {
523 | $queryStr .= ' AND d.`document`='.(int) $documentID;
524 | if ($version)
525 | $queryStr .= ' AND d.`version`='.(int) $version;
526 | }
527 | $resArr = $db->getResultArray($queryStr);
528 | if (is_bool($resArr) && $resArr == false)
529 | return false;
530 | $result = array();
531 | if (count($resArr)>0) {
532 | foreach ($resArr as $res) {
533 | $result[] = $res;
534 | }
535 | }
536 | return $result;
537 | } /* }}} */
538 |
539 | /**
540 | * Get all notifications of group
541 | *
542 | * @param integer $type type of item (T_DOCUMENT or T_FOLDER)
543 | * @return SeedDMS_Core_Notification[]|bool array of notifications
544 | */
545 | public function getNotifications($type = 0) { /* {{{ */
546 | $db = $this->_dms->getDB();
547 | $queryStr = "SELECT `tblNotify`.* FROM `tblNotify` ".
548 | "WHERE `tblNotify`.`groupID` = ". $this->_id;
549 | if ($type) {
550 | $queryStr .= " AND `tblNotify`.`targetType` = ". (int) $type;
551 | }
552 |
553 | $resArr = $db->getResultArray($queryStr);
554 | if (is_bool($resArr) && !$resArr)
555 | return false;
556 |
557 | $notifications = array();
558 | foreach ($resArr as $row) {
559 | $not = new SeedDMS_Core_Notification($row["target"], $row["targetType"], $row["userID"], $row["groupID"]);
560 | $not->setDMS($this->_dms);
561 | array_push($notifications, $not);
562 | }
563 |
564 | return $notifications;
565 | } /* }}} */
566 |
567 | } /* }}} */