Commit 6601055515f8023887f24d56e81c10b4a23f21dc

Authored by Paul Barrett
1 parent c09ffcc0

Hide search criteria when plugin not enabled

Story ID:2450996. Enable search of document metadata (custom numbering plugin)

Committed by: Paul Barrett
search2/search/fieldRegistry.inc.php
@@ -271,37 +271,36 @@ class ExprFieldRegistry @@ -271,37 +271,36 @@ class ExprFieldRegistry
271 // check the database for any registered plugin specific search criteria 271 // check the database for any registered plugin specific search criteria
272 $pluginSearchCriteria = null; 272 $pluginSearchCriteria = null;
273 273
274 - $result = DBUtil::getOneResult('Select pathname FROM plugin_helper WHERE classtype = "search_criteria"'); 274 + $result = DBUtil::getResultArray('Select h.pathname FROM plugin_helper h INNER JOIN plugins p ON (p.namespace = h.plugin) '
  275 + . 'WHERE p.disabled = 0 AND h.classtype = "search_criteria"');
275 if (PEAR::isError($result)) { 276 if (PEAR::isError($result)) {
276 return; 277 return;
277 } 278 }
278 279
279 - $fieldPath = KT_DIR . DIRECTORY_SEPARATOR . $result['pathname']; 280 + foreach ($result as $pluginSearchResult) {
  281 + $fieldPath = KT_DIR . DIRECTORY_SEPARATOR . $pluginSearchResult['pathname'];
280 282
281 - // loop through those found and include from the plugin path  
282 - $dir = opendir($fieldPath);  
283 - while (($file = readdir($dir)) !== false)  
284 - {  
285 - if (substr($file,-13) == 'Field.inc.php')  
286 - {  
287 - require_once($fieldPath . DIRECTORY_SEPARATOR . $file);  
288 - $class = substr($file, 0, -8);  
289 -  
290 - if (!class_exists($class))  
291 - {  
292 - continue;  
293 - }  
294 -  
295 - $field = new $class;  
296 - if (is_null($field) || !($field instanceof FieldExpr))  
297 - {  
298 - continue;  
299 - }  
300 -  
301 - $this->registerField($field);  
302 - }  
303 - }  
304 - closedir($dir); 283 + // loop through those found and include from the plugin path
  284 + $dir = opendir($fieldPath);
  285 + while (($file = readdir($dir)) !== false) {
  286 + if (substr($file,-13) == 'Field.inc.php') {
  287 + require_once($fieldPath . DIRECTORY_SEPARATOR . $file);
  288 + $class = substr($file, 0, -8);
  289 +
  290 + if (!class_exists($class)) {
  291 + continue;
  292 + }
  293 +
  294 + $field = new $class;
  295 + if (is_null($field) || !($field instanceof FieldExpr)) {
  296 + continue;
  297 + }
  298 +
  299 + $this->registerField($field);
  300 + }
  301 + }
  302 + closedir($dir);
  303 + }
305 } 304 }
306 305
307 /** 306 /**