Commit 142528a8b9816c812c92c6fdd8527ac351e6e7e1
1 parent
7c470e09
Initial revision. Functionality to remove the link between a parent
and a child document git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1893 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
117 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/removeDocumentLinkBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | +* Business logic for unlinking a parent document from a child documenbt | |
| 5 | +* | |
| 6 | +* Expected form variables: | |
| 7 | +* $fDocumentLinkID - primary key of document link to delete | |
| 8 | +* $fChildDocumentID - primary key of child document to which parent document is linked | |
| 9 | +* $fParentDocumentID - primary key of parent document | |
| 10 | +* | |
| 11 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 12 | +* @date 22 May 2003 | |
| 13 | +* | |
| 14 | +*/ | |
| 15 | + | |
| 16 | + | |
| 17 | +require_once("../../../../config/dmsDefaults.php"); | |
| 18 | + | |
| 19 | +if (checkSession()) { | |
| 20 | + require_once("$default->fileSystemRoot/lib/security/permission.inc"); | |
| 21 | + require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 22 | + require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentLink.inc"); | |
| 23 | + require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 24 | + require_once("removeDocumentLinkUI.inc"); | |
| 25 | + | |
| 26 | + | |
| 27 | + if (Permission::userHasDocumentWritePermission($fParentDocumentID)) { | |
| 28 | + if (isset($fForDelete)) { | |
| 29 | + //deleting a document link | |
| 30 | + $oDocumentLink = DocumentLink::get($fDocumentLinkID); | |
| 31 | + if ($oDocumentLink->delete()) { | |
| 32 | + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fParentDocumentID"); | |
| 33 | + } else { | |
| 34 | + //an error occured whilst trying to delete the document link | |
| 35 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 36 | + | |
| 37 | + $oParentDocument = Document::get($fParentDocumentID); | |
| 38 | + $oChildDocument = Document::get($fChildDocumentID); | |
| 39 | + | |
| 40 | + $oPatternCustom = & new PatternCustom(); | |
| 41 | + $oPatternCustom->setHtml(getPage($oParentDocument->getName(), $oChildDocument->getName(), $fParentDocumentID)); | |
| 42 | + $main->setCentralPayload($oPatternCustom); | |
| 43 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentLinkID=$fDocumentLinkID&fParentDocumentID=$fParentDocumentID&fChildDocumentID=$fChildDocumentID&fForDelete=1"); | |
| 44 | + $mail->setErrorMessage("An error occured whilst attempting to delete the link between the two documents"); | |
| 45 | + $main->render(); | |
| 46 | + } | |
| 47 | + } else { | |
| 48 | + //user has document write permission and can therefore remove the | |
| 49 | + //link between the two documents | |
| 50 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 51 | + | |
| 52 | + $oParentDocument = Document::get($fParentDocumentID); | |
| 53 | + $oChildDocument = Document::get($fChildDocumentID); | |
| 54 | + | |
| 55 | + $oPatternCustom = & new PatternCustom(); | |
| 56 | + $oPatternCustom->setHtml(getPage($oParentDocument->getName(), $oChildDocument->getName(), $fParentDocumentID)); | |
| 57 | + $main->setCentralPayload($oPatternCustom); | |
| 58 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentLinkID=$fDocumentLinkID&fParentDocumentID=$fParentDocumentID&fChildDocumentID=$fChildDocumentID&fForDelete=1"); | |
| 59 | + $main->render(); | |
| 60 | + } | |
| 61 | + } else { | |
| 62 | + //user does not have permission to be here | |
| 63 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 64 | + | |
| 65 | + $oPatternCustom = & new PatternCustom(); | |
| 66 | + $oPatternCustom->setHtml(""); | |
| 67 | + $main->setCentralPayload($oPatternCustom); | |
| 68 | + $main->setErrorMessage("You do not have permission to delete links between documents"); | |
| 69 | + $main->render(); | |
| 70 | + } | |
| 71 | +} | |
| 72 | + | |
| 73 | + | |
| 74 | +?> | |
| 0 | 75 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/removeDocumentLinkUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | +* Presentation logic for removing a link between two documents | |
| 4 | +* | |
| 5 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 6 | +* @date 22 May 2003 | |
| 7 | +*/ | |
| 8 | + | |
| 9 | +function renderHeading() { | |
| 10 | + global $default; | |
| 11 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 12 | + $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); | |
| 13 | + $sToRender = "<table border=\"0\" width=\"600\">\n"; | |
| 14 | + $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\"><font color=\"ffffff\">Unlink document</font></th></tr>\n"; | |
| 15 | + $sToRender .= "<tr/>\n"; | |
| 16 | + $sToRender .= "<tr/>\n"; | |
| 17 | + $sToRender .= "</table>\n"; | |
| 18 | + return $sToRender; | |
| 19 | +} | |
| 20 | + | |
| 21 | +function getPage($sParentDocumentName, $sChildDocumentName, $iParentDocumentID) { | |
| 22 | + global $default; | |
| 23 | + $sToRender = renderHeading(); | |
| 24 | + $sToRender .= "<table>\n"; | |
| 25 | + $sToRender .= "<tr>\n"; | |
| 26 | + $sToRender .= "<td>You have chosen to delete the link between the document '$sParentDocumentName' and the document '$sChildDocumentName'</td>\n"; | |
| 27 | + $sToRender .= "</tr>\n"; | |
| 28 | + $sToRender .= "<tr>\n"; | |
| 29 | + $sToRender .= "<td> </td>\n"; | |
| 30 | + $sToRender .= "</tr>\n"; | |
| 31 | + $sToRender .= "<td>Select 'Delete' to confirm or 'Cancel' to cancel</td>\n"; | |
| 32 | + $sToRender .= "</tr>\n"; | |
| 33 | + $sToRender .= "<tr>\n"; | |
| 34 | + $sToRender .= "<td> </td>\n"; | |
| 35 | + $sToRender .= "</tr>\n"; ; | |
| 36 | + $sToRender .= "<tr>\n"; | |
| 37 | + $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/delete.gif\" border=\"0\"></td> <td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $iParentDocumentID . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a></td></tr></table></td>"; | |
| 38 | + $sToRender .= "</tr>"; | |
| 39 | + $sToRender .= "</table>"; | |
| 40 | + return $sToRender; | |
| 41 | +} | |
| 42 | + | |
| 43 | +?> | |
| 0 | 44 | \ No newline at end of file | ... | ... |