Commit 36dff29a4ccf16f69f77a212392218f80e36b0e0
1 parent
84dfb3b2
Initial revision. Create dependant documents on the fly from the
document page git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2108 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
192 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/createDependantDocumentBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** Business logic for requesting the creation of a new document that | |
| 4 | +* will be linked to an existing one | |
| 5 | +* | |
| 6 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 7 | +* @date 10 June 2003 | |
| 8 | +*/ | |
| 9 | + | |
| 10 | + | |
| 11 | +require_once("../../../../config/dmsDefaults.php"); | |
| 12 | + | |
| 13 | +if (checkSession()) { | |
| 14 | + require_once("createDependantDocumentUI.inc"); | |
| 15 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 16 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | |
| 17 | + require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 18 | + require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 19 | + require_once("$default->fileSystemRoot/lib/security/permission.inc"); | |
| 20 | + require_once("$default->fileSystemRoot/lib/email/Email.inc"); | |
| 21 | + require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc"); | |
| 22 | + require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 23 | + require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 24 | + | |
| 25 | + | |
| 26 | + //TODO REMOVE THIS LINE - FOR TESTING ONLY!!!! | |
| 27 | + if (!isset($fDocumentID)) { | |
| 28 | + $fDocumentID = 1; | |
| 29 | + } | |
| 30 | + | |
| 31 | + if (isset($fForStore)) { | |
| 32 | + $oDependantDocument = & new DependantDocumentInstance($fDocumentTitle, $fUserID, $fTargetDocumentID, $fDocumentID); | |
| 33 | + if ($oDependantDocument->create()) { | |
| 34 | + $oUser = User::get($fUserID); | |
| 35 | + if ($oUser->getEmailNotification()) { | |
| 36 | + //notify the user by email if they wish to be notified by email | |
| 37 | + $oTemplateDocument = & Document::get($fTargetDocumentID); | |
| 38 | + | |
| 39 | + | |
| 40 | + $sBody = $oUser->getName() . ", a step in the document collaboration process requires you to create a new document. " . | |
| 41 | + generateLink("/control.php","action=dashboard","Log onto KnowledgeTree") . " and select the relevant link under the 'Dependant Documents' heading on your dashboard when you are ready upload it."; | |
| 42 | + //if we have a template document | |
| 43 | + if (!($oTemplateDocument === false)) { | |
| 44 | + $sBody .= "The document entitled " . generateLink("/control.php", "action=viewDocument&fDocumentID=" . $oTemplateDocument->getID(), $oTemplateDocument->getName()) . " " . | |
| 45 | + "can be used as a template"; | |
| 46 | + } | |
| 47 | + | |
| 48 | + $oEmail = & new Email(); | |
| 49 | + $oEmail->send($oUser->getEmail(), "Dependant document creation required", $sBody); | |
| 50 | + } | |
| 51 | + //go back to the document page you were viewing | |
| 52 | + redirect($default->rootUrl . "/control.php?action=viewDocument&fDocumentID=$fDocumentID"); | |
| 53 | + } else { | |
| 54 | + //dependant document creation failed - display an error message | |
| 55 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 56 | + $oDocument = Document::get($fDocumentID); | |
| 57 | + | |
| 58 | + $oPatternCustom = & new PatternCustom(); | |
| 59 | + $oPatternCustom->setHtml(getAddPage($oDocument->getFolderID(), $fDocumentID, $fUnitID, $fUserID, $fDocumentTitle, $fTemplateDocument)); | |
| 60 | + $main->setCentralPayload($oPatternCustom); | |
| 61 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1"); | |
| 62 | + $main->setErrorMessage("An error occured whilst trying to create the dependant document"); | |
| 63 | + $main->render(); | |
| 64 | + | |
| 65 | + } | |
| 66 | + } else { | |
| 67 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 68 | + //we're browsing, so just display the page | |
| 69 | + $oDocument = Document::get($fDocumentID); | |
| 70 | + | |
| 71 | + $oPatternCustom = & new PatternCustom(); | |
| 72 | + $oPatternCustom->setHtml(getAddPage($oDocument->getFolderID(), $fDocumentID, $fUnitID, $fUserID, $fDocumentTitle, $fTemplateDocument)); | |
| 73 | + $main->setCentralPayload($oPatternCustom); | |
| 74 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1"); | |
| 75 | + $main->render(); | |
| 76 | + } | |
| 77 | +} | |
| 78 | + | |
| 79 | +?> | |
| 0 | 80 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/createDependantDocumentUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | + | |
| 4 | +function getFolderPath($iFolderID) { | |
| 5 | + global $default; | |
| 6 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 7 | + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 8 | + $sFolderPathLink = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse"); | |
| 9 | + return "<table border=\"0\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sFolderPathLink</td></tr></table>\n"; | |
| 10 | +} | |
| 11 | + | |
| 12 | +function getAddPage($iFolderID, $iDocumentID, $iUnitID, $iUserID, $sDocumentTitle, $sTemplateDocument) { | |
| 13 | + global $default; | |
| 14 | + $sToRender = renderHeading("Create a new dependant document"); | |
| 15 | + $sToRender .= getFolderPath($iFolderID); | |
| 16 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 17 | + $sToRender .= "<tr>\n"; | |
| 18 | + $sToRender .= "<td>Document title</td><td><input type=\"text\" name=\"fDocumentTitle\" value=\"$sDocumentTitle\" /></td>\n"; | |
| 19 | + $sToRender .= "</tr>\n"; | |
| 20 | + $sToRender .= "<tr>\n"; | |
| 21 | + $sToRender .= "<td>User's Unit</td><td>" . getUnitDropDown($iDocumentID, $iUnitID) . "</td>\n"; | |
| 22 | + $sToRender .= "</tr>\n"; | |
| 23 | + $sToRender .= "<tr>\n"; | |
| 24 | + $sToRender .= "<td>User</td><td>" . getUserDropDown($iUnitID, $iUserID) . "</td>\n"; | |
| 25 | + $sToRender .= "</tr>\n"; | |
| 26 | + $sToRender .= "<tr>\n"; | |
| 27 | + | |
| 28 | + //had a slight problem with netscape 4.7x - it doesn't support disabled. So I had to use | |
| 29 | + //javascript to set the onFocus attribute to blur | |
| 30 | + $bAddNetscapeScript = false; | |
| 31 | + if (! (($default->phpSniff->property("browser") == "moz") && ($default->phpSniff->property("version") <= "4.79")) ) { | |
| 32 | + //for any other browser but netscape 4.7 do this | |
| 33 | + $sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTargetDocument\" value=\"$sTemplateDocument\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('$default->rootUrl/control.php?action=templateBrowse','window2')\"></td>\n"; | |
| 34 | + }else { | |
| 35 | + //for netscape 4.7 do this | |
| 36 | + $sToRender .= "<td>Template document</td><td><input type=\"text\" name=\"fTargetDocument\" onblur=\"disable(document.MainForm.fTargetDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTargetDocument);newWindow('$default->rootUrl/control.php?action=templateBrowse','window2')\"></td>\n"; | |
| 37 | + $bAddNetscapeScript = true; | |
| 38 | + } | |
| 39 | + $sToRender .= "</tr>\n"; | |
| 40 | + $sToRender .= "<tr>\n"; | |
| 41 | + $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/done.gif\" onClick='return validateForm(document.MainForm);' border=\"0\"/></td><td><a href=\"" . $default->rootUrl . "/control.php?action=viewDocument&fDocumentID=$iDocumentID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n"; | |
| 42 | + $sToRender .= "</tr>\n"; | |
| 43 | + $sToRender .= "</table>\n"; | |
| 44 | + $sToRender .= "<input type=\"hidden\" name=\"fTargetDocumentID\" value=\"-1\" />\n"; | |
| 45 | + | |
| 46 | + return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : ""); | |
| 47 | +} | |
| 48 | + | |
| 49 | +function getUserDropDown($iUnitID, $iUserID) { | |
| 50 | + global $default; | |
| 51 | + if (!isset($iUnitID)) { | |
| 52 | + $iUnitID = -1; | |
| 53 | + } | |
| 54 | + $oPatternListBox = & new PatternListBox($default->owl_users_table, "Name", "id", "fUserID", "GUL.unit_id = $iUnitID"); | |
| 55 | + $sFromClause = "INNER join users_groups_link AS UGL ON UGL.user_id = ST.id " . | |
| 56 | + "INNER JOIN groups_units_link AS GUL ON GUL.group_id = UGL.group_id "; | |
| 57 | + $oPatternListBox->setFromClause($sFromClause); | |
| 58 | + if (isset($iUserID)) { | |
| 59 | + $oPatternListBox->setSelectedValue($iUserID); | |
| 60 | + } | |
| 61 | + return $oPatternListBox->render(); | |
| 62 | + | |
| 63 | + | |
| 64 | +} | |
| 65 | + | |
| 66 | +function getUnitDropDown($iDocumentID, $iUnitID) { | |
| 67 | + global $default; | |
| 68 | + if (!isset($iUnitID)) { | |
| 69 | + $iUnitID = -1; | |
| 70 | + } | |
| 71 | + $oPatternListBox = & new PatternListBox($default->owl_units_table, "Name", "id", "fUnitID"); | |
| 72 | + $oPatternListBox->setPostBackOnChange(true); | |
| 73 | + $oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fDocumentID=$iDocumentID&fForAdd=1')"); | |
| 74 | + if (isset($iUnitID)) { | |
| 75 | + $oPatternListBox->setSelectedValue($iUnitID); | |
| 76 | + } | |
| 77 | + return $oPatternListBox->render(); | |
| 78 | +} | |
| 79 | + | |
| 80 | +function getValidationJavaScript() { | |
| 81 | + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 82 | + $sToRender .= "function validateForm(theForm) {\n"; | |
| 83 | + $sToRender .= "\tif (!(validRequired(theForm.fDocumentTitle,'Document title') && validRequired(theForm.fUserID,'User'))) {\n"; | |
| 84 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 85 | + $sToRender .= "return true;\n}\n"; | |
| 86 | + $sToRender .= "//-->\n</script>\n\n"; | |
| 87 | + return $sToRender; | |
| 88 | +} | |
| 89 | + | |
| 90 | +function getBrowseJavaScript() { | |
| 91 | + $sToRender = "<script language=\"JavaScript\"><!--\n "; | |
| 92 | + $sToRender .= "function newWindow(file,window) {\n "; | |
| 93 | + $sToRender .= "\tmsgWindow=open(file,window,'resizable=yes,scrollbars=yes, width=400,height=600');\n "; | |
| 94 | + $sToRender .= "\tif (msgWindow.opener == null) msgWindow.opener = self; \n "; | |
| 95 | + $sToRender .= "}\n"; | |
| 96 | + $sToRender .= "//--></script>\n"; | |
| 97 | + return $sToRender; | |
| 98 | +} | |
| 99 | + | |
| 100 | +function getNetscapeDisableScript() { | |
| 101 | + $sToRender = "<script language=\"JavaScript\"><!--\n "; | |
| 102 | + $sToRender .= "function disable(elem) {\n"; | |
| 103 | + $sToRender .= "\telem.onfocus=elem.blur;\n"; | |
| 104 | + $sToRender .= "}\n"; | |
| 105 | + $sToRender .= "//--></script>\n\n"; | |
| 106 | + return $sToRender; | |
| 107 | + | |
| 108 | +} | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | +?> | |
| 0 | 114 | \ No newline at end of file | ... | ... |