diff --git a/config/config.ini b/config/config.ini index e5d158f..91d068a 100644 --- a/config/config.ini +++ b/config/config.ini @@ -206,13 +206,31 @@ uiUrl = ${rootUrl}/presentation/lookAndFeel/knowledgeTree stopwordsFile = ${fileSystemRoot}/config/stopwords.txt [webservice] +; Directory to which all uploads via webservices are persisted before moving into the repository uploadDirectory = ${varDirectory}/uploads + +; Url which is sent to clients via web service calls so they can then download file via HTTP GET downloadUrl = ${rootUrl}/ktwebservice/download.php + +; Period indicating how long a file should be retained in the uploads directory. uploadExpiry = 30 + +; Period indicating how long a download link will be available downloadExpiry = 30 + +; Random text used to construct a hash. This can be customised on installations so there is less chance of overlap between installations. randomKeyText = bkdfjhg23yskjdhf2iu + +; Validating session counts can interfere with access. It is best to leave this disabled, unless very strict access is required. validateSessionCount = false +; If the document type is invalid when adding a document, we can be tollerant and just default to the Default document type. +useDefaultDocumentTypeIfInvalid = true + +; The web service debugging if the logLevel is set to DEBUG. We can set the value to 4 or 5 to get more verbose web service logging. +; Level 4 logs the name of functions being accessed. Level 5 logs the SOAP XML requests and responses. +debug = false + [session] ; session timeout (in seconds) sessionTimeout = 1200 diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc index 9416729..bb8f3b0 100644 --- a/lib/util/ktutil.inc +++ b/lib/util/ktutil.inc @@ -748,6 +748,7 @@ class KTUtil { // {{{ isAbsolutePath static function isAbsolutePath($sPath) { + if (substr($sPath, 0, 1) == '/') { return true; } @@ -949,6 +950,79 @@ class KTUtil { return $aRet; } + + /** + * Generates breadcrumbs for a browsable collection + * + * @param object $oFolder The folder being browsed to + * @param integer $iFolderId The id of the folder + * @param array $aURLParams The url parameters for each folder/breadcrumb link + * @return unknown + */ + function generate_breadcrumbs($oFolder, $iFolderId, $aURLParams) { + static $aFolders = array(); + static $aBreadcrumbs = array(); + + // Check if selected folder is a parent of the current folder + if(in_array($iFolderId, $aFolders)){ + $temp = array_flip($aFolders); + $key = $temp[$iFolderId]; + array_splice($aFolders, $key); + array_splice($aBreadcrumbs, $key); + return $aBreadcrumbs; + } + + // Check for the parent of the selected folder unless its the root folder + $iParentId = $oFolder->getParentID(); + + if(is_null($iParentId)){ + // folder is root + return ''; + } + + if($iFolderId != 1 && in_array($iParentId, $aFolders)){ + $temp = array_flip($aFolders); + $key = $temp[$iParentId]; + array_splice($aFolders, $key); + array_splice($aBreadcrumbs, $key); + array_push($aFolders, $iFolderId); + + $aParams = $aURLParams; + $aParams['fFolderId'] = $iFolderId; + $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams); + $aBreadcrumbs[] = array('url' => $url, 'name' => $oFolder->getName()); + return $aBreadcrumbs; + } + + // Get the root folder name + $oRootFolder = Folder::get(1); + $sRootFolder =$oRootFolder->getName(); + + // Create the breadcrumbs + $folder_path_names = $oFolder->getPathArray(); + array_unshift($folder_path_names, $sRootFolder); + $folder_path_ids = explode(',', $oFolder->getParentFolderIds()); + $folder_path_ids[] = $oFolder->getId(); + if ($folder_path_ids[0] == 0) { + array_shift($folder_path_ids); + array_shift($folder_path_names); + } + + $iCount = count($folder_path_ids); + $range = range(0, $iCount - 1); + foreach ($range as $index) { + $id = $folder_path_ids[$index]; + $name = $folder_path_names[$index]; + + $aParams = $aURLParams; + $aParams['fFolderId'] = $id; + $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams); + $aBreadcrumbs[] = array('url' => $url, 'name' => $name); + } + $aFolders = $folder_path_ids; + return $aBreadcrumbs; + } + } /** diff --git a/plugins/ktcore/admin/archivedDocuments.php b/plugins/ktcore/admin/archivedDocuments.php index 3072083..c9533d2 100755 --- a/plugins/ktcore/admin/archivedDocuments.php +++ b/plugins/ktcore/admin/archivedDocuments.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * 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, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -53,12 +53,12 @@ require_once(KT_LIB_DIR . "/documentmanagement/PhysicalDocumentManager.inc"); // FIXME chain in a notification alert for un-archival requests. class KTArchiveTitle extends TitleColumn { - + function renderDocumentLink($aDataRow) { $outStr .= $aDataRow["document"]->getName(); return $outStr; - } - + } + function buildFolderLink($aDataRow) { return KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $aDataRow["folder"]->getId())); } @@ -68,94 +68,88 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher { var $sHelpPage = 'ktcore/admin/archived documents.html'; function do_main () { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents')); - + $this->oPage->setBreadcrumbDetails(_kt('browse')); - + $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1)); - if (PEAR::isError($oFolder)) { + if (PEAR::isError($oFolder)) { $this->errorRedirectToMain(_kt('Invalid folder selected.')); exit(0); } - - // Setup the collection for move display. - + + // Setup the collection for restore display. $aBaseParams = array(); $collection = new AdvancedCollection(); $oCR =& KTColumnRegistry::getSingleton(); - - // selection col $col = $oCR->getColumn('ktcore.columns.selection'); - $col->setOptions(array('show_folders' => false, 'rangename' => '_d[]')); + $aColOptions = array(); + //$aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId())); + $aColOptions['show_folders'] = false; + $aColOptions['show_documents'] = true; + $aColOptions['rangename'] = '_d[]'; + $col->setOptions($aColOptions); $collection->addColumn($col); - - // title col + $col = $oCR->getColumn('ktcore.columns.title'); + //$col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId())))); $col->setOptions(array('link_documents' => false)); - $collection->addColumn($col); + //$qObj = new BrowseQuery($iFolderId); $qObj = new ArchivedBrowseQuery($oFolder->getId()); $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); - $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], + $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId())))); $collection->setOptions($aOptions); - $oWF =& KTWidgetFactory::getSingleton(); - $oWidget = $oWF->get('ktcore.widgets.collection', - array('label' => _kt('Target Documents'), - 'description' => _kt('Use the folder collection and path below to browse to the folder containing the documents you wish to restore.'), - 'required' => true, - 'name' => 'browse', - 'folder_id' => $oFolder->getId(), - 'bcurl_params' => $aBaseParams, - 'collection' => $collection)); + $aURLParams = $aBaseParams; + $aURLParams['action'] = 'restore'; + $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); - - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate("ktcore/document/admin/archivebrowse"); $aTemplateData = array( - "context" => $this, + 'context' => $this, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, - 'collection' => $oWidget, + 'collection' => $collection ); - - return $oTemplate->render($aTemplateData); + + $oTemplate =& $this->oValidator->validateTemplate('ktcore/document/admin/archivebrowse'); + return $oTemplate->render($aTemplateData); } - + /* * Provide for "archived" browsing. */ function do_browse() { - + } - + function do_confirm_restore() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents')); - - $selected_docs = KTUtil::arrayGet($_REQUEST, '_d', array()); - + + $selected_docs = KTUtil::arrayGet($_REQUEST, '_d', array()); + $this->oPage->setTitle(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs))); - + $this->oPage->setBreadcrumbDetails(sprintf(_kt('confirm restore of %d documents'), count($selected_docs))); - + $aDocuments = array(); foreach ($selected_docs as $doc_id) { $oDoc =& Document::get($doc_id); - if (PEAR::isError($oDoc) || ($oDoc === false)) { + if (PEAR::isError($oDoc) || ($oDoc === false)) { $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore.')); } else if ($oDoc->getStatusId() != ARCHIVED) { $this->errorRedirectToMain(sprintf(_kt('%s is not an archived document. Aborting restore.'), $oDoc->getName())); } $aDocuments[] = $oDoc; } - - + + $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/dearchiveconfirmlist'); $oTemplate->setData(array( @@ -167,22 +161,22 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher { function do_finish_restore() { - - $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); - + + $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); + $aDocuments = array(); foreach ($selected_docs as $doc_id) { $oDoc =& Document::get($doc_id); - if (PEAR::isError($oDoc) || ($oDoc === false)) { + if (PEAR::isError($oDoc) || ($oDoc === false)) { $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore.')); } else if ($oDoc->getStatusId() != ARCHIVED) { $this->errorRedirectToMain(sprintf(_kt('%s is not an archived document. Aborting restore.'), $oDoc->getName())); } $aDocuments[] = $oDoc; } - + $this->startTransaction(); - + foreach ($aDocuments as $oDoc) { // FIXME find de-archival source. // FIXME purge old notifications. @@ -192,11 +186,15 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher { if (PEAR::isError($res) || ($res == false)) { $this->errorRedirectToMain(sprintf(_kt('%s could not be made "live".'), $oDoc->getName)); } + $oDocumentTransaction = & new DocumentTransaction($oDoc, _kt('Document restored.'), 'ktcore.transactions.update'); + $oDocumentTransaction->create(); } + $this->commitTransaction(); $msg = sprintf(_kt('%d documents made active.'), count($aDocuments)); $this->successRedirectToMain($msg); } + } ?> diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php index c9f7c48..af0cdc8 100644 --- a/plugins/ktcore/document/edit.php +++ b/plugins/ktcore/document/edit.php @@ -294,68 +294,76 @@ class KTDocumentEditAction extends KTDocumentAction { } $document_type = $data['type']; + $doctypeid = $document_type->getId(); + // Get the current document type, fieldsets and metadata + $iOldDocTypeID = $this->oDocument->getDocumentTypeID(); + $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $iOldDocTypeID); + $mdlist = DocumentFieldLink::getByDocument($this->oDocument); - $doctypeid = $document_type->getId(); - - - DBUtil::startTransaction(); - $this->oDocument->setDocumentTypeId($doctypeid); - $res = $this->oDocument->update(); + $field_values = array(); + foreach ($mdlist as $oFieldLink) { + $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); + } + DBUtil::startTransaction(); - if (PEAR::isError($res)) - { - DBUtil::rollback(); - return $res; - } - DBUtil::commit(); + // Update the document with the new document type id + $this->oDocument->startNewMetadataVersion($this->oUser); + $this->oDocument->setDocumentTypeId($doctypeid); + $res = $this->oDocument->update(); - $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid); + if (PEAR::isError($res)) + { + DBUtil::rollback(); + return $res; + } - $fs_ids = array(); + // Ensure all values for fieldsets common to both document types are retained + $fs_ids = array(); - $doctype_fieldsets = KTFieldSet::getForDocumentType($doctypeid); - foreach($doctype_fieldsets as $fieldset) - { - $fs_ids[] = $fieldset->getId(); - } - $MDPack = array(); - foreach ($fieldsets as $oFieldset) - { - if ($oFieldset->getIsGeneric() || in_array($oFieldset->getId(),$fs_ids)) - { - //print $oFieldset->getName() . "
"; - $fields = $oFieldset->getFields(); - $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId()); - foreach ($fields as $oField) - { - $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); + $doctype_fieldsets = KTFieldSet::getForDocumentType($doctypeid); + foreach($doctype_fieldsets as $fieldset) + { + $fs_ids[] = $fieldset->getId(); + } - // FIXME "null" has strange meanings here. - if (!is_null($val)) - { - $MDPack[] = array( - $oField, - $val - ); - } - } - } + $MDPack = array(); + foreach ($fieldsets as $oFieldset) + { + if ($oFieldset->getIsGeneric() || in_array($oFieldset->getId(), $fs_ids)) + { + $fields = $oFieldset->getFields(); + + foreach ($fields as $oField) + { + $val = isset($field_values[$oField->getId()]) ? $field_values[$oField->getId()] : ''; + + if (!empty($val)) + { + $MDPack[] = array($oField, $val); + } + } + } + } - } + $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack, array('novalidate' => true)); - $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack); + if (PEAR::isError($core_res)) { + DBUtil::rollback(); + return $core_res; + } + DBUtil::commit(); - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate'); foreach ($aTriggers as $aTrigger) { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger; $aInfo = array( - "document" => $this->oDocument, - "aOptions" => $MDPack, + "document" => $this->oDocument, + "aOptions" => $MDPack, ); $oTrigger->setInfo($aInfo); $ret = $oTrigger->postValidate(); @@ -366,4 +374,4 @@ class KTDocumentEditAction extends KTDocumentAction { } // }}} -?> +?> \ No newline at end of file diff --git a/plugins/ktstandard/KTDocumentLinks.php b/plugins/ktstandard/KTDocumentLinks.php index 8190a2f..b92f7c6 100644 --- a/plugins/ktstandard/KTDocumentLinks.php +++ b/plugins/ktstandard/KTDocumentLinks.php @@ -247,7 +247,7 @@ class KTDocumentLinkAction extends KTDocumentAction { $aURLParams = $aBaseParams; $aURLParams['action'] = 'new'; - $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); + $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); $aTemplateData = array( 'context' => $this, @@ -438,59 +438,6 @@ class KTDocumentLinkAction extends KTDocumentAction { $this->successRedirectToMain(_kt('Document link deleted'), sprintf('fDocumentId=%d', $oParentDocument->getId())); exit(0); } - - function _generate_breadcrumbs($oFolder, $iFolderId, $aURLParams) { - static $aFolders = array(); - static $aBreadcrumbs = array(); - - // Check if selected folder is a parent of the current folder - if(in_array($iFolderId, $aFolders)){ - $temp = array_flip($aFolders); - $key = $temp[$iFolderId]; - array_splice($aFolders, $key); - array_splice($aBreadcrumbs, $key); - return $aBreadcrumbs; - } - - // Check for the parent of the selected folder unless its the root folder - $iParentId = $oFolder->getParentID(); - if($iFolderId != 1 && in_array($iParentId, $aFolders)){ - $temp = array_flip($aFolders); - $key = $temp[$iParentId]; - array_splice($aFolders, $key); - array_splice($aBreadcrumbs, $key); - array_push($aFolders, $iFolderId); - - $aParams = $aURLParams; - $aParams['fFolderId'] = $iFolderId; - $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams); - $aBreadcrumbs[] = array('url' => $url, 'name' => $oFolder->getName()); - return $aBreadcrumbs; - } - - // Create the breadcrumbs - $folder_path_names = $oFolder->getPathArray(); - $folder_path_ids = explode(',', $oFolder->getParentFolderIds()); - $folder_path_ids[] = $oFolder->getId(); - if ($folder_path_ids[0] == 0) { - array_shift($folder_path_ids); - array_shift($folder_path_names); - } - - $iCount = count($folder_path_ids); - $range = range(0, $iCount - 1); - foreach ($range as $index) { - $id = $folder_path_ids[$index]; - $name = $folder_path_names[$index]; - - $aParams = $aURLParams; - $aParams['fFolderId'] = $id; - $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams); - $aBreadcrumbs[] = array('url' => $url, 'name' => $name); - } - $aFolders = $folder_path_ids; - return $aBreadcrumbs; - } } class KTDocLinkAdminDispatcher extends KTAdminDispatcher { diff --git a/resources/js/search2widget.js b/resources/js/search2widget.js index d6230a3..a82fd8c 100644 --- a/resources/js/search2widget.js +++ b/resources/js/search2widget.js @@ -176,7 +176,7 @@ function createSearchBar(div, suffix) value: quickQuery, selectOnFocus:true, id:'txtSearchBar' + suffix, - width: 110 + width: (suffix == 1)?180:110 }), button); var map = new Ext.KeyMap("txtSearchBar" + suffix, @@ -190,7 +190,7 @@ function createSearchBar(div, suffix) var el = Ext.get(div); if (suffix == 1) { - el.applyStyles('position:relative; top: -3px'); + el.applyStyles('position:relative; top: -15px; margin-right: 15px'); } else { diff --git a/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php b/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php index 4795220..e3a7fa9 100644 --- a/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php +++ b/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php @@ -202,7 +202,7 @@ class JavaXMLRPCLuceneIndexer extends Indexer } else { - $_SESSION['KTErrorMessage'][] = _kt('The XMLRPC Server did not respond correctly. Please notify the system administrator to investigate.'); + $_SESSION['KTErrorMessage'][] = _kt('The Document Indexer did not respond correctly. Your search results will not include content results. Please notify the system administrator to investigate why the Document Indexer is not running.'); } return $results; } diff --git a/templates/kt3/standard_page.smarty b/templates/kt3/standard_page.smarty index 72b17b9..fbd7472 100644 --- a/templates/kt3/standard_page.smarty +++ b/templates/kt3/standard_page.smarty @@ -158,7 +158,7 @@ -
+ @@ -198,6 +198,7 @@ {if ($page->breadcrumbDetails !== false)} ({$page->breadcrumbDetails|sanitize}) {/if} +
{/if}
diff --git a/templates/ktcore/document/admin/archivebrowse.smarty b/templates/ktcore/document/admin/archivebrowse.smarty index 3f83fdd..8bed3cc 100644 --- a/templates/ktcore/document/admin/archivebrowse.smarty +++ b/templates/ktcore/document/admin/archivebrowse.smarty @@ -7,17 +7,23 @@ will typically be done within the system and will generate a notification to you.{/i18n}

+

{i18n}Use the folder collection and path below to browse to the folder containing the documents you wish to restore.{/i18n} +

+
+ +{foreach from=$breadcrumbs item=breadcrumb name=bc} + {if !$smarty.foreach.bc.last} + {$breadcrumb.name|sanitize} » + {else} + {$breadcrumb.name|sanitize} + {/if} +{/foreach} +
-{foreach from=$collection_breadcrumbs item=breadcrumb name=bc} -{$breadcrumb.name} -{if !$smarty.foreach.bc.last} -» -{/if} -{/foreach} -{$collection->render()} +{$collection->render()}