Commit de8044440068e193f8b79fecbd3cb6c7925f81e7

Authored by rob
1 parent 847795ff

Added checks for failed document linking


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2020 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
@@ -61,6 +61,24 @@ if (checkSession()) { @@ -61,6 +61,24 @@ if (checkSession()) {
61 if ($oDocumentLink->create()) { 61 if ($oDocumentLink->create()) {
62 //no longer a dependant document, but a linked document 62 //no longer a dependant document, but a linked document
63 $oDependantDocument->delete(); 63 $oDependantDocument->delete();
  64 + } else {
  65 + //an error occured whilst trying to link the two documents automatically. Email the parent document
  66 + //original to inform him/her that the two documents must be linked manually
  67 + $oParentDocument = Document::get($oDependantDocument->getParentDocumentID());
  68 + $oUserDocCreator = User::get($oParentDocument->getCreatorID());
  69 +
  70 + $sBody = $oUserDocCreator->getName() . ", an error occured whilst attempting to automatically link the document, '" .
  71 + $oDocument->getName() . "' to the document, '" . $oParentDocument->getName() . "'. These two documents " .
  72 + " are meant to be linked for collaboration purposes. As creator of the document, ' " . $oParentDocument->getName() . "', you are requested to " .
  73 + "please link them manually by browsing to the parent document, " .
  74 + generateControllerLink("viewDocument","fDocumentID=" . $oParentDocument->getID(), $oParentDocument->getName()) .
  75 + " and selecting the link button. " . $oDocument->getName() . " can be found at " . $oDocument->generateFullFolderPath($oDocument->getFolderID());
  76 +
  77 + $oEmail = & new Email();
  78 + $oEmail->send($oUserDocCreator->getEmail(), "Automatic document linking failed", $sBody);
  79 +
  80 + //document no longer dependant document, but must be linked manually
  81 + $oDependantDocument->delete();
64 } 82 }
65 } 83 }
66 84
@@ -147,7 +165,7 @@ if (checkSession()) { @@ -147,7 +165,7 @@ if (checkSession()) {
147 //so don't display add button 165 //so don't display add button
148 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 166 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
149 $oPatternCustom = & new PatternCustom(); 167 $oPatternCustom = & new PatternCustom();
150 - $oPatternCustom->setHtml(getBrowsePage($fFolderID)); 168 + $oPatternCustom->setHtml(getBrowsePage($fFolderID, $fDependantDocumentID));
151 $main->setCentralPayload($oPatternCustom); 169 $main->setCentralPayload($oPatternCustom);
152 $main->setErrorMessage("You do not have permission to add a document to this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>"); 170 $main->setErrorMessage("You do not have permission to add a document to this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>");
153 $main->render(); 171 $main->render();