removeDocumentLinkBL.php
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* $Id$
*
* Business logic for unlinking a parent document from a child documenbt
*
* Expected form variables:
* $fDocumentLinkID - primary key of document link to delete
* $fChildDocumentID - primary key of child document to which parent document is linked
* $fParentDocumentID - primary key of parent document
*
* Licensed under the GNU GPL. For full terms see the file DOCS/COPYING.
*
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @package presentation.lookAndFeel.knowledgeTree.documentmanagement
*/
require_once("../../../../config/dmsDefaults.php");
if (checkSession()) {
require_once("$default->fileSystemRoot/lib/security/permission.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentLink.inc");
require_once("$default->fileSystemRoot/presentation/Html.inc");
require_once("documentUI.inc");
require_once("removeDocumentLinkUI.inc");
if (Permission::userHasDocumentWritePermission($fParentDocumentID)) {
if (isset($fForDelete)) {
//deleting a document link
$oDocumentLink = DocumentLink::get($fDocumentLinkID);
if ($oDocumentLink->delete()) {
redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fParentDocumentID");
} else {
//an error occured whilst trying to delete the document link
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oParentDocument = Document::get($fParentDocumentID);
$oChildDocument = Document::get($fChildDocumentID);
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getPage($oParentDocument->getName(), $oChildDocument->getName(), $fParentDocumentID));
$main->setCentralPayload($oPatternCustom);
$main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentLinkID=$fDocumentLinkID&fParentDocumentID=$fParentDocumentID&fChildDocumentID=$fChildDocumentID&fForDelete=1");
$main->setErrorMessage("An error occured whilst attempting to delete the link between the two documents");
$main->render();
}
} else {
//user has document write permission and can therefore remove the
//link between the two documents
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oParentDocument = Document::get($fParentDocumentID);
$oChildDocument = Document::get($fChildDocumentID);
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getPage($oParentDocument->getName(), $oChildDocument->getName(), $fParentDocumentID));
$main->setCentralPayload($oPatternCustom);
$main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentLinkID=$fDocumentLinkID&fParentDocumentID=$fParentDocumentID&fChildDocumentID=$fChildDocumentID&fForDelete=1");
$main->render();
}
} else {
//user does not have permission to be here
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml("");
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("You do not have permission to delete links between documents");
$main->render();
}
}
?>