diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index 0556027..b0a979e 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -76,6 +76,16 @@ if (!defined('KT_LIB_DIR')) { define('KT_LIB_DIR', KT_DIR . '/lib'); } +// If not defined, set KT_INSTALL_DIR based on my usual location in the tree +if (!defined('KT_INSTALL_DIR')) { + $installLoc = realpath(dirname(__FILE__) . '/../..'); + if (substr(PHP_OS, 0, 3) == 'WIN') { + $installLoc = str_replace('\\','/',$installLoc); + } + define('KT_INSTALL_DIR', $installLoc); +} + + // PATH_SEPARATOR added in PHP 4.3.0 if (!defined('PATH_SEPARATOR')) { if (substr(PHP_OS, 0, 3) == 'WIN') { diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index f00dd9a..b4c91f4 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -558,12 +558,12 @@ class KTDocumentUtil { DBUtil::startTransaction(); $oDocument =& KTDocumentUtil::_add($oFolder, $sFilename, $oUser, $aOptions); - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Document created'))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Document created'))); if (PEAR::isError($oDocument)) { return $oDocument; } - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Scanning file'))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Scanning file'))); $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'scan'); $iTrigger = 0; @@ -582,22 +582,8 @@ class KTDocumentUtil { // NEW SEARCH Indexer::index($oDocument); - /* - $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Transforming file'))); - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); - $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); - foreach ($aTriggers as $aTrigger) { - $sTrigger = $aTrigger[0]; - if ($aTrigger[1]) { - require_once($aTrigger[1]); - } - $oTrigger = new $sTrigger; - $oTrigger->setDocument($oDocument); - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(sprintf(_kt(" (trigger %s)"), $sTrigger))); - $oTrigger->transform(); - }*/ - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating transaction'))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating transaction'))); $aOptions = array('user' => $oUser); //create the document transaction record $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document created'), 'ktcore.transactions.create', $aOptions); @@ -607,7 +593,7 @@ class KTDocumentUtil { return $res; } - // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Sending subscriptions'))); + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Sending subscriptions'))); // fire subscription alerts for the checked in document $oSubscriptionEvent = new SubscriptionEvent(); $oFolder = Folder::get($oDocument->getFolderID()); @@ -630,6 +616,20 @@ class KTDocumentUtil { KTDocumentUtil::updateSearchableText($oDocument, true); DBUtil::commit(); + + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Checking permissions...'))); + + // Check if there are any dynamic conditions / permissions that need to be updated on the document + // If there are dynamic conditions then update the permissions on the document + // The dynamic condition test fails unless the document exists in the DB therefore update permissions after committing the transaction. + include_once(KT_LIB_DIR.'/permissions/permissiondynamiccondition.inc.php'); + $iPermissionObjectId = $oFolder->getPermissionObjectID(); + $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId); + + if(!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)){ + $res = KTPermissionUtil::updatePermissionLookup($oDocument); + } + $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('All done...'))); return $oDocument; diff --git a/lib/permissions/permissiondynamiccondition.inc.php b/lib/permissions/permissiondynamiccondition.inc.php index 4b37267..0329612 100644 --- a/lib/permissions/permissiondynamiccondition.inc.php +++ b/lib/permissions/permissiondynamiccondition.inc.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): ______________________________________ * */ @@ -89,6 +89,15 @@ class KTPermissionDynamicCondition extends KTEntity { )); } + function &getByPermissionObjectId($iPermissionObjectId) { + return KTEntityUtil::getByDict('KTPermissionDynamicCondition', array( + 'permission_object_id' => $iPermissionObjectId, + ), array( + 'multi' => true, + )); + } + + function &getByPermissionObjectAndCondition($oPermissionObject, $oCondition) { $iPermissionObjectId = KTUtil::getId($oPermissionObject); $iConditionId = KTUtil::getId($oCondition); @@ -142,7 +151,7 @@ class KTPermissionDynamicCondition extends KTEntity { array($iConditionId), ); $aIds = DBUtil::getResultArrayKey($aQuery, 'id'); - + $sParam = DBUtil::paramArray($aIds); diff --git a/lib/permissions/permissionutil.inc.php b/lib/permissions/permissionutil.inc.php index a4907a3..01e8f39 100644 --- a/lib/permissions/permissionutil.inc.php +++ b/lib/permissions/permissionutil.inc.php @@ -431,7 +431,7 @@ class KTPermissionUtil { */ - if (is_null($oPermLookup)) { + //if (is_null($oPermLookup)) { $aMapPermDesc = array(); foreach ($aMapPermAllowed as $iPermissionId => $aAllowed) { $oLookupPD = KTPermissionUtil::getOrCreateDescriptor($aAllowed); @@ -439,7 +439,7 @@ class KTPermissionUtil { } $oPermLookup = KTPermissionLookupAssignment::findOrCreateLookupByPermissionDescriptorMap($aMapPermDesc); - } + //} $oFolderOrDocument->setPermissionLookupID($oPermLookup->getID()); $oFolderOrDocument->update(); @@ -600,7 +600,8 @@ class KTPermissionUtil { $sQuery = "UPDATE $default->documents_table SET permission_object_id = ? WHERE permission_object_id = ? AND - parent_folder_ids LIKE ?"; + (parent_folder_ids LIKE ? OR folder_id = ?)"; + $aParams[] = $iFolderID; DBUtil::runQuery(array($sQuery, $aParams)); Document::clearAllCaches(); diff --git a/lib/upgrades/UpgradeFunctions.inc.php b/lib/upgrades/UpgradeFunctions.inc.php index cb0b904..0b4aab0 100644 --- a/lib/upgrades/UpgradeFunctions.inc.php +++ b/lib/upgrades/UpgradeFunctions.inc.php @@ -1038,17 +1038,18 @@ class UpgradeFunctions { $ini->addItem('webservice', 'validateSessionCount', 'false'); // externalBinary Section + $ini->delSection('externalBinary'); if(OS_WINDOWS){ - $ini->addItem('externalBinary', 'xls2csv', 'xls2csv', '', 'The following are external binaries that may be used by various parts of knowledgeTree.'); - $ini->addItem('externalBinary', 'pdftotext', 'pdftotext'); - $ini->addItem('externalBinary', 'catppt', 'catppt'); - $ini->addItem('externalBinary', 'pstotext', 'pstotext'); - $ini->addItem('externalBinary', 'catdoc', 'catdoc'); - $ini->addItem('externalBinary', 'antiword', 'antiword.exe'); - $ini->addItem('externalBinary', 'python', 'python.bat'); - $ini->addItem('externalBinary', 'java', 'java.exe'); - $ini->addItem('externalBinary', 'php', 'php.exe'); - $ini->addItem('externalBinary', 'df', 'df.exe'); + $ini->addItem('externalBinary', 'xls2csv', KT_INSTALL_DIR . '/bin/catdoc/xls2csv.exe', '', 'The following are external binaries that may be used by various parts of knowledgeTree.'); + $ini->addItem('externalBinary', 'pdftotext', KT_INSTALL_DIR . '/bin/xpdf/pdftotext.exe'); + $ini->addItem('externalBinary', 'catppt', KT_INSTALL_DIR . '/bin/catdoc/catppt.exe'); + $ini->addItem('externalBinary', 'pstotext', KT_INSTALL_DIR . '/pstotext'); + $ini->addItem('externalBinary', 'catdoc', KT_INSTALL_DIR . '/bin/catdoc/catdoc.exe'); + $ini->addItem('externalBinary', 'antiword', KT_INSTALL_DIR . '/bin/antiword/antiword.exe'); + $ini->addItem('externalBinary', 'python', KT_INSTALL_DIR . '/python.bat'); + $ini->addItem('externalBinary', 'java', KT_INSTALL_DIR . '/java/jre/bin/java.exe'); + $ini->addItem('externalBinary', 'php', KT_INSTALL_DIR . '/php/php.exe'); + $ini->addItem('externalBinary', 'df', KT_INSTALL_DIR . '/bin/gnuwin32/df.exe'); } else { $ini->addItem('externalBinary', 'xls2csv', 'xls2csv', '', 'The following are external binaries that may be used by various parts of knowledgeTree.'); @@ -1056,7 +1057,7 @@ class UpgradeFunctions { $ini->addItem('externalBinary', 'catppt', 'catppt'); $ini->addItem('externalBinary', 'pstotext', 'pstotext'); $ini->addItem('externalBinary', 'catdoc', 'catdoc'); - $ini->addItem('externalBinary', 'antiword', 'antiword.exe'); + $ini->addItem('externalBinary', 'antiword', ''); $ini->addItem('externalBinary', 'python', 'python'); $ini->addItem('externalBinary', 'java', 'java'); $ini->addItem('externalBinary', 'php', 'php'); diff --git a/plugins/ktcore/admin/fieldsets/conditional.inc.php b/plugins/ktcore/admin/fieldsets/conditional.inc.php index 4e1a64a..8b57eba 100644 --- a/plugins/ktcore/admin/fieldsets/conditional.inc.php +++ b/plugins/ktcore/admin/fieldsets/conditional.inc.php @@ -111,12 +111,15 @@ class ConditionalFieldsetManagementDispatcher extends BasicFieldsetManagementDis // now prep for the warnings. if ($this->oMasterfield) { if (!empty($this->aFreeFields)) { - $this->addErrorMessage(_kt("All fields must be assigned to an order in the conditional system. To correct this, please use the \"manage field ordering\" link below. This fieldset will display as a normal, non-conditional fieldset until this problem is corrected.")); + $this->addErrorMessage(_kt("Al fields must be assigned to an order in the conditional system. To correct this, please use the \"manage field ordering\" link below. This fieldset will display as a normal, non-conditional fieldset until this problem is corrected.")); + $this->oPage->booleanLink = true; } else if ($this->bIncomplete) { - $this->addErrorMessage(sprintf(_kt("This fieldset is incomplete: %s This fieldset will display as a normal, non-conditional fieldset until this problem is corrected."), $sIncomplete)); + $this->addErrorMessage(sprintf(_kt("This fieldset is incomplete: %s This fieldset will display as a normal, non-conditional fieldset until this problem is corrected."), $sIncomplete)); + $this->oPage->booleanLink = true; } } else { - $this->addErrorMessage(_kt("A conditional fieldset must have a master field before it can be used. To correct this, please use the \"manage field ordering\" link below. This fieldset will display as a normal, non-conditional fieldset until this problem is corrected.")); + $this->addErrorMessage(_kt("A conditional fieldset must have a master field before it can be used. To correct this, please use the \"manage field ordering\" link below. This fieldset will display as a normal, non-conditional fieldset until this problem is corrected.")); + $this->oPage->booleanLink = true; } } diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php index af0cdc8..f466b02 100644 --- a/plugins/ktcore/document/edit.php +++ b/plugins/ktcore/document/edit.php @@ -49,6 +49,7 @@ require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); require_once(KT_LIB_DIR . "/widgets/forms.inc.php"); require_once(KT_LIB_DIR . "/metadata/fieldsetregistry.inc.php"); require_once(KT_LIB_DIR . "/util/sanitize.inc"); +require_once(KT_LIB_DIR.'/permissions/permissiondynamiccondition.inc.php'); // {{{ KTDocumentEditAction class KTDocumentEditAction extends KTDocumentAction { @@ -233,6 +234,16 @@ class KTDocumentEditAction extends KTDocumentAction { $oDocumentTransaction = & new DocumentTransaction($this->oDocument, _kt('Document metadata updated'), 'ktcore.transactions.update'); $oDocumentTransaction->create(); + // Check if there are any dynamic conditions / permissions that need to be updated on the document + // If there are dynamic conditions then update the permissions on the document + // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction. + $iPermissionObjectId = $this->oDocument->getPermissionObjectID(); + $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId); + + if(!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)){ + $res = KTPermissionUtil::updatePermissionLookup($this->oDocument); + } + redirect(KTBrowseUtil::getUrlForDocument($this->oDocument->getId())); exit(0); } @@ -369,6 +380,16 @@ class KTDocumentEditAction extends KTDocumentAction { $ret = $oTrigger->postValidate(); } + // Check if there are any dynamic conditions / permissions that need to be updated on the document + // If there are dynamic conditions then update the permissions on the document + // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction. + $iPermissionObjectId = $this->oDocument->getPermissionObjectID(); + $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId); + + if(!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)){ + $res = KTPermissionUtil::updatePermissionLookup($this->oDocument); + } + $this->successRedirectToMain(sprintf(_kt("You have selected a new document type: %s. "), $data['type']->getName())); } } diff --git a/templates/ktcore/metadata/admin/list.smarty b/templates/ktcore/metadata/admin/list.smarty index 1d9a8f6..51ac378 100644 --- a/templates/ktcore/metadata/admin/list.smarty +++ b/templates/ktcore/metadata/admin/list.smarty @@ -25,7 +25,7 @@ {foreach from=$fieldsets item=oFieldset} - { $oFieldset->getName() } + { $oFieldset->getName()|truncate:40:"..." }