From 8b51b65b067d5e28fa8f886e7fcace2275a0dbea Mon Sep 17 00:00:00 2001 From: rob Date: Thu, 22 May 2003 08:19:12 +0000 Subject: [PATCH] Added delete button to depedant documents --- presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------- presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc | 10 +++++----- 2 files changed, 107 insertions(+), 98 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php index 2c124a2..05cc88a 100644 --- a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php +++ b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php @@ -15,110 +15,119 @@ require_once("../../../../config/dmsDefaults.php"); if (checkSession()) { - if (isset($fFolderID) && isset($fFolderCollaborationID)) { - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); - require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc"); - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); + if (isset($fFolderID) && isset($fFolderCollaborationID)) { + + //folder and collaboration are selected + require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); + require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc"); + require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); - require_once("$default->fileSystemRoot/lib/users/User.inc"); - require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc"); - require_once("$default->fileSystemRoot/presentation/Html.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); - require_once("viewDependantDocumentsUI.inc"); + require_once("$default->fileSystemRoot/lib/users/User.inc"); + require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc"); + require_once("$default->fileSystemRoot/presentation/Html.inc"); + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); + require_once("viewDependantDocumentsUI.inc"); - //folder and collaboration are selected - if (isset($fForStore)) { - $oDependantDocumentTemplate; - if ($fTemplateDocumentID == "-1") { - $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID); - } else { - $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID); - } - if (!($oDependantDocumentTemplate->create())) { - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); - $main->setErrorMessage("An error occured attempting to store the depedant document"); - $main->render(); - } else { - redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); - } - } else if (isset($fForAdd)) { - //we are adding a new dependant document - $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); - if ($oFolderCollaboration->hasDocumentInProcess()) { - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); - $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration"); - $main->render(); + + if (Permission::userHasFolderWritePermission($fFolderID)) { + //user has folder write permission + if (isset($fForStore)) { + $oDependantDocumentTemplate; + if ($fTemplateDocumentID == "-1") { + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID); + } else { + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID); + } + if (!($oDependantDocumentTemplate->create())) { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - } else { - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); + $main->setErrorMessage("An error occured attempting to store the depedant document"); + $main->render(); + } else { + redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); + } + } else if (isset($fForAdd)) { + //we are adding a new dependant document + $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); + if ($oFolderCollaboration->hasDocumentInProcess()) { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") )); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1"); - $main->setHasRequiredFields(true); - $main->render(); - } - } else if (isset($fForEdit)) { - $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); - if ($oFolderCollaboration->hasDocumentInProcess()) { - //can't edit if there is a document currently undergoing collaboration - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForUpdate=1"); - $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration"); - $main->render(); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); + $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration"); + $main->render(); + + } else { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") )); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1"); + $main->setHasRequiredFields(true); + $main->render(); + } + } else if (isset($fForEdit)) { + $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); + if ($oFolderCollaboration->hasDocumentInProcess()) { + //can't edit if there is a document currently undergoing collaboration + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - } else { - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForUpdate=1"); + $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration"); + $main->render(); + + } else { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); + if ($oDependantDocumentTemplate->getTemplateDocumentID() >= 1) { + $oDocument = Document::get($oDependantDocumentTemplate->getTemplateDocumentID()); + } + + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getEditPage($fFolderID, $fDependantDocumentTemplateID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), (isset($oDocument) ? $oDocument->getName() : ""), (isset($oDocument) ? $oDependantDocumentTemplate->getTemplateDocumentID() : null), $oDependantDocumentTemplate->getDefaultUserID())); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForUpdate=1"); + $main->setHasRequiredFields(true); + $main->render(); + } + } else if (isset($fForUpdate)) { + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); + $oDependantDocumentTemplate->setDefaultUserID($fUserID); + $oDependantDocumentTemplate->setDocumentTitle($fDocumentTitle); + $oDependantDocumentTemplate->setTemplateDocumentID((isset($fTemplateDocumentID) ? $fTemplateDocumentID : null)); + $oDependantDocumentTemplate->update(); + + redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); - $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); - if ($oDependantDocumentTemplate->getTemplateDocumentID() >= 1) { - $oDocument = Document::get($oDependantDocumentTemplate->getTemplateDocumentID()); - } + } else { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getEditPage($fFolderID, $fDependantDocumentTemplateID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), (isset($oDocument) ? $oDocument->getName() : ""), (isset($oDocument) ? $oDependantDocumentTemplate->getTemplateDocumentID() : null), $oDependantDocumentTemplate->getDefaultUserID())); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForUpdate=1"); - $main->setHasRequiredFields(true); - $main->render(); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); + $main->render(); } - } else if (isset($fForUpdate)) { - $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); - $oDependantDocumentTemplate->setDefaultUserID($fUserID); - $oDependantDocumentTemplate->setDocumentTitle($fDocumentTitle); - $oDependantDocumentTemplate->setTemplateDocumentID((isset($fTemplateDocumentID) ? $fTemplateDocumentID : null)); - $oDependantDocumentTemplate->update(); - - redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); - } else { - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); - $main->render(); - } - + //redirect the user back to their start page if they somehow + //got here without the relevant permission + redirect($default->root_url . "/control.php"); + } } + } diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc index a69c95e..ef5c5f9 100644 --- a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc @@ -23,21 +23,21 @@ function getFolderPath($iFolderID) { function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) { global $default; - $sQuery = "SELECT DDT.id, GFAL.folder_id AS folder_id, U.name AS username, DDT.document_title, D.name AS template_document_name, D.id AS template_document_id, DDT.group_folder_approval_link_id, 'Edit' AS edit " . + $sQuery = "SELECT DDT.id, GFAL.folder_id AS folder_id, U.name AS username, DDT.document_title, D.name AS template_document_name, D.id AS template_document_id, DDT.group_folder_approval_link_id, 'Edit' AS edit, 'Delete' AS del " . "FROM dependant_document_template AS DDT INNER JOIN groups_folders_approval_link AS GFAL ON DDT.group_folder_approval_link_id = GFAL.id " . "INNER JOIN users AS U ON U.id = DDT.default_user_id " . "LEFT OUTER JOIN documents AS D ON D.id = DDT.template_document_id " . "WHERE DDT.group_folder_approval_link_id = $iFolderCollaborationID"; //echo $sQuery; - $aColumns = array("document_title", "username", "template_document_name","edit"); - $aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit"); - $aColumnTypes = array(1,1,3,3); + $aColumns = array("document_title", "username", "template_document_name","edit", "del"); + $aColumnHeaders = array("Document title", "Default creator", "Template document"); + $aColumnTypes = array(1,1,3,3,3); //$aDBColumnArray = array("id","group_folder_approval_link_id","template_document_id"); $aDBColumnArray = array("id","group_folder_approval_link_id","folder_id"); //$aQueryStringVariableNames = array("fDependantDocumentTemplateID", "fFolderCollaborationID", "fDocumentID"); $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fFolderID"); - $aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=viewDependantDocument&fForEdit=1"); + $aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=viewDependantDocument&fForEdit=1", 4=>"$default->rootUrl/control.php?action=deleteDependantDocument"); $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames); $oPatternTableSqlQuery->setTableHeading("Dependant Documents"); -- libgit2 0.21.4