Ejemplo n.º 1
1
 public function setUp()
 {
     global $beanList, $beanFiles;
     include 'include/modules.php';
     //Reload langauge strings
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Accounts');
     //Create an anonymous user for login purposes/
     $this->_user = new User();
     $this->_user->retrieve('1');
     $GLOBALS['current_user'] = $this->_user;
     self::$helperObject = new APIv3Helper();
     if (file_exists(sugar_cached('modules/unified_search_modules.php'))) {
         $this->unified_search_modules_content = file_get_contents(sugar_cached('modules/unified_search_modules.php'));
         unlink(sugar_cached('modules/unified_search_modules.php'));
     }
     require_once 'modules/Home/UnifiedSearchAdvanced.php';
     $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
     $_REQUEST['enabled_modules'] = 'Accounts,Contacts,Opportunities';
     $unifiedSearchAdvanced->saveGlobalSearchSettings();
     $GLOBALS['db']->query("DELETE FROM accounts WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM opportunities WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM contacts WHERE first_name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM calls WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM tasks WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM meetings WHERE name like 'UNIT TEST%' ");
     //$this->useOutputBuffering = false;
 }
Ejemplo n.º 2
0
 public function testFisrtUnifiedSearchWithoutUserPreferences()
 {
     //Enable the Tasks, Accounts and Contacts modules
     require_once 'modules/Home/UnifiedSearchAdvanced.php';
     $_REQUEST = array();
     $_REQUEST['enabled_modules'] = 'Tasks,Accounts,Contacts';
     $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
     $unifiedSearchAdvanced->saveGlobalSearchSettings();
     $_REQUEST = array();
     $_REQUEST['advanced'] = 'false';
     $unifiedSearchAdvanced->query_stirng = 'blah';
     $unifiedSearchAdvanced->search();
     global $current_user;
     $users_modules = $current_user->getPreference('globalSearch', 'search');
     $this->assertTrue(!empty($users_modules), 'Assert we have set the user preferences properly');
     $this->assertTrue(isset($users_modules['Tasks']), 'Assert that we have added the Tasks module');
     $this->assertEquals(count($users_modules), 3, 'Assert that we have 3 modules in user preferences for global search');
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     //Create an anonymous user for login purposes/
     $this->_user = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['current_user'] = $this->_user;
     self::$helperObject = new APIv3Helper();
     if (file_exists(sugar_cached('modules/unified_search_modules.php'))) {
         $this->unified_search_modules_content = file_get_contents(sugar_cached('modules/unified_search_modules.php'));
         unlink(sugar_cached('modules/unified_search_modules.php'));
     }
     require_once 'modules/Home/UnifiedSearchAdvanced.php';
     $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
     $_REQUEST['enabled_modules'] = 'Accounts,Contacts,Opportunities';
     $unifiedSearchAdvanced->saveGlobalSearchSettings();
     $GLOBALS['db']->query("DELETE FROM accounts WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM opportunities WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM contacts WHERE first_name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM calls WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM tasks WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->query("DELETE FROM meetings WHERE name like 'UNIT TEST%' ");
     $GLOBALS['db']->commit();
     //$this->useOutputBuffering = false;
 }
Ejemplo n.º 4
0
 public function test_create_unified_search_modules_display()
 {
     if (file_exists('custom/modules/unified_search_modules_display.php')) {
         unlink('custom/modules/unified_search_modules_display.php');
     }
     require_once 'modules/UpgradeWizard/uw_utils.php';
     $usa = new UnifiedSearchAdvanced();
     $_REQUEST['enabled_modules'] = 'Accounts,Bug36845Test';
     $usa->saveGlobalSearchSettings();
     $this->assertTrue(file_exists('custom/modules/unified_search_modules_display.php'), 'Assert that unified_search_modules_display.php file was created');
 }
 public function testUserPreferencesSearch()
 {
     global $mod_strings, $modListHeader, $app_strings, $beanList, $beanFiles, $current_user;
     require 'config.php';
     require 'include/modules.php';
     $usa = new UnifiedSearchAdvanced();
     $_REQUEST['enabled_modules'] = 'Accounts,Contacts';
     $usa->saveGlobalSearchSettings();
     $current_user->setPreference('globalSearch', array('Accounts', 'Contacts'), 0, 'search');
     $current_user->savePreferencesToDB();
     $_REQUEST = array();
     $_REQUEST['query_string'] = $this->_contact->first_name . ' ' . $this->_contact->last_name;
     $_REQUEST['module'] = 'Home';
     $usa->search();
     $modules = $current_user->getPreference('globalSearch', 'search');
     $this->assertEquals(count($modules), 2, 'Assert that there are two modules in the user preferences as defined from the global search');
     $this->assertEquals('Accounts', $modules[0], 'Assert that the Accounts module has been added');
     $this->assertEquals('Contacts', $modules[1], 'Assert that the Contacts module has been added');
 }
Ejemplo n.º 6
0
 /**
  * action_saveglobalsearchsettings
  *
  * This method handles saving the selected modules to display in the Global Search Settings.
  * It instantiates an instance of UnifiedSearchAdvanced and then calls the saveGlobalSearchSettings
  * method.
  *
  */
 public function action_saveglobalsearchsettings()
 {
     global $current_user, $app_strings;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     try {
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
         $unifiedSearchAdvanced->saveGlobalSearchSettings();
         //Save FTS Settings
         $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : '';
         $host = !empty($_REQUEST['host']) ? $_REQUEST['host'] : '';
         $port = !empty($_REQUEST['port']) ? $_REQUEST['port'] : '';
         $ftsConfig = $this->mergeFtsConfig($type, array('port' => $port, 'host' => $host));
         $this->cfg = new Configurator();
         $this->cfg->config['full_text_engine'] = '';
         $this->cfg->saveConfig();
         $ftsConnectionValid = TRUE;
         if (!empty($type)) {
             //Check if the connection is valid on save:
             require_once 'include/SugarSearchEngine/SugarSearchEngineFactory.php';
             $searchEngine = SugarSearchEngineFactory::getInstance($type, $ftsConfig);
             $result = $searchEngine->getServerStatus();
             if (!$result['valid']) {
                 $ftsConnectionValid = FALSE;
             }
             // bug 54274 -- only bother with an override if we have data to place there, empty string breaks Sugar On-Demand!
             $ftsConfig['valid'] = $ftsConnectionValid;
             $this->cfg->config['full_text_engine'] = array($type => $ftsConfig);
             $this->cfg->handleOverride();
         }
         // Refresh the server info & module list sections of the metadata
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_SERVERINFO, MetaDataManager::MM_MODULES));
         if (!$ftsConnectionValid) {
             echo $GLOBALS['mod_strings']['LBL_FTS_CONNECTION_INVALID'];
         } else {
             echo "true";
         }
     } catch (Exception $ex) {
         echo "false";
     }
 }
Ejemplo n.º 7
0
 /**
  * action_saveglobalsearchsettings
  *
  * This method handles saving the selected modules to display in the Global Search Settings.
  * It instantiates an instance of UnifiedSearchAdvanced and then calls the saveGlobalSearchSettings
  * method.
  *
  */
 public function action_saveglobalsearchsettings()
 {
     global $current_user, $app_strings;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     try {
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
         $unifiedSearchAdvanced->saveGlobalSearchSettings();
         $return = 'true';
         echo $return;
     } catch (Exception $ex) {
         echo "false";
     }
 }