Commit c31c6897d3c6e7278d83dedab758d7054ce65179
1 parent
598ecfc7
Remove obsoleted files
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4105 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
13 changed files
with
0 additions
and
2024 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocument.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Web interface to adding a document to a folder | ||
| 6 | - * | ||
| 7 | - * Copyright (c) 2005 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 Neil Blakey-Milner, Jam Warehouse (Pty) Ltd, South Africa | ||
| 25 | - */ | ||
| 26 | - | ||
| 27 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 28 | -require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | ||
| 29 | - | ||
| 30 | - | ||
| 31 | -require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); | ||
| 32 | -require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); | ||
| 33 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentLink.inc'); | ||
| 34 | - | ||
| 35 | -require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); | ||
| 36 | -require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); | ||
| 37 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc'); | ||
| 38 | -require_once(KT_LIB_DIR . '/metadata/fieldset.inc.php'); | ||
| 39 | -require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 40 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternMetaData.inc'); | ||
| 41 | - | ||
| 42 | -require_once(KT_DIR . '/presentation/webpageTemplate.inc'); | ||
| 43 | - | ||
| 44 | -$oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 45 | - | ||
| 46 | -class KTAddDocumentDispatcher extends KTStandardDispatcher { | ||
| 47 | - var $bAutomaticTransaction = true; | ||
| 48 | - | ||
| 49 | - function check() { | ||
| 50 | - if ($_REQUEST['fFolderID']) { | ||
| 51 | - $_REQUEST['fFolderId'] = $_REQUEST['fFolderID']; | ||
| 52 | - unset($_REQUEST['fFolderID']); | ||
| 53 | - } | ||
| 54 | - $this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); | ||
| 55 | - $this->oPermission =& $this->oValidator->validatePermissionByName('ktcore.permissions.write'); | ||
| 56 | - $this->validateFolderPermission(); | ||
| 57 | - $this->validatePost(); | ||
| 58 | - return true; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - function validateDocumentType($iId) { | ||
| 62 | - $this->oDocumentType =& DocumentType::get($iId); | ||
| 63 | - if (PEAR::isError($this->oDocumentType) || ($this->oDocumentType === false)) { | ||
| 64 | - $this->errorPage(_("Invalid document type given")); | ||
| 65 | - exit(0); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - function validateFolderPermission() { | ||
| 70 | - $oUser =& User::get($_SESSION['userID']); | ||
| 71 | - if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $this->oPermission, $this->oFolder)) { | ||
| 72 | - $this->errorPage(_("Permission denied")); | ||
| 73 | - exit(0); | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - function validatePost() { | ||
| 78 | - $postExpected = KTUtil::arrayGet($_REQUEST, "postExpected"); | ||
| 79 | - $postReceived = KTUtil::arrayGet($_REQUEST, "postReceived"); | ||
| 80 | - | ||
| 81 | - if (is_null($postExpected)) { | ||
| 82 | - return; | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - if (!is_null($postReceived)) { | ||
| 86 | - return; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - $this->errorPage(_("You tried to upload a file that is larger than the PHP post_max_size setting.")); | ||
| 90 | - exit(0); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - function errorPage($errorMessage) { | ||
| 94 | - $this->handleOutput($errorMessage); | ||
| 95 | - exit(0); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - function do_main() { | ||
| 99 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 100 | - $oTemplate =& $oTemplating->loadTemplate("ktcore/document/add"); | ||
| 101 | - $aTypes = $this->getDocumentTypes(); | ||
| 102 | - $iDefaultType = $aTypes[0]->getId(); | ||
| 103 | - $aTemplateData = array( | ||
| 104 | - 'context' => $this, | ||
| 105 | - 'folder_id' => $this->oFolder->getID(), | ||
| 106 | - 'folder_path_array' => $this->oFolder->getPathArray(), | ||
| 107 | - 'document_type_choice' => $this->getDocumentTypeChoice($aTypes, 'getMetadataForType(this.value);'), | ||
| 108 | - 'generic_metadata_fields' => $this->getGenericMetadataFieldsets(), | ||
| 109 | - 'type_metadata_fields' => $this->getTypeMetadataFieldsets($iDefaultType), | ||
| 110 | - ); | ||
| 111 | - $oTemplate->setData($aTemplateData); | ||
| 112 | - return $oTemplate->render(); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - function getDocumentTypeChoice($aTypes, $onchange = "") { | ||
| 116 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 117 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document/document_type_choice'); | ||
| 118 | - $aFields = array( | ||
| 119 | - 'document_types' => $aTypes, | ||
| 120 | - 'onchange' => $onchange, | ||
| 121 | - ); | ||
| 122 | - return $oTemplate->render($aFields); | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - function getGenericMetadataFieldsets() { | ||
| 126 | - $oTemplating = KTTemplating::getSingleton(); | ||
| 127 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fieldsets"); | ||
| 128 | - $aTemplateData = array( | ||
| 129 | - | ||
| 130 | - 'caption' => _('Generic meta data'), | ||
| 131 | - 'empty_message' => _("No Generic Meta Data"), | ||
| 132 | - 'fieldsets' => KTFieldset::getGenericFieldsets(), | ||
| 133 | - ); | ||
| 134 | - $aTemplateData['context'] =& $this; | ||
| 135 | - return $oTemplate->render($aTemplateData); | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - function getTypeMetadataFieldsets($iDocumentTypeID) { | ||
| 139 | - $aTemplateData = array( | ||
| 140 | - | ||
| 141 | - 'caption' => _('Type specific meta data'), | ||
| 142 | - 'empty_message' => _("No Type Specific Meta Data"), | ||
| 143 | - 'fieldsets' => KTFieldset::getForDocumentType($iDocumentTypeID), | ||
| 144 | - ); | ||
| 145 | - $aTemplateData['context'] =& $this; | ||
| 146 | - $oTemplating = KTTemplating::getSingleton(); | ||
| 147 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fieldsets"); | ||
| 148 | - return $oTemplate->render($aTemplateData); | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - function getDocumentTypes() { | ||
| 152 | - if (!$this->oFolder->getRestrictDocumentTypes()) { | ||
| 153 | - return DocumentType::getList(); | ||
| 154 | - } | ||
| 155 | - $sTable = KTUtil::getTableName('folder_doctypes'); | ||
| 156 | - $aQuery = array( | ||
| 157 | - "SELECT document_type_id FROM $sTable WHERE folder_id = ?", | ||
| 158 | - array($this->oFolder->getId()), | ||
| 159 | - ); | ||
| 160 | - $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); | ||
| 161 | - $aRet = array(); | ||
| 162 | - foreach ($aIds as $iId) { | ||
| 163 | - $aRet[] = DocumentType::get($iId); | ||
| 164 | - } | ||
| 165 | - return $aRet; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - function do_upload() { | ||
| 169 | - // make sure the user actually selected a file first | ||
| 170 | - // and that something was uploaded | ||
| 171 | - if (!((strlen($_FILES['fFile']['name']) > 0) && $_FILES['fFile']['size'] > 0)) { | ||
| 172 | - // no uploaded file | ||
| 173 | - $message = _("You did not select a valid document to upload"); | ||
| 174 | - | ||
| 175 | - $errors = array( | ||
| 176 | - 1 => _("The uploaded file is larger than the PHP upload_max_filesize setting"), | ||
| 177 | - 2 => _("The uploaded file is larger than the MAX_FILE_SIZE directive that was specified in the HTML form"), | ||
| 178 | - 3 => _("The uploaded file was not fully uploaded to KnowledgeTree"), | ||
| 179 | - 4 => _("No file was selected to be uploaded to KnowledgeTree"), | ||
| 180 | - 6 => _("An internal error occurred receiving the uploaded document"), | ||
| 181 | - ); | ||
| 182 | - $message = KTUtil::arrayGet($errors, $_FILES['fFile']['error'], $message); | ||
| 183 | - | ||
| 184 | - if (@ini_get("file_uploads") == false) { | ||
| 185 | - $message = _("File uploads are disabled in your PHP configuration"); | ||
| 186 | - } | ||
| 187 | - | ||
| 188 | - $this->errorRedirectToMain($message, 'fFolderId=' . $this->oFolder->getId()); | ||
| 189 | - exit(0); | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - $matches = array(); | ||
| 193 | - $aFields = array(); | ||
| 194 | - foreach ($_REQUEST as $k => $v) { | ||
| 195 | - if (preg_match('/^emd(\d+)$/', $k, $matches)) { | ||
| 196 | - $aFields[] = array(DocumentField::get($matches[1]), $v); | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - $this->validateDocumentType($_REQUEST['fDocumentTypeID']); | ||
| 201 | - | ||
| 202 | - $aOptions = array( | ||
| 203 | - 'contents' => new KTFSFileLike($_FILES['fFile']['tmp_name']), | ||
| 204 | - 'documenttype' => $this->oDocumentType, | ||
| 205 | - 'metadata' => $aFields, | ||
| 206 | - 'description' => $_REQUEST['fName'], | ||
| 207 | - ); | ||
| 208 | - | ||
| 209 | - $oUser =& User::get($_SESSION["userID"]); | ||
| 210 | - $oDocument =& KTDocumentUtil::add($this->oFolder, basename($_FILES['fFile']['name']), $oUser, $aOptions); | ||
| 211 | - if (PEAR::isError($oDocument)) { | ||
| 212 | - $message = $oDocument->getMessage(); | ||
| 213 | - $this->errorRedirectToMain($message, 'fFolderId=' . $this->oFolder->getId()); | ||
| 214 | - exit(0); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - $this->commitTransaction(); | ||
| 218 | - //redirect to the document details page | ||
| 219 | - controllerRedirect("viewDocument", "fDocumentId=" . $oDocument->getID()); | ||
| 220 | - } | ||
| 221 | -} | ||
| 222 | -$d =& new KTAddDocumentDispatcher; | ||
| 223 | -$d->dispatch(); | ||
| 224 | - | ||
| 225 | - | ||
| 226 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | - | ||
| 5 | -KTUtil::extractGPC('fActions', 'fBrowseType', 'fDocumentIDs', 'fFolderID', 'fSortBy', 'fSortDirection'); | ||
| 6 | - | ||
| 7 | -require_once(KT_LIB_DIR . "/browse/BrowserFactory.inc"); | ||
| 8 | -require_once(KT_LIB_DIR . "/browse/Browser.inc"); | ||
| 9 | -require_once(KT_LIB_DIR . "/documentmanagement/DocumentType.inc"); | ||
| 10 | -require_once(KT_LIB_DIR . "/documentmanagement/DocumentTransaction.inc"); | ||
| 11 | -require_once(KT_LIB_DIR . "/visualpatterns/PatternCustom.inc"); | ||
| 12 | -require_once("$default->uiDirectory/documentmanagement/browseUI.inc"); | ||
| 13 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 14 | -/** | ||
| 15 | - * $Id$ | ||
| 16 | - * | ||
| 17 | - * This page controls browsing for documents- this can be done either by | ||
| 18 | - * folder, category or document type. | ||
| 19 | - * The relevant permission checking is performed, calls to the business logic | ||
| 20 | - * layer to retrieve the details of the documents to view are made and the user | ||
| 21 | - * interface is contructed. | ||
| 22 | - * | ||
| 23 | - * Querystring variables | ||
| 24 | - * --------------------- | ||
| 25 | - * fBrowseType - determines whether to browse by (folder, category, documentType) [mandatory] | ||
| 26 | - * fFolderID - the folder to browse [optional depending on fBrowseType] | ||
| 27 | - * fCategoryName - the category to browse [optional depending on fBrowseType] | ||
| 28 | - * fDocumentTypeID - the document type id to browse [optional depending on fBrowseType] | ||
| 29 | - * fSortBy - the document attribute to sort the browse results by | ||
| 30 | - * fSortDirection - the direction to sort | ||
| 31 | - * fActions - action for group operations | ||
| 32 | - * | ||
| 33 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 34 | - * | ||
| 35 | - * This program is free software; you can redistribute it and/or modify | ||
| 36 | - * it under the terms of the GNU General Public License as published by | ||
| 37 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 38 | - * (at your option) any later version. | ||
| 39 | - * | ||
| 40 | - * This program is distributed in the hope that it will be useful, | ||
| 41 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 42 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 43 | - * GNU General Public License for more details. | ||
| 44 | - * | ||
| 45 | - * You should have received a copy of the GNU General Public License | ||
| 46 | - * along with this program; if not, write to the Free Software | ||
| 47 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 48 | - * | ||
| 49 | - * @version $Revision$ | ||
| 50 | - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 51 | - * @package documentmanagement | ||
| 52 | - */ | ||
| 53 | - | ||
| 54 | -// only if we have a valid session | ||
| 55 | -if (!checkSession()) { | ||
| 56 | - exit(0); | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -if (isset($fActions)) { | ||
| 60 | - // tack on POSTed document ids and redirect to the expunge deleted documents page | ||
| 61 | - $sUniqueID = KTUtil::randomString(); | ||
| 62 | - $_SESSION["documents"][$sUniqueID] = $fDocumentIDs; | ||
| 63 | - $sQueryString = "fRememberDocumentID=$sUniqueID&"; | ||
| 64 | - $sQueryString .= "fReturnFolderID=$fFolderID&"; | ||
| 65 | - | ||
| 66 | - switch ($fActions) { | ||
| 67 | - case "delete": | ||
| 68 | - // delete all selected docs | ||
| 69 | - controllerRedirect("deleteDocument", $sQueryString); | ||
| 70 | - exit(0); | ||
| 71 | - break; | ||
| 72 | - case "move": | ||
| 73 | - // Move selected docs to root folder | ||
| 74 | - controllerRedirect("moveDocument", $sQueryString . "fFolderID=1"); | ||
| 75 | - exit(0); | ||
| 76 | - break; | ||
| 77 | - } | ||
| 78 | -} | ||
| 79 | - | ||
| 80 | -// retrieve variables | ||
| 81 | -if (!$fBrowseType) { | ||
| 82 | - // required param not set- internal error or user querystring hacking | ||
| 83 | - // set it to default= folder | ||
| 84 | - $fBrowseType = "folder"; | ||
| 85 | -} | ||
| 86 | - | ||
| 87 | -// retrieve field to sort by | ||
| 88 | -if (!$fSortBy) { | ||
| 89 | - // no sort field specified- default is document name | ||
| 90 | - $fSortBy = "filename"; | ||
| 91 | -} | ||
| 92 | -// retrieve sort direction | ||
| 93 | -if (!$fSortDirection) { | ||
| 94 | - $fSortDirection = "asc"; | ||
| 95 | -} | ||
| 96 | - | ||
| 97 | -// fire up the document browser | ||
| 98 | -$oBrowser =& BrowserFactory::create($fBrowseType, $fSortBy, $fSortDirection); | ||
| 99 | -$sectionName = $oBrowser->getSectionName(); | ||
| 100 | - | ||
| 101 | -// instantiate my content pattern | ||
| 102 | -$oContent = new PatternCustom(); | ||
| 103 | -$aResults = $oBrowser->browse(); | ||
| 104 | - | ||
| 105 | -require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 106 | - | ||
| 107 | -if (PEAR::isError($aResults)) { | ||
| 108 | - $oContent->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | ||
| 109 | - $main->setErrorMessage($aResults->getMessage()); | ||
| 110 | - $main->setCentralPayload($oContent); | ||
| 111 | - $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 112 | - $main->setSubmitMethod("GET"); | ||
| 113 | - $main->render(); | ||
| 114 | - exit(0); | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | -if (($fBrowseType == "folder") && (!isset($fFolderID))) { | ||
| 118 | - // FIXME: check that the first folder in the array exists, no permission otherwise | ||
| 119 | - if ($default->browseToRoot) { | ||
| 120 | - controllerRedirect("browse", "fFolderID=1"); | ||
| 121 | - } else { | ||
| 122 | - controllerRedirect("browse", "fFolderID=" . $aResults["folders"][0]->getID()); | ||
| 123 | - } | ||
| 124 | -} | ||
| 125 | - | ||
| 126 | -// display the browse results | ||
| 127 | -$oContent->addHtml(renderPage($aResults, $fBrowseType, $fSortBy, $fSortDirection)); | ||
| 128 | -$main->setCentralPayload($oContent); | ||
| 129 | -$main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 130 | -$main->setSubmitMethod("GET"); | ||
| 131 | -$main->render(); | ||
| 132 | - | ||
| 133 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -/// XXX: extractGPC in UI?(!) | ||
| 4 | -KTUtil::extractGPC('fBrowseType', 'fCategoryName', 'fDocumentTypeID', 'fFolderID'); | ||
| 5 | - | ||
| 6 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 7 | -require_once("$default->uiDirectory/foldermanagement/folderUI.inc"); | ||
| 8 | -require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); | ||
| 9 | -require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * $Id$ | ||
| 13 | - * | ||
| 14 | - * Document browsing page html UI building functions. | ||
| 15 | - * | ||
| 16 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 17 | - * | ||
| 18 | - * This program is free software; you can redistribute it and/or modify | ||
| 19 | - * it under the terms of the GNU General Public License as published by | ||
| 20 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 21 | - * (at your option) any later version. | ||
| 22 | - * | ||
| 23 | - * This program is distributed in the hope that it will be useful, | ||
| 24 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 25 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 26 | - * GNU General Public License for more details. | ||
| 27 | - * | ||
| 28 | - * You should have received a copy of the GNU General Public License | ||
| 29 | - * along with this program; if not, write to the Free Software | ||
| 30 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 31 | - * | ||
| 32 | - * @version $Revision$ | ||
| 33 | - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 34 | - * @package documentmanagement | ||
| 35 | - */ | ||
| 36 | - | ||
| 37 | -/** | ||
| 38 | - * Generates radio button selects for document browse by type | ||
| 39 | - * Javascript refreshes the form when it changes | ||
| 40 | - * | ||
| 41 | - * @param string the selected browse by option | ||
| 42 | - */ | ||
| 43 | -function renderBrowseTypeSelect($sBrowseType) { | ||
| 44 | - // TODO: write function for onChange that checks if the new value | ||
| 45 | - return "<span class=\"browseTypeSelect\">\n | ||
| 46 | - \t" . _("View documents by") . ": <input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"folder\"" . | ||
| 47 | - ((($sBrowseType=="folder") || (strlen($sBrowseType)==0)) ? " checked=\"checked\"" : "") . "/> " . _("Folders") ."\n" . | ||
| 48 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"category\"" . | ||
| 49 | - (($sBrowseType=="category") ? " checked=\"checked\"" : "") . "/> " . _("Category") . "\n" . | ||
| 50 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"documentType\"" . | ||
| 51 | - (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> " . _("Document Type") . "\n</span>"; | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -// <category browse helper methods> | ||
| 55 | - | ||
| 56 | -/** | ||
| 57 | - * Displays the passed category path as a link | ||
| 58 | - * | ||
| 59 | - * @param string the category name to display | ||
| 60 | - */ | ||
| 61 | -function displayCategoryPathLink($aCategories) { | ||
| 62 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 63 | - if ($aCategories[0] == "Categories") { | ||
| 64 | - return displayCategoryLink($aCategories[0]); | ||
| 65 | - } else { | ||
| 66 | - // else the first entry is the category name, so build a little path | ||
| 67 | - return displayCategoryLink("Categories") . ($aCategories[0] ? " > " . displayCategoryLink($aCategories[0]) : ""); | ||
| 68 | - } | ||
| 69 | -} | ||
| 70 | - | ||
| 71 | -/** | ||
| 72 | - * Displays the passed category as a link | ||
| 73 | - * | ||
| 74 | - * @param string the category name to display | ||
| 75 | - */ | ||
| 76 | -function displayCategoryLink($sCategoryName) { | ||
| 77 | - if ($sCategoryName != "") { | ||
| 78 | - return generateLink($_SERVER["PHP_SELF"], | ||
| 79 | - "fBrowseType=category" . | ||
| 80 | - // if the category title is passed in, link back to the list of categories | ||
| 81 | - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), | ||
| 82 | - $sCategoryName); | ||
| 83 | - } else { | ||
| 84 | - return false; | ||
| 85 | - } | ||
| 86 | -} | ||
| 87 | - | ||
| 88 | -/** | ||
| 89 | - * Displays the results for category browsing | ||
| 90 | - * | ||
| 91 | - * @param array the category browse results | ||
| 92 | - */ | ||
| 93 | -function renderCategoryResults($aResults) { | ||
| 94 | - global $oBrowser; | ||
| 95 | - $sToRender = ""; | ||
| 96 | - | ||
| 97 | - //var_dump($aResults["categories"][0]); | ||
| 98 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 99 | - if ($aResults["categories"][0] == "Categories") { | ||
| 100 | - // loop through categories and display them | ||
| 101 | - for ($i=1; $i<count($aResults["categories"]); $i++) { | ||
| 102 | - $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; | ||
| 103 | - $sToRender .= "<td> </td>\n"; // for the checkboxes | ||
| 104 | - | ||
| 105 | - // category name | ||
| 106 | - $sToRender .= "<td>" . displayCategoryLink($aResults["categories"][$i]) . "</td>"; | ||
| 107 | - // blank filename | ||
| 108 | - $sToRender .= "<td> </td>"; | ||
| 109 | - // creator name | ||
| 110 | - $sToRender .= "<td> </td>"; | ||
| 111 | - // modified date | ||
| 112 | - $sToRender .= "<td> </td>"; | ||
| 113 | - // document type | ||
| 114 | - $sToRender .= "<td> </td>"; | ||
| 115 | - | ||
| 116 | - $sToRender .= "</tr>\n"; | ||
| 117 | - } | ||
| 118 | - } else { | ||
| 119 | - if (count($aResults["categories"]) > 0) { | ||
| 120 | - // else the first entry is the category name, so display the documents in the category | ||
| 121 | - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); | ||
| 122 | - } else { | ||
| 123 | - $sToRender .= "<tr><td colspan=\"" . ($oBrowser->columns() + 1) . "\"><font color=\"red\">" . _("There is no Category Document Field- contact a System Administrator.") . "</font></td></tr>"; | ||
| 124 | - } | ||
| 125 | - } | ||
| 126 | - return $sToRender; | ||
| 127 | -} | ||
| 128 | - | ||
| 129 | -// </category browse helper methods> | ||
| 130 | - | ||
| 131 | -// <document type display helper methods> | ||
| 132 | -/** | ||
| 133 | - * Displays the passed document type path as a link | ||
| 134 | - * | ||
| 135 | - * @param string the document type to display | ||
| 136 | - */ | ||
| 137 | -function displayDocumentTypePathLink($aDocumentTypes) { | ||
| 138 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 139 | - if ($aDocumentTypes[0]["name"] == "Document Types") { | ||
| 140 | - return displayDocumentTypeLink($aDocumentTypes[0]); | ||
| 141 | - } else { | ||
| 142 | - // else the first entry is the category name, so build a little path | ||
| 143 | - return displayDocumentTypeLink(array("name"=>"Document Types")) . " > " . displayDocumentTypeLink($aDocumentTypes[0]); | ||
| 144 | - } | ||
| 145 | -} | ||
| 146 | - | ||
| 147 | -/** | ||
| 148 | - * Displays the passed document type as a link | ||
| 149 | - * | ||
| 150 | - * @param string the document type to display | ||
| 151 | - */ | ||
| 152 | -function displayDocumentTypeLink($aDocumentType) { | ||
| 153 | - return generateLink($_SERVER["PHP_SELF"], | ||
| 154 | - "fBrowseType=documentType" . | ||
| 155 | - // if the document type title is passed in, link back to the list of document types | ||
| 156 | - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), | ||
| 157 | - $aDocumentType["name"]); | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -/** | ||
| 161 | - * Displays the results for document type browsing | ||
| 162 | - * | ||
| 163 | - * @param array the document type browse results | ||
| 164 | - */ | ||
| 165 | -function renderDocumentTypeResults($aResults) { | ||
| 166 | - $sToRender = ""; | ||
| 167 | - | ||
| 168 | - // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types | ||
| 169 | - if ($aResults["documentTypes"][0]["name"] == "Document Types") { | ||
| 170 | - // loop through document types and display them | ||
| 171 | - for ($i=1; $i<count($aResults["documentTypes"]); $i++) { | ||
| 172 | - $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">\n"; | ||
| 173 | - $sToRender .= "<td> </td>\n"; // for the checkboxes | ||
| 174 | - // document type name | ||
| 175 | - $sToRender .= "<td>" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "</td>\n"; | ||
| 176 | - // blank filename | ||
| 177 | - $sToRender .= "<td> </td>\n"; | ||
| 178 | - // creator name | ||
| 179 | - $sToRender .= "<td> </td>\n"; | ||
| 180 | - // modified date | ||
| 181 | - $sToRender .= "<td> </td>\n"; | ||
| 182 | - // document type | ||
| 183 | - $sToRender .= "<td> </td>\n"; | ||
| 184 | - $sToRender .= "</tr>\n"; | ||
| 185 | - } | ||
| 186 | - } else { | ||
| 187 | - // else the first entry is the document type name, so display the documents in the document type | ||
| 188 | - $sToRender .= renderDocumentList($aResults, _("This document type contains no documents"), _("You don't have access to the documents in this document type")); | ||
| 189 | - } | ||
| 190 | - return $sToRender; | ||
| 191 | -} | ||
| 192 | -// </document type browse helper methods> | ||
| 193 | - | ||
| 194 | - | ||
| 195 | -// <folder browse helper methods> | ||
| 196 | -/** | ||
| 197 | - * Displays the folders in the browse results | ||
| 198 | - * | ||
| 199 | - * @param array the browse result objects | ||
| 200 | - */ | ||
| 201 | -function renderFolderResults($aResults, $bTemplateBrowsing = false) { | ||
| 202 | - global $default; | ||
| 203 | - global $oBrowser; | ||
| 204 | - $sToRender = ""; | ||
| 205 | - | ||
| 206 | - // now loop through the rest of the folders and display links | ||
| 207 | - if (count($aResults["folders"]) > 1) { | ||
| 208 | - for ($i=1; $i<count($aResults["folders"]); $i++) { | ||
| 209 | - $oFolder = $aResults["folders"][$i]; | ||
| 210 | - | ||
| 211 | - $sFolderLink = displayFolderLink($aResults["folders"][$i]); | ||
| 212 | - $oCreator = User::get($aResults["folders"][$i]->getCreatorID()); | ||
| 213 | - | ||
| 214 | - // the first element of the array contains the current folder name | ||
| 215 | - $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">\n"; | ||
| 216 | - $sToRender .= "<td width=\"10\"> </td>\n"; // for the checkboxes | ||
| 217 | - | ||
| 218 | - foreach (array_values($oBrowser->getSortCriteria()) as $oCriterion) { | ||
| 219 | - $sToRender .= "<td valign=\"bottom\">" . $oCriterion->folderDisplay($oFolder) . "</td>\n"; | ||
| 220 | - } | ||
| 221 | - $sToRender .= "</tr>\n"; | ||
| 222 | - } | ||
| 223 | - } else { | ||
| 224 | - $sToRender .= "<tr><td colspan=\"" . ($oBrowser->columns() + 1) . "\">" . _("This folder contains no sub folders") . "</td></tr>"; | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - $sToRender .= renderDocumentList($aResults, _("This folder contains no documents"), | ||
| 228 | - _("You don't have access to the documents in this folder"), | ||
| 229 | - false, $bTemplateBrowsing) . "\n"; | ||
| 230 | - | ||
| 231 | - return $sToRender; | ||
| 232 | -} | ||
| 233 | -// </folder browse helper methods> | ||
| 234 | - | ||
| 235 | -/** | ||
| 236 | - * Displays the headings for the displayed document details and enables | ||
| 237 | - * resorting the contents | ||
| 238 | - * | ||
| 239 | - * @param string the field currently sorting by | ||
| 240 | - * @param string the direction currently sorted in | ||
| 241 | - */ | ||
| 242 | -function renderSortHeadings($sSortBy, $sSortDirection) { | ||
| 243 | - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; | ||
| 244 | - | ||
| 245 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 246 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 247 | - | ||
| 248 | - // need list of display criteria and sort name | ||
| 249 | - $aSortCriteria = $oBrowser->getSortCriteria(); | ||
| 250 | - | ||
| 251 | - $sToRender .= "<tr bgcolor=\"$sTDBGColour\">\n"; | ||
| 252 | - $sToRender .= "<td width=\"10\"> </td>\n"; // For the checkboxes | ||
| 253 | - while (list($key, $value) = each ($aSortCriteria)) { | ||
| 254 | - $sCurrentSortDirection = "asc"; | ||
| 255 | - if (is_array($value)) { | ||
| 256 | - $displayText = $value["display"]; | ||
| 257 | - } else { | ||
| 258 | - $displayText = $value->headerDisplay(); | ||
| 259 | - } | ||
| 260 | - // if the current heading is being sorted then flip the sort direction | ||
| 261 | - if ($sSortBy == $key) { | ||
| 262 | - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); | ||
| 263 | - $displayText = "<img border=\"0\" src=\"" . imgSrc($sCurrentSortDirection . ".gif") . "\">" . $displayText; | ||
| 264 | - } | ||
| 265 | - switch ($fBrowseType) { | ||
| 266 | - case "folder" : | ||
| 267 | - $queryString = "fFolderID=$fFolderID"; | ||
| 268 | - break; | ||
| 269 | - case "category" : | ||
| 270 | - $queryString = "fCategoryName=$fCategoryName"; | ||
| 271 | - break; | ||
| 272 | - case "documentType" : | ||
| 273 | - $queryString = "fDocumentTypeID=$fDocumentTypeID"; | ||
| 274 | - break; | ||
| 275 | - } | ||
| 276 | - $sToRender .= "<td>" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . "</td>\n"; | ||
| 277 | - } | ||
| 278 | - | ||
| 279 | - $sToRender .= "</tr>\n"; | ||
| 280 | - return $sToRender; | ||
| 281 | -} | ||
| 282 | - | ||
| 283 | -/** | ||
| 284 | - * Displays the documents in the browse results | ||
| 285 | - * | ||
| 286 | - * @param array the browse result objects | ||
| 287 | - * @param string the message to display if there are no documents | ||
| 288 | - * @param string the message to display if the current user doesn't have permission to view the documents | ||
| 289 | - * @param boolean whether to display the complete path to the document or not | ||
| 290 | - */ | ||
| 291 | -function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false, $bTemplateBrowsing = false) { | ||
| 292 | - global $default; | ||
| 293 | - global $oBrowser; | ||
| 294 | - | ||
| 295 | - $oBrowser->setOptions(array( | ||
| 296 | - 'displayFullPath' => $bDisplayFullPath, | ||
| 297 | - 'templateBrowsing' => $bTemplateBrowsing, | ||
| 298 | - )); | ||
| 299 | - | ||
| 300 | - $aSortCriteria = $oBrowser->getSortCriteria(); | ||
| 301 | - | ||
| 302 | - $iFolderCount = count($aResults["folders"]) - 1; | ||
| 303 | - // loop through the files and display links | ||
| 304 | - if (count($aResults["documents"]) > 0) { | ||
| 305 | - for ($i=0; $i<count($aResults["documents"]); $i++) { | ||
| 306 | - // in order for candy striping to work we need to take the number of folders | ||
| 307 | - // into account when alternating | ||
| 308 | - $oDocument = $aResults["documents"][$i]; | ||
| 309 | - | ||
| 310 | - $sToRender .= "<tr bgcolor=\"" . getColour($i+$iFolderCount) . "\" width=\"100%\">\n"; | ||
| 311 | - $sToRender .= "<td valign=\"bottom\" width=\"10\">" . | ||
| 312 | - "<input type=\"checkbox\" name=\"fDocumentIDs[]\" value=\"" . $aResults["documents"][$i]->getID() . "\"/></td>\n"; | ||
| 313 | - | ||
| 314 | - /*$sToRender .= "<td valign=\"bottom\">" . $aSortCriteria["name"]->documentDisplay($oDocument) . "</td>"; | ||
| 315 | - $sToRender .= "<td valign=\"bottom\">" . $aSortCriteria["filename"]->documentDisplay($oDocument) . "</td>"; | ||
| 316 | - $sToRender .= "<td valign=\"bottom\">" . $aSortCriteria["creator_id"]->documentDisplay($oDocument) . "</td>"; | ||
| 317 | - $sToRender .= "<td valign=\"bottom\">" . $aSortCriteria['id']->documentDisplay($oDocument) . "</td>"; | ||
| 318 | - $sToRender .= "<td valign=\"bottom\">" . $aSortCriteria['document_type_id']->documentDisplay($oDocument) . "</td>"; | ||
| 319 | - $sToRender .= "<td valign=\"bottom\">" . $aSortCriteria['category']->documentDisplay($oDocument) . "</td>"; | ||
| 320 | - */ | ||
| 321 | - foreach (array_values($aSortCriteria) as $oCriterion) { | ||
| 322 | - $sToRender .= "<td valign=\"bottom\">" . $oCriterion->documentDisplay($oDocument) . "</td>"; | ||
| 323 | - } | ||
| 324 | - | ||
| 325 | - $sToRender .= "</tr>\n"; | ||
| 326 | - } | ||
| 327 | - | ||
| 328 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 329 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 330 | - | ||
| 331 | - $sToRender .= "<tr bgcolor=\"". $sTDBGColour . "\"><td colspan=\"" . ($oBrowser->columns() + 1) . "\" valign=\"bottom\">" . | ||
| 332 | - "<input type=\"checkbox\" name=\"selectall\" onClick=\"selectAll()\"/> " . _("Select all documents") . "</td></tr>"; | ||
| 333 | - | ||
| 334 | - $sToRender .= "<tr><td colspan=\"" . ($oBrowser->columns() + 1) . "\" >"; | ||
| 335 | - $sToRender .= "<input type=\"hidden\" name=\"fActions\">"; | ||
| 336 | - | ||
| 337 | - $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='move'; document.MainForm.method = 'POST'; document.MainForm.submit()\" src=\"" . KTHtml::getMoveButton() . "\" border=\"0\"/>"; | ||
| 338 | - $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='delete'; document.MainForm.method = 'POST'; document.MainForm.submit()\" src=\"" . KTHtml::getDeleteButton() . "\" border=\"0\"/>"; | ||
| 339 | - $sToRender .= "</td></tr>\n"; | ||
| 340 | - // Change for group Operations | ||
| 341 | - | ||
| 342 | - | ||
| 343 | - } else if ($aResults["accessDenied"]) { | ||
| 344 | - $sToRender .= "<tr><td colspan=\"" . ($oBrowser->columns() + 1) . "\">$sNoPermissionMessage</td></tr>"; | ||
| 345 | - } else { | ||
| 346 | - $sToRender .= "<tr><td colspan=\"" . ($oBrowser->columns() + 1) . "\">$sNoDocumentsMessage</td></tr>"; | ||
| 347 | - } | ||
| 348 | - return $sToRender; | ||
| 349 | -} | ||
| 350 | - | ||
| 351 | -/** | ||
| 352 | - * #3426 | ||
| 353 | - * Appends folder and document counts to the last folder path | ||
| 354 | - */ | ||
| 355 | -function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { | ||
| 356 | - // append to the last path component and return | ||
| 357 | - $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . | ||
| 358 | - " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . | ||
| 359 | - ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; | ||
| 360 | - return $aFolderPath; | ||
| 361 | -} | ||
| 362 | - | ||
| 363 | -/** | ||
| 364 | - * Displays the browse page- lists folders and documents | ||
| 365 | - * | ||
| 366 | - * @param array the browse results to display | ||
| 367 | - * @param string the browse view (folder, category, document type) | ||
| 368 | - * @param string the field to sort the results by | ||
| 369 | - * @param string the direction to sort | ||
| 370 | - */ | ||
| 371 | - | ||
| 372 | -function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection, $bTemplateBrowsing = false) { | ||
| 373 | - global $default; | ||
| 374 | - | ||
| 375 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 376 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 377 | - | ||
| 378 | - $sToRender = renderHeading(_("Browse collection")); | ||
| 379 | - | ||
| 380 | - // Script function to select all documents | ||
| 381 | - $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n "; | ||
| 382 | - $sToRender .= "<!--\n"; | ||
| 383 | - $sToRender .= "function selectAll() {\n"; | ||
| 384 | - $sToRender .= "\tf = document.MainForm;\n"; | ||
| 385 | - $sToRender .= "\tc = f.selectall.checked;\n"; | ||
| 386 | - $sToRender .= "\tif (f.elements['fDocumentIDs[]']) {\n"; | ||
| 387 | - $sToRender .= "\t\tif (f.elements['fDocumentIDs[]'].length > 1) {\n"; | ||
| 388 | - $sToRender .= "\t\t\tfor (i = 0; i < f.elements['fDocumentIDs[]'].length; i++) f.elements['fDocumentIDs[]'][i].checked = c;\n"; | ||
| 389 | - $sToRender .= "\t\t} else {\n"; | ||
| 390 | - $sToRender .= "\t\t\tf.elements['fDocumentIDs[]'].checked = c;\n"; | ||
| 391 | - $sToRender .= "\t}}}\n"; | ||
| 392 | - $sToRender .= "//-->\n"; | ||
| 393 | - $sToRender .= "</SCRIPT>\n\n"; | ||
| 394 | - | ||
| 395 | - $sToRender .= "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td bgcolor=\"$sTDBGColour\">"; | ||
| 396 | - switch ($sBrowseType) { | ||
| 397 | - case "folder": | ||
| 398 | - $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), | ||
| 399 | - appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), | ||
| 400 | - count($aResults["folders"])-1, count($aResults["documents"]))); | ||
| 401 | - break; | ||
| 402 | - case "category": | ||
| 403 | - $sToRender .= displayCategoryPathLink($aResults["categories"]); | ||
| 404 | - break; | ||
| 405 | - case "documentType": | ||
| 406 | - $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); | ||
| 407 | - break; | ||
| 408 | - } | ||
| 409 | - $sToRender .= "</td></tr></table>\n"; | ||
| 410 | - | ||
| 411 | - // browse type select | ||
| 412 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 413 | - $sToRender .= "\t<tr><td bgcolor=\"$sTDBGColour\">" . renderBrowseTypeSelect($sBrowseType) . "</td></tr>"; | ||
| 414 | - $sToRender .= "\t</table>"; | ||
| 415 | - | ||
| 416 | - // display folders|documents | ||
| 417 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 418 | - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); | ||
| 419 | - // $sToRender .= "<tr><td>\n"; | ||
| 420 | - switch ($sBrowseType) { | ||
| 421 | - case "folder": | ||
| 422 | - $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); | ||
| 423 | - break; | ||
| 424 | - case "category": | ||
| 425 | - $sToRender .= renderCategoryResults($aResults); | ||
| 426 | - break; | ||
| 427 | - case "documentType": | ||
| 428 | - $sToRender .= renderDocumentTypeResults($aResults); | ||
| 429 | - break; | ||
| 430 | - } | ||
| 431 | - // $sToRender .= "</tr></td>\n"; | ||
| 432 | - $sToRender .= "\t</table>"; | ||
| 433 | - | ||
| 434 | - return $sToRender; | ||
| 435 | -} | ||
| 436 | - | ||
| 437 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyBL.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Business logic data used to modify documents (will use modifyUI.inc) | ||
| 6 | - * | ||
| 7 | - * Expected form variables: | ||
| 8 | - * o fDocumentID - primary key of document being edited | ||
| 9 | - * Optional form variables | ||
| 10 | - * o fForUpdate - generated when user clicks update on page and results in database update | ||
| 11 | - * o fFirstEdit - generated from the document upload page when the user first uploads a document. | ||
| 12 | - * Is used to force the user to enter the necessary generic meta data. | ||
| 13 | - * | ||
| 14 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 15 | - * | ||
| 16 | - * This program is free software; you can redistribute it and/or modify | ||
| 17 | - * it under the terms of the GNU General Public License as published by | ||
| 18 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 19 | - * (at your option) any later version. | ||
| 20 | - * | ||
| 21 | - * This program is distributed in the hope that it will be useful, | ||
| 22 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 23 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 24 | - * GNU General Public License for more details. | ||
| 25 | - * | ||
| 26 | - * You should have received a copy of the GNU General Public License | ||
| 27 | - * along with this program; if not, write to the Free Software | ||
| 28 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 29 | - * | ||
| 30 | - * @version $Revision$ | ||
| 31 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 32 | - * @package documentmanagement | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 36 | - | ||
| 37 | -KTUtil::extractGPC('fDocumentID', 'fDocumentName', 'fDocumentTypeID', 'fFirstEdit', 'fForUpdate'); | ||
| 38 | - | ||
| 39 | -if (checkSession()) { | ||
| 40 | - | ||
| 41 | - require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 42 | - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 43 | - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 44 | - require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); | ||
| 45 | - require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionManager.inc"); | ||
| 46 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 47 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | ||
| 48 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); | ||
| 49 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc"); | ||
| 50 | - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc"); | ||
| 51 | - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | ||
| 52 | - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 53 | - require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 54 | - | ||
| 55 | - $oDocument = & Document::get($fDocumentID); | ||
| 56 | - if (Permission::userHasDocumentWritePermission($oDocument)) { | ||
| 57 | - //if the user has write permission | ||
| 58 | - if (isset($fForUpdate)) { | ||
| 59 | - //if the user is updating the values | ||
| 60 | - $oDocument->setName($fDocumentName); | ||
| 61 | - | ||
| 62 | - if ($oDocument->getDocumentTypeID() != $fDocumentTypeID) { | ||
| 63 | - //the user has changed the document type | ||
| 64 | - //get rid of all the old document type entries | ||
| 65 | - $oDocument->removeInvalidDocumentTypeEntries(); | ||
| 66 | - $oDocument->setDocumentTypeID($fDocumentTypeID); | ||
| 67 | - $bUpdateMetaData = true; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - if ($oDocument->update()) { | ||
| 71 | - // fire subscription alerts for the modified document | ||
| 72 | - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"), | ||
| 73 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | ||
| 74 | - array( "folderID" => $oDocument->getFolderID(), | ||
| 75 | - "modifiedDocumentName" => $oDocument->getName())); | ||
| 76 | - $default->log->info("modifyBL.php fired $count subscription alerts for modified document " . $oDocument->getName()); | ||
| 77 | - | ||
| 78 | - //on successful update, redirect to the view page | ||
| 79 | - if (isset($bUpdateMetaData)) { | ||
| 80 | - controllerRedirect("modifyDocumentTypeMetaData", "fDocumentID=" . $oDocument->getID() . "&fFirstEdit=1"); | ||
| 81 | - } else { | ||
| 82 | - controllerRedirect("viewDocument", "fDocumentID=" . $oDocument->getID()); | ||
| 83 | - } | ||
| 84 | - } else { | ||
| 85 | - //display the update page with an error message | ||
| 86 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 87 | - $oPatternCustom = & new PatternCustom(); | ||
| 88 | - $oPatternCustom->setHtml(renderPage($oDocument, $oDocument->getDocumentTypeID(), $fFirstEdit)); | ||
| 89 | - $main->setCentralPayload($oPatternCustom); | ||
| 90 | - $main->setHasRequiredFields(true); | ||
| 91 | - if (isset($fFirstEdit)) { | ||
| 92 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fFirstEdit=1"); | ||
| 93 | - } else { | ||
| 94 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); | ||
| 95 | - } | ||
| 96 | - $main->setHasRequiredFields(true); | ||
| 97 | - $main->setErrorMessage(_("An error occured while attempting to update the document")); | ||
| 98 | - $main->render(); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - } else { | ||
| 102 | - //display the update page | ||
| 103 | - $oDocument = & Document::get($fDocumentID); | ||
| 104 | - $oPatternCustom = & new PatternCustom(); | ||
| 105 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 106 | - $oPatternCustom->setHtml(renderPage($oDocument, $oDocument->getDocumentTypeID(), $fFirstEdit)); | ||
| 107 | - $main->setCentralPayload($oPatternCustom); | ||
| 108 | - $main->setHasRequiredFields(true); | ||
| 109 | - if (isset($fFirstEdit)) { | ||
| 110 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fFirstEdit=1"); | ||
| 111 | - } else { | ||
| 112 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - $main->setHasRequiredFields(true); | ||
| 116 | - $main->render(); | ||
| 117 | - } | ||
| 118 | - } else { | ||
| 119 | - //user doesn't have permission to edit this page | ||
| 120 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 121 | - $oPatternCustom = & new PatternCustom(); | ||
| 122 | - $oPatternCustom->setHtml(""); | ||
| 123 | - $main->setCentralPayload($oPatternCustom); | ||
| 124 | - $main->setErrorMessage(_("You do not have permission to edit this document")); | ||
| 125 | - $main->render(); | ||
| 126 | - } | ||
| 127 | -} | ||
| 128 | - | ||
| 129 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataBL.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Expected form variables: | ||
| 6 | - * o fDocumentID - primary key of document being editid | ||
| 7 | - * Optional form variables: | ||
| 8 | - * o fFirstTime - set by addDocumentBL on first time uploads and forces the user to | ||
| 9 | - * fill out the generic meta data | ||
| 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('fDocumentID', 'fFirstEdit'); | ||
| 35 | - | ||
| 36 | -if (checkSession()) { | ||
| 37 | - | ||
| 38 | - require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 39 | - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 40 | - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 41 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); | ||
| 42 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMetaData.inc"); | ||
| 43 | - require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 44 | - require_once("documentUI.inc"); | ||
| 45 | - require_once("modifyGenericMetaDataUI.inc"); | ||
| 46 | - | ||
| 47 | - $oDocument = Document::get($fDocumentID); | ||
| 48 | - if (Permission::userHasDocumentWritePermission($oDocument)) { | ||
| 49 | - | ||
| 50 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 51 | - $oPatternCustom = & new PatternCustom(); | ||
| 52 | - $oPatternCustom->setHtml(getPage($fDocumentID, $oDocument->getDocumentTypeID(), $fFirstEdit)); | ||
| 53 | - $main->setCentralPayload($oPatternCustom); | ||
| 54 | - if (isset($fFirstEdit)) { | ||
| 55 | - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true; | ||
| 56 | - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=modifyDocumentTypeMetaData&fDocumentID=$fDocumentID&fFirstEdit=1")); | ||
| 57 | - } else { | ||
| 58 | - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true; | ||
| 59 | - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID&fShowSection=genericMetaData")); | ||
| 60 | - } | ||
| 61 | - $main->setHasRequiredFields(true); | ||
| 62 | - $main->render(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | -} | ||
| 66 | - | ||
| 67 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataUI.inc deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Contains UI functions to display the generic meta data edit page.. | ||
| 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 | -function getEditableGenericMetaData($iDocumentID, $iDocumentTypeID) { | ||
| 29 | - global $default; | ||
| 30 | - /*ok*/ $sQuery = array("SELECT DISTINCT ? AS document_id, COALESCE(DFL.id, -1) AS id, DF.id AS document_field_id, DFL.value AS value, DF.name AS field_name " . | ||
| 31 | - "FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id AND DFL.document_id = ? " . | ||
| 32 | - "WHERE DF.is_generic = 1 ", array($iDocumentID, $iDocumentID)); | ||
| 33 | - | ||
| 34 | - $aStoreColumnNames = array("document_id", "document_field_id","value"); | ||
| 35 | - $aDisplayColumnNames = array("document_id", "field_name", "value"); | ||
| 36 | - $aMetaDataColumnNames = array(2=>"field_name"); | ||
| 37 | - $aColumnsEditable = array(0,0,1); | ||
| 38 | - $aColumnsVisible = array(0,1,1); | ||
| 39 | - $aColumnDisplayTypes = array(1,1,4); | ||
| 40 | - $aColumnDatabaseTypes = array(0,0,1); | ||
| 41 | - | ||
| 42 | - $oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes); | ||
| 43 | - $oPatternTableSqlQuery->setTableCaption(_("Generic Meta Data")); | ||
| 44 | - $oPatternTableSqlQuery->setUniqueName("gmd"); | ||
| 45 | - $oPatternTableSqlQuery->setRequiredColumnNames(array("value")); | ||
| 46 | - $oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames); | ||
| 47 | - $oPatternTableSqlQuery->setEmptyTableMessage(_("No Generic Meta Data")); | ||
| 48 | - $oPatternTableSqlQuery->setPreCode(sprintf('require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); KTDocumentUtil::createMetadataVersion(%d);', (int)$iDocumentID)); | ||
| 49 | - $oPatternTableSqlQuery->setPostCode(sprintf('require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); KTDocumentUtil::bumpVersion(%d); KTDocumentUtil::setModifiedDate(%d);', (int)$iDocumentID, (int)$iDocumentID)); | ||
| 50 | - return $oPatternTableSqlQuery->render(); | ||
| 51 | - | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -function getPage($iDocumentID, $iDocumentTypeID, $bFirstEdit) { | ||
| 55 | - global $default; | ||
| 56 | - | ||
| 57 | - $sToRender .= renderHeading(_("Edit Generic Meta Data")); | ||
| 58 | - $sToRender .= displayDocumentPath($iDocumentID); | ||
| 59 | - $sToRender .= "<table>\n"; | ||
| 60 | - $sToRender .= "<tr>\n"; | ||
| 61 | - $sToRender .= "<td>\n"; | ||
| 62 | - $sToRender .= getEditableGenericMetaData($iDocumentID, $iDocumentTypeID); | ||
| 63 | - $sToRender .= "</td>\n"; | ||
| 64 | - $sToRender .= "</tr>\n"; | ||
| 65 | - $sToRender .= "<tr>\n"; | ||
| 66 | - $sToRender .= "<td>\n"; | ||
| 67 | - | ||
| 68 | - $sToRender .= "<table>\n"; | ||
| 69 | - $sToRender .= "<tr>\n"; | ||
| 70 | - $sToRender .= "<td>\n"; | ||
| 71 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getUpdateButton() . "\" border=\"0\"/>\n"; | ||
| 72 | - $sToRender .= "</td>\n"; | ||
| 73 | - if (!isset($bFirstEdit)) { | ||
| 74 | - //can't cancel if you're uploading for the first time, must fill out the generic meta data | ||
| 75 | - $sToRender .= "<td>\n"; | ||
| 76 | - $sToRender .= "<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID&fShowSection=genericMetaData\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\" /></a>\n"; | ||
| 77 | - $sToRender .= "</td>\n"; | ||
| 78 | - $sToRender .= "</tr>\n"; | ||
| 79 | - } | ||
| 80 | - $sToRender .= "</table>\n"; | ||
| 81 | - | ||
| 82 | - $sToRender .= "</td>\n"; | ||
| 83 | - $sToRender .= "</tr>\n"; | ||
| 84 | - $sToRender .= "</table>\n"; | ||
| 85 | - | ||
| 86 | - return $sToRender; | ||
| 87 | -} | ||
| 88 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataBL.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Business logic to modify type specific meta data for a document. | ||
| 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("../../../../config/dmsDefaults.php"); | ||
| 29 | - | ||
| 30 | -KTUtil::extractGPC('fDocumentID', 'fFirstEdit', 'fForStore'); | ||
| 31 | - | ||
| 32 | -if (!checkSession()) { | ||
| 33 | - die(); | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 37 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 38 | -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 39 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 40 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); | ||
| 41 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMetaData.inc"); | ||
| 42 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 43 | -require_once("documentUI.inc"); | ||
| 44 | -require_once("modifySpecificMetaDataUI.inc"); | ||
| 45 | - | ||
| 46 | -require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); | ||
| 47 | - | ||
| 48 | -$oDocument = Document::get($fDocumentID); | ||
| 49 | -if (!Permission::userHasDocumentWritePermission($oDocument)) { | ||
| 50 | - die(); | ||
| 51 | -} | ||
| 52 | - | ||
| 53 | -if (empty($fForStore)) { | ||
| 54 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 55 | - $oPatternCustom = & new PatternCustom(); | ||
| 56 | - $oPatternCustom->setHtml(getPage($fDocumentID, $oDocument->getDocumentTypeID(), $fFirstEdit)); | ||
| 57 | - $main->setCentralPayload($oPatternCustom); | ||
| 58 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForStore=1"); | ||
| 59 | - $main->setHasRequiredFields(true); | ||
| 60 | - $main->render(); | ||
| 61 | - exit(0); | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -$matches = array(); | ||
| 65 | -$aFields = array(); | ||
| 66 | -foreach ($_REQUEST as $k => $v) { | ||
| 67 | - if (preg_match('/^emd(\d+)$/', $k, $matches)) { | ||
| 68 | - $aFields[] = array(DocumentField::get($matches[1]), $v); | ||
| 69 | - } | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -DBUtil::startTransaction(); | ||
| 73 | -KTDocumentUtil::createMetadataVersion($oDocument->getID()); | ||
| 74 | -$res = KTDocumentUtil::saveMetadata($oDocument, $aFields); | ||
| 75 | -if (PEAR::isError($res)) { | ||
| 76 | - DBUtil::rollback(); | ||
| 77 | - $_SESSION['KTErrorMessages'][] = $res->getMessage(); | ||
| 78 | - controllerRedirect('modifyDocumentTypeMetaData', "fDocumentID=$fDocumentID"); | ||
| 79 | - exit(0); | ||
| 80 | -} | ||
| 81 | -KTDocumentUtil::bumpVersion($oDocument->getID()); | ||
| 82 | -KTDocumentUtil::setModifiedDate($oDocument->getID()); | ||
| 83 | -DBUtil::commit(); | ||
| 84 | - | ||
| 85 | -if (isset($fFirstEdit)) { | ||
| 86 | - controllerRedirect('viewDocument', "fDocumentID=$fDocumentID"); | ||
| 87 | -} else { | ||
| 88 | - controllerRedirect('viewDocument', "fDocumentID=$fDocumentID&fShowSection=typeSpecificMetaData"); | ||
| 89 | -} | ||
| 90 | - | ||
| 91 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataUI.inc deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Presentation information used by modifySpecificMetaDataBL.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 . '/templating/templating.inc.php'); | ||
| 29 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentField.inc'); | ||
| 30 | - | ||
| 31 | -function getEditableTypeSpecificMetaData($iDocumentID, $iDocumentTypeID) { | ||
| 32 | - global $default; | ||
| 33 | - /*ok*/ $sQuery = array("SELECT DF.id AS id " . | ||
| 34 | - "FROM document_fields AS DF LEFT JOIN document_type_fields_link AS DTFL ON DTFL.field_id = DF.id " . | ||
| 35 | - "WHERE DF.is_generic = ? " . | ||
| 36 | - "AND DTFL.document_type_id = ?", array(false, $iDocumentTypeID)); | ||
| 37 | - | ||
| 38 | - $aIDs = DBUtil::getResultArrayKey($sQuery, 'id'); | ||
| 39 | - | ||
| 40 | - $aFields = array(); | ||
| 41 | - $aValues = array(); | ||
| 42 | - foreach ($aIDs as $iID) { | ||
| 43 | - $aFields[] =& call_user_func(array('DocumentField', 'get'), $iID); | ||
| 44 | - $aValues[$iID] = DBUtil::getOneResultKey(array( | ||
| 45 | - "SELECT value FROM document_fields_link WHERE document_id = ? AND document_field_id = ?", | ||
| 46 | - array($iDocumentID, $iID), | ||
| 47 | - ), 'value'); | ||
| 48 | - } | ||
| 49 | - $aTemplateData = array( | ||
| 50 | - 'caption' => _('Type specific meta data'), | ||
| 51 | - 'empty_message' => _("No Type Specific Meta Data"), | ||
| 52 | - 'fields' => $aFields, | ||
| 53 | - 'values' => $aValues, | ||
| 54 | - ); | ||
| 55 | - $oTemplating = KTTemplating::getSingleton(); | ||
| 56 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fields"); | ||
| 57 | - return $oTemplate->render($aTemplateData); | ||
| 58 | -} | ||
| 59 | - | ||
| 60 | -function getPage($iDocumentID, $iDocumentTypeID, $bFirstEdit) { | ||
| 61 | - global $default; | ||
| 62 | - $sToRender .= renderHeading(_("Edit Type Specific Meta Data")); | ||
| 63 | - $sToRender .= displayDocumentPath($iDocumentID); | ||
| 64 | - $sToRender .= "<table>\n"; | ||
| 65 | - $sToRender .= "<tr>\n"; | ||
| 66 | - $sToRender .= "<td>\n"; | ||
| 67 | - $sToRender .= getEditableTypeSpecificMetaData($iDocumentID, $iDocumentTypeID); | ||
| 68 | - $sToRender .= "</td>\n"; | ||
| 69 | - $sToRender .= "</tr>\n"; | ||
| 70 | - $sToRender .= "<tr>\n"; | ||
| 71 | - $sToRender .= "<td>\n"; | ||
| 72 | - | ||
| 73 | - $sToRender .= "<table>\n"; | ||
| 74 | - $sToRender .= "<tr>\n"; | ||
| 75 | - $sToRender .= "<td>\n"; | ||
| 76 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getUpdateButton() . "\" border=\"0\"/>\n"; | ||
| 77 | - $sToRender .= "</td>\n"; | ||
| 78 | - if (!isset($bFirstEdit)) { | ||
| 79 | - $sToRender .= "<td>\n"; | ||
| 80 | - $sToRender .= generateControllerLink("viewDocument", "fDocumentID=$iDocumentID&fShowSection=typeSpecificMetaData", "<img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/>"); | ||
| 81 | - $sToRender .= "</td>\n"; | ||
| 82 | - } | ||
| 83 | - $sToRender .= "</tr>\n"; | ||
| 84 | - $sToRender .= "</table>\n"; | ||
| 85 | - | ||
| 86 | - $sToRender .= "</td>\n"; | ||
| 87 | - $sToRender .= "</tr>\n"; | ||
| 88 | - $sToRender .= "</table>\n"; | ||
| 89 | - | ||
| 90 | - return $sToRender; | ||
| 91 | -} | ||
| 92 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Presentation data used to modify documents (will be used by modifyBL.inc) | ||
| 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 | -function renderEditableDocumentData($oDocument, $iDocumentTypeID) { | ||
| 29 | - global $default; | ||
| 30 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 31 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 32 | - | ||
| 33 | - $sToRender; | ||
| 34 | - if ($oDocument) { | ||
| 35 | - $sToRender .= "<table>\n"; | ||
| 36 | - $sToRender .= "<caption><strong>" . _("Document Data") . "</strong></caption>\n"; | ||
| 37 | - $sToRender .= "<tr>\n"; | ||
| 38 | - $sToRender .= "<td bgcolor=\"$sTDBGColour\">\n"; | ||
| 39 | - $sToRender .= "<b>" . _("Document Title") . " </b>\n"; | ||
| 40 | - $sToRender .= "</td>\n"; | ||
| 41 | - $sToRender .= "<td>\n"; | ||
| 42 | - $sToRender .= "<input type=\"text\" name=\"fDocumentName\" value=\"" . $oDocument->getName() . "\" />\n"; | ||
| 43 | - $sToRender .= "</td>\n"; | ||
| 44 | - $sToRender .= "</tr>\n"; | ||
| 45 | - $sToRender .= "<tr>\n"; | ||
| 46 | - $sToRender .= "<td bgcolor=\"$sTDBGColour\">\n"; | ||
| 47 | - $sToRender .= "<b>" . _("Document Type") . " </b>\n"; | ||
| 48 | - $sToRender .= "</td>\n"; | ||
| 49 | - $sToRender .= "<td>\n"; | ||
| 50 | - $sToRender .= getDocumentType($oDocument->getFolderID(), $iDocumentTypeID); | ||
| 51 | - $sToRender .= "</td>\n"; | ||
| 52 | - $sToRender .= "</tr>\n"; | ||
| 53 | - $sToRender .= "</table>\n"; | ||
| 54 | - | ||
| 55 | - return $sToRender; | ||
| 56 | - } | ||
| 57 | - return ""; | ||
| 58 | -} | ||
| 59 | - | ||
| 60 | -function getDocumentType($iFolderID, $iDocumentTypeID) { | ||
| 61 | - global $default; | ||
| 62 | - $sWhereClause = "FDL.folder_id = $iFolderID"; | ||
| 63 | - $oPatternListBox = & new PatternListBox("$default->document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause); | ||
| 64 | - $oPatternListBox->setIncludeDefaultValue(false); | ||
| 65 | - $oPatternListBox->setFromClause("INNER JOIN $default->folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id"); | ||
| 66 | - if (isset($iDocumentTypeID)) { | ||
| 67 | - $oPatternListBox->setSelectedValue($iDocumentTypeID); | ||
| 68 | - } | ||
| 69 | - return $oPatternListBox->render(); | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | - | ||
| 73 | - | ||
| 74 | -function renderPage($oDocument, $iDocumentTypeID, $bFirstEdit) { | ||
| 75 | - global $default; | ||
| 76 | - $sToRender = renderHeading(_("Edit Document Details")); | ||
| 77 | - $sToRender .= displayDocumentPath($oDocument->getID()); | ||
| 78 | - $sToRender .= "<table border = 0>\n"; | ||
| 79 | - $sToRender .= "<tr>\n"; | ||
| 80 | - $sToRender .= "<td>\n"; | ||
| 81 | - $sToRender .= renderEditableDocumentData($oDocument, $iDocumentTypeID) . "\n"; | ||
| 82 | - $sToRender .= "</tr>\n"; | ||
| 83 | - $sToRender .= "</table>\n"; | ||
| 84 | - $sToRender .= "<table>\n"; | ||
| 85 | - $sToRender .= "<tr>\n"; | ||
| 86 | - $sToRender .= "<td><input type=\"image\" src=\"" . KTHtml::getUpdateButton() . "\" border=\"0\"/><td>\n"; | ||
| 87 | - if (!isset($bFirstEdit)) { | ||
| 88 | - //can't this action on a first time upload, you must fill out the necessary fields | ||
| 89 | - $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\" /></a><td>\n"; | ||
| 90 | - } | ||
| 91 | - $sToRender .= "</tr>\n"; | ||
| 92 | - $sToRender .= "</table>\n"; | ||
| 93 | - | ||
| 94 | - return $sToRender . getValidationJavaScript(); | ||
| 95 | -} | ||
| 96 | - | ||
| 97 | -function getValidationJavaScript() { | ||
| 98 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | ||
| 99 | - $sToRender .= "function validateForm(theForm) {\n"; | ||
| 100 | - $sToRender .= "\tif (!(validRequired(document.MainForm.fDocumentName, 'Document Title'))) {\n"; | ||
| 101 | - $sToRender .= "\t\treturn false;\n"; | ||
| 102 | - $sToRender .= "\t}\n"; | ||
| 103 | - $sToRender .= "return true;\n}\n"; | ||
| 104 | - $sToRender .= "//-->\n</script>\n\n"; | ||
| 105 | - | ||
| 106 | - return $sToRender; | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | -function wrapInTable($sHtml) { | ||
| 110 | - return "\n\t\t\t<table border = 1, width = 100%><tr><td>$sHtml</td></tr></table>\n"; | ||
| 111 | -}?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseBL.php deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | - | ||
| 5 | -KTUtil::extractGPC('fBrowseType', 'fSortBy', 'fSortDirection'); | ||
| 6 | - | ||
| 7 | -require_once("$default->fileSystemRoot/lib/browse/BrowserFactory.inc"); | ||
| 8 | -require_once("$default->fileSystemRoot/lib/browse/Browser.inc"); | ||
| 9 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentType.inc"); | ||
| 10 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | ||
| 11 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 12 | -require_once("$default->uiDirectory/documentmanagement/browseUI.inc"); | ||
| 13 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 14 | -/** | ||
| 15 | - * $Id$ | ||
| 16 | - * | ||
| 17 | - * This page very closely follows browseBL.php. This page is ONLY used when a user | ||
| 18 | - * browses for a template document when setting up document linking in folder | ||
| 19 | - * collaboration. This page is launched as a separate window by javascript. The | ||
| 20 | - * user browses for the document that will serve as a template and then selects it. | ||
| 21 | - * This causes this window to close and set the template document value in the | ||
| 22 | - * the parent window. | ||
| 23 | - * | ||
| 24 | - * The main difference between this file and browseBL.php is the way the document | ||
| 25 | - * links are generated. When clicking on a document link, instead of being taken | ||
| 26 | - * to the document, the document values are sent to the parent window and the | ||
| 27 | - * window is closed | ||
| 28 | - * | ||
| 29 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 30 | - * | ||
| 31 | - * This program is free software; you can redistribute it and/or modify | ||
| 32 | - * it under the terms of the GNU General Public License as published by | ||
| 33 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 34 | - * (at your option) any later version. | ||
| 35 | - * | ||
| 36 | - * This program is distributed in the hope that it will be useful, | ||
| 37 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 38 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 39 | - * GNU General Public License for more details. | ||
| 40 | - * | ||
| 41 | - * You should have received a copy of the GNU General Public License | ||
| 42 | - * along with this program; if not, write to the Free Software | ||
| 43 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 44 | - * | ||
| 45 | - * @version $Revision$ | ||
| 46 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 47 | - * @package documentmanagement | ||
| 48 | - */ | ||
| 49 | - | ||
| 50 | -// only if we have a valid session | ||
| 51 | -if (checkSession()) { | ||
| 52 | - require_once("../../../../phpSniff/phpTimer.class.php"); | ||
| 53 | - $timer = new phpTimer(); | ||
| 54 | - $timer->start(); | ||
| 55 | - | ||
| 56 | - // retrieve variables | ||
| 57 | - if (!$fBrowseType) { | ||
| 58 | - // required param not set- internal error or user querystring hacking | ||
| 59 | - // set it to default= folder | ||
| 60 | - $fBrowseType = "folder"; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - // retrieve field to sort by | ||
| 64 | - if (!$fSortBy) { | ||
| 65 | - // no sort field specified- default is document name | ||
| 66 | - $fSortBy = "name"; | ||
| 67 | - } | ||
| 68 | - // retrieve sort direction | ||
| 69 | - if (!$fSortDirection) { | ||
| 70 | - $fSortDirection = "asc"; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - // fire up the document browser | ||
| 74 | - $oBrowser = BrowserFactory::create($fBrowseType, $fSortBy, $fSortDirection); | ||
| 75 | - | ||
| 76 | - // instantiate my content pattern | ||
| 77 | - $oContent = new PatternCustom(); | ||
| 78 | - | ||
| 79 | - $aResults = $oBrowser->browse(); | ||
| 80 | - | ||
| 81 | - require_once("../../../webpageTemplate.inc"); | ||
| 82 | - // display the browse results | ||
| 83 | - $oContent->addHtml(renderPage($aResults, $fBrowseType, $fSortBy, $fSortDirection, true)); | ||
| 84 | - | ||
| 85 | - $sToRender = "<html>\n"; | ||
| 86 | - $sToRender .= "<head>\n"; | ||
| 87 | - $sToRender .= "<meta http-equiv=\"refresh\" content=\"" . ($default->sessionTimeout+3) . "\">\n"; | ||
| 88 | - $sToRender .= "<link rel=\"SHORTCUT ICON\" href=\"$default->graphicsUrl/tree.ico\">\n"; | ||
| 89 | - $sToRender .= "<link rel=\"stylesheet\" href=\"$default->uiUrl/stylesheet.php\">\n"; | ||
| 90 | - $sToRender .= "</head>\n"; | ||
| 91 | - $sToRender .= "<body>\n"; | ||
| 92 | - $sToRender .= $oContent->render() . "\n"; | ||
| 93 | - $sToRender .= "</body>"; | ||
| 94 | - $sToRender .= "</html>\n"; | ||
| 95 | - | ||
| 96 | - echo $sToRender . "\n\n" . getSendInfoToParentJavaScript(); | ||
| 97 | - | ||
| 98 | -} | ||
| 99 | - | ||
| 100 | -function getSendInfoToParentJavaScript() { | ||
| 101 | - $sToRender = "<script language=\"JavaScript\"><!--\n"; | ||
| 102 | - $sToRender .= "function load(documentName, documentID, target) {\n"; | ||
| 103 | - $sToRender .= "\tif (target != '') {\n"; | ||
| 104 | - //$sToRender .= "\t\ttarget.window.document.MainForm.fTemplateDocument.value = documentName;\n"; | ||
| 105 | - //$sToRender .= "\t\ttarget.window.document.MainForm.fTemplateDocumentID.value = documentID;\n"; | ||
| 106 | - $sToRender .= "\t\ttarget.window.document.MainForm.fTargetDocumentID.value = documentID;\n"; | ||
| 107 | - $sToRender .= "\t\ttarget.window.document.MainForm.fTargetDocument.value = documentName;\n"; | ||
| 108 | - $sToRender .= "\t}\n"; | ||
| 109 | - $sToRender .= "\telse {\n"; | ||
| 110 | - $sToRender .= "\t\twindow.location.href = file;\n"; | ||
| 111 | - $sToRender .= "\t}\n"; | ||
| 112 | - $sToRender .= "\twindow.close();\n"; | ||
| 113 | - $sToRender .= "}\n"; | ||
| 114 | - $sToRender .= "//--></script>\n\n"; | ||
| 115 | - return $sToRender; | ||
| 116 | - | ||
| 117 | -} | ||
| 118 | - | ||
| 119 | -/*function renderBrowsePage($oContent) { | ||
| 120 | - global $default; | ||
| 121 | - $sToRender = "<html>\n"; | ||
| 122 | - $sToRender .= "<head>\n"; | ||
| 123 | - $sToRender .= "<meta http-equiv=\"refresh\" content=\"" . ($default->sessionTimeout+3) . "\">\n"; | ||
| 124 | - $sToRender .= "<link rel=\"SHORTCUT ICON\" href=\"$default->graphicsUrl/tree.ico\">\n"; | ||
| 125 | - $sToRender .= "<link rel=\"stylesheet\" href=\"$default->uiUrl/stylesheet.php\">\n"; | ||
| 126 | - $sToRender .= "</head>\n"; | ||
| 127 | - $sToRender .= "<body>\n"; | ||
| 128 | - $sToRender .= $oContent->render() . "\n"; | ||
| 129 | - $sToRender .= "</body>"; | ||
| 130 | - $sToRender .= "</html>\n"; | ||
| 131 | - return $sToRender; | ||
| 132 | - | ||
| 133 | - | ||
| 134 | -}*/ | ||
| 135 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseUI.inc deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -KTUtil::extractGPC('fBrowseType', 'fCategoryName', 'fDocumentTypeID', 'fFolderID'); | ||
| 4 | - | ||
| 5 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 6 | -require_once("$default->uiDirectory/foldermanagement/folderUI.inc"); | ||
| 7 | -require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); | ||
| 8 | -require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); | ||
| 9 | -/** | ||
| 10 | - * $Id$ | ||
| 11 | - * | ||
| 12 | - * Template document browsing page html UI building functions. | ||
| 13 | - * | ||
| 14 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 15 | - * | ||
| 16 | - * This program is free software; you can redistribute it and/or modify | ||
| 17 | - * it under the terms of the GNU General Public License as published by | ||
| 18 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 19 | - * (at your option) any later version. | ||
| 20 | - * | ||
| 21 | - * This program is distributed in the hope that it will be useful, | ||
| 22 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 23 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 24 | - * GNU General Public License for more details. | ||
| 25 | - * | ||
| 26 | - * You should have received a copy of the GNU General Public License | ||
| 27 | - * along with this program; if not, write to the Free Software | ||
| 28 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 29 | - * | ||
| 30 | - * @version $Revision$ | ||
| 31 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 32 | - * @package documentmanagement | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | -/** | ||
| 36 | - * Generates radio button selects for document browse by type | ||
| 37 | - * Javascript refreshes the form when it changes | ||
| 38 | - * | ||
| 39 | - * @param string the selected browse by option | ||
| 40 | - */ | ||
| 41 | -function renderBrowseTypeSelect($sBrowseType) { | ||
| 42 | - // TODO: write function for onChange that checks if the new value | ||
| 43 | - return "<span class=\"browseTypeSelect\">\n | ||
| 44 | - \tView documents by: <input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"folder\"" . | ||
| 45 | - ((($sBrowseType=="folder") || (strlen($sBrowseType)==0)) ? " checked=\"checked\"" : "") . "/> Folders\n" . | ||
| 46 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"category\"" . | ||
| 47 | - (($sBrowseType=="category") ? " checked=\"checked\"" : "") . "/> Category\n" . | ||
| 48 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"documentType\"" . | ||
| 49 | - (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> Document Type\n</span>"; | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | -// <category browse helper methods> | ||
| 53 | - | ||
| 54 | -/** | ||
| 55 | - * Displays the passed category path as a link | ||
| 56 | - * | ||
| 57 | - * @param string the category name to display | ||
| 58 | - */ | ||
| 59 | -function displayCategoryPathLink($aCategories) { | ||
| 60 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 61 | - if ($aCategories[0] == "Categories") { | ||
| 62 | - return displayCategoryLink($aCategories[0]); | ||
| 63 | - } else { | ||
| 64 | - // else the first entry is the category name, so build a little path | ||
| 65 | - return displayCategoryLink("Categories") . " > " . displayCategoryLink($aCategories[0]); | ||
| 66 | - } | ||
| 67 | -} | ||
| 68 | - | ||
| 69 | -/** | ||
| 70 | - * Displays the passed category as a link | ||
| 71 | - * | ||
| 72 | - * @param string the category name to display | ||
| 73 | - */ | ||
| 74 | -function displayCategoryLink($sCategoryName) { | ||
| 75 | - if ($sCategoryName != "") { | ||
| 76 | - return generateLink($_SERVER["PHP_SELF"], | ||
| 77 | - "fBrowseType=category" . | ||
| 78 | - // if the category title is passed in, link back to the list of categories | ||
| 79 | - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), | ||
| 80 | - $sCategoryName); | ||
| 81 | - } else { | ||
| 82 | - return false; | ||
| 83 | - } | ||
| 84 | -} | ||
| 85 | - | ||
| 86 | -/** | ||
| 87 | - * Displays the results for category browsing | ||
| 88 | - * | ||
| 89 | - * @param array the category browse results | ||
| 90 | - */ | ||
| 91 | -function renderCategoryResults($aResults) { | ||
| 92 | - $sToRender = ""; | ||
| 93 | - | ||
| 94 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 95 | - if ($aResults["categories"][0] == "Categories") { | ||
| 96 | - // loop through categories and display them | ||
| 97 | - for ($i=1; $i<count($aResults["categories"]); $i++) { | ||
| 98 | - $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | ||
| 99 | - | ||
| 100 | - // category name | ||
| 101 | - $sToRender .= "<td>" . displayCategoryLink($aResults["categories"][$i]) . "</td>"; | ||
| 102 | - // blank filename | ||
| 103 | - $sToRender .= "<td></td>"; | ||
| 104 | - // creator name | ||
| 105 | - $sToRender .= "<td></td>"; | ||
| 106 | - // modified date | ||
| 107 | - $sToRender .= "<td></td>"; | ||
| 108 | - // document type | ||
| 109 | - $sToRender .= "<td></td>"; | ||
| 110 | - | ||
| 111 | - $sToRender .= "</tr>\n"; | ||
| 112 | - } | ||
| 113 | - } else { | ||
| 114 | - // else the first entry is the category name, so display the documents in the category | ||
| 115 | - // with full paths | ||
| 116 | - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category"), true); | ||
| 117 | - } | ||
| 118 | - return $sToRender; | ||
| 119 | -} | ||
| 120 | - | ||
| 121 | -// </category browse helper methods> | ||
| 122 | - | ||
| 123 | -// <document type display helper methods> | ||
| 124 | -/** | ||
| 125 | - * Displays the passed document type path as a link | ||
| 126 | - * | ||
| 127 | - * @param string the document type to display | ||
| 128 | - */ | ||
| 129 | -function displayDocumentTypePathLink($aDocumentTypes) { | ||
| 130 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | ||
| 131 | - if ($aDocumentTypes[0]["name"] == "Document Types") { | ||
| 132 | - return displayDocumentTypeLink($aDocumentTypes[0]); | ||
| 133 | - } else { | ||
| 134 | - // else the first entry is the category name, so build a little path | ||
| 135 | - return displayDocumentTypeLink(array("name"=>"Document Types")) . " > " . displayDocumentTypeLink($aDocumentTypes[0]); | ||
| 136 | - } | ||
| 137 | -} | ||
| 138 | - | ||
| 139 | -/** | ||
| 140 | - * Displays the passed document type as a link | ||
| 141 | - * | ||
| 142 | - * @param string the document type to display | ||
| 143 | - */ | ||
| 144 | -function displayDocumentTypeLink($aDocumentType) { | ||
| 145 | - return generateLink($_SERVER["PHP_SELF"], | ||
| 146 | - "fBrowseType=documentType" . | ||
| 147 | - // if the document type title is passed in, link back to the list of document types | ||
| 148 | - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), | ||
| 149 | - $aDocumentType["name"]); | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -/** | ||
| 153 | - * Displays the results for document type browsing | ||
| 154 | - * | ||
| 155 | - * @param array the document type browse results | ||
| 156 | - */ | ||
| 157 | -function renderDocumentTypeResults($aResults) { | ||
| 158 | - $sToRender = ""; | ||
| 159 | - | ||
| 160 | - // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types | ||
| 161 | - if ($aResults["documentTypes"][0]["name"] == "Document Types") { | ||
| 162 | - // loop through document types and display them | ||
| 163 | - for ($i=1; $i<count($aResults["documentTypes"]); $i++) { | ||
| 164 | - $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | ||
| 165 | - // document type name | ||
| 166 | - $sToRender .= "<td>" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "</td>"; | ||
| 167 | - // blank filename | ||
| 168 | - $sToRender .= "<td></td>"; | ||
| 169 | - // creator name | ||
| 170 | - $sToRender .= "<td></td>"; | ||
| 171 | - // modified date | ||
| 172 | - $sToRender .= "<td></td>"; | ||
| 173 | - // document type | ||
| 174 | - $sToRender .= "<td></td>"; | ||
| 175 | - $sToRender .= "</tr>\n"; | ||
| 176 | - } | ||
| 177 | - } else { | ||
| 178 | - // else the first entry is the document type name, so display the documents in the document type | ||
| 179 | - // with full paths | ||
| 180 | - $sToRender .= renderDocumentList($aResults, _("This document type contains no documents"), _("You don't have access to the documents in this document type"), true); | ||
| 181 | - } | ||
| 182 | - return $sToRender; | ||
| 183 | -} | ||
| 184 | -// </document type browse helper methods> | ||
| 185 | - | ||
| 186 | - | ||
| 187 | -// <folder browse helper methods> | ||
| 188 | -/** | ||
| 189 | - * Displays the folders in the browse results | ||
| 190 | - * | ||
| 191 | - * @param array the browse result objects | ||
| 192 | - */ | ||
| 193 | -function renderFolderResults($aResults) { | ||
| 194 | - global $default; | ||
| 195 | - $sToRender = ""; | ||
| 196 | - | ||
| 197 | - // now loop through the rest of the folders and display links | ||
| 198 | - if (count($aResults["folders"]) > 1) { | ||
| 199 | - for ($i=1; $i<count($aResults["folders"]); $i++) { | ||
| 200 | - $sFolderLink = displayFolderLink($aResults["folders"][$i]); | ||
| 201 | - $oCreator = User::get($aResults["folders"][$i]->getCreatorID()); | ||
| 202 | - | ||
| 203 | - $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | ||
| 204 | - // folder name | ||
| 205 | - $sToRender .= "<td>" . $sFolderLink . "</td>"; | ||
| 206 | - // blank filename (??: folder description?) | ||
| 207 | - $sToRender .= "<td></td>"; | ||
| 208 | - // creator name | ||
| 209 | - $sToRender .= "<td>" . $oCreator->getName() . "</td>"; | ||
| 210 | - // modified date (TODO: add to db) | ||
| 211 | - $sToRender .= "<td></td>"; | ||
| 212 | - // document type (??: display one of the mapped document types?) | ||
| 213 | - $sToRender .= "<td></td>"; | ||
| 214 | - $sToRender .= "</tr>\n"; | ||
| 215 | - } | ||
| 216 | - } else { | ||
| 217 | - $sToRender .= "<tr><td colspan=\"5\">" . _("This folder contains no sub folders") . "</td></tr>"; | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - $sToRender .= "<tr><td>" . renderDocumentList($aResults, _("This folder contains no documents"), _("You don't have access to the documents in this folder")) . "</td></tr>\n"; | ||
| 221 | - | ||
| 222 | - return $sToRender; | ||
| 223 | -} | ||
| 224 | -// </folder browse helper methods> | ||
| 225 | - | ||
| 226 | -/** | ||
| 227 | - * Displays the headings for the displayed document details and enables | ||
| 228 | - * resorting the contents | ||
| 229 | - * | ||
| 230 | - * @param string the field currently sorting by | ||
| 231 | - * @param string the direction currently sorted in | ||
| 232 | - */ | ||
| 233 | -function renderSortHeadings($sSortBy, $sSortDirection) { | ||
| 234 | - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; | ||
| 235 | - | ||
| 236 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 237 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 238 | - | ||
| 239 | - // need list of display criteria and sort name | ||
| 240 | - $aSortCriteria = $oBrowser->getSortCriteria(); | ||
| 241 | - | ||
| 242 | - $sToRender .= "<tr bgcolor=\"$sTDBGColour\">"; | ||
| 243 | - while (list($key, $value) = each ($aSortCriteria)) { | ||
| 244 | - $sCurrentSortDirection = "asc"; | ||
| 245 | - $displayText = $value["display"]; | ||
| 246 | - // if the current heading is being sorted then flip the sort direction | ||
| 247 | - if ($sSortBy == $key) { | ||
| 248 | - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); | ||
| 249 | - $displayText = "<img border=\"0\" src=\"$default->graphicsUrl/" . $sCurrentSortDirection . ".gif\">" . $displayText; | ||
| 250 | - } | ||
| 251 | - switch ($fBrowseType) { | ||
| 252 | - case "folder" : | ||
| 253 | - $queryString = "fFolderID=$fFolderID"; | ||
| 254 | - break; | ||
| 255 | - case "category" : | ||
| 256 | - $queryString = "fCategoryName=$fCategoryName"; | ||
| 257 | - break; | ||
| 258 | - case "documentType" : | ||
| 259 | - $queryString = "fDocumentTypeID=$fDocumentTypeID"; | ||
| 260 | - break; | ||
| 261 | - } | ||
| 262 | - $sToRender .= "<td>" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . "</td>"; | ||
| 263 | - } | ||
| 264 | - | ||
| 265 | - $sToRender .= "</tr>\n"; | ||
| 266 | - return $sToRender; | ||
| 267 | -} | ||
| 268 | - | ||
| 269 | -/** | ||
| 270 | - * Displays the documents in the browse results | ||
| 271 | - * | ||
| 272 | - * @param array the browse result objects | ||
| 273 | - * @param string the message to display if there are no documents | ||
| 274 | - * @param string the message to display if the current user doesn't have permission to view the documents | ||
| 275 | - * @param boolean whether to display the complete path to the document or not | ||
| 276 | - */ | ||
| 277 | -function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false) { | ||
| 278 | - // loop through the files and display links | ||
| 279 | - if (count($aResults["documents"]) > 0) { | ||
| 280 | - for ($i=0; $i<count($aResults["documents"]); $i++) { | ||
| 281 | - $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\" width=\"100%\"><td>" . displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) . "</td>"; | ||
| 282 | - //$sToRender .= "<tr>"; | ||
| 283 | - $sToRender .= "<td>" . $aResults["documents"][$i]->getFileName() . "</td>"; | ||
| 284 | - $oCreator = User::get($aResults["documents"][$i]->getCreatorID()); | ||
| 285 | - $sToRender .= "<td>" . $oCreator->getName() . "</td>"; | ||
| 286 | - $sToRender .= "<td>" . $aResults["documents"][$i]->getLastModifiedDate() . "</td>"; | ||
| 287 | - $oDocumentType = DocumentType::get($aResults["documents"][$i]->getDocumentTypeID()); | ||
| 288 | - if ($oDocumentType) { | ||
| 289 | - $sToRender .= "<td>" . $oDocumentType->getName() . "</td>"; | ||
| 290 | - } | ||
| 291 | - $sToRender .= "</tr>\n"; | ||
| 292 | - } | ||
| 293 | - } else if ($aResults["accessDenied"]) { | ||
| 294 | - $sToRender .= "<tr><td>$sNoPermissionMessage</td></tr>"; | ||
| 295 | - } else { | ||
| 296 | - $sToRender .= "<tr><td>$sNoDocumentsMessage</td></tr>"; | ||
| 297 | - } | ||
| 298 | - return $sToRender; | ||
| 299 | -} | ||
| 300 | - | ||
| 301 | -/** | ||
| 302 | - * Displays the browse page- lists folders and documents | ||
| 303 | - * | ||
| 304 | - * @param array the browse results to display | ||
| 305 | - * @param string the browse view (folder, category, document type) | ||
| 306 | - * @param string the field to sort the results by | ||
| 307 | - * @param string the direction to sort | ||
| 308 | - */ | ||
| 309 | -function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection) { | ||
| 310 | - global $default; | ||
| 311 | - | ||
| 312 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 313 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | ||
| 314 | - | ||
| 315 | - $sToRender = renderHeading(_("Browse Collection")); | ||
| 316 | - | ||
| 317 | - $sToRender .= "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td bgcolor=\"$sTDBGColour\">"; | ||
| 318 | - switch ($sBrowseType) { | ||
| 319 | - case "folder" : $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID())); break; | ||
| 320 | - case "category" : $sToRender .= displayCategoryPathLink($aResults["categories"]); break; | ||
| 321 | - case "documentType" : $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); break; | ||
| 322 | - } | ||
| 323 | - $sToRender .= "</td></tr></table>\n"; | ||
| 324 | - | ||
| 325 | - // browse type select | ||
| 326 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 327 | - //$sToRender .= "\t<tr><td bgcolor=\"$sTDBGColour\">" . renderBrowseTypeSelect($sBrowseType) . "</td></tr>"; | ||
| 328 | - $sToRender .= "\t</table>"; | ||
| 329 | - | ||
| 330 | - // display folders|documents | ||
| 331 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | ||
| 332 | - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); | ||
| 333 | - $sToRender .= "<tr><td>\n"; | ||
| 334 | - switch ($sBrowseType) { | ||
| 335 | - case "folder" : $sToRender .= renderFolderResults($aResults, $sSortBy, $sSortDirection); break; | ||
| 336 | - case "category" : $sToRender .= renderCategoryResults($aResults); break; | ||
| 337 | - case "documentType" : $sToRender .= renderDocumentTypeResults($aResults); break; | ||
| 338 | - } | ||
| 339 | - $sToRender .= "</tr></td>\n"; | ||
| 340 | - $sToRender .= "\t</table>"; | ||
| 341 | - | ||
| 342 | - return $sToRender; | ||
| 343 | -} | ||
| 344 | - | ||
| 345 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Contains the business logic required to build the document history view page. | ||
| 6 | - * Will use viewHistoryUI.php for HTML | ||
| 7 | - * | ||
| 8 | - * Expected form varaibles: | ||
| 9 | - * o $fDocumentID - Primary key of document to view | ||
| 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('fDocumentID'); | ||
| 35 | - | ||
| 36 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 37 | - | ||
| 38 | -require_once("$default->fileSystemRoot/lib/users/User.inc"); | ||
| 39 | - | ||
| 40 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | ||
| 41 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 42 | -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 43 | - | ||
| 44 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | ||
| 45 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 46 | - | ||
| 47 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | ||
| 48 | - | ||
| 49 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc"); | ||
| 50 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | ||
| 51 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 52 | - | ||
| 53 | - | ||
| 54 | -if (checkSession()) { | ||
| 55 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 56 | - if (isset($fDocumentID)) { | ||
| 57 | - $oDocument = & Document::get($fDocumentID); | ||
| 58 | - if (Permission::userHasDocumentReadPermission($oDocument)) { | ||
| 59 | - $oPatternCustom = & new PatternCustom(); | ||
| 60 | - $oPatternCustom->setHtml(getPage($oDocument->getID(), $oDocument->getFolderID(), $oDocument->getName())); | ||
| 61 | - $main->setCentralPayload($oPatternCustom); | ||
| 62 | - $main->render(); | ||
| 63 | - } else { | ||
| 64 | - $oPatternCustom = & new PatternCustom(); | ||
| 65 | - $oPatternCustom->setHtml(""); | ||
| 66 | - $main->setErrorMessage(_("You do not have permission to view this document's history")); | ||
| 67 | - $main->setCentralPayload($oPatternCustom); | ||
| 68 | - $main->render(); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - } else { | ||
| 72 | - $oPatternCustom = & new PatternCustom(); | ||
| 73 | - $oPatternCustom->setHtml(""); | ||
| 74 | - $main->setErrorMessage(_("No document currently selected")); | ||
| 75 | - $main->setCentralPayload($oPatternCustom); | ||
| 76 | - $main->render(); | ||
| 77 | - } | ||
| 78 | -} | ||
| 79 | - | ||
| 80 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id$ | ||
| 4 | - * | ||
| 5 | - * Contains HTML information required to build the document history view page. | ||
| 6 | - * Will be used by viewHistoryBL.php | ||
| 7 | - * | ||
| 8 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 9 | - * | ||
| 10 | - * This program is free software; you can redistribute it and/or modify | ||
| 11 | - * it under the terms of the GNU General Public License as published by | ||
| 12 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 13 | - * (at your option) any later version. | ||
| 14 | - * | ||
| 15 | - * This program is distributed in the hope that it will be useful, | ||
| 16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | - * GNU General Public License for more details. | ||
| 19 | - * | ||
| 20 | - * You should have received a copy of the GNU General Public License | ||
| 21 | - * along with this program; if not, write to the Free Software | ||
| 22 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 23 | - * | ||
| 24 | - * @version $Revision$ | ||
| 25 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 26 | - * @package documentmanagement | ||
| 27 | - */ | ||
| 28 | - | ||
| 29 | -function getDocumentHistory($iDocumentID) { | ||
| 30 | - global $default; | ||
| 31 | - /*ok*/ $sQuery = array("SELECT DTT.name AS transaction_name, U.name AS user_name, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime " . | ||
| 32 | - "FROM $default->document_transactions_table AS DT INNER JOIN $default->users_table AS U ON DT.user_id = U.id " . | ||
| 33 | - "INNER JOIN $default->transaction_types_table AS DTT ON DTT.id = DT.transaction_id " . | ||
| 34 | - "WHERE DT.document_id = ? ORDER BY DT.datetime DESC", $iDocumentID); | ||
| 35 | - $sql = $default->db; | ||
| 36 | - $sToRender = "<table cellpadding=\"5\" width=\"100%\">\n"; | ||
| 37 | - $sToRender .= "<caption align=\"top\" colspan=\"5\" align=\"left\"><b>" . _("Transaction History") . "</b></caption>\n"; | ||
| 38 | - $sql->query($sQuery); | ||
| 39 | - if ($sql->num_rows() == 0) { | ||
| 40 | - $sToRender .= "<tr>\n"; | ||
| 41 | - $sToRender .= "\t<td colspan=\"5\">" . _("No Transaction History data") . "</td>\n"; | ||
| 42 | - $sToRender .= "</tr>\n"; | ||
| 43 | - } else { | ||
| 44 | - $sToRender .= "<tr><th align=\"left\">" . _("Type") . "</th>\n"; | ||
| 45 | - $sToRender .= "<th align=\"left\">" . _("Users") . "</th>\n"; | ||
| 46 | - $sToRender .= "<th align=\"left\">" . _("Version") . "</th>\n"; | ||
| 47 | - $sToRender .= "<th align=\"left\">" . _("Comment") . "</th>\n"; | ||
| 48 | - $sToRender .= "<th align=\"left\">" . _("Datetime") . "</th></tr>\n"; | ||
| 49 | - $i = 0; | ||
| 50 | - while ($sql->next_record()) { | ||
| 51 | - if ($sql->f("transaction_name") == "Check Out") { | ||
| 52 | - $sVersion = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID&fVersion=" . $sql->f("version"), "<strong>" . $sql->f("version") . "</strong>"); | ||
| 53 | - } else { | ||
| 54 | - $sVersion = $sql->f("version"); | ||
| 55 | - } | ||
| 56 | - $sToRender .= "<tr bgcolor=\"" . getColour($i++) . "\">\n"; | ||
| 57 | - $sToRender .= "<td>" . $sql->f("transaction_name") . "</td><td>" . $sql->f("user_name") . "</td><td>$sVersion</td>\n"; | ||
| 58 | - $sToRender .= "<td>" . displaySpace($sql->f("comment")) . "</td><td>" . $sql->f("datetime") . "</td></tr>\n"; | ||
| 59 | - } | ||
| 60 | - $sToRender .= "</table>\n"; | ||
| 61 | - } | ||
| 62 | - return $sToRender; | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | -function displaySpace($sHtml) { | ||
| 66 | - if ($sHtml == "") { | ||
| 67 | - return " "; | ||
| 68 | - } else { | ||
| 69 | - return $sHtml; | ||
| 70 | - } | ||
| 71 | -} | ||
| 72 | - | ||
| 73 | -function getPage($iDocumentID, $iFolderID, $sDocumentName) { | ||
| 74 | - global $default; | ||
| 75 | - $sToRender = renderHeading(_("Document History")); | ||
| 76 | - $sToRender .= "<table>\n"; | ||
| 77 | - $sToRender .= "<tr>\n"; | ||
| 78 | - $sToRender .= "<td>" . displayDocumentPath($iDocumentID) . "</td>\n"; | ||
| 79 | - $sToRender .= "</tr>\n"; | ||
| 80 | - $sToRender .= "</table>\n"; | ||
| 81 | - $sToRender .= "<table>\n"; | ||
| 82 | - $sToRender .= "<tr>\n"; | ||
| 83 | - $sToRender .= "<td>" . getDocumentHistory($iDocumentID) . "</td>\n"; | ||
| 84 | - $sToRender .= "</tr>\n"; | ||
| 85 | - $sToRender .= "<tr><td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a></td></tr>\n"; | ||
| 86 | - $sToRender .= "</table>\n"; | ||
| 87 | - return $sToRender; | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -?> |