Commit a0b6b9a0ac6b375ca1cbab1f326a8f9af88c38d3

Authored by rob
1 parent a90ae21f

Initial revision. Roll back a document collaboration step


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1301 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/collaborationRollbackBL.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* Business logic used for the rollback of a collaboration step
  5 +*
  6 +*
  7 +*/
  8 +
  9 +require_once("../../../../config/dmsDefaults.php");
  10 +
  11 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  12 +
  13 +require_once("$default->fileSystemRoot/lib/email/Email.inc");
  14 +
  15 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  16 +
  17 +require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc");
  18 +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc");
  19 +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  20 +
  21 +require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
  22 +require_once("$default->fileSystemRoot/lib/foldermanagement/FolderUserRole.inc");
  23 +require_once("$default->fileSystemRoot/lib/roles/Role.inc");
  24 +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  25 +
  26 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc");
  27 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/collaborationRollbackUI.inc");
  28 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  29 +
  30 +if (checkSession()) {
  31 + if (isset($fDocumentID)) {
  32 + if (Document::userIsPerformingCurrentCollaborationStep($fDocumentID)) {
  33 + if (isset($fForStore)) {
  34 + //user has entered a comment
  35 + //create the transaction and rollback the step
  36 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, $fComment, COLLAB_ROLLBACK);
  37 + if ($oDocumentTransaction->create()) {
  38 + Document::rollbackCollaborationStep($fDocumentID, $fComment);
  39 + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");
  40 + } else {
  41 + $oDocument = Document::get($fDocumentID);
  42 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  43 + $oPatternCustom = & new PatternCustom();
  44 + $oPatternCustom->setHtml(getPage($oDocument->getFolderID(), $oDocument->getID(), $oDocument->getName()));
  45 + $main->setCentralPayload($oPatternCustom);
  46 + $main->setHasRequiredFields(true);
  47 + $main->setErrorMessage("An error occured while creating the document transaction");
  48 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1");
  49 + $main->render();
  50 + }
  51 + } else {
  52 + $oDocument = Document::get($fDocumentID);
  53 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  54 + $oPatternCustom = & new PatternCustom();
  55 + $oPatternCustom->setHtml(getPage($oDocument->getFolderID(), $oDocument->getID(), $oDocument->getName()));
  56 + $main->setCentralPayload($oPatternCustom);
  57 + $main->setHasRequiredFields(true);
  58 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1");
  59 + $main->render();
  60 + }
  61 + } else {
  62 + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");
  63 + }
  64 + }
  65 +}
  66 +
  67 +
  68 +?>
presentation/lookAndFeel/knowledgeTree/documentmanagement/collaborationRollbackUI.inc 0 → 100644
  1 +<?php
  2 +
  3 +function getDocumentPath($iFolderID, $iDocumentID, $sDocumentName) {
  4 + global $default;
  5 + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
  6 + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
  7 + $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse") . " > <a href=\"$default->rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $iDocumentID . "&fForInlineView=1\" target=\"View document\">" . $sDocumentName . "</a>";
  8 + return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n";
  9 +}
  10 +
  11 +function getPage($iFolderID, $iDocumentID, $sDocumentName) {
  12 + global $default;
  13 + $sToRender = getDocumentPath($iFolderID, $iDocumentID, $sDocumentName);
  14 + $sToRender .= "<p>You have chosen to reject the previous collaboration step for the document, '$sDocumentName'. " .
  15 + "Please enter a valid reason</p>\n";
  16 + $sToRender .= "<br>\n";
  17 + $sToRender .= "<table>\n";
  18 + $sToRender .= "<tr>\n";
  19 + $sToRender .= "<td><b>Comment<b></td>\n";
  20 + $sToRender .= "</tr>\n";
  21 + $sToRender .= "<tr>\n";
  22 + $sToRender .= "<td><textarea cols=\"40\" rows=\"5\" name=\"fComment\"></textarea></td>\n";
  23 + $sToRender .= "</tr>\n";
  24 + $sToRender .= "</table>\n";
  25 +
  26 + $sToRender .= "<input type=\"image\" src=\"$default->graphicsUrl/widgets/done.gif\" border=\"0\" />\n";
  27 + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a>\n";
  28 +
  29 +
  30 +
  31 + return $sToRender . getValidationJavaScript();
  32 +}
  33 +
  34 +function getValidationJavaScript() {
  35 + $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
  36 + $sToRender .= "<!--\n";
  37 + $sToRender .= "function validateForm(theForm) {\n";
  38 + $sToRender .= "\tif (!(validRequired(document.MainForm.fComment, 'Comment'))) {\n";
  39 + $sToRender .= "\t\treturn false;\n\t}\n";
  40 + $sToRender .= "\tdocument.MainForm.submit();\n}\n";
  41 + $sToRender .= "-->\n";
  42 + $sToRender .= "</SCRIPT>\n\n";
  43 + return $sToRender;
  44 +
  45 +}
  46 +
  47 +?>