1 | <?php |
---|
2 | |
---|
3 | function getDocument($id) |
---|
4 | { |
---|
5 | if (!is_numeric($id)) |
---|
6 | die ("invalid documentid"); |
---|
7 | |
---|
8 | $queryStr = "SELECT * FROM phpgw_mydms_Documents WHERE id = " . $id; |
---|
9 | $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
10 | if (is_bool($resArr) && $resArr == false) |
---|
11 | return false; |
---|
12 | |
---|
13 | if (count($resArr) != 1) |
---|
14 | return false; |
---|
15 | |
---|
16 | $resArr = $resArr[0]; |
---|
17 | $newDocument = new Document($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["locked"], $resArr["keywords"], $resArr["sequence"]); |
---|
18 | |
---|
19 | if($newDocument->getAccessMode(getUser($GLOBALS['phpgw_info']['user']['account_id'])) > M_NONE) |
---|
20 | return $newDocument; |
---|
21 | else |
---|
22 | return false; |
---|
23 | } |
---|
24 | |
---|
25 | class Document |
---|
26 | { |
---|
27 | var $_id; |
---|
28 | var $_name; |
---|
29 | var $_comment; |
---|
30 | var $_ownerID; |
---|
31 | var $_folderID; |
---|
32 | var $_expires; |
---|
33 | var $_inheritAccess; |
---|
34 | var $_defaultAccess; |
---|
35 | var $_locked; |
---|
36 | var $_keywords; |
---|
37 | var $_sequence; |
---|
38 | |
---|
39 | function Document($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) |
---|
40 | { |
---|
41 | $this->_id = $id; |
---|
42 | $this->_name = $name; |
---|
43 | $this->_comment = $comment; |
---|
44 | $this->_date = $date; |
---|
45 | $this->_expires = $expires; |
---|
46 | $this->_ownerID = $ownerID; |
---|
47 | $this->_folderID = $folderID; |
---|
48 | $this->_inheritAccess = $inheritAccess; |
---|
49 | $this->_defaultAccess = $defaultAccess; |
---|
50 | $this->_locked = $locked; |
---|
51 | $this->_keywords = $keywords; |
---|
52 | $this->_sequence = $sequence; |
---|
53 | |
---|
54 | $this->db = clone($GLOBALS['phpgw']->db); |
---|
55 | $this->db->set_app('mydms'); |
---|
56 | } |
---|
57 | |
---|
58 | function getID() { return $this->_id; } |
---|
59 | |
---|
60 | function getName() { return $this->_name; } |
---|
61 | |
---|
62 | function setName($newName) |
---|
63 | { |
---|
64 | $data = array('name' => $newName); |
---|
65 | $where = array('id' => $this->_id); |
---|
66 | |
---|
67 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
68 | return false; |
---|
69 | } |
---|
70 | |
---|
71 | $this->_name = $newName; |
---|
72 | return true; |
---|
73 | } |
---|
74 | |
---|
75 | function getComment() { return $this->_comment; } |
---|
76 | |
---|
77 | function setComment($newComment) |
---|
78 | { |
---|
79 | $data = array('comment' => $newComment); |
---|
80 | $where = array('id' => $this->_id); |
---|
81 | |
---|
82 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
83 | return false; |
---|
84 | } |
---|
85 | |
---|
86 | $this->_comment = $newComment; |
---|
87 | return true; |
---|
88 | } |
---|
89 | |
---|
90 | function getKeywords() { return $this->_keywords; } |
---|
91 | |
---|
92 | function setKeywords($newKeywords) |
---|
93 | { |
---|
94 | $data = array('keywords' => $newKeywords); |
---|
95 | $where = array('id' => $this->_id); |
---|
96 | |
---|
97 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
98 | return false; |
---|
99 | } |
---|
100 | |
---|
101 | $this->_keywords = $newKeywords; |
---|
102 | return true; |
---|
103 | } |
---|
104 | |
---|
105 | function getDate() |
---|
106 | { |
---|
107 | return $this->_date; |
---|
108 | } |
---|
109 | |
---|
110 | function getFolder() |
---|
111 | { |
---|
112 | if (!isset($this->_folder)) |
---|
113 | $this->_folder = getFolder($this->_folderID); |
---|
114 | return $this->_folder; |
---|
115 | } |
---|
116 | |
---|
117 | function setFolder($newFolder) |
---|
118 | { |
---|
119 | $data = array('folder' => $newFolder->getID()); |
---|
120 | $where = array('id' => $this->_id); |
---|
121 | |
---|
122 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
123 | return false; |
---|
124 | } |
---|
125 | |
---|
126 | $this->_folderID = $newFolder->getID(); |
---|
127 | $this->_folder = $newFolder; |
---|
128 | return true; |
---|
129 | } |
---|
130 | |
---|
131 | function getOwner() |
---|
132 | { |
---|
133 | if (!isset($this->_owner)) |
---|
134 | $this->_owner = getUser($this->_ownerID); |
---|
135 | return $this->_owner; |
---|
136 | } |
---|
137 | |
---|
138 | function setOwner($user) |
---|
139 | { |
---|
140 | $data = array('owner' => $user->getID()); |
---|
141 | $where = array('id' => $this->_id); |
---|
142 | |
---|
143 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
144 | return false; |
---|
145 | } |
---|
146 | |
---|
147 | $this->_ownerID = $user->getID(); |
---|
148 | $this->_owner = $user; |
---|
149 | return true; |
---|
150 | } |
---|
151 | |
---|
152 | function getDefaultAccess() |
---|
153 | { |
---|
154 | if ($this->inheritsAccess()) |
---|
155 | { |
---|
156 | $res = $this->getFolder(); |
---|
157 | if (!$res) return false; |
---|
158 | return $this->_folder->getDefaultAccess(); |
---|
159 | } |
---|
160 | return $this->_defaultAccess; |
---|
161 | } |
---|
162 | |
---|
163 | function setDefaultAccess($mode) |
---|
164 | { |
---|
165 | $data = array('defaultAccess' => $mode); |
---|
166 | $where = array('id' => $this->_id); |
---|
167 | |
---|
168 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
169 | return false; |
---|
170 | } |
---|
171 | |
---|
172 | $this->_defaulAccess = $mode; |
---|
173 | return true; |
---|
174 | } |
---|
175 | |
---|
176 | function inheritsAccess() { return $this->_inheritAccess; } |
---|
177 | |
---|
178 | function setInheritAccess($inheritAccess) |
---|
179 | { |
---|
180 | $inheritAccess = ($inheritAccess) ? "1" : "0"; |
---|
181 | $data = array('inheritAccess' => $inheritAccess); |
---|
182 | $where = array('id' => $this->_id); |
---|
183 | |
---|
184 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
185 | return false; |
---|
186 | } |
---|
187 | |
---|
188 | $this->_inheritAccess = $inheritAccess; |
---|
189 | return true; |
---|
190 | } |
---|
191 | |
---|
192 | function expires() |
---|
193 | { |
---|
194 | if (intval($this->_expires) == 0) |
---|
195 | return false; |
---|
196 | else |
---|
197 | return true; |
---|
198 | } |
---|
199 | |
---|
200 | function getExpires() |
---|
201 | { |
---|
202 | if (intval($this->_expires) == 0) |
---|
203 | return false; |
---|
204 | else |
---|
205 | return $this->_expires; |
---|
206 | } |
---|
207 | |
---|
208 | function setExpires($expires) |
---|
209 | { |
---|
210 | $expires = (!$expires) ? 0 : $expires; |
---|
211 | $data = array('expires' => $expires); |
---|
212 | $where = array('id' => $this->_id); |
---|
213 | |
---|
214 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
215 | return false; |
---|
216 | } |
---|
217 | |
---|
218 | $this->_expires = $expires; |
---|
219 | return true; |
---|
220 | } |
---|
221 | |
---|
222 | function isLocked() { return $this->_locked != -1; } |
---|
223 | |
---|
224 | function setLocked($falseOrUser) |
---|
225 | { |
---|
226 | $locked = (is_object($falseOrUser)) ? $falseOrUser->getID() : -1; |
---|
227 | $data = array('locked' => $locked); |
---|
228 | $where = array('id' => $this->_id); |
---|
229 | |
---|
230 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
231 | return false; |
---|
232 | } |
---|
233 | |
---|
234 | unset($this->_lockingUser); |
---|
235 | $this->_locked = $locked; |
---|
236 | return true; |
---|
237 | } |
---|
238 | |
---|
239 | function getLockingUser() |
---|
240 | { |
---|
241 | if (!$this->isLocked()) |
---|
242 | return false; |
---|
243 | |
---|
244 | if (!isset($this->_lockingUser)) |
---|
245 | $this->_lockingUser = getUser($this->_locked); |
---|
246 | return $this->_lockingUser; |
---|
247 | } |
---|
248 | |
---|
249 | function getSequence() { return $this->_sequence; } |
---|
250 | |
---|
251 | function setSequence($seq) |
---|
252 | { |
---|
253 | $data = array('sequence' => $seq); |
---|
254 | $where = array('id' => $this->_id); |
---|
255 | |
---|
256 | if(!$this->db->update('phpgw_mydms_Documents', $data, $where, __LINE__, __FILE__)) { |
---|
257 | return false; |
---|
258 | } |
---|
259 | |
---|
260 | $this->_sequence = $seq; |
---|
261 | return true; |
---|
262 | } |
---|
263 | |
---|
264 | function clearAccessList() |
---|
265 | { |
---|
266 | $where = array( |
---|
267 | 'targetType' => T_DOCUMENT, |
---|
268 | 'target' => $this->_id, |
---|
269 | ); |
---|
270 | |
---|
271 | if(!$this->db->delete('phpgw_mydms_ACLs', $where, __LINE__, __FILE__)) { |
---|
272 | return false; |
---|
273 | } |
---|
274 | |
---|
275 | unset($this->_accessList); |
---|
276 | return true; |
---|
277 | } |
---|
278 | |
---|
279 | function getAccessList() |
---|
280 | { |
---|
281 | if ($this->inheritsAccess()) |
---|
282 | { |
---|
283 | $res = $this->getFolder(); |
---|
284 | if (!$res) return false; |
---|
285 | return $this->_folder->getAccessList(); |
---|
286 | } |
---|
287 | |
---|
288 | if (!isset($this->_accessList)) |
---|
289 | { |
---|
290 | $cols = array('userID', 'groupID', 'mode'); |
---|
291 | $where = array( |
---|
292 | 'targetType' => T_DOCUMENT, |
---|
293 | 'target' => $this->_id, |
---|
294 | ); |
---|
295 | |
---|
296 | if(!$this->db->select('phpgw_mydms_ACLs', $cols, $where, __LINE__, __FILE__, false, 'ORDER BY targetType')) { |
---|
297 | return false; |
---|
298 | } |
---|
299 | |
---|
300 | $this->_accessList = array("groups" => array(), "users" => array()); |
---|
301 | while ($this->db->next_record()) { |
---|
302 | if ($this->db->f('userID') != -1) |
---|
303 | array_push($this->_accessList["users"], new UserAccess($this->db->f('userid'), $this->db->f('mode'))); |
---|
304 | else //if ($row["groupID"] != -1) |
---|
305 | array_push($this->_accessList["groups"], new GroupAccess($this->db->f('groupid'), $this->db->f('mode'))); |
---|
306 | } |
---|
307 | |
---|
308 | # $queryStr = "SELECT * FROM phpgw_mydms_ACLs WHERE targetType = ".T_DOCUMENT." AND target = " . $this->_id . " ORDER BY targetType"; |
---|
309 | # $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
310 | # if (is_bool($resArr) && !$resArr) |
---|
311 | # return false; |
---|
312 | # |
---|
313 | # $this->_accessList = array("groups" => array(), "users" => array()); |
---|
314 | # foreach ($resArr as $row) |
---|
315 | # { |
---|
316 | # if ($row["userID"] != -1) |
---|
317 | # array_push($this->_accessList["users"], new UserAccess($row["userID"], $row["mode"])); |
---|
318 | # else //if ($row["groupID"] != -1) |
---|
319 | # array_push($this->_accessList["groups"], new GroupAccess($row["groupID"], $row["mode"])); |
---|
320 | # } |
---|
321 | } |
---|
322 | |
---|
323 | return $this->_accessList; |
---|
324 | } |
---|
325 | |
---|
326 | function addAccess($mode, $userOrGroupID, $isUser) |
---|
327 | { |
---|
328 | $userOrGroup = ($isUser) ? "userID" : "groupID"; |
---|
329 | |
---|
330 | $data = array ( |
---|
331 | 'target' => $this->_id, |
---|
332 | 'targetType' => T_DOCUMENT, |
---|
333 | $userOrGroup => $userOrGroupID, |
---|
334 | 'mode' => $mode, |
---|
335 | ); |
---|
336 | $res = $this->db->insert('phpgw_mydms_ACLs', $data, '', __LINE__, __FILE__); |
---|
337 | if (!$res) { |
---|
338 | return false; |
---|
339 | } |
---|
340 | |
---|
341 | #$queryStr = "INSERT INTO phpgw_mydms_ACLs (target, targetType, ".$userOrGroup.", mode) VALUES |
---|
342 | # (".$this->_id.", ".T_DOCUMENT.", " . $userOrGroupID . ", " .$mode. ")"; |
---|
343 | #if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
344 | # return false; |
---|
345 | |
---|
346 | unset($this->_accessList); |
---|
347 | return true; |
---|
348 | } |
---|
349 | |
---|
350 | function changeAccess($newMode, $userOrGroupID, $isUser) |
---|
351 | { |
---|
352 | $userOrGroup = ($isUser) ? "userID" : "groupID"; |
---|
353 | |
---|
354 | $data = array('mode' => $newMode); |
---|
355 | $where = array( |
---|
356 | 'targetType' => T_DOCUMENT, |
---|
357 | 'target' => $this->_id, |
---|
358 | $userOrGroup => $userOrGroupID, |
---|
359 | ); |
---|
360 | |
---|
361 | if(!$this->db->update('phpgw_mydms_ACLs', $data, $where, __LINE__, __FILE__)) { |
---|
362 | return false; |
---|
363 | } |
---|
364 | |
---|
365 | # $queryStr = "UPDATE phpgw_mydms_ACLs SET mode = " . $newMode . " WHERE targetType = ".T_DOCUMENT." AND target = " . $this->_id . " AND " . $userOrGroup . " = " . $userOrGroupID; |
---|
366 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
367 | # return false; |
---|
368 | |
---|
369 | unset($this->_accessList); |
---|
370 | return true; |
---|
371 | } |
---|
372 | |
---|
373 | function removeAccess($userOrGroupID, $isUser) |
---|
374 | { |
---|
375 | $userOrGroup = ($isUser) ? "userID" : "groupID"; |
---|
376 | |
---|
377 | $where = array( |
---|
378 | 'targetType' => T_DOCUMENT, |
---|
379 | 'target' => $this->_id, |
---|
380 | $userOrGroup => $userOrGroupID, |
---|
381 | ); |
---|
382 | |
---|
383 | if(!$this->db->delete('phpgw_mydms_ACLs', $where, __LINE__, __FILE__)) { |
---|
384 | return false; |
---|
385 | } |
---|
386 | |
---|
387 | # $queryStr = "DELETE FROM phpgw_mydms_ACLs WHERE targetType = ".T_DOCUMENT." AND target = ".$this->_id." AND ".$userOrGroup." = " . $userOrGroupID; |
---|
388 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
389 | # return false; |
---|
390 | |
---|
391 | unset($this->_accessList); |
---|
392 | return true; |
---|
393 | } |
---|
394 | |
---|
395 | /* |
---|
396 | * Liefert die Art der Zugriffsberechtigung fï¿œr den User $user; Mï¿œgliche Rechte: n (keine), r (lesen), w (schreiben+lesen), a (alles) |
---|
397 | * Zunï¿œchst wird Geprï¿œft, ob die Berechtigung geerbt werden soll; in diesem Fall wird die Anfrage an den Eltern-Ordner weitergeleitet. |
---|
398 | * Ansonsten werden die ACLs durchgegangen: Die hï¿œchstwertige Berechtigung gilt. |
---|
399 | * Wird bei den ACLs nicht gefunden, wird die Standard-Berechtigung zurï¿œckgegeben. |
---|
400 | * Ach ja: handelt es sich bei $user um den Besitzer ist die Berechtigung automatisch "a". |
---|
401 | */ |
---|
402 | function getAccessMode($user) |
---|
403 | { |
---|
404 | //Administrator?? |
---|
405 | if ($user->isAdmin()) |
---|
406 | return M_ALL; |
---|
407 | |
---|
408 | //Besitzer?? |
---|
409 | if ($user->getID() == $this->_ownerID) |
---|
410 | return M_ALL; |
---|
411 | |
---|
412 | //Gast-Benutzer?? |
---|
413 | if (($user->getID() == $GLOBALS['mydms']->settings->_guestID) && ($GLOBALS['mydms']->settings->_enableGuestLogin)) |
---|
414 | { |
---|
415 | $mode = $this->getDefaultAccess(); |
---|
416 | if ($mode >= M_READ) |
---|
417 | return M_READ; |
---|
418 | else |
---|
419 | return M_NONE; |
---|
420 | } |
---|
421 | |
---|
422 | //Berechtigung erben?? |
---|
423 | // wird ï¿œber GetAccessList() bereits realisiert. |
---|
424 | // durch das Verwenden der folgenden Zeilen wï¿œren auch Owner-Rechte vererbt worden. |
---|
425 | /* |
---|
426 | if ($this->inheritsAccess()) |
---|
427 | { |
---|
428 | if (!$this->getFolder()) |
---|
429 | return false; |
---|
430 | return $this->_folder->getAccessMode($user); |
---|
431 | } |
---|
432 | */ |
---|
433 | $highestPrivileged = M_NONE; |
---|
434 | |
---|
435 | //ACLs durchforsten |
---|
436 | $foundInACL = false; |
---|
437 | $accessList = $this->getAccessList(); |
---|
438 | if (!$accessList) |
---|
439 | return false; |
---|
440 | |
---|
441 | foreach ($accessList["users"] as $userAccess) |
---|
442 | { |
---|
443 | if ($userAccess->getUserID() == $user->getID()) |
---|
444 | { |
---|
445 | $foundInACL = true; |
---|
446 | if ($userAccess->getMode() > $highestPrivileged) |
---|
447 | $highestPrivileged = $userAccess->getMode(); |
---|
448 | if ($highestPrivileged == M_ALL) //hï¿œher geht's nicht -> wir kï¿œnnen uns die arbeit schenken |
---|
449 | return $highestPrivileged; |
---|
450 | } |
---|
451 | } |
---|
452 | foreach ($accessList["groups"] as $groupAccess) |
---|
453 | { |
---|
454 | if ($user->isMemberOfGroup($groupAccess->getGroup())) |
---|
455 | { |
---|
456 | $foundInACL = true; |
---|
457 | if ($groupAccess->getMode() > $highestPrivileged) |
---|
458 | $highestPrivileged = $groupAccess->getMode(); |
---|
459 | if ($highestPrivileged == M_ALL) //hï¿œher geht's nicht -> wir kï¿œnnen uns die arbeit schenken |
---|
460 | return $highestPrivileged; |
---|
461 | } |
---|
462 | } |
---|
463 | if ($foundInACL) |
---|
464 | return $highestPrivileged; |
---|
465 | |
---|
466 | //Standard-Berechtigung verwenden |
---|
467 | return $this->getDefaultAccess(); |
---|
468 | } |
---|
469 | |
---|
470 | function getNotifyList() |
---|
471 | { |
---|
472 | if (!isset($this->_notifyList)) |
---|
473 | { |
---|
474 | $cols = array('userID', 'groupID'); |
---|
475 | $where = array( |
---|
476 | 'targetType' => T_DOCUMENT, |
---|
477 | 'target' => $this->_id, |
---|
478 | ); |
---|
479 | |
---|
480 | if(!$this->db->select('phpgw_mydms_Notify', $cols, $where, __LINE__, __FILE__)) { |
---|
481 | return false; |
---|
482 | } |
---|
483 | |
---|
484 | $this->_notifyList = array("groups" => array(), "users" => array()); |
---|
485 | while ($this->db->next_record()) { |
---|
486 | if ($this->db->f('userID') != -1) |
---|
487 | array_push($this->_notifyList["users"], getUser($this->db->f('userid'))); |
---|
488 | else //if ($row["groupID"] != -1) |
---|
489 | array_push($this->_notifyList["groups"], getGroup($this->db->f('groupid'))); |
---|
490 | } |
---|
491 | |
---|
492 | # $queryStr ="SELECT * FROM phpgw_mydms_Notify WHERE targetType = " . T_DOCUMENT . " AND target = " . $this->_id; |
---|
493 | # $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
494 | # if (is_bool($resArr) && $resArr == false) |
---|
495 | # return false; |
---|
496 | # |
---|
497 | # $this->_notifyList = array("groups" => array(), "users" => array()); |
---|
498 | # foreach ($resArr as $row) |
---|
499 | # { |
---|
500 | # if ($row["userID"] != -1) |
---|
501 | # array_push($this->_notifyList["users"], getUser($row["userID"]) ); |
---|
502 | # else //if ($row["groupID"] != -1) |
---|
503 | # array_push($this->_notifyList["groups"], getGroup($row["groupID"]) ); |
---|
504 | # } |
---|
505 | } |
---|
506 | return $this->_notifyList; |
---|
507 | } |
---|
508 | |
---|
509 | function addNotify($userOrGroupID, $isUser) |
---|
510 | { |
---|
511 | $userOrGroup = ($isUser) ? "userID" : "groupID"; |
---|
512 | |
---|
513 | $data = array ( |
---|
514 | 'target' => $this->_id, |
---|
515 | 'targetType' => T_DOCUMENT, |
---|
516 | $userOrGroup => $userOrGroupID, |
---|
517 | ); |
---|
518 | $res = $this->db->insert('phpgw_mydms_Notify', $data, '', __LINE__, __FILE__); |
---|
519 | if (!$res) { |
---|
520 | return false; |
---|
521 | } |
---|
522 | |
---|
523 | # $queryStr = "INSERT INTO phpgw_mydms_Notify (target, targetType, " . $userOrGroup . ") VALUES (" . $this->_id . ", " . T_DOCUMENT . ", " . $userOrGroupID . ")"; |
---|
524 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
525 | # return false; |
---|
526 | |
---|
527 | unset($this->_notifyList); |
---|
528 | return true; |
---|
529 | } |
---|
530 | |
---|
531 | function removeNotify($userOrGroupID, $isUser) |
---|
532 | { |
---|
533 | $userOrGroup = ($isUser) ? "userID" : "groupID"; |
---|
534 | |
---|
535 | $where = array( |
---|
536 | 'targetType' => T_DOCUMENT, |
---|
537 | 'target' => $this->_id, |
---|
538 | $userOrGroup => $userOrGroupID, |
---|
539 | ); |
---|
540 | |
---|
541 | if(!$this->db->delete('phpgw_mydms_Notify', $where, __LINE__, __FILE__)) { |
---|
542 | return false; |
---|
543 | } |
---|
544 | |
---|
545 | # $queryStr = "DELETE FROM phpgw_mydms_Notify WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT . " AND " . $userOrGroup . " = " . $userOrGroupID; |
---|
546 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
547 | # return false; |
---|
548 | |
---|
549 | unset($this->_notifyList); |
---|
550 | return true; |
---|
551 | } |
---|
552 | |
---|
553 | |
---|
554 | function addContent($comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType) |
---|
555 | { |
---|
556 | // if ($this->isLocked() && ($user->getID() != $this->getLockingUser()->getID())) |
---|
557 | // return false; |
---|
558 | |
---|
559 | $res = $this->getContent(); |
---|
560 | if (is_bool($res) && !$res) |
---|
561 | return false; |
---|
562 | |
---|
563 | if (count($this->_content) == 0) { |
---|
564 | $newVersion = 1; |
---|
565 | } else { |
---|
566 | $res = $this->getLatestContent(); |
---|
567 | if (is_bool($res) && !$res) |
---|
568 | return false; |
---|
569 | $newVersion = $this->_latestContent->getVersion()+1; |
---|
570 | } |
---|
571 | |
---|
572 | $dir = getSuitableDocumentDir(); |
---|
573 | if (is_bool($res) && !$res) |
---|
574 | return false; |
---|
575 | |
---|
576 | //Kopieren der temporï¿œren Datei |
---|
577 | if(!file_exists($GLOBALS['mydms']->settings->_contentDir . $dir)) |
---|
578 | { |
---|
579 | if (!makeDir($GLOBALS['mydms']->settings->_contentDir . $dir)) |
---|
580 | return false; |
---|
581 | } |
---|
582 | |
---|
583 | if (!copyFile($tmpFile, $GLOBALS['mydms']->settings->_contentDir . $dir . "data" . $fileType)) |
---|
584 | return false; |
---|
585 | |
---|
586 | //Eintrag in phpgw_mydms_DocumentContent |
---|
587 | $insertData = array( |
---|
588 | 'document' => $this->_id, |
---|
589 | 'version' => $newVersion, |
---|
590 | 'comment' => $comment, |
---|
591 | 'date' => mktime(), |
---|
592 | 'createdBy' => $user->getID(), |
---|
593 | 'dir' => $dir, |
---|
594 | 'orgFileName' => $orgFileName, |
---|
595 | 'fileType' => $fileType, |
---|
596 | 'mimeType' => $mimeType, |
---|
597 | ); |
---|
598 | $res = $this->db->insert('phpgw_mydms_DocumentContent', $insertData, '', __LINE__, __FILE__); |
---|
599 | if (!$res) |
---|
600 | return false; |
---|
601 | |
---|
602 | # $queryStr = "INSERT INTO phpgw_mydms_DocumentContent (document, version, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ". |
---|
603 | # "(".$this->_id.", ".$newVersion.", '".$comment."', ".mktime().", ".$user->getID().", '".$dir."', '".$orgFileName."', '".$fileType."', '" . $mimeType . "')"; |
---|
604 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
605 | # return false; |
---|
606 | |
---|
607 | unset($this->_content); |
---|
608 | unset($this->_latestContent); |
---|
609 | |
---|
610 | $this->getLatestContent(); |
---|
611 | # if ($GLOBALS['mydms']->settings->_enableConverting && in_array($this->_latestContent->getFileType(), array_keys($GLOBALS['mydms']->settings->_convertFileTypes))) |
---|
612 | # $this->_latestContent->convert(); //Auch wenn das schiefgeht, wird deswegen nicht gleich alles "hingeschmissen" (sprich: false zurï¿œckgegeben) |
---|
613 | |
---|
614 | // $this->setLocked(false); |
---|
615 | |
---|
616 | return true; |
---|
617 | } |
---|
618 | |
---|
619 | function getContent() |
---|
620 | { |
---|
621 | if (!isset($this->_content)) |
---|
622 | { |
---|
623 | $cols = array('id', 'document', 'version', 'comment', 'date', 'createdBy', 'dir', 'orgFileName', 'fileType', 'mimeType'); |
---|
624 | $where = array( |
---|
625 | 'document' => $this->_id, |
---|
626 | ); |
---|
627 | |
---|
628 | if(!$this->db->select('phpgw_mydms_DocumentContent', $cols, $where, __LINE__, __FILE__, false, 'ORDER BY version')) { |
---|
629 | return false; |
---|
630 | } |
---|
631 | |
---|
632 | $this->_content = array(); |
---|
633 | while ($this->db->next_record()) { |
---|
634 | array_push( |
---|
635 | $this->_content, |
---|
636 | new DocumentContent( |
---|
637 | $this->db->f('id'), |
---|
638 | $this->db->f('document'), |
---|
639 | $this->db->f('version'), |
---|
640 | $this->db->f('comment'), |
---|
641 | $this->db->f('date'), |
---|
642 | $this->db->f('createdby'), |
---|
643 | $this->db->f('dir'), |
---|
644 | $this->db->f('orgfilename'), |
---|
645 | $this->db->f('filetype'), |
---|
646 | $this->db->f('mimetype') |
---|
647 | ) |
---|
648 | ); |
---|
649 | } |
---|
650 | |
---|
651 | # $queryStr = "SELECT * FROM phpgw_mydms_DocumentContent WHERE document = ".$this->_id." ORDER BY version"; |
---|
652 | # $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
653 | # if (is_bool($resArr) && !$res) |
---|
654 | # return false; |
---|
655 | # |
---|
656 | # $this->_content = array(); |
---|
657 | # foreach ($resArr as $row) |
---|
658 | # array_push($this->_content, new DocumentContent($row["id"], $row["document"], $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"])); |
---|
659 | } |
---|
660 | |
---|
661 | return $this->_content; |
---|
662 | } |
---|
663 | |
---|
664 | function getContentByVersion($version) |
---|
665 | { |
---|
666 | if (!is_numeric($version)) |
---|
667 | die ("invalid version"); |
---|
668 | |
---|
669 | if (isset($this->_content)) |
---|
670 | { |
---|
671 | foreach ($this->_content as $revision) |
---|
672 | { |
---|
673 | if ($revision->getVersion() == $version) |
---|
674 | return $revision; |
---|
675 | } |
---|
676 | return false; |
---|
677 | } |
---|
678 | |
---|
679 | $cols = array('id', 'document', 'version', 'comment', 'date', 'createdBy', 'dir', 'orgFileName', 'fileType', 'mimeType'); |
---|
680 | $where = array( |
---|
681 | 'document' => $this->_id, |
---|
682 | 'version' => $version, |
---|
683 | ); |
---|
684 | |
---|
685 | if(!$this->db->select('phpgw_mydms_DocumentContent', $cols, $where, __LINE__, __FILE__)) { |
---|
686 | return false; |
---|
687 | } |
---|
688 | |
---|
689 | if ($this->db->next_record()) { |
---|
690 | return new DocumentContent( |
---|
691 | $this->db->f('id'), |
---|
692 | $this->db->f('document'), |
---|
693 | $this->db->f('version'), |
---|
694 | $this->db->f('comment'), |
---|
695 | $this->db->f('date'), |
---|
696 | $this->db->f('createdby'), |
---|
697 | $this->db->f('dir'), |
---|
698 | $this->db->f('orgfilename'), |
---|
699 | $this->db->f('filetype'), |
---|
700 | $this->db->f('mimetype') |
---|
701 | ); |
---|
702 | } else { |
---|
703 | return false; |
---|
704 | } |
---|
705 | |
---|
706 | # $queryStr = "SELECT * FROM phpgw_mydms_DocumentContent WHERE document = ".$this->_id." AND version = " . $version; |
---|
707 | # $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
708 | # if (is_bool($resArr) && !$res) |
---|
709 | # return false; |
---|
710 | # if (count($resArr) != 1) |
---|
711 | # return false; |
---|
712 | # |
---|
713 | # $resArr = $resArr[0]; |
---|
714 | # return new DocumentContent($resArr["id"], $resArr["document"], $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]); |
---|
715 | } |
---|
716 | |
---|
717 | function getLatestContent() |
---|
718 | { |
---|
719 | if (!isset($this->_latestContent)) |
---|
720 | { |
---|
721 | /* if (isset($this->_content)) |
---|
722 | { |
---|
723 | $this->getContent(); |
---|
724 | $this->_latestContent = $this->_content[count($this->_content)-1]; |
---|
725 | return $this->_latestContent; |
---|
726 | } |
---|
727 | */ |
---|
728 | $cols = array('id', 'document', 'version', 'comment', 'date', 'createdBy', 'dir', 'orgFileName', 'fileType', 'mimeType'); |
---|
729 | $where = array( |
---|
730 | 'document' => $this->_id, |
---|
731 | ); |
---|
732 | |
---|
733 | if(!$this->db->select('phpgw_mydms_DocumentContent', $cols, $where, __LINE__, __FILE__, false, 'ORDER BY version DESC')) { |
---|
734 | return false; |
---|
735 | } |
---|
736 | |
---|
737 | $this->_latestContent = array(); |
---|
738 | if ($this->db->next_record()) { |
---|
739 | $this->_latestContent = new DocumentContent( |
---|
740 | $this->db->f('id'), |
---|
741 | $this->db->f('document'), |
---|
742 | $this->db->f('version'), |
---|
743 | $this->db->f('comment'), |
---|
744 | $this->db->f('date'), |
---|
745 | $this->db->f('createdby'), |
---|
746 | $this->db->f('dir'), |
---|
747 | $this->db->f('orgfilename'), |
---|
748 | $this->db->f('filetype'), |
---|
749 | $this->db->f('mimeType') |
---|
750 | ); |
---|
751 | } |
---|
752 | |
---|
753 | # $queryStr = "SELECT * FROM phpgw_mydms_DocumentContent WHERE document = ".$this->_id." ORDER BY version DESC"; |
---|
754 | # $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
755 | # if (is_bool($resArr) && !$resArr) |
---|
756 | # return false; |
---|
757 | # |
---|
758 | # $resArr = $resArr[0]; |
---|
759 | # $this->_latestContent = new DocumentContent($resArr["id"], $resArr["document"], $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]); |
---|
760 | } |
---|
761 | return $this->_latestContent; |
---|
762 | } |
---|
763 | |
---|
764 | function getDocumentLinks() |
---|
765 | { |
---|
766 | if (!isset($this->_documentLinks)) |
---|
767 | { |
---|
768 | $queryStr = "SELECT * FROM phpgw_mydms_DocumentLinks WHERE document = " . $this->_id; |
---|
769 | $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
770 | if (is_bool($resArr) && !$resArr) |
---|
771 | return false; |
---|
772 | $this->_documentLinks = array(); |
---|
773 | |
---|
774 | foreach ($resArr as $row) |
---|
775 | array_push($this->_documentLinks, new DocumentLink($row["id"], $row["document"], $row["target"], $row["userID"], $row["public"])); |
---|
776 | } |
---|
777 | return $this->_documentLinks; |
---|
778 | } |
---|
779 | |
---|
780 | function addDocumentLink($targetID, $userID, $public) |
---|
781 | { |
---|
782 | $data = array( |
---|
783 | 'document' => $this->_id, |
---|
784 | 'target' => $targetID, |
---|
785 | 'userID' => $userID, |
---|
786 | 'public' => $GLOBALS['phpgw']->db->quote($public,'bool'), |
---|
787 | ); |
---|
788 | $res = $this->db->insert('phpgw_mydms_DocumentLinks', $data, '', __LINE__, __FILE__); |
---|
789 | if (!$res) |
---|
790 | return false; |
---|
791 | |
---|
792 | # $queryStr = "INSERT INTO phpgw_mydms_DocumentLinks(document, target, userID, public) VALUES (".$this->_id.", ".$targetID.", ".$userID.", " . $GLOBALS['phpgw']->db->quote($public,'bool').")"; |
---|
793 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
794 | # return false; |
---|
795 | |
---|
796 | unset($this->_documentLinks); |
---|
797 | return true; |
---|
798 | } |
---|
799 | |
---|
800 | function removeDocumentLink($linkID) |
---|
801 | { |
---|
802 | $where = array( |
---|
803 | 'id' => $linkID, |
---|
804 | ); |
---|
805 | |
---|
806 | if(!$this->db->delete('phpgw_mydms_DocumentLinks', $where, __LINE__, __FILE__)) { |
---|
807 | return false; |
---|
808 | } |
---|
809 | |
---|
810 | # $queryStr = "DELETE FROM phpgw_mydms_DocumentLinks WHERE id = " . $linkID; |
---|
811 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
812 | # return false; |
---|
813 | unset ($this->_documentLinks); |
---|
814 | return true; |
---|
815 | } |
---|
816 | |
---|
817 | |
---|
818 | function remove() |
---|
819 | { |
---|
820 | $res = $this->getContent(); |
---|
821 | if (is_bool($res) && !$res) return false; |
---|
822 | |
---|
823 | for ($i = 0; $i < count($this->_content); $i++) { |
---|
824 | if (!$this->_content[$i]->remove()) { |
---|
825 | return false; |
---|
826 | } |
---|
827 | } |
---|
828 | |
---|
829 | $where = array('id' => $this->_id); |
---|
830 | if(!$this->db->delete('phpgw_mydms_Documents', $where, __LINE__, __FILE__)) { |
---|
831 | return false; |
---|
832 | } |
---|
833 | |
---|
834 | $where = array('target' => $this->_id, 'targetType' => T_DOCUMENT); |
---|
835 | if(!$this->db->delete('phpgw_mydms_ACLs', $where, __LINE__, __FILE__)) { |
---|
836 | return false; |
---|
837 | } |
---|
838 | if(!$this->db->delete('phpgw_mydms_Notify', $where, __LINE__, __FILE__)) { |
---|
839 | return false; |
---|
840 | } |
---|
841 | |
---|
842 | $where = array('document' => $this->_id, 'target' => $this->_id); |
---|
843 | if(!$this->db->delete('phpgw_mydms_DocumentLinks', $where, __LINE__, __FILE__)) { |
---|
844 | return false; |
---|
845 | } |
---|
846 | |
---|
847 | # $queryStr = "DELETE FROM phpgw_mydms_Documents WHERE id = " . $this->_id; |
---|
848 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
849 | # return false; |
---|
850 | # $queryStr = "DELETE FROM phpgw_mydms_ACLs WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT; |
---|
851 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
852 | # return false; |
---|
853 | # $queryStr = "DELETE FROM phpgw_mydms_Notify WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT; |
---|
854 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
855 | # return false; |
---|
856 | # $queryStr = "DELETE FROM phpgw_mydms_DocumentLinks WHERE document = " . $this->_id . " OR target = " . $this->_id; |
---|
857 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
858 | # return false; |
---|
859 | |
---|
860 | return true; |
---|
861 | } |
---|
862 | } |
---|
863 | |
---|
864 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
865 | |
---|
866 | /** |
---|
867 | * Die Datei wird als "data.ext" (z.b. data.txt) gespeichert. Getrennt davon wird in der DB der ursprï¿œngliche |
---|
868 | * Dateiname festgehalten (-> $orgFileName). Die Datei wird deshalb nicht unter diesem ursprï¿œnglichen Namen |
---|
869 | * gespeichert, da es zu Problemen mit verschiedenen Dateisystemen kommen kann: Linux hat z.b. Probleme mit |
---|
870 | * deutschen Umlauten, wï¿œhrend Windows wiederum den Doppelpunkt in Dateinamen nicht verwenden kann. |
---|
871 | * Der ursprï¿œngliche Dateiname wird nur zum Download verwendet (siehe op.Download.pgp) |
---|
872 | */ |
---|
873 | class DocumentContent |
---|
874 | { |
---|
875 | |
---|
876 | function DocumentContent($id, $documentID, $version, $comment, $date, $userID, $dir, $orgFileName, $fileType, $mimeType) |
---|
877 | { |
---|
878 | $this->_id = $id; |
---|
879 | $this->_documentID = $documentID; |
---|
880 | $this->_version = $version; |
---|
881 | $this->_comment = $comment; |
---|
882 | $this->_date = $date; |
---|
883 | $this->_userID = $userID; |
---|
884 | $this->_dir = $dir; |
---|
885 | $this->_orgFileName = $orgFileName; |
---|
886 | $this->_fileType = $fileType; |
---|
887 | $this->_mimeType = $mimeType; |
---|
888 | |
---|
889 | $this->db = clone($GLOBALS['phpgw']->db); |
---|
890 | $this->db->set_app('mydms'); |
---|
891 | } |
---|
892 | |
---|
893 | function getVersion() { return $this->_version; } |
---|
894 | function getComment() { return $this->_comment; } |
---|
895 | function getDate() { return $this->_date; } |
---|
896 | function getOriginalFileName() { return $this->_orgFileName; } |
---|
897 | function getFileType() { return $this->_fileType; } |
---|
898 | function getFileName(){ return "data" . $this->_fileType; } |
---|
899 | function getDir() { return $this->_dir; } |
---|
900 | function getMimeType() { return $this->_mimeType; } |
---|
901 | function getUser() |
---|
902 | { |
---|
903 | if (!isset($this->_user)) |
---|
904 | $this->_user = getUser($this->_userID); |
---|
905 | return $this->_user; |
---|
906 | } |
---|
907 | function getPath() { return $this->_dir ."data" . $this->_fileType; } |
---|
908 | |
---|
909 | function convert() |
---|
910 | { |
---|
911 | if (file_exists($GLOBALS['mydms']->settings->_contentDir . $this->_dir . "index.html")) |
---|
912 | return true; |
---|
913 | |
---|
914 | if (!in_array($this->_fileType, array_keys($GLOBALS['mydms']->settings->_convertFileTypes))) |
---|
915 | return false; |
---|
916 | |
---|
917 | $source = $GLOBALS['mydms']->settings->_contentDir . $this->_dir . $this->getFileName(); |
---|
918 | $target = $GLOBALS['mydms']->settings->_contentDir . $this->_dir . "index.html"; |
---|
919 | // $source = str_replace("/", "\\", $source); |
---|
920 | // $target = str_replace("/", "\\", $target); |
---|
921 | |
---|
922 | $command = $GLOBALS['mydms']->settings->_convertFileTypes[$this->_fileType]; |
---|
923 | $command = str_replace("{SOURCE}", "\"$source\"", $command); |
---|
924 | $command = str_replace("{TARGET}", "\"$target\"", $command); |
---|
925 | |
---|
926 | $output = array(); |
---|
927 | $res = 0; |
---|
928 | exec($command, $output, $res); |
---|
929 | |
---|
930 | if ($res != 0) |
---|
931 | { |
---|
932 | print (implode("\n", $output)); |
---|
933 | return false; |
---|
934 | } |
---|
935 | return true; |
---|
936 | } |
---|
937 | |
---|
938 | function viewOnline() |
---|
939 | { |
---|
940 | if (in_array($this->_fileType, $GLOBALS['mydms']->settings->_viewOnlineFileTypes)) |
---|
941 | return true; |
---|
942 | if ($GLOBALS['mydms']->settings->_enableConverting && in_array($this->_fileType, array_keys($GLOBALS['mydms']->settings->_convertFileTypes))) |
---|
943 | if ($this->wasConverted()) |
---|
944 | return true; |
---|
945 | |
---|
946 | return false; |
---|
947 | } |
---|
948 | |
---|
949 | function wasConverted() |
---|
950 | { |
---|
951 | return file_exists($GLOBALS['mydms']->settings->_contentDir . $this->_dir . "index.html"); |
---|
952 | } |
---|
953 | |
---|
954 | function getURL() |
---|
955 | { |
---|
956 | if (!$this->viewOnline()) |
---|
957 | return false; |
---|
958 | |
---|
959 | if (in_array($this->_fileType, $GLOBALS['mydms']->settings->_viewOnlineFileTypes)) |
---|
960 | return "/" . $this->_documentID . "/" . $this->_version . "/" . $this->getOriginalFileName(); |
---|
961 | else |
---|
962 | return "/" . $this->_documentID . "/" . $this->_version . "/index.html"; |
---|
963 | } |
---|
964 | |
---|
965 | function remove() |
---|
966 | { |
---|
967 | # does this check make sense here??? Lars |
---|
968 | #if (!removeDir($GLOBALS['mydms']->settings->_contentDir . $this->_dir)) { |
---|
969 | # return false; |
---|
970 | #} |
---|
971 | |
---|
972 | $where = array( |
---|
973 | 'id' => $this->_id, |
---|
974 | ); |
---|
975 | |
---|
976 | if(!$this->db->delete('phpgw_mydms_DocumentContent', $where, __LINE__, __FILE__)) { |
---|
977 | return false; |
---|
978 | } |
---|
979 | |
---|
980 | return true; |
---|
981 | } |
---|
982 | } |
---|
983 | |
---|
984 | |
---|
985 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
986 | function getDocumentLink($linkID) |
---|
987 | { |
---|
988 | if (!is_numeric($linkID)) |
---|
989 | die ("invalid linkID"); |
---|
990 | |
---|
991 | $queryStr = "SELECT * FROM phpgw_mydms_DocumentLinks WHERE id = " . $linkID; |
---|
992 | $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr); |
---|
993 | if (is_bool($resArr) && !$resArr) |
---|
994 | return false; |
---|
995 | |
---|
996 | $resArr = $resArr[0]; |
---|
997 | return new DocumentLink($resArr["id"], $resArr["document"], $resArr["target"], $resArr["userID"], $resArr["public"]); |
---|
998 | } |
---|
999 | |
---|
1000 | function filterDocumentLinks($user, $links) |
---|
1001 | { |
---|
1002 | $tmp = array(); |
---|
1003 | foreach ($links as $link) |
---|
1004 | if ($link->isPublic() || ($link->_userID == $user->getID()) || ($user->getID() == $GLOBALS['mydms']->settings->_adminID) ) |
---|
1005 | array_push($tmp, $link); |
---|
1006 | return $tmp; |
---|
1007 | } |
---|
1008 | |
---|
1009 | class DocumentLink |
---|
1010 | { |
---|
1011 | var $_id; |
---|
1012 | var $_documentID; |
---|
1013 | var $_targetID; |
---|
1014 | var $_userID; |
---|
1015 | var $_public; |
---|
1016 | |
---|
1017 | function DocumentLink($id, $documentID, $targetID, $userID, $public) |
---|
1018 | { |
---|
1019 | $this->_id = $id; |
---|
1020 | $this->_documentID = $documentID; |
---|
1021 | $this->_targetID = $targetID; |
---|
1022 | $this->_userID = $userID; |
---|
1023 | $this->_public = $public; |
---|
1024 | |
---|
1025 | $this->db = clone($GLOBALS['phpgw']->db); |
---|
1026 | $this->db->set_app('mydms'); |
---|
1027 | } |
---|
1028 | |
---|
1029 | function getID() { return $this->_id; } |
---|
1030 | |
---|
1031 | function getDocument() |
---|
1032 | { |
---|
1033 | if (!isset($this->_document)) |
---|
1034 | $this->_document = getDocument($this->_documentID); |
---|
1035 | return $this->_document; |
---|
1036 | } |
---|
1037 | |
---|
1038 | function getTarget() |
---|
1039 | { |
---|
1040 | if (!isset($this->_target)) |
---|
1041 | $this->_target = getDocument($this->_targetID); |
---|
1042 | return $this->_target; |
---|
1043 | } |
---|
1044 | |
---|
1045 | function getUser() |
---|
1046 | { |
---|
1047 | if (!isset($this->_user)) |
---|
1048 | $this->_user = getUser($this->_userID); |
---|
1049 | return $this->_user; |
---|
1050 | } |
---|
1051 | |
---|
1052 | function isPublic() { return $this->_public; } |
---|
1053 | |
---|
1054 | function remove() |
---|
1055 | { |
---|
1056 | $where = array( |
---|
1057 | 'id' => $this->_id, |
---|
1058 | ); |
---|
1059 | |
---|
1060 | if(!$this->db->delete('phpgw_mydms_DocumentLinks', $where, __LINE__, __FILE__)) { |
---|
1061 | return false; |
---|
1062 | } |
---|
1063 | # $queryStr = "DELETE FROM phpgw_mydms_DocumentLinks WHERE id = " . $this->_id; |
---|
1064 | # if (!$GLOBALS['mydms']->db->getResult($queryStr)) |
---|
1065 | # return false; |
---|
1066 | |
---|
1067 | return true; |
---|
1068 | } |
---|
1069 | } |
---|