From c4456bb8183a11273b93353b989be487bbab10f5 Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Wed, 20 Feb 2008 10:33:04 +0000 Subject: [PATCH] Merged in from DEV trunk... --- bin/win32/schedulerService.php | 44 ++++++++++++++++++++++++++++++++++++++++++-- ktapi/KTAPIDocument.inc.php | 2 +- lib/permissions/permissiondynamiccondition.inc.php | 6 ++++++ plugins/ktcore/admin/conditions.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------- resources/js/search2widget.js | 4 +--- templates/kt3/standard_page.smarty | 18 +++++++++++++++--- 6 files changed, 130 insertions(+), 43 deletions(-) diff --git a/bin/win32/schedulerService.php b/bin/win32/schedulerService.php index cc19763..5b8cccc 100644 --- a/bin/win32/schedulerService.php +++ b/bin/win32/schedulerService.php @@ -1,7 +1,7 @@ log->info("Scheduler Service: starting main loop"); $loop = true; +$bTableExists = false; + +while(!$bTableExists){ + switch (win32_get_last_control_message()) + { + + case WIN32_SERVICE_CONTROL_CONTINUE: + break; // Continue server routine + case WIN32_SERVICE_CONTROL_INTERROGATE: + win32_set_service_status(WIN32_NO_ERROR); + break; // Respond with status + case WIN32_SERVICE_CONTROL_STOP: win32_set_service_status(WIN32_SERVICE_STOPPED); + $loop = false; // Terminate script + $bTableExists = true; + continue; + default: + win32_set_service_status(WIN32_ERROR_CALL_NOT_IMPLEMENTED); // Add more cases to handle other service calls + } + + $default->log->info("Scheduler Service: Checking if the scheduler_tasks table exists."); + + $checkQuery = 'show tables'; + $tableList = DBUtil::getResultArray($checkQuery); + + if(!empty($tableList)){ + foreach($tableList as $table){ + if(in_array('scheduler_tasks', $table)){ + $bTableExists = true; + } + } + } + + + if(!$bTableExists){ + $default->log->error('Scheduler Service: Scheduler_tasks table does not exist, sleeping for 30 seconds'); + sleep(30); + } +} + +$default->log->info("Scheduler Service: starting main loop"); + // Main Scheduler Service Loop while ($loop) { diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php index d8ad531..2639dcd 100644 --- a/ktapi/KTAPIDocument.inc.php +++ b/ktapi/KTAPIDocument.inc.php @@ -1146,7 +1146,7 @@ class KTAPI_Document extends KTAPI_FolderItem // just ignore continue; } - switch($name) + switch(strtolower($name)) { case 'unique_oem_document_no': $documents['oem_no'] = $value; diff --git a/lib/permissions/permissiondynamiccondition.inc.php b/lib/permissions/permissiondynamiccondition.inc.php index 0329612..a26be4c 100644 --- a/lib/permissions/permissiondynamiccondition.inc.php +++ b/lib/permissions/permissiondynamiccondition.inc.php @@ -80,6 +80,12 @@ class KTPermissionDynamicCondition extends KTEntity { return KTEntityUtil::getList2('KTPermissionDynamicCondition', $sWhereClause); } + function getPermissionObjectIdList($sWhereClause, $aParams) { + $query = 'SELECT DISTINCT(permission_object_id) FROM permission_dynamic_conditions WHERE '.$sWhereClause; + $aQuery = array($query, $aParams); + return DBUtil::getResultArray($aQuery); + } + function &getByPermissionObject($oPermissionObject) { $iPermissionObjectId = KTUtil::getId($oPermissionObject); return KTEntityUtil::getByDict('KTPermissionDynamicCondition', array( diff --git a/plugins/ktcore/admin/conditions.php b/plugins/ktcore/admin/conditions.php index 44d4d7d..39418c2 100755 --- a/plugins/ktcore/admin/conditions.php +++ b/plugins/ktcore/admin/conditions.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): ______________________________________ * */ @@ -39,6 +39,7 @@ require_once(KT_LIB_DIR . "/templating/templating.inc.php"); require_once(KT_LIB_DIR . "/dispatcher.inc.php"); require_once(KT_LIB_DIR . "/browse/Criteria.inc"); require_once(KT_LIB_DIR . "/search/savedsearch.inc.php"); +require_once(KT_LIB_DIR .'/permissions/permissiondynamiccondition.inc.php'); class KTConditionDispatcher extends KTAdminDispatcher { var $bAutomaticTransaction = true; @@ -72,6 +73,12 @@ class KTConditionDispatcher extends KTAdminDispatcher { function do_delete_confirmed() { $id = KTUtil::arrayGet($_REQUEST, 'fSavedSearchId'); + + // Get associated permission objects before deleting the condition + $sWhere = 'condition_id = ?'; + $aParams = array($id); + $aPermissionObjects = KTPermissionDynamicCondition::getPermissionObjectIdList($sWhere, $aParams); + $oSearch = KTSavedSearch::get($id); KTPermissionDynamicCondition::deleteByCondition($oSearch); $res = $oSearch->delete(); @@ -79,19 +86,29 @@ class KTConditionDispatcher extends KTAdminDispatcher { 'redirect_to' => 'main', 'message' => _kt('Search not deleted'), )); + + // Update permission objects if they exist + if(!PEAR::isError($aPermissionObjects) && !empty($aPermissionObjects)){ + // update permission objects + foreach($aPermissionObjects as $iPermObjectId){ + $oPO = KTPermissionObject::get($iPermObjectId['permission_object_id']); + KTPermissionUtil::updatePermissionLookupForPO($oPO); + } + } + $this->successRedirectToMain(_kt('Dynamic condition deleted')); } function do_new() { $this->oPage->setBreadcrumbDetails(_kt('Create a new condition')); $this->oPage->setTitle(_kt('Create a new condition')); - + $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search"); - + $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); $aCriteria =& $oCriteriaRegistry->getCriteria(); - + $aTemplateData = array( "title" => _kt("Create a new condition"), "sNameTitle" => _kt("Name of condition"), @@ -105,24 +122,24 @@ class KTConditionDispatcher extends KTAdminDispatcher { function do_view() { } - + function do_edit() { $id = KTUtil::arrayGet($_REQUEST, 'fSavedSearchId'); $oSearch = KTSavedSearch::get($id); - + if (PEAR::isError($oSearch) || ($oSearch == false)) { $this->errorRedirectToMain('No such dynamic condition'); } - + $aSearch = $oSearch->getSearch(); - - + + $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search_edit"); - + $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); $aCriteria =& $oCriteriaRegistry->getCriteria(); - + // we need to help out here, since it gets unpleasant inside the template. foreach ($aSearch['subgroup'] as $isg => $as) { $aSubgroup =& $aSearch['subgroup'][$isg]; @@ -139,8 +156,8 @@ class KTConditionDispatcher extends KTAdminDispatcher { } } } - - + + $aTemplateData = array( "title" => _kt("Edit an existing condition"), "aCriteria" => $aCriteria, @@ -151,26 +168,26 @@ class KTConditionDispatcher extends KTAdminDispatcher { 'old_name' => $oSearch->getName(), 'sNameTitle' => _kt('Edit Dynamic Condition'), ); - return $oTemplate->render($aTemplateData); + return $oTemplate->render($aTemplateData); } - + // XXX: Rename to do_save function do_updateSearch() { $id = KTUtil::arrayGet($_REQUEST, 'fSavedSearchId'); $sName = KTUtil::arrayGet($_REQUEST, 'name'); $oSearch = KTSavedSearch::get($id); - + if (PEAR::isError($oSearch) || ($oSearch == false)) { $this->errorRedirectToMain('No such dynamic condition'); } - - + + $datavars = KTUtil::arrayGet($_REQUEST, 'boolean_search'); if (!is_array($datavars)) { $datavars = unserialize($datavars); } - + if (empty($datavars)) { $this->errorRedirectToMain(_kt('You need to have at least 1 condition.')); } @@ -179,16 +196,30 @@ class KTConditionDispatcher extends KTAdminDispatcher { if (!empty($sName)) { $oSearch->setName($sName); } - + $oSearch->setSearch($datavars); $res = $oSearch->update(); - + $this->oValidator->notError($res, array( 'redirect_to' => 'main', 'message' => _kt('Search not saved'), )); + + // Update permission object if exists + $sWhere = 'condition_id = ?'; + $aParams = array($id); + $aPermissionObjects = KTPermissionDynamicCondition::getPermissionObjectIdList($sWhere, $aParams); + + if(!PEAR::isError($aPermissionObjects) && !empty($aPermissionObjects)){ + // update permission objects + foreach($aPermissionObjects as $iPermObjectId){ + $oPO = KTPermissionObject::get($iPermObjectId['permission_object_id']); + KTPermissionUtil::updatePermissionLookupForPO($oPO); + } + } + $this->successRedirectToMain(_kt('Dynamic condition saved')); - } + } // XXX: Rename to do_save function do_performSearch() { @@ -196,17 +227,17 @@ class KTConditionDispatcher extends KTAdminDispatcher { if (!is_array($datavars)) { $datavars = unserialize($datavars); } - + if (empty($datavars)) { $this->errorRedirectToMain(_kt('You need to have at least 1 condition.')); } $sName = $this->oValidator->validateEntityName( - 'KTSavedSearch', - KTUtil::arrayGet($_REQUEST, 'name'), + 'KTSavedSearch', + KTUtil::arrayGet($_REQUEST, 'name'), array('extra_condition' => 'is_condition', 'redirect_to' => array('new')) ); - + $sNamespace = KTUtil::nameToLocalNamespace('Saved searches', $sName); $oSearch = KTSavedSearch::createFromArray(array( diff --git a/resources/js/search2widget.js b/resources/js/search2widget.js index 7f48657..e0756fe 100644 --- a/resources/js/search2widget.js +++ b/resources/js/search2widget.js @@ -190,9 +190,7 @@ function createSearchBar(div, suffix) var el = Ext.get(div); if (suffix == 1) { - el.applyStyles('position:relative; top: -15px; margin-right: 15px'); - if (Ext.isSafari) - el.applyStyles('top: 0px'); + el.applyStyles('position:relative; margin-right: 15px'); } else { diff --git a/templates/kt3/standard_page.smarty b/templates/kt3/standard_page.smarty index bf36016..a6ae85c 100644 --- a/templates/kt3/standard_page.smarty +++ b/templates/kt3/standard_page.smarty @@ -172,7 +172,13 @@ {/if} {if (!$page->hide_section)} {/if} -- libgit2 0.21.4