Beispiel #1
0
/**
 * repairSearchFields
 *
 * This method goes through the list of SearchFields files based and calls TemplateRange::repairCustomSearchFields
 * method on the files in an attempt to ensure the range search attributes are properly set in SearchFields.php.
 *
 * @param $globString String value used for glob search defaults to searching for all SearchFields.php files in modules directory
 * @param $path String value used to point to log file should logging be required.  Defaults to empty.
 *
 */
function repairSearchFields($globString = 'modules/*/metadata/SearchFields.php', $path = '')
{
    if (!empty($path)) {
        logThis('Begin repairSearchFields', $path);
    }
    require_once 'include/dir_inc.php';
    require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
    require 'include/modules.php';
    global $beanList;
    $searchFieldsFiles = glob($globString);
    foreach ($searchFieldsFiles as $file) {
        if (preg_match('/modules\\/(.*?)\\/metadata\\/SearchFields\\.php/', $file, $matches) && isset($beanList[$matches[1]])) {
            $module = $matches[1];
            $beanName = $beanList[$module];
            VardefManager::loadVardef($module, $beanName);
            if (isset($GLOBALS['dictionary'][$beanName]['fields'])) {
                if (!empty($path)) {
                    logThis('Calling TemplateRange::repairCustomSearchFields for module ' . $module, $path);
                }
                TemplateRange::repairCustomSearchFields($GLOBALS['dictionary'][$beanName]['fields'], $module);
            }
        }
    }
    if (!empty($path)) {
        logThis('End repairSearchFields', $path);
    }
}
Beispiel #2
0
 /**
  * testActionAdvancedSearchSaveWithoutAnyRangeSearchFields
  * One last test to check what would happen if we had a module that did not have any range search fields enabled
  */
 public function testActionAdvancedSearchSaveWithoutAnyRangeSearchFields()
 {
     //Load the vardefs for the module to pass to TemplateRange
     VardefManager::loadVardef('Cases', 'aCase', true);
     global $dictionary;
     $vardefs = $dictionary['Case']['fields'];
     foreach ($vardefs as $key => $def) {
         if (!empty($def['enable_range_search'])) {
             unset($vardefs[$key]['enable_range_search']);
         }
     }
     require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
     TemplateRange::repairCustomSearchFields($vardefs, 'Cases');
     //In this case there would be no custom SearchFields.php file created
     $this->assertTrue(!file_exists('custom/modules/Cases/metadata/SearchFields.php'));
     //Yet we have the defaults set still in out of box settings
     require 'modules/Cases/metadata/SearchFields.php';
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']['enable_range_search']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']['enable_range_search']));
 }
Beispiel #3
0
 function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php';
     $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName);
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }
Beispiel #4
0
 public function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     // Bug 56789 - Set the client from the view to ensure the proper viewdef file
     $client = MetaDataFiles::getClientByView($_REQUEST['view']);
     if (isModuleBWC($_REQUEST['view_module'])) {
         $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $client);
     } else {
         $client = empty($client) ? 'base' : $client;
         $parser = new SidecarFilterLayoutMetaDataParser($_REQUEST['view_module'], $packageName, $client);
     }
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }