Commit 87ad02299bb9003c882dd0d6df54ebd523120f0b
1 parent
881295c3
Replaced by addDocument.php
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3689 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
0 additions
and
425 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Business Logic to add a new document to the | ||
| 6 | - * database. Will use addDocumentUI.inc for presentation | ||
| 7 | - * | ||
| 8 | - * Expected form variable: | ||
| 9 | - * o $fFolderID - primary key of folder user is currently browsing | ||
| 10 | - * | ||
| 11 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 12 | - * | ||
| 13 | - * This program is free software; you can redistribute it and/or modify | ||
| 14 | - * it under the terms of the GNU General Public License as published by | ||
| 15 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 16 | - * (at your option) any later version. | ||
| 17 | - * | ||
| 18 | - * This program is distributed in the hope that it will be useful, | ||
| 19 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | - * GNU General Public License for more details. | ||
| 22 | - * | ||
| 23 | - * You should have received a copy of the GNU General Public License | ||
| 24 | - * along with this program; if not, write to the Free Software | ||
| 25 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 26 | - * | ||
| 27 | - * @version $Revision$ | ||
| 28 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 29 | - * @package documentmanagement | ||
| 30 | - */ | ||
| 31 | - | ||
| 32 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 33 | - | ||
| 34 | -KTUtil::extractGPC('fFolderID', 'fStore', 'fDocumentTypeID', 'fName', 'fDependantDocumentID'); | ||
| 35 | -if (!checkSession()) { | ||
| 36 | - exit(0); | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternCustom.inc'); | ||
| 40 | -require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); | ||
| 41 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 42 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc"); | ||
| 43 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentLink.inc"); | ||
| 44 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | ||
| 45 | -require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); | ||
| 46 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 47 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 48 | -require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); | ||
| 49 | -require_once("addDocumentUI.inc"); | ||
| 50 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/store.inc"); | ||
| 51 | - | ||
| 52 | -require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); | ||
| 53 | -require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 54 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc'); | ||
| 55 | -require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 56 | - | ||
| 57 | -$oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 58 | - | ||
| 59 | -$postExpected = KTUtil::arrayGet($_REQUEST, "postExpected"); | ||
| 60 | -$postReceived = KTUtil::arrayGet($_REQUEST, "postReceived"); | ||
| 61 | -if (!is_null($postExpected) && is_null($postReceived)) { | ||
| 62 | - // A post was to be initiated by the client, but none was received. | ||
| 63 | - // This means post_max_size was violated. | ||
| 64 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 65 | - $oPatternCustom = & new PatternCustom(); | ||
| 66 | - $errorMessage = _("You tried to upload a file that is larger than the PHP post_max_size setting."); | ||
| 67 | - $oPatternCustom->setHtml(getStatusPage($fFolderID, $errorMessage . "</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"></a>")); | ||
| 68 | - $main->setCentralPayload($oPatternCustom); | ||
| 69 | - $main->render(); | ||
| 70 | - exit(0); | ||
| 71 | -} | ||
| 72 | - | ||
| 73 | -if (!isset($fFolderID)) { | ||
| 74 | - //no folder id was set when coming to this page, | ||
| 75 | - //so display an error message | ||
| 76 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 77 | - $oPatternCustom = & new PatternCustom(); | ||
| 78 | - $oPatternCustom->setHtml("<p class=\"errorText\">" . _("You haven't selected a folder to add a document to.") . "</p>\n"); | ||
| 79 | - $main->setCentralPayload($oPatternCustom); | ||
| 80 | - $main->render(); | ||
| 81 | - exit(0); | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -$oFolder = Folder::get($fFolderID); | ||
| 85 | -if (!Permission::userHasFolderWritePermission($oFolder)) { | ||
| 86 | - //user does not have write permission for this folder, | ||
| 87 | - //so don't display add button | ||
| 88 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 89 | - $oPatternCustom = & new PatternCustom(); | ||
| 90 | - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentTypeID, $fDependantDocumentID, _("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=\"" . KTHtml::getCancelButton() . "\" border=\"0\"></a>")); | ||
| 91 | - $main->setCentralPayload($oPatternCustom); | ||
| 92 | - $main->render(); | ||
| 93 | - exit(0); | ||
| 94 | -} | ||
| 95 | - | ||
| 96 | -//user has permission to add document to this folder | ||
| 97 | -if (!isset($fStore)) { | ||
| 98 | - //we're still just browsing | ||
| 99 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 100 | - $oPatternCustom = & new PatternCustom(); | ||
| 101 | - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentTypeID, $fDependantDocumentID)); | ||
| 102 | - $main->setCentralPayload($oPatternCustom); | ||
| 103 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&postExpected=1" . | ||
| 104 | - (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "") . | ||
| 105 | - (isset($fDocumentTypeID) ? "&fDocumentTypeID=$fDocumentTypeID" : "")); | ||
| 106 | - $main->setFormEncType("multipart/form-data"); | ||
| 107 | - $main->setHasRequiredFields(true); | ||
| 108 | - $main->render(); | ||
| 109 | - exit(0); | ||
| 110 | -} | ||
| 111 | - | ||
| 112 | -// check that a document type has been selected | ||
| 113 | -if (!$fDocumentTypeID) { | ||
| 114 | - // no document type was selected | ||
| 115 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 116 | - $oPatternCustom = & new PatternCustom(); | ||
| 117 | - $oPatternCustom->setHtml(getStatusPage($fFolderID, _("A valid document type was not selected.") . "</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"></a>")); | ||
| 118 | - $main->setCentralPayload($oPatternCustom); | ||
| 119 | - $main->render(); | ||
| 120 | - exit(0); | ||
| 121 | -} | ||
| 122 | - | ||
| 123 | -// make sure the user actually selected a file first | ||
| 124 | -// and that something was uploaded | ||
| 125 | -if (!((strlen($_FILES['fFile']['name']) > 0) && $_FILES['fFile']['size'] > 0)) { | ||
| 126 | - // no uploaded file | ||
| 127 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 128 | - $oPatternCustom = & new PatternCustom(); | ||
| 129 | - $message = _("You did not select a valid document to upload"); | ||
| 130 | - | ||
| 131 | - $errors = array( | ||
| 132 | - 1 => _("The uploaded file is larger than the PHP upload_max_filesize setting"), | ||
| 133 | - 2 => _("The uploaded file is larger than the MAX_FILE_SIZE directive that was specified in the HTML form"), | ||
| 134 | - 3 => _("The uploaded file was not fully uploaded to KnowledgeTree"), | ||
| 135 | - 4 => _("No file was selected to be uploaded to KnowledgeTree"), | ||
| 136 | - 6 => _("An internal error occurred receiving the uploaded document"), | ||
| 137 | - ); | ||
| 138 | - $message = KTUtil::arrayGet($errors, $_FILES['fFile']['error'], $message); | ||
| 139 | - | ||
| 140 | - if (@ini_get("file_uploads") == false) { | ||
| 141 | - $message = _("File uploads are disabled in your PHP configuration"); | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - $oPatternCustom->setHtml(getStatusPage($fFolderID, $message . "</td><td><a href=\"$default->rootUrl/control.php?action=addDocument&fFolderID=$fFolderID&fDocumentTypeID=$fDocumentTypeID\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\"></a>")); | ||
| 145 | - $main->setCentralPayload($oPatternCustom); | ||
| 146 | - $main->render(); | ||
| 147 | - exit(0); | ||
| 148 | -} | ||
| 149 | - | ||
| 150 | -function localRenderError($oDocument) { | ||
| 151 | - print $oDocument->toString(); | ||
| 152 | - return; | ||
| 153 | -} | ||
| 154 | - | ||
| 155 | -DBUtil::startTransaction(); | ||
| 156 | - | ||
| 157 | -$matches = array(); | ||
| 158 | -$aFields = array(); | ||
| 159 | -foreach ($_REQUEST as $k => $v) { | ||
| 160 | - if (preg_match('/^emd(\d+)$/', $k, $matches)) { | ||
| 161 | - $aFields[] = array(DocumentField::get($matches[1]), $v); | ||
| 162 | - } | ||
| 163 | -} | ||
| 164 | - | ||
| 165 | -$aOptions = array( | ||
| 166 | - 'contents' => new KTFSFileLike($_FILES['fFile']['tmp_name']), | ||
| 167 | - 'documenttype' => DocumentType::get($fDocumentTypeID), | ||
| 168 | - 'metadata' => $aFields, | ||
| 169 | - 'description' => $fName, | ||
| 170 | -); | ||
| 171 | - | ||
| 172 | -$oUser =& User::get($_SESSION["userID"]); | ||
| 173 | -$oDocument =& KTDocumentUtil::add($oFolder, basename($_FILES['fFile']['name']), $oUser, $aOptions); | ||
| 174 | -if (PEAR::isError($oDocument)) { | ||
| 175 | - localRenderError($oDocument); | ||
| 176 | - exit(0); | ||
| 177 | -} | ||
| 178 | - | ||
| 179 | -//the document was created/uploaded due to a collaboration step in another | ||
| 180 | -//document and must be linked to that document | ||
| 181 | -if (isset($fDependantDocumentID)) { | ||
| 182 | - $oDependantDocument = DependantDocumentInstance::get($fDependantDocumentID); | ||
| 183 | - $oDocumentLink = & new DocumentLink($oDependantDocument->getParentDocumentID(), $oDocument->getID(), -1); // XXX: KT_LINK_DEPENDENT | ||
| 184 | - if ($oDocumentLink->create()) { | ||
| 185 | - //no longer a dependant document, but a linked document | ||
| 186 | - $oDependantDocument->delete(); | ||
| 187 | - } else { | ||
| 188 | - //an error occured whilst trying to link the two documents automatically. Email the parent document | ||
| 189 | - //original to inform him/her that the two documents must be linked manually | ||
| 190 | - $oParentDocument = Document::get($oDependantDocument->getParentDocumentID()); | ||
| 191 | - $oUserDocCreator = User::get($oParentDocument->getCreatorID()); | ||
| 192 | - | ||
| 193 | - $sBody = $oUserDocCreator->getName() . ", an error occured whilst attempting to automatically link the document, '" . | ||
| 194 | - $oDocument->getName() . "' to the document, '" . $oParentDocument->getName() . "'. These two documents " . | ||
| 195 | - " are meant to be linked for collaboration purposes. As creator of the document, ' " . $oParentDocument->getName() . "', you are requested to " . | ||
| 196 | - "please link them manually by browsing to the parent document, " . | ||
| 197 | - generateControllerLink("viewDocument","fDocumentID=" . $oParentDocument->getID(), $oParentDocument->getName()) . | ||
| 198 | - " and selecting the link button. " . $oDocument->getName() . " can be found at " . $oDocument->getDisplayPath(); | ||
| 199 | - | ||
| 200 | - $oEmail = & new Email(); | ||
| 201 | - $oEmail->send($oUserDocCreator->getEmail(), "Automatic document linking failed", $sBody); | ||
| 202 | - | ||
| 203 | - //document no longer dependant document, but must be linked manually | ||
| 204 | - $oDependantDocument->delete(); | ||
| 205 | - } | ||
| 206 | -} | ||
| 207 | - | ||
| 208 | -DBUtil::commit(); | ||
| 209 | -//redirect to the document details page | ||
| 210 | -controllerRedirect("viewDocument", "fDocumentID=" . $oDocument->getID()); | ||
| 211 | - | ||
| 212 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Presentation data used to add a document. Used by addDocumentBL.php. | ||
| 6 | - * | ||
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 8 | - * | ||
| 9 | - * This program is free software; you can redistribute it and/or modify | ||
| 10 | - * it under the terms of the GNU General Public License as published by | ||
| 11 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | - * (at your option) any later version. | ||
| 13 | - * | ||
| 14 | - * This program is distributed in the hope that it will be useful, | ||
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | - * GNU General Public License for more details. | ||
| 18 | - * | ||
| 19 | - * You should have received a copy of the GNU General Public License | ||
| 20 | - * along with this program; if not, write to the Free Software | ||
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | - * | ||
| 23 | - * @version $Revision$ | ||
| 24 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 25 | - * @package documentmanagement | ||
| 26 | - */ | ||
| 27 | - | ||
| 28 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternTableSqlQuery.inc'); | ||
| 29 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternMetaData.inc'); | ||
| 30 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternEditableTableSqlQuery.inc'); | ||
| 31 | - | ||
| 32 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentField.inc'); | ||
| 33 | - | ||
| 34 | -function getDocumentType($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null) { | ||
| 35 | - global $default; | ||
| 36 | - | ||
| 37 | - $sWhereClause = "FDL.folder_id = $iFolderID"; | ||
| 38 | - $oPatternListBox = & new PatternListBox("$default->document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause); | ||
| 39 | - // #3548 removed default document type | ||
| 40 | - $oPatternListBox->setIncludeDefaultValue(false); | ||
| 41 | - $oPatternListBox->setFromClause("INNER JOIN $default->folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id"); | ||
| 42 | - $oPatternListBox->setEmptyErrorMessage(_("No document types defined! Please contact an Administrator")); | ||
| 43 | - | ||
| 44 | - if ($iDocumentTypeID) { | ||
| 45 | - $oPatternListBox->setSelectedValue($iDocumentTypeID); | ||
| 46 | - $sHeading = _("Document Type"); | ||
| 47 | - } else { | ||
| 48 | - $sHeading = _("Please select the document type:"); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - $sToRender = "<table><tr><td><b>$sHeading<b></td></tr><tr><td>" . $oPatternListBox->render() . "</td></tr></table>"; | ||
| 52 | - | ||
| 53 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | ||
| 54 | - $sToRender .= "function validateForm(theForm) {\n"; | ||
| 55 | - $sToRender .= "\tif (!(validRequired(theForm.fDocumentTypeID, 'Document Type'))) {\n"; | ||
| 56 | - $sToRender .= "\t\treturn false;\n\t}\n"; | ||
| 57 | - $sToRender .= "return true;\n}\n"; | ||
| 58 | - $sToRender .= "//-->\n</script>\n\n"; | ||
| 59 | - return $sToRender; | ||
| 60 | -} | ||
| 61 | - | ||
| 62 | -/** | ||
| 63 | - * Displays the file browse widget | ||
| 64 | - */ | ||
| 65 | -function getUploadDocument() { | ||
| 66 | - global $default; | ||
| 67 | - $sToRender .= "<table border=\"0\">\n"; | ||
| 68 | - $sToRender .= "<tr>\n"; | ||
| 69 | - $sToRender .= "<td colspan=\"2\"><b>" . _("Document to add") . ":<b></td>\n"; | ||
| 70 | - $sToRender .= "</tr>\n"; | ||
| 71 | - $sToRender .= "<tr><td>" . _("File") . "</td><td><input type=\"file\" name=\"fFile\"></td></tr>\n"; | ||
| 72 | - $sToRender .= "<tr><td>" . _("Title") . "</td><td><input type=\"text\" name=\"fName\" size=\"20\"></td></tr>\n"; | ||
| 73 | - $sToRender .= "</table>\n"; | ||
| 74 | - return $sToRender; | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -/** | ||
| 78 | - * Displays the generic meta data fields form | ||
| 79 | - */ | ||
| 80 | -function getGenericMetaDataForm() { | ||
| 81 | - $oTemplating = KTTemplating::getSingleton(); | ||
| 82 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata_fields/editable_metadata_fields"); | ||
| 83 | - $aTemplateData = array( | ||
| 84 | - 'caption' => _('Generic meta data'), | ||
| 85 | - 'empty_message' => _("No Generic Meta Data"), | ||
| 86 | - 'fields' => DocumentField::getList(array('is_generic = ?', array(true))), | ||
| 87 | - ); | ||
| 88 | - return $oTemplate->render($aTemplateData); | ||
| 89 | -} | ||
| 90 | - | ||
| 91 | -/** | ||
| 92 | - * Displays the type specific meta data fields form | ||
| 93 | - */ | ||
| 94 | -function getTypeSpecificMetaDataForm($iDocumentTypeID) { | ||
| 95 | - global $default; | ||
| 96 | - /*ok*/ $sQuery = array("SELECT DF.id AS id " . | ||
| 97 | - "FROM document_fields AS DF LEFT JOIN document_type_fields_link AS DTFL ON DTFL.field_id = DF.id " . | ||
| 98 | - "WHERE DF.is_generic = ? " . | ||
| 99 | - "AND DTFL.document_type_id = ?", array(false, $iDocumentTypeID)); | ||
| 100 | - | ||
| 101 | - $aIDs = DBUtil::getResultArray($sQuery); | ||
| 102 | - | ||
| 103 | - $aFields = array(); | ||
| 104 | - foreach ($aIDs as $iID) { | ||
| 105 | - $aFields[] =& call_user_func(array('DocumentField', 'get'), $iID); | ||
| 106 | - } | ||
| 107 | - $aTemplateData = array( | ||
| 108 | - 'caption' => _('Type specific meta data'), | ||
| 109 | - 'empty_message' => _("No Type Specific Meta Data"), | ||
| 110 | - 'fields' => $aFields, | ||
| 111 | - ); | ||
| 112 | - $oTemplating = KTTemplating::getSingleton(); | ||
| 113 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata_fields/editable_metadata_fields"); | ||
| 114 | - return $oTemplate->render($aTemplateData); | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | -function getMetaDataForm($iFolderID, $iDocumentTypeID) { | ||
| 118 | - $oGenericPattern = getGenericMetaDataForm(); | ||
| 119 | - $oTypeSpecificPattern = getTypeSpecificMetaDataForm($iDocumentTypeID); | ||
| 120 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 121 | - $sToRender .= "<tr><td><b>" . _("Document Meta Data") . "<b></td></tr>\n"; | ||
| 122 | - $sToRender .= "<tr><td valign=\"top\">" . $oGenericPattern . "</td></tr>"; | ||
| 123 | - $sToRender .= "<tr><td valign=\"top\">" . $oTypeSpecificPattern . "</td></tr>"; | ||
| 124 | - $sToRender .= "</table>"; | ||
| 125 | - | ||
| 126 | - // validation starts | ||
| 127 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | ||
| 128 | - $sToRender .= "function validateForm(theForm) {\n"; | ||
| 129 | - // document title | ||
| 130 | - $sToRender .= "\tif (!(validRequired(theForm.fName, 'Document Title'))) {\n"; | ||
| 131 | - $sToRender .= "\t\treturn false;\n\t}\n"; | ||
| 132 | - // filename | ||
| 133 | - $sToRender .= "\tif (!(validRequired(theForm.fFile, 'Document Filename'))) {\n"; | ||
| 134 | - $sToRender .= "\t\treturn false;\n\t}\n"; | ||
| 135 | - $sToRender .= "return true;\n}\n"; | ||
| 136 | - $sToRender .= "//-->\n</script>\n\n"; | ||
| 137 | - | ||
| 138 | - return $sToRender; | ||
| 139 | -} | ||
| 140 | - | ||
| 141 | -function getPage($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null, $sMessage = "") { | ||
| 142 | - global $default; | ||
| 143 | - | ||
| 144 | - $sQueryString = "fFolderID=$iFolderID" . (isset($iDependantDocumentID) ? "&fDependantDocumentID=$iDependantDocumentID" : ""); | ||
| 145 | - | ||
| 146 | - if (isset($iDependantDocumentID)) { | ||
| 147 | - $sToRender .= renderHeading(_("Add Dependant Document")); | ||
| 148 | - } else { | ||
| 149 | - $sToRender .= renderHeading(_("Add Document")); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - $sToRender .= renderFolderPath($iFolderID, generateControllerUrl("addDocument", $sQueryString, false), true); | ||
| 153 | - | ||
| 154 | - if ($sMessage) { | ||
| 155 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 156 | - $sToRender .= "<tr>\n"; | ||
| 157 | - $sToRender .= "\t<td><font color=\"red\">$sMessage</font></td>\n"; | ||
| 158 | - $sToRender .= "</tr>\n"; | ||
| 159 | - $sToRender .= "</table>\n"; | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - if ($iDocumentTypeID) { | ||
| 163 | - $sToRender .= "<table><tr><td><b>" . _("Document Type") . "<b></td></tr><tr><td>" . lookupName($default->document_types_table, $iDocumentTypeID) . "</td></tr></table>"; | ||
| 164 | - $sToRender .= getUploadDocument(); | ||
| 165 | - $sToRender .= getMetaDataForm($iFolderID, $iDocumentTypeID); | ||
| 166 | - $sActionButtons = "<input type=\"image\" src=\"" . KTHtml::getAddButton() . "\" border=\"0\"/>"; | ||
| 167 | - $sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">"; | ||
| 168 | - $sToRender .= "<input type=\"hidden\" name=\"postReceived\" value=\"1\">"; | ||
| 169 | - $sActionButtons .= generateControllerLink("addDocument", $sQueryString , "<img src=\"" . KTHtml::getBackButton() . "\" border=\"0\"/>") . | ||
| 170 | - generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/>"); | ||
| 171 | - | ||
| 172 | - $sToRender .= "<table border=\"0\" width=\"100%\" >\n"; | ||
| 173 | - $sToRender .= "<tr><td>$sActionButtons</td></tr>"; | ||
| 174 | - $sToRender .= "</table>"; | ||
| 175 | - | ||
| 176 | - } else { | ||
| 177 | - // only allow document type choosing if the user has write permission | ||
| 178 | - $oFolder = Folder::get($iFolderID); | ||
| 179 | - if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 180 | - $sToRender .= getDocumentType($iFolderID, $iDocumentTypeID, $iDependantDocumentID); | ||
| 181 | - $sActionButtons .= generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/>"); | ||
| 182 | - $sActionButtons .= "<input type=\"image\" src=\"" . KTHtml::getNextButton() . "\" border=\"0\"/>"; | ||
| 183 | - $sToRender .= "<input type=\"hidden\" name=\"postReceived\" value=\"1\">"; | ||
| 184 | - | ||
| 185 | - $sToRender .= "<table border=\"0\" width=\"100%\" >\n"; | ||
| 186 | - $sToRender .= "<tr><td>$sActionButtons</td></tr>"; | ||
| 187 | - $sToRender .= "</table>"; | ||
| 188 | - } | ||
| 189 | - // display folders for browsing | ||
| 190 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 191 | - $sToRender .= "<tr>\n"; | ||
| 192 | - $sToRender .= "\t<td>" . renderFolderList($iFolderID, generateControllerUrl("addDocument", $sQueryString, false)) . "<td>\n"; | ||
| 193 | - $sToRender .= "</tr>\n"; | ||
| 194 | - $sToRender .= "<tr>\n"; | ||
| 195 | - $sToRender .= "</tr>"; | ||
| 196 | - $sToRender .= "</table><br>\n"; | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - return $sToRender; | ||
| 200 | -} | ||
| 201 | - | ||
| 202 | -function getStatusPage($iFolderID, $sMessage) { | ||
| 203 | - $sToRender .= renderHeading(_("Add Document")); | ||
| 204 | - $sToRender .= renderFolderPath($iFolderID, generateControllerUrl("addDocument", "fFolderID=$iFolderID", false), true); | ||
| 205 | - | ||
| 206 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 207 | - $sToRender .= "<tr>\n"; | ||
| 208 | - $sToRender .= "\t<td><font color=\"red\">$sMessage</font></td>\n"; | ||
| 209 | - $sToRender .= "</tr>\n"; | ||
| 210 | - $sToRender .= "</table>\n"; | ||
| 211 | - return $sToRender; | ||
| 212 | -} | ||
| 213 | -?> |