Commit dbf1d88e1dc8f70b88e4afa8332bddc269581dc5
1 parent
134ae2f0
Initial revision. Functionality for deleting a depedant document
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1883 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
109 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteDependantDocumentBL.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | +* Business logic for deleting a dependant document | ||
| 5 | +* | ||
| 6 | +* Expected variables: | ||
| 7 | +* $fFolderCollaborationID: primary key of folder collaboration to check | ||
| 8 | +* $fFolderID: folder we are currently editing | ||
| 9 | +* $fDependantDocumentTemplateID: primary key of dependant document to be deleted | ||
| 10 | +* | ||
| 11 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 12 | +* @date 14 May 2003 | ||
| 13 | +* @package presentation.lookAndFeel.knowledgeTree.foldermanagement | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | +require_once("../../../../config/dmsDefaults.php"); | ||
| 17 | + | ||
| 18 | +if (checkSession()) { | ||
| 19 | + if (isset($fFolderID) && isset($fFolderCollaborationID)) { | ||
| 20 | + require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 21 | + require_once("$default->fileSystemRoot/lib/users/User.inc"); | ||
| 22 | + require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc"); | ||
| 23 | + require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 24 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 25 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | ||
| 26 | + require_once("deleteDependantDocumentUI.inc"); | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + if (Permission::userHasFolderWritePermission($fFolderID)) { | ||
| 30 | + //user has permission to alter folder contents | ||
| 31 | + if (isset($fForDelete)) { | ||
| 32 | + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); | ||
| 33 | + if ($oDependantDocumentTemplate->delete()) { | ||
| 34 | + redirect($default->rootUrl . "/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); | ||
| 35 | + } else { | ||
| 36 | + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); | ||
| 37 | + $oUser = User::get($oDependantDocumentTemplate->getDefaultUserId()); | ||
| 38 | + | ||
| 39 | + $oPatternCustom = & new PatternCustom(); | ||
| 40 | + $oPatternCustom->setHtml(getPage($fFolderID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), $oUser->getName(), 'sTemplateDocument')); | ||
| 41 | + $main->setCentralPayload($oPatternCustom); | ||
| 42 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForDelete=1"); | ||
| 43 | + $main->setErrorMessage("An error occured while attempting to delete the depedant document"); | ||
| 44 | + $main->render(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + } else { | ||
| 48 | + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 49 | + | ||
| 50 | + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); | ||
| 51 | + $oUser = User::get($oDependantDocumentTemplate->getDefaultUserId()); | ||
| 52 | + | ||
| 53 | + $oPatternCustom = & new PatternCustom(); | ||
| 54 | + $oPatternCustom->setHtml(getPage($fFolderID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), $oUser->getName(), 'sTemplateDocument')); | ||
| 55 | + $main->setCentralPayload($oPatternCustom); | ||
| 56 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForDelete=1"); | ||
| 57 | + $main->render(); | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + } | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +?> | ||
| 68 | + | ||
| 0 | \ No newline at end of file | 69 | \ No newline at end of file |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteDependantDocumentUI.inc
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** Presentation logic for deleting a dependant document | ||
| 4 | +* | ||
| 5 | +* @author Rob Cherry | ||
| 6 | +* @date 22 May 2002 | ||
| 7 | +* @package presentation.lookAndFeel.knowledgeTree.foldermanagement | ||
| 8 | +*/ | ||
| 9 | + | ||
| 10 | +function renderHeading($sHeading) { | ||
| 11 | + global $default; | ||
| 12 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 13 | + $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); | ||
| 14 | + $sToRender = "<table border=\"0\" width=\"600\">\n"; | ||
| 15 | + $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">$sHeading</th></tr>\n"; | ||
| 16 | + $sToRender .= "<tr/>\n"; | ||
| 17 | + $sToRender .= "<tr/>\n"; | ||
| 18 | + $sToRender .= "</table>\n"; | ||
| 19 | + return $sToRender; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +function getPage($iFolderID, $iFolderCollaborationID, $sDocumentTitle, $sUserName, $sTemplateDocument) { | ||
| 23 | + global $default; | ||
| 24 | + $sToRender = renderHeading("Delete dependant document"); | ||
| 25 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 26 | + $sToRender .= "<tr>\n"; | ||
| 27 | + $sToRender .= "<td>Document title</td><td>$sDocumentTitle</td>"; | ||
| 28 | + $sToRender .= "</tr>\n"; | ||
| 29 | + $sToRender .= "<tr>\n"; | ||
| 30 | + $sToRender .= "<td>User</td><td>$sUserName</td>"; | ||
| 31 | + $sToRender .= "</tr>\n"; | ||
| 32 | + $sToRender .= "<tr>\n"; | ||
| 33 | + $sToRender .= "<td>Template document</td><td>$sTemplateDocument</td>"; | ||
| 34 | + $sToRender .= "<tr>\n"; | ||
| 35 | + $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=viewDependantDocument&fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n"; | ||
| 36 | + $sToRender .= "</table\n"; | ||
| 37 | + | ||
| 38 | + return $sToRender; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +?> | ||
| 0 | \ No newline at end of file | 42 | \ No newline at end of file |