diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocument.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocument.php deleted file mode 100644 index b27d3b3..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocument.php +++ /dev/null @@ -1,226 +0,0 @@ -oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); - $this->oPermission =& $this->oValidator->validatePermissionByName('ktcore.permissions.write'); - $this->validateFolderPermission(); - $this->validatePost(); - return true; - } - - function validateDocumentType($iId) { - $this->oDocumentType =& DocumentType::get($iId); - if (PEAR::isError($this->oDocumentType) || ($this->oDocumentType === false)) { - $this->errorPage(_("Invalid document type given")); - exit(0); - } - } - - function validateFolderPermission() { - $oUser =& User::get($_SESSION['userID']); - if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $this->oPermission, $this->oFolder)) { - $this->errorPage(_("Permission denied")); - exit(0); - } - } - - function validatePost() { - $postExpected = KTUtil::arrayGet($_REQUEST, "postExpected"); - $postReceived = KTUtil::arrayGet($_REQUEST, "postReceived"); - - if (is_null($postExpected)) { - return; - } - - if (!is_null($postReceived)) { - return; - } - - $this->errorPage(_("You tried to upload a file that is larger than the PHP post_max_size setting.")); - exit(0); - } - - function errorPage($errorMessage) { - $this->handleOutput($errorMessage); - exit(0); - } - - function do_main() { - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate =& $oTemplating->loadTemplate("ktcore/document/add"); - $aTypes = $this->getDocumentTypes(); - $iDefaultType = $aTypes[0]->getId(); - $aTemplateData = array( - 'context' => $this, - 'folder_id' => $this->oFolder->getID(), - 'folder_path_array' => $this->oFolder->getPathArray(), - 'document_type_choice' => $this->getDocumentTypeChoice($aTypes, 'getMetadataForType(this.value);'), - 'generic_metadata_fields' => $this->getGenericMetadataFieldsets(), - 'type_metadata_fields' => $this->getTypeMetadataFieldsets($iDefaultType), - ); - $oTemplate->setData($aTemplateData); - return $oTemplate->render(); - } - - function getDocumentTypeChoice($aTypes, $onchange = "") { - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document/document_type_choice'); - $aFields = array( - 'document_types' => $aTypes, - 'onchange' => $onchange, - ); - return $oTemplate->render($aFields); - } - - function getGenericMetadataFieldsets() { - $oTemplating = KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fieldsets"); - $aTemplateData = array( - - 'caption' => _('Generic meta data'), - 'empty_message' => _("No Generic Meta Data"), - 'fieldsets' => KTFieldset::getGenericFieldsets(), - ); - $aTemplateData['context'] =& $this; - return $oTemplate->render($aTemplateData); - } - - function getTypeMetadataFieldsets($iDocumentTypeID) { - $aTemplateData = array( - - 'caption' => _('Type specific meta data'), - 'empty_message' => _("No Type Specific Meta Data"), - 'fieldsets' => KTFieldset::getForDocumentType($iDocumentTypeID), - ); - $aTemplateData['context'] =& $this; - $oTemplating = KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fieldsets"); - return $oTemplate->render($aTemplateData); - } - - function getDocumentTypes() { - if (!$this->oFolder->getRestrictDocumentTypes()) { - return DocumentType::getList(); - } - $sTable = KTUtil::getTableName('folder_doctypes'); - $aQuery = array( - "SELECT document_type_id FROM $sTable WHERE folder_id = ?", - array($this->oFolder->getId()), - ); - $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id'); - $aRet = array(); - foreach ($aIds as $iId) { - $aRet[] = DocumentType::get($iId); - } - return $aRet; - } - - function do_upload() { - // make sure the user actually selected a file first - // and that something was uploaded - if (!((strlen($_FILES['fFile']['name']) > 0) && $_FILES['fFile']['size'] > 0)) { - // no uploaded file - $message = _("You did not select a valid document to upload"); - - $errors = array( - 1 => _("The uploaded file is larger than the PHP upload_max_filesize setting"), - 2 => _("The uploaded file is larger than the MAX_FILE_SIZE directive that was specified in the HTML form"), - 3 => _("The uploaded file was not fully uploaded to KnowledgeTree"), - 4 => _("No file was selected to be uploaded to KnowledgeTree"), - 6 => _("An internal error occurred receiving the uploaded document"), - ); - $message = KTUtil::arrayGet($errors, $_FILES['fFile']['error'], $message); - - if (@ini_get("file_uploads") == false) { - $message = _("File uploads are disabled in your PHP configuration"); - } - - $this->errorRedirectToMain($message, 'fFolderId=' . $this->oFolder->getId()); - exit(0); - } - - $matches = array(); - $aFields = array(); - foreach ($_REQUEST as $k => $v) { - if (preg_match('/^emd(\d+)$/', $k, $matches)) { - $aFields[] = array(DocumentField::get($matches[1]), $v); - } - } - - $this->validateDocumentType($_REQUEST['fDocumentTypeID']); - - $aOptions = array( - 'contents' => new KTFSFileLike($_FILES['fFile']['tmp_name']), - 'documenttype' => $this->oDocumentType, - 'metadata' => $aFields, - 'description' => $_REQUEST['fName'], - ); - - $oUser =& User::get($_SESSION["userID"]); - $oDocument =& KTDocumentUtil::add($this->oFolder, basename($_FILES['fFile']['name']), $oUser, $aOptions); - if (PEAR::isError($oDocument)) { - $message = $oDocument->getMessage(); - $this->errorRedirectToMain($message, 'fFolderId=' . $this->oFolder->getId()); - exit(0); - } - - $this->commitTransaction(); - //redirect to the document details page - controllerRedirect("viewDocument", "fDocumentId=" . $oDocument->getID()); - } -} -$d =& new KTAddDocumentDispatcher; -$d->dispatch(); - - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php deleted file mode 100644 index c4a6a61..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php +++ /dev/null @@ -1,133 +0,0 @@ -uiDirectory/documentmanagement/browseUI.inc"); -require_once("$default->fileSystemRoot/presentation/Html.inc"); -/** - * $Id$ - * - * This page controls browsing for documents- this can be done either by - * folder, category or document type. - * The relevant permission checking is performed, calls to the business logic - * layer to retrieve the details of the documents to view are made and the user - * interface is contructed. - * - * Querystring variables - * --------------------- - * fBrowseType - determines whether to browse by (folder, category, documentType) [mandatory] - * fFolderID - the folder to browse [optional depending on fBrowseType] - * fCategoryName - the category to browse [optional depending on fBrowseType] - * fDocumentTypeID - the document type id to browse [optional depending on fBrowseType] - * fSortBy - the document attribute to sort the browse results by - * fSortDirection - the direction to sort - * fActions - action for group operations - * - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Revision$ - * @author Michael Joseph , Jam Warehouse (Pty) Ltd, South Africa - * @package documentmanagement - */ - -// only if we have a valid session -if (!checkSession()) { - exit(0); -} - -if (isset($fActions)) { - // tack on POSTed document ids and redirect to the expunge deleted documents page - $sUniqueID = KTUtil::randomString(); - $_SESSION["documents"][$sUniqueID] = $fDocumentIDs; - $sQueryString = "fRememberDocumentID=$sUniqueID&"; - $sQueryString .= "fReturnFolderID=$fFolderID&"; - - switch ($fActions) { - case "delete": - // delete all selected docs - controllerRedirect("deleteDocument", $sQueryString); - exit(0); - break; - case "move": - // Move selected docs to root folder - controllerRedirect("moveDocument", $sQueryString . "fFolderID=1"); - exit(0); - break; - } -} - -// retrieve variables -if (!$fBrowseType) { - // required param not set- internal error or user querystring hacking - // set it to default= folder - $fBrowseType = "folder"; -} - -// retrieve field to sort by -if (!$fSortBy) { - // no sort field specified- default is document name - $fSortBy = "filename"; -} -// retrieve sort direction -if (!$fSortDirection) { - $fSortDirection = "asc"; -} - -// fire up the document browser -$oBrowser =& BrowserFactory::create($fBrowseType, $fSortBy, $fSortDirection); -$sectionName = $oBrowser->getSectionName(); - -// instantiate my content pattern -$oContent = new PatternCustom(); -$aResults = $oBrowser->browse(); - -require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - -if (PEAR::isError($aResults)) { - $oContent->setHtml("\n"); - $main->setErrorMessage($aResults->getMessage()); - $main->setCentralPayload($oContent); - $main->setFormAction($_SERVER["PHP_SELF"]); - $main->setSubmitMethod("GET"); - $main->render(); - exit(0); -} - -if (($fBrowseType == "folder") && (!isset($fFolderID))) { - // FIXME: check that the first folder in the array exists, no permission otherwise - if ($default->browseToRoot) { - controllerRedirect("browse", "fFolderID=1"); - } else { - controllerRedirect("browse", "fFolderID=" . $aResults["folders"][0]->getID()); - } -} - -// display the browse results -$oContent->addHtml(renderPage($aResults, $fBrowseType, $fSortBy, $fSortDirection)); -$main->setCentralPayload($oContent); -$main->setFormAction($_SERVER["PHP_SELF"]); -$main->setSubmitMethod("GET"); -$main->render(); - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc deleted file mode 100644 index 3ac391f..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc +++ /dev/null @@ -1,437 +0,0 @@ -fileSystemRoot/presentation/Html.inc"); -require_once("$default->uiDirectory/foldermanagement/folderUI.inc"); -require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); -require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); - -/** - * $Id$ - * - * Document browsing page html UI building functions. - * - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Revision$ - * @author Michael Joseph , Jam Warehouse (Pty) Ltd, South Africa - * @package documentmanagement - */ - -/** - * Generates radio button selects for document browse by type - * Javascript refreshes the form when it changes - * - * @param string the selected browse by option - */ -function renderBrowseTypeSelect($sBrowseType) { - // TODO: write function for onChange that checks if the new value - return "\n - \t" . _("View documents by") . ": " . _("Folders") ."\n" . - " " . _("Category") . "\n" . - " " . _("Document Type") . "\n"; -} - -// - -/** - * Displays the passed category path as a link - * - * @param string the category name to display - */ -function displayCategoryPathLink($aCategories) { - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aCategories[0] == "Categories") { - return displayCategoryLink($aCategories[0]); - } else { - // else the first entry is the category name, so build a little path - return displayCategoryLink("Categories") . ($aCategories[0] ? " > " . displayCategoryLink($aCategories[0]) : ""); - } -} - -/** - * Displays the passed category as a link - * - * @param string the category name to display - */ -function displayCategoryLink($sCategoryName) { - if ($sCategoryName != "") { - return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=category" . - // if the category title is passed in, link back to the list of categories - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), - $sCategoryName); - } else { - return false; - } -} - -/** - * Displays the results for category browsing - * - * @param array the category browse results - */ -function renderCategoryResults($aResults) { - global $oBrowser; - $sToRender = ""; - - //var_dump($aResults["categories"][0]); - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aResults["categories"][0] == "Categories") { - // loop through categories and display them - for ($i=1; $i"; - $sToRender .= " \n"; // for the checkboxes - - // category name - $sToRender .= "" . displayCategoryLink($aResults["categories"][$i]) . ""; - // blank filename - $sToRender .= " "; - // creator name - $sToRender .= " "; - // modified date - $sToRender .= " "; - // document type - $sToRender .= " "; - - $sToRender .= "\n"; - } - } else { - if (count($aResults["categories"]) > 0) { - // else the first entry is the category name, so display the documents in the category - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); - } else { - $sToRender .= "columns() + 1) . "\">" . _("There is no Category Document Field- contact a System Administrator.") . ""; - } - } - return $sToRender; -} - -// - -// -/** - * Displays the passed document type path as a link - * - * @param string the document type to display - */ -function displayDocumentTypePathLink($aDocumentTypes) { - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aDocumentTypes[0]["name"] == "Document Types") { - return displayDocumentTypeLink($aDocumentTypes[0]); - } else { - // else the first entry is the category name, so build a little path - return displayDocumentTypeLink(array("name"=>"Document Types")) . " > " . displayDocumentTypeLink($aDocumentTypes[0]); - } -} - -/** - * Displays the passed document type as a link - * - * @param string the document type to display - */ -function displayDocumentTypeLink($aDocumentType) { - return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=documentType" . - // if the document type title is passed in, link back to the list of document types - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), - $aDocumentType["name"]); -} - -/** - * Displays the results for document type browsing - * - * @param array the document type browse results - */ -function renderDocumentTypeResults($aResults) { - $sToRender = ""; - - // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types - if ($aResults["documentTypes"][0]["name"] == "Document Types") { - // loop through document types and display them - for ($i=1; $i\n"; - $sToRender .= " \n"; // for the checkboxes - // document type name - $sToRender .= "" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "\n"; - // blank filename - $sToRender .= " \n"; - // creator name - $sToRender .= " \n"; - // modified date - $sToRender .= " \n"; - // document type - $sToRender .= " \n"; - $sToRender .= "\n"; - } - } else { - // else the first entry is the document type name, so display the documents in the document type - $sToRender .= renderDocumentList($aResults, _("This document type contains no documents"), _("You don't have access to the documents in this document type")); - } - return $sToRender; -} -// - - -// -/** - * Displays the folders in the browse results - * - * @param array the browse result objects - */ -function renderFolderResults($aResults, $bTemplateBrowsing = false) { - global $default; - global $oBrowser; - $sToRender = ""; - - // now loop through the rest of the folders and display links - if (count($aResults["folders"]) > 1) { - for ($i=1; $igetCreatorID()); - - // the first element of the array contains the current folder name - $sToRender .= "\n"; - $sToRender .= " \n"; // for the checkboxes - - foreach (array_values($oBrowser->getSortCriteria()) as $oCriterion) { - $sToRender .= "" . $oCriterion->folderDisplay($oFolder) . "\n"; - } - $sToRender .= "\n"; - } - } else { - $sToRender .= "columns() + 1) . "\">" . _("This folder contains no sub folders") . ""; - } - - $sToRender .= renderDocumentList($aResults, _("This folder contains no documents"), - _("You don't have access to the documents in this folder"), - false, $bTemplateBrowsing) . "\n"; - - return $sToRender; -} -// - -/** - * Displays the headings for the displayed document details and enables - * resorting the contents - * - * @param string the field currently sorting by - * @param string the direction currently sorted in - */ -function renderSortHeadings($sSortBy, $sSortDirection) { - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - // need list of display criteria and sort name - $aSortCriteria = $oBrowser->getSortCriteria(); - - $sToRender .= "\n"; - $sToRender .= " \n"; // For the checkboxes - while (list($key, $value) = each ($aSortCriteria)) { - $sCurrentSortDirection = "asc"; - if (is_array($value)) { - $displayText = $value["display"]; - } else { - $displayText = $value->headerDisplay(); - } - // if the current heading is being sorted then flip the sort direction - if ($sSortBy == $key) { - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); - $displayText = "" . $displayText; - } - switch ($fBrowseType) { - case "folder" : - $queryString = "fFolderID=$fFolderID"; - break; - case "category" : - $queryString = "fCategoryName=$fCategoryName"; - break; - case "documentType" : - $queryString = "fDocumentTypeID=$fDocumentTypeID"; - break; - } - $sToRender .= "" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . "\n"; - } - - $sToRender .= "\n"; - return $sToRender; -} - -/** - * Displays the documents in the browse results - * - * @param array the browse result objects - * @param string the message to display if there are no documents - * @param string the message to display if the current user doesn't have permission to view the documents - * @param boolean whether to display the complete path to the document or not - */ -function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false, $bTemplateBrowsing = false) { - global $default; - global $oBrowser; - - $oBrowser->setOptions(array( - 'displayFullPath' => $bDisplayFullPath, - 'templateBrowsing' => $bTemplateBrowsing, - )); - - $aSortCriteria = $oBrowser->getSortCriteria(); - - $iFolderCount = count($aResults["folders"]) - 1; - // loop through the files and display links - if (count($aResults["documents"]) > 0) { - for ($i=0; $i\n"; - $sToRender .= "" . - "getID() . "\"/>\n"; - - /*$sToRender .= "" . $aSortCriteria["name"]->documentDisplay($oDocument) . ""; - $sToRender .= "" . $aSortCriteria["filename"]->documentDisplay($oDocument) . ""; - $sToRender .= "" . $aSortCriteria["creator_id"]->documentDisplay($oDocument) . ""; - $sToRender .= "" . $aSortCriteria['id']->documentDisplay($oDocument) . ""; - $sToRender .= "" . $aSortCriteria['document_type_id']->documentDisplay($oDocument) . ""; - $sToRender .= "" . $aSortCriteria['category']->documentDisplay($oDocument) . ""; - */ - foreach (array_values($aSortCriteria) as $oCriterion) { - $sToRender .= "" . $oCriterion->documentDisplay($oDocument) . ""; - } - - $sToRender .= "\n"; - } - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $sToRender .= "columns() + 1) . "\" valign=\"bottom\">" . - " " . _("Select all documents") . ""; - - $sToRender .= "columns() + 1) . "\" >"; - $sToRender .= ""; - - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= "\n"; - // Change for group Operations - - - } else if ($aResults["accessDenied"]) { - $sToRender .= "columns() + 1) . "\">$sNoPermissionMessage"; - } else { - $sToRender .= "columns() + 1) . "\">$sNoDocumentsMessage"; - } - return $sToRender; -} - -/** - * #3426 - * Appends folder and document counts to the last folder path - */ -function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { - // append to the last path component and return - $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . - " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . - ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; - return $aFolderPath; -} - -/** - * Displays the browse page- lists folders and documents - * - * @param array the browse results to display - * @param string the browse view (folder, category, document type) - * @param string the field to sort the results by - * @param string the direction to sort - */ - -function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection, $bTemplateBrowsing = false) { - global $default; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $sToRender = renderHeading(_("Browse collection")); - - // Script function to select all documents - $sToRender = "\n\n\n\n"; - - $sToRender .= "
"; - switch ($sBrowseType) { - case "folder": - $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), - appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), - count($aResults["folders"])-1, count($aResults["documents"]))); - break; - case "category": - $sToRender .= displayCategoryPathLink($aResults["categories"]); - break; - case "documentType": - $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); - break; - } - $sToRender .= "
\n"; - - // browse type select - $sToRender .= "\n"; - $sToRender .= "\t"; - $sToRender .= "\t
" . renderBrowseTypeSelect($sBrowseType) . "
"; - - // display folders|documents - $sToRender .= "\n"; - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); - // $sToRender .= "\n"; - $sToRender .= "\t
\n"; - switch ($sBrowseType) { - case "folder": - $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); - break; - case "category": - $sToRender .= renderCategoryResults($aResults); - break; - case "documentType": - $sToRender .= renderDocumentTypeResults($aResults); - break; - } - // $sToRender .= "
"; - - return $sToRender; -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyBL.php deleted file mode 100644 index 55f3c08..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyBL.php +++ /dev/null @@ -1,129 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); - require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); - require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionManager.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc"); - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc"); - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); - require_once("$default->fileSystemRoot/presentation/Html.inc"); - - $oDocument = & Document::get($fDocumentID); - if (Permission::userHasDocumentWritePermission($oDocument)) { - //if the user has write permission - if (isset($fForUpdate)) { - //if the user is updating the values - $oDocument->setName($fDocumentName); - - if ($oDocument->getDocumentTypeID() != $fDocumentTypeID) { - //the user has changed the document type - //get rid of all the old document type entries - $oDocument->removeInvalidDocumentTypeEntries(); - $oDocument->setDocumentTypeID($fDocumentTypeID); - $bUpdateMetaData = true; - } - - if ($oDocument->update()) { - // fire subscription alerts for the modified document - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"), - SubscriptionConstants::subscriptionType("DocumentSubscription"), - array( "folderID" => $oDocument->getFolderID(), - "modifiedDocumentName" => $oDocument->getName())); - $default->log->info("modifyBL.php fired $count subscription alerts for modified document " . $oDocument->getName()); - - //on successful update, redirect to the view page - if (isset($bUpdateMetaData)) { - controllerRedirect("modifyDocumentTypeMetaData", "fDocumentID=" . $oDocument->getID() . "&fFirstEdit=1"); - } else { - controllerRedirect("viewDocument", "fDocumentID=" . $oDocument->getID()); - } - } else { - //display the update page with an error message - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(renderPage($oDocument, $oDocument->getDocumentTypeID(), $fFirstEdit)); - $main->setCentralPayload($oPatternCustom); - $main->setHasRequiredFields(true); - if (isset($fFirstEdit)) { - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fFirstEdit=1"); - } else { - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - $main->setHasRequiredFields(true); - $main->setErrorMessage(_("An error occured while attempting to update the document")); - $main->render(); - } - - } else { - //display the update page - $oDocument = & Document::get($fDocumentID); - $oPatternCustom = & new PatternCustom(); - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom->setHtml(renderPage($oDocument, $oDocument->getDocumentTypeID(), $fFirstEdit)); - $main->setCentralPayload($oPatternCustom); - $main->setHasRequiredFields(true); - if (isset($fFirstEdit)) { - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fFirstEdit=1"); - } else { - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - - $main->setHasRequiredFields(true); - $main->render(); - } - } else { - //user doesn't have permission to edit this page - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(""); - $main->setCentralPayload($oPatternCustom); - $main->setErrorMessage(_("You do not have permission to edit this document")); - $main->render(); - } -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataBL.php deleted file mode 100644 index addfa02..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataBL.php +++ /dev/null @@ -1,67 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMetaData.inc"); - require_once("$default->fileSystemRoot/presentation/Html.inc"); - require_once("documentUI.inc"); - require_once("modifyGenericMetaDataUI.inc"); - - $oDocument = Document::get($fDocumentID); - if (Permission::userHasDocumentWritePermission($oDocument)) { - - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getPage($fDocumentID, $oDocument->getDocumentTypeID(), $fFirstEdit)); - $main->setCentralPayload($oPatternCustom); - if (isset($fFirstEdit)) { - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true; - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=modifyDocumentTypeMetaData&fDocumentID=$fDocumentID&fFirstEdit=1")); - } else { - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true; - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID&fShowSection=genericMetaData")); - } - $main->setHasRequiredFields(true); - $main->render(); - } - -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataUI.inc deleted file mode 100644 index a1310a1..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyGenericMetaDataUI.inc +++ /dev/null @@ -1,88 +0,0 @@ -"field_name"); - $aColumnsEditable = array(0,0,1); - $aColumnsVisible = array(0,1,1); - $aColumnDisplayTypes = array(1,1,4); - $aColumnDatabaseTypes = array(0,0,1); - - $oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes); - $oPatternTableSqlQuery->setTableCaption(_("Generic Meta Data")); - $oPatternTableSqlQuery->setUniqueName("gmd"); - $oPatternTableSqlQuery->setRequiredColumnNames(array("value")); - $oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames); - $oPatternTableSqlQuery->setEmptyTableMessage(_("No Generic Meta Data")); - $oPatternTableSqlQuery->setPreCode(sprintf('require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); KTDocumentUtil::createMetadataVersion(%d);', (int)$iDocumentID)); - $oPatternTableSqlQuery->setPostCode(sprintf('require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); KTDocumentUtil::bumpVersion(%d); KTDocumentUtil::setModifiedDate(%d);', (int)$iDocumentID, (int)$iDocumentID)); - return $oPatternTableSqlQuery->render(); - -} - -function getPage($iDocumentID, $iDocumentTypeID, $bFirstEdit) { - global $default; - - $sToRender .= renderHeading(_("Edit Generic Meta Data")); - $sToRender .= displayDocumentPath($iDocumentID); - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
\n"; - $sToRender .= getEditableGenericMetaData($iDocumentID, $iDocumentTypeID); - $sToRender .= "
\n"; - - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - if (!isset($bFirstEdit)) { - //can't cancel if you're uploading for the first time, must fill out the generic meta data - $sToRender .= "\n"; - $sToRender .= "\n"; - } - $sToRender .= "
\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID&fShowSection=genericMetaData\">\n"; - $sToRender .= "
\n"; - - $sToRender .= "
\n"; - - return $sToRender; -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataBL.php deleted file mode 100644 index dae323f..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataBL.php +++ /dev/null @@ -1,91 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMetaData.inc"); -require_once("$default->fileSystemRoot/presentation/Html.inc"); -require_once("documentUI.inc"); -require_once("modifySpecificMetaDataUI.inc"); - -require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php'); - -$oDocument = Document::get($fDocumentID); -if (!Permission::userHasDocumentWritePermission($oDocument)) { - die(); -} - -if (empty($fForStore)) { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getPage($fDocumentID, $oDocument->getDocumentTypeID(), $fFirstEdit)); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForStore=1"); - $main->setHasRequiredFields(true); - $main->render(); - exit(0); -} - -$matches = array(); -$aFields = array(); -foreach ($_REQUEST as $k => $v) { - if (preg_match('/^emd(\d+)$/', $k, $matches)) { - $aFields[] = array(DocumentField::get($matches[1]), $v); - } -} - -DBUtil::startTransaction(); -KTDocumentUtil::createMetadataVersion($oDocument->getID()); -$res = KTDocumentUtil::saveMetadata($oDocument, $aFields); -if (PEAR::isError($res)) { - DBUtil::rollback(); - $_SESSION['KTErrorMessages'][] = $res->getMessage(); - controllerRedirect('modifyDocumentTypeMetaData', "fDocumentID=$fDocumentID"); - exit(0); -} -KTDocumentUtil::bumpVersion($oDocument->getID()); -KTDocumentUtil::setModifiedDate($oDocument->getID()); -DBUtil::commit(); - -if (isset($fFirstEdit)) { - controllerRedirect('viewDocument', "fDocumentID=$fDocumentID"); -} else { - controllerRedirect('viewDocument', "fDocumentID=$fDocumentID&fShowSection=typeSpecificMetaData"); -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataUI.inc deleted file mode 100644 index d0dc107..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifySpecificMetaDataUI.inc +++ /dev/null @@ -1,92 +0,0 @@ - _('Type specific meta data'), - 'empty_message' => _("No Type Specific Meta Data"), - 'fields' => $aFields, - 'values' => $aValues, - ); - $oTemplating = KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/editable_metadata_fields"); - return $oTemplate->render($aTemplateData); -} - -function getPage($iDocumentID, $iDocumentTypeID, $bFirstEdit) { - global $default; - $sToRender .= renderHeading(_("Edit Type Specific Meta Data")); - $sToRender .= displayDocumentPath($iDocumentID); - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
\n"; - $sToRender .= getEditableTypeSpecificMetaData($iDocumentID, $iDocumentTypeID); - $sToRender .= "
\n"; - - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - if (!isset($bFirstEdit)) { - $sToRender .= "\n"; - } - $sToRender .= "\n"; - $sToRender .= "
\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= generateControllerLink("viewDocument", "fDocumentID=$iDocumentID&fShowSection=typeSpecificMetaData", ""); - $sToRender .= "
\n"; - - $sToRender .= "
\n"; - - return $sToRender; -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc deleted file mode 100644 index a7b50be..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/modifyUI.inc +++ /dev/null @@ -1,111 +0,0 @@ -siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $sToRender; - if ($oDocument) { - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
" . _("Document Data") . "
\n"; - $sToRender .= "" . _("Document Title") . " \n"; - $sToRender .= "\n"; - $sToRender .= "getName() . "\" />\n"; - $sToRender .= "
\n"; - $sToRender .= "" . _("Document Type") . " \n"; - $sToRender .= "\n"; - $sToRender .= getDocumentType($oDocument->getFolderID(), $iDocumentTypeID); - $sToRender .= "
\n"; - - return $sToRender; - } - return ""; -} - -function getDocumentType($iFolderID, $iDocumentTypeID) { - global $default; - $sWhereClause = "FDL.folder_id = $iFolderID"; - $oPatternListBox = & new PatternListBox("$default->document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause); - $oPatternListBox->setIncludeDefaultValue(false); - $oPatternListBox->setFromClause("INNER JOIN $default->folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id"); - if (isset($iDocumentTypeID)) { - $oPatternListBox->setSelectedValue($iDocumentTypeID); - } - return $oPatternListBox->render(); -} - - - -function renderPage($oDocument, $iDocumentTypeID, $bFirstEdit) { - global $default; - $sToRender = renderHeading(_("Edit Document Details")); - $sToRender .= displayDocumentPath($oDocument->getID()); - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
\n"; - $sToRender .= renderEditableDocumentData($oDocument, $iDocumentTypeID) . "\n"; - $sToRender .= "
\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
\n"; - if (!isset($bFirstEdit)) { - //can't this action on a first time upload, you must fill out the necessary fields - $sToRender .= "rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\">\n"; - } - $sToRender .= "
\n"; - - return $sToRender . getValidationJavaScript(); -} - -function getValidationJavaScript() { - $sToRender .= "\n\n\n\n"; - - return $sToRender; -} - -function wrapInTable($sHtml) { - return "\n\t\t\t
$sHtml
\n"; -}?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseBL.php deleted file mode 100644 index e0aa44e..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseBL.php +++ /dev/null @@ -1,135 +0,0 @@ -fileSystemRoot/lib/browse/BrowserFactory.inc"); -require_once("$default->fileSystemRoot/lib/browse/Browser.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentType.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); -require_once("$default->uiDirectory/documentmanagement/browseUI.inc"); -require_once("$default->fileSystemRoot/presentation/Html.inc"); -/** - * $Id$ - * - * This page very closely follows browseBL.php. This page is ONLY used when a user - * browses for a template document when setting up document linking in folder - * collaboration. This page is launched as a separate window by javascript. The - * user browses for the document that will serve as a template and then selects it. - * This causes this window to close and set the template document value in the - * the parent window. - * - * The main difference between this file and browseBL.php is the way the document - * links are generated. When clicking on a document link, instead of being taken - * to the document, the document values are sent to the parent window and the - * window is closed - * - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Revision$ - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa - * @package documentmanagement - */ - -// only if we have a valid session -if (checkSession()) { - require_once("../../../../phpSniff/phpTimer.class.php"); - $timer = new phpTimer(); - $timer->start(); - - // retrieve variables - if (!$fBrowseType) { - // required param not set- internal error or user querystring hacking - // set it to default= folder - $fBrowseType = "folder"; - } - - // retrieve field to sort by - if (!$fSortBy) { - // no sort field specified- default is document name - $fSortBy = "name"; - } - // retrieve sort direction - if (!$fSortDirection) { - $fSortDirection = "asc"; - } - - // fire up the document browser - $oBrowser = BrowserFactory::create($fBrowseType, $fSortBy, $fSortDirection); - - // instantiate my content pattern - $oContent = new PatternCustom(); - - $aResults = $oBrowser->browse(); - - require_once("../../../webpageTemplate.inc"); - // display the browse results - $oContent->addHtml(renderPage($aResults, $fBrowseType, $fSortBy, $fSortDirection, true)); - - $sToRender = "\n"; - $sToRender .= "\n"; - $sToRender .= "sessionTimeout+3) . "\">\n"; - $sToRender .= "graphicsUrl/tree.ico\">\n"; - $sToRender .= "uiUrl/stylesheet.php\">\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= $oContent->render() . "\n"; - $sToRender .= ""; - $sToRender .= "\n"; - - echo $sToRender . "\n\n" . getSendInfoToParentJavaScript(); - -} - -function getSendInfoToParentJavaScript() { - $sToRender = "\n\n"; - return $sToRender; - -} - -/*function renderBrowsePage($oContent) { - global $default; - $sToRender = "\n"; - $sToRender .= "\n"; - $sToRender .= "sessionTimeout+3) . "\">\n"; - $sToRender .= "graphicsUrl/tree.ico\">\n"; - $sToRender .= "uiUrl/stylesheet.php\">\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= $oContent->render() . "\n"; - $sToRender .= ""; - $sToRender .= "\n"; - return $sToRender; - - -}*/ -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseUI.inc deleted file mode 100644 index 5a488bd..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/templateDocumentBrowseUI.inc +++ /dev/null @@ -1,345 +0,0 @@ -fileSystemRoot/presentation/Html.inc"); -require_once("$default->uiDirectory/foldermanagement/folderUI.inc"); -require_once("$default->uiDirectory/documentmanagement/documentUI.inc"); -require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); -/** - * $Id$ - * - * Template document browsing page html UI building functions. - * - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Revision$ - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa - * @package documentmanagement - */ - -/** - * Generates radio button selects for document browse by type - * Javascript refreshes the form when it changes - * - * @param string the selected browse by option - */ -function renderBrowseTypeSelect($sBrowseType) { - // TODO: write function for onChange that checks if the new value - return "\n - \tView documents by: Folders\n" . - " Category\n" . - " Document Type\n"; -} - -// - -/** - * Displays the passed category path as a link - * - * @param string the category name to display - */ -function displayCategoryPathLink($aCategories) { - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aCategories[0] == "Categories") { - return displayCategoryLink($aCategories[0]); - } else { - // else the first entry is the category name, so build a little path - return displayCategoryLink("Categories") . " > " . displayCategoryLink($aCategories[0]); - } -} - -/** - * Displays the passed category as a link - * - * @param string the category name to display - */ -function displayCategoryLink($sCategoryName) { - if ($sCategoryName != "") { - return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=category" . - // if the category title is passed in, link back to the list of categories - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), - $sCategoryName); - } else { - return false; - } -} - -/** - * Displays the results for category browsing - * - * @param array the category browse results - */ -function renderCategoryResults($aResults) { - $sToRender = ""; - - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aResults["categories"][0] == "Categories") { - // loop through categories and display them - for ($i=1; $i"; - - // category name - $sToRender .= "" . displayCategoryLink($aResults["categories"][$i]) . ""; - // blank filename - $sToRender .= ""; - // creator name - $sToRender .= ""; - // modified date - $sToRender .= ""; - // document type - $sToRender .= ""; - - $sToRender .= "\n"; - } - } else { - // else the first entry is the category name, so display the documents in the category - // with full paths - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category"), true); - } - return $sToRender; -} - -// - -// -/** - * Displays the passed document type path as a link - * - * @param string the document type to display - */ -function displayDocumentTypePathLink($aDocumentTypes) { - // if the first value in arr["categories"] == Categories then we've got a list of categories - if ($aDocumentTypes[0]["name"] == "Document Types") { - return displayDocumentTypeLink($aDocumentTypes[0]); - } else { - // else the first entry is the category name, so build a little path - return displayDocumentTypeLink(array("name"=>"Document Types")) . " > " . displayDocumentTypeLink($aDocumentTypes[0]); - } -} - -/** - * Displays the passed document type as a link - * - * @param string the document type to display - */ -function displayDocumentTypeLink($aDocumentType) { - return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=documentType" . - // if the document type title is passed in, link back to the list of document types - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), - $aDocumentType["name"]); -} - -/** - * Displays the results for document type browsing - * - * @param array the document type browse results - */ -function renderDocumentTypeResults($aResults) { - $sToRender = ""; - - // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types - if ($aResults["documentTypes"][0]["name"] == "Document Types") { - // loop through document types and display them - for ($i=1; $i"; - // document type name - $sToRender .= "" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . ""; - // blank filename - $sToRender .= ""; - // creator name - $sToRender .= ""; - // modified date - $sToRender .= ""; - // document type - $sToRender .= ""; - $sToRender .= "\n"; - } - } else { - // else the first entry is the document type name, so display the documents in the document type - // with full paths - $sToRender .= renderDocumentList($aResults, _("This document type contains no documents"), _("You don't have access to the documents in this document type"), true); - } - return $sToRender; -} -// - - -// -/** - * Displays the folders in the browse results - * - * @param array the browse result objects - */ -function renderFolderResults($aResults) { - global $default; - $sToRender = ""; - - // now loop through the rest of the folders and display links - if (count($aResults["folders"]) > 1) { - for ($i=1; $igetCreatorID()); - - $sToRender .= ""; - // folder name - $sToRender .= "" . $sFolderLink . ""; - // blank filename (??: folder description?) - $sToRender .= ""; - // creator name - $sToRender .= "" . $oCreator->getName() . ""; - // modified date (TODO: add to db) - $sToRender .= ""; - // document type (??: display one of the mapped document types?) - $sToRender .= ""; - $sToRender .= "\n"; - } - } else { - $sToRender .= "" . _("This folder contains no sub folders") . ""; - } - - $sToRender .= "" . renderDocumentList($aResults, _("This folder contains no documents"), _("You don't have access to the documents in this folder")) . "\n"; - - return $sToRender; -} -// - -/** - * Displays the headings for the displayed document details and enables - * resorting the contents - * - * @param string the field currently sorting by - * @param string the direction currently sorted in - */ -function renderSortHeadings($sSortBy, $sSortDirection) { - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - // need list of display criteria and sort name - $aSortCriteria = $oBrowser->getSortCriteria(); - - $sToRender .= ""; - while (list($key, $value) = each ($aSortCriteria)) { - $sCurrentSortDirection = "asc"; - $displayText = $value["display"]; - // if the current heading is being sorted then flip the sort direction - if ($sSortBy == $key) { - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); - $displayText = "graphicsUrl/" . $sCurrentSortDirection . ".gif\">" . $displayText; - } - switch ($fBrowseType) { - case "folder" : - $queryString = "fFolderID=$fFolderID"; - break; - case "category" : - $queryString = "fCategoryName=$fCategoryName"; - break; - case "documentType" : - $queryString = "fDocumentTypeID=$fDocumentTypeID"; - break; - } - $sToRender .= "" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . ""; - } - - $sToRender .= "\n"; - return $sToRender; -} - -/** - * Displays the documents in the browse results - * - * @param array the browse result objects - * @param string the message to display if there are no documents - * @param string the message to display if the current user doesn't have permission to view the documents - * @param boolean whether to display the complete path to the document or not - */ -function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false) { - // loop through the files and display links - if (count($aResults["documents"]) > 0) { - for ($i=0; $i" . displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) . ""; - //$sToRender .= ""; - $sToRender .= "" . $aResults["documents"][$i]->getFileName() . ""; - $oCreator = User::get($aResults["documents"][$i]->getCreatorID()); - $sToRender .= "" . $oCreator->getName() . ""; - $sToRender .= "" . $aResults["documents"][$i]->getLastModifiedDate() . ""; - $oDocumentType = DocumentType::get($aResults["documents"][$i]->getDocumentTypeID()); - if ($oDocumentType) { - $sToRender .= "" . $oDocumentType->getName() . ""; - } - $sToRender .= "\n"; - } - } else if ($aResults["accessDenied"]) { - $sToRender .= "$sNoPermissionMessage"; - } else { - $sToRender .= "$sNoDocumentsMessage"; - } - return $sToRender; -} - -/** - * Displays the browse page- lists folders and documents - * - * @param array the browse results to display - * @param string the browse view (folder, category, document type) - * @param string the field to sort the results by - * @param string the direction to sort - */ -function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection) { - global $default; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $sToRender = renderHeading(_("Browse Collection")); - - $sToRender .= "
"; - switch ($sBrowseType) { - case "folder" : $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID())); break; - case "category" : $sToRender .= displayCategoryPathLink($aResults["categories"]); break; - case "documentType" : $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); break; - } - $sToRender .= "
\n"; - - // browse type select - $sToRender .= "\n"; - //$sToRender .= "\t"; - $sToRender .= "\t
" . renderBrowseTypeSelect($sBrowseType) . "
"; - - // display folders|documents - $sToRender .= "\n"; - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); - $sToRender .= "\n"; - $sToRender .= "\t
\n"; - switch ($sBrowseType) { - case "folder" : $sToRender .= renderFolderResults($aResults, $sSortBy, $sSortDirection); break; - case "category" : $sToRender .= renderCategoryResults($aResults); break; - case "documentType" : $sToRender .= renderDocumentTypeResults($aResults); break; - } - $sToRender .= "
"; - - return $sToRender; -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php deleted file mode 100644 index d6fbfb4..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php +++ /dev/null @@ -1,80 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); - -require_once("$default->fileSystemRoot/lib/users/User.inc"); - -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); - -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); - -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); - -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc"); -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); -require_once("$default->fileSystemRoot/presentation/Html.inc"); - - -if (checkSession()) { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - if (isset($fDocumentID)) { - $oDocument = & Document::get($fDocumentID); - if (Permission::userHasDocumentReadPermission($oDocument)) { - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getPage($oDocument->getID(), $oDocument->getFolderID(), $oDocument->getName())); - $main->setCentralPayload($oPatternCustom); - $main->render(); - } else { - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(""); - $main->setErrorMessage(_("You do not have permission to view this document's history")); - $main->setCentralPayload($oPatternCustom); - $main->render(); - } - - } else { - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(""); - $main->setErrorMessage(_("No document currently selected")); - $main->setCentralPayload($oPatternCustom); - $main->render(); - } -} - -?> diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc deleted file mode 100644 index d9b5a27..0000000 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryUI.inc +++ /dev/null @@ -1,90 +0,0 @@ -document_transactions_table AS DT INNER JOIN $default->users_table AS U ON DT.user_id = U.id " . - "INNER JOIN $default->transaction_types_table AS DTT ON DTT.id = DT.transaction_id " . - "WHERE DT.document_id = ? ORDER BY DT.datetime DESC", $iDocumentID); - $sql = $default->db; - $sToRender = "\n"; - $sToRender .= "\n"; - $sql->query($sQuery); - if ($sql->num_rows() == 0) { - $sToRender .= "\n"; - $sToRender .= "\t\n"; - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $i = 0; - while ($sql->next_record()) { - if ($sql->f("transaction_name") == "Check Out") { - $sVersion = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID&fVersion=" . $sql->f("version"), "" . $sql->f("version") . ""); - } else { - $sVersion = $sql->f("version"); - } - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - } - $sToRender .= "
" . _("Transaction History") . "
" . _("No Transaction History data") . "
" . _("Type") . "" . _("Users") . "" . _("Version") . "" . _("Comment") . "" . _("Datetime") . "
" . $sql->f("transaction_name") . "" . $sql->f("user_name") . "$sVersion" . displaySpace($sql->f("comment")) . "" . $sql->f("datetime") . "
\n"; - } - return $sToRender; -} - -function displaySpace($sHtml) { - if ($sHtml == "") { - return " "; - } else { - return $sHtml; - } -} - -function getPage($iDocumentID, $iFolderID, $sDocumentName) { - global $default; - $sToRender = renderHeading(_("Document History")); - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
" . displayDocumentPath($iDocumentID) . "
\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
" . getDocumentHistory($iDocumentID) . "
rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID\">
\n"; - return $sToRender; -} - -?>