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;
 }
 public function setUp()
 {
     $beanList = array();
     $beanFiles = array();
     require 'include/modules.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     //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 = SugarTestUserUtilities::createAnonymousUser();
     $this->_admin_user = SugarTestUserUtilities::createAnonymousUser();
     $this->_admin_user->status = 'Active';
     $this->_admin_user->is_admin = 1;
     $this->_admin_user->save();
     $GLOBALS['db']->commit();
     // Making sure we commit any changes before continuing
     $GLOBALS['current_user'] = $this->_user;
     self::$helperObject = new APIv3Helper();
     //Disable access to the website field.
     $this->aclRole = new ACLRole();
     $this->aclRole->name = "Unit Test";
     $this->aclRole->save();
     $GLOBALS['db']->commit();
     // Making sure we commit any changes before continuing
     $this->aclRole->set_relationship('acl_roles_users', array('role_id' => $this->aclRole->id, 'user_id' => $this->_user->id), false);
     $GLOBALS['db']->commit();
     // Making sure we commit any changes before continuing
 }
 public static function setUpBeforeClass()
 {
     global $mod_strings, $app_strings, $theme;
     $theme = SugarTestThemeUtilities::createAnonymousTheme();
     $mod_strings = return_module_language($GLOBALS['current_language'], 'Connectors');
     $app_strings = return_application_language($GLOBALS['current_language']);
 }
Example #4
0
 public function setUp()
 {
     $this->markTestIncomplete("Disabling after discussing with Eddy.  Eddy will take a look at why this is breaking Stack 66 build");
     //create user
     $this->user = SugarTestUserUtilities::createAnonymousUser();
     $this->user->default_team_name = 'global';
     $this->user->is_admin = 1;
     $this->user->save();
     $this->user->retrieve($this->user->id);
     $GLOBALS['current_user'] = $this->user;
     //set some global values that will help with the view
     $_REQUEST['action'] = $GLOBALS['action'] = 'DetailView';
     $_REQUEST['module'] = $GLOBALS['module'] = 'Opportunities';
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], "Opportunities");
     //create opportunity
     $name = 'Test_51980_' . time();
     $this->opp = new Opportunity();
     $this->opp->name = $name;
     $this->opp->amount = '1000000';
     $this->opp->account_id = '1';
     $this->opp->team_id = '1';
     $this->opp->currency_id = -99;
     $this->opp->save();
 }
Example #5
0
 public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $acc = new Account();
     $this->form = new SearchFormMock($acc, "Accounts");
 }
 /**
  * This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob
  *
  * @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run
  * @return bool true on success, false on error
  */
 public function run($data)
 {
     global $app_strings, $language;
     $app_strings = return_application_language($language);
     $admin = BeanFactory::getBean('Administration');
     $config = $admin->getConfigForModule('Forecasts', 'base');
     $timeperiodInterval = $config['timeperiod_interval'];
     $timeperiodLeafInterval = $config['timeperiod_leaf_interval'];
     $parentTimePeriod = TimePeriod::getLatest($timeperiodInterval);
     $latestTimePeriod = TimePeriod::getLatest($timeperiodLeafInterval);
     $currentTimePeriod = TimePeriod::getCurrentTimePeriod($timeperiodLeafInterval);
     if (empty($latestTimePeriod)) {
         $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . '[latest]');
         return false;
     } else {
         if (empty($currentTimePeriod)) {
             $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [current]');
             return false;
         } else {
             if (empty($parentTimePeriod)) {
                 $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [parent]');
                 return false;
             }
         }
     }
     $timedate = TimeDate::getInstance();
     //We run the rebuild command if the latest TimePeriod is less than the specified configuration interval
     //from the current TimePeriod
     $correctStartDate = $timedate->fromDbDate($currentTimePeriod->start_date);
     $latestStartDate = $timedate->fromDbDate($latestTimePeriod->start_date);
     $shownForward = $config['timeperiod_shown_forward'];
     //Move the current start date forward by the leaf period amounts
     for ($x = 0; $x < $shownForward; $x++) {
         $correctStartDate->modify($parentTimePeriod->next_date_modifier);
     }
     $leafCycle = $latestTimePeriod->leaf_cycle;
     //If the current start data that was modified according to the shown forward period is past the latest
     //leaf period we need to build more timeperiods
     while ($correctStartDate > $latestStartDate) {
         //We need to keep creating leaf periods until we are in sync.
         //If the leaf period we need to create is the start of the leaf cycle
         //then we should also create the parent TimePeriod record.
         $startDate = $latestStartDate->modify($latestTimePeriod->next_date_modifier);
         $leafCycle = $leafCycle == $parentTimePeriod->leaf_periods ? 1 : $leafCycle + 1;
         if ($leafCycle == 1) {
             $parentTimePeriod = TimePeriod::getByType($timeperiodInterval);
             $parentTimePeriod->setStartDate($startDate->asDbDate());
             $parentTimePeriod->name = $parentTimePeriod->getTimePeriodName($leafCycle);
             $parentTimePeriod->save();
         }
         $leafTimePeriod = TimePeriod::getByType($timeperiodLeafInterval);
         $leafTimePeriod->setStartDate($startDate->asDbDate());
         $leafTimePeriod->name = $leafTimePeriod->getTimePeriodName($leafCycle, $parentTimePeriod);
         $leafTimePeriod->leaf_cycle = $leafCycle;
         $leafTimePeriod->parent_id = $parentTimePeriod->id;
         $leafTimePeriod->save();
     }
     $this->job->succeedJob();
     return true;
 }
    function createAppStringsCache($lang = 'en_us')
    {
        global $sugar_config;
        $lst_mod = array('Accounts', 'Contacts', 'Opportunities', 'Leads', 'Calls', 'Meetings', 'Cases', 'Project', 'ProjectTask', 'Tasks', 'Notes');
        $required_list = $this->getListOfLists($lst_mod);
        // List of application list strings used in the application (enums)
        $app_strings = return_application_language($lang);
        $all_app_list_strings = return_app_list_strings_language($lang);
        $app_list_strings = array();
        foreach ($lst_mod as $key => $lst) {
            $app_list_strings["moduleList"][$lst] = $all_app_list_strings["moduleList"][$lst];
            $app_list_strings["moduleListSingular"][$lst] = isset($all_app_list_strings["moduleListSingular"][$lst]) ? $all_app_list_strings["moduleListSingular"][$lst] : $all_app_list_strings["moduleList"][$lst];
        }
        $app_list_strings["parent_type_display"] = $all_app_list_strings["parent_type_display"];
        $app_list_strings["duration_intervals"] = $all_app_list_strings["duration_intervals"];
        $app_list_strings["duration_dom"] = $all_app_list_strings["duration_dom"];
        $app_list_strings["moduleList"]["SavedSearches"] = $all_app_list_strings["moduleList"]["SavedSearch"];
        // date_range_search_dom in not defined until 6.2
        $app_list_strings["date_search"] = isset($all_app_list_strings["date_range_search_dom"]) ? $all_app_list_strings["date_range_search_dom"] : $all_app_list_strings["kbdocument_date_filter_options"];
        $app_list_strings["date_search"]['today'] = $app_strings['LBL_TODAY'];
        if (isset($all_app_list_strings["numeric_range_search_dom"])) {
            $app_list_strings["num_search"] = $all_app_list_strings["numeric_range_search_dom"];
        }
        foreach ($required_list as $lst) {
            $app_list_strings[$lst] = $all_app_list_strings[$lst];
        }
        $json = getJSONobj();
        $app_list_strings_encoded = str_replace('\\\\', "\\/", preg_replace("/'/", "&#039;", $json->encode($app_list_strings)));
        $SS_mod_strings = return_module_language($lang, "SavedSearch");
        $ADM_mod_strings = return_module_language($lang, "Administration");
        $str = <<<EOQ
var RES_CREATE='{$app_strings['LBL_CREATE_BUTTON_LABEL']}',RES_LIST='{$app_strings['LBL_LIST']}',RES_ADD_TO_HOME='{$app_strings['LBL_MARK_AS_FAVORITES']}',RES_REM_FROM_HOME='{$app_strings['LBL_REMOVE_FROM_FAVORITES']}',RES_RECORD_ERROR='{$app_strings['ERROR_NO_RECORD']}',RES_LAST_VIEWED='{$app_strings['LBL_LAST_VIEWED']}', RES_DELETE_CONFIRMATION='{$app_strings['NTC_DELETE_CONFIRMATION']}', RES_DEL_LABEL='{$app_strings['LBL_DELETE_BUTTON_LABEL']}', RES_NEXT_LABEL='{$app_strings['LNK_LIST_NEXT']}', RES_PREVIOUS_LABEL='{$app_strings['LNK_LIST_PREVIOUS']}',
 RES_ASC='{$SS_mod_strings["LBL_ASCENDING"]}',RES_DESC='{$SS_mod_strings["LBL_DESCENDING"]}',RES_HOME_LABEL='{$all_app_list_strings["moduleList"]["Home"]}',RES_SYNC='{$all_app_list_strings["moduleList"]["Sync"]}',RES_SAVEDSEARCH='{$all_app_list_strings["moduleList"]["SavedSearch"]}',RES_SAVESEARCH='{$SS_mod_strings["LBL_SAVE_SEARCH_AS"]}',RES_DISABLED='{$ADM_mod_strings["LBL_DISABLED"]}',
 sugar_app_list_strings = {$app_list_strings_encoded};
EOQ;
        $SS_mod_strings = null;
        $ADM_mod_strings = null;
        $all_app_list_strings = null;
        $app_array = array('LBL_CREATE_BUTTON_LABEL', 'LBL_EDIT_BUTTON', 'LBL_LIST', 'LBL_SEARCH_BUTTON_LABEL', 'LBL_CURRENT_USER_FILTER', 'LBL_BACK', 'LBL_SAVE_BUTTON_LABEL', 'LBL_CANCEL_BUTTON_LABEL', 'LBL_MARK_AS_FAVORITES', 'LBL_REMOVE_FROM_FAVORITES', 'NTC_DELETE_CONFIRMATION', 'LBL_DELETE_BUTTON_LABEL', 'ERROR_NO_RECORD', 'LBL_LAST_VIEWED', 'LNK_LIST_NEXT', 'LNK_LIST_PREVIOUS', 'LBL_LINK_SELECT', 'LBL_LIST_USER_NAME', 'NTC_LOGIN_MESSAGE', 'ERR_INVALID_EMAIL_ADDRESS', 'LBL_ASSIGNED_TO', 'LBL_CLEAR_BUTTON_LABEL', 'LBL_DURATION_DAYS', 'LBL_CLOSE_AND_CREATE_BUTTON_TITLE', 'LBL_CLOSE_AND_CREATE_BUTTON_LABEL', 'LBL_CLOSE_BUTTON_TITLE', 'LBL_CLOSE_BUTTON_LABEL', 'LBL_LISTVIEW_ALL', 'LBL_LISTVIEW_NONE', 'LBL_SAVED', 'LBL_PRIMARY_ADDRESS', 'LBL_BILLING_ADDRESS', 'LBL_ALT_ADDRESS', 'LBL_SHIPPING_ADDRESS', 'LBL_DUPLICATE_BUTTON', 'MSG_SHOW_DUPLICATES', 'LBL_EMAIL_OPT_OUT', 'MSG_LIST_VIEW_NO_RESULTS_BASIC', 'LBL_CITY');
        $str_app_array = array();
        foreach ($app_array as $key) {
            $str_app_array[$key] = str_replace('"', '\\"', isset($app_strings[$key]) ? $app_strings[$key] : $key);
        }
        $app_strings_encoded = $json->encode($str_app_array);
        $str .= "var sugar_app_strings = {$app_strings_encoded};";
        require_once 'modules/Administration/Administration.php';
        $administration = new Administration();
        $administration->saveSetting('QuickCRM', $lang, base64_encode($str));
        $in_file = strlen($str) > 49000 ? '1' : '0';
        $administration->saveSetting('QuickCRM', $lang . 'f', $in_file);
        //		if ($sugar_config['sugar_version']<'6.3'){
        $saveDir = realpath(dirname(__FILE__) . '/../../../mobile/fielddefs/');
        if ($fh = @fopen($saveDir . '/' . $lang . '.js', "w")) {
            fputs($fh, $str);
            fclose($fh);
        } else {
            // die();
        }
        //		}
    }
Example #8
0
 static function initAppGlobals()
 {
     global $current_language, $app_strings, $app_list_strings, $app_currency_strings;
     $app_currency_strings = return_app_currency_strings_language($current_language);
     $app_strings = return_application_language($current_language);
     $app_list_strings = return_app_list_strings_language($current_language);
 }
Example #9
0
 /**
  * Create test user
  *
  */
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v3/soap.php';
     parent::setUp();
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     self::$helperObject = new APIv3Helper();
 }
Example #10
0
 public static function setUpBeforeClass()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['current_user']->is_admin = "1";
     $GLOBALS['current_language'] = "en_us";
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Administration');
     mkdir_recursive("cache/ExtTest");
 }
Example #11
0
 /**
  * Initialize globals
  */
 protected function initGlobals()
 {
     global $current_language, $app_list_strings, $app_strings, $sugar_config;
     if (empty($current_language)) {
         $current_language = $sugar_config['default_language'];
     }
     $app_list_strings = return_app_list_strings_language($current_language);
     $app_strings = return_application_language($current_language);
 }
Example #12
0
 public function setUp()
 {
     global $current_user;
     $this->beans = array();
     $this->old_user = $current_user;
     $current_user = $this->_user = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
 }
 public function setUp()
 {
     require 'include/modules.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     //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');
 }
Example #14
0
 public function setUp()
 {
     $this->current_user = new User();
     $this->focus = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_list_strings'] = return_application_language($GLOBALS['current_language']);
     global $sugar_config;
     $sugar_config['default_user_name'] = $this->focus->user_name;
     global $app_list_strings;
     $app_list_strings = return_app_list_strings_language($GLOBALS['current_language']);
 }
Example #15
0
 public function setUp()
 {
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->contact = SugarTestContactUtilities::createContact();
     $this->task = SugarTestTaskUtilities::createTask();
     $this->task->contact_id = $this->contact->id;
     $this->task->save();
 }
 public function setUp()
 {
     $this->_lvd = new ListViewDisplayMock();
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     global $sugar_config;
     if (isset($sugar_config['save_query'])) {
         $this->save_query = $sugar_config['save_query'];
     }
 }
Example #17
0
 public function setUp()
 {
     global $moduleList, $beanList, $beanFiles;
     require 'include/modules.php';
     $this->_view = new SugarViewTestMock();
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Users');
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->_backup['currentTheme'] = SugarThemeRegistry::current();
 }
Example #18
0
 public function setUp()
 {
     global $current_user, $mod_strings, $app_strings, $app_list_strings, $sugar_config, $locale;
     $mod_strings = return_module_language($GLOBALS['current_language'], "Configurator");
     $current_user = SugarTestUserUtilities::createAnonymousUser();
     $app_strings = return_application_language($GLOBALS['current_language']);
     $app_list_strings = return_app_list_strings_language($GLOBALS['current_language']);
     $sugar_config = $GLOBALS['sugar_config'];
     $locale = new Localization();
 }
Example #19
0
 public function setAppLanguage()
 {
     if (R_DEBUG) {
         $this->sshow("START RT");
         $this->getR4UDifTime(0);
     }
     $this->current_language = isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != "" ? $_SESSION['authenticated_user_language'] : "en_us";
     if (isset($this->current_language) && $this->current_language != "") {
         $this->app_strings = return_application_language($this->current_language);
     }
 }
Example #20
0
 public function setUp()
 {
     global $mod_strings, $app_strings;
     $mod_strings = return_module_language($GLOBALS['current_language'], 'Accounts');
     $app_strings = return_application_language($GLOBALS['current_language']);
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     // create a dummy module directory
     $this->_moduleName = 'TestModule' . mt_rand();
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     sugar_mkdir("modules/{$this->_moduleName}", null, true);
 }
Example #21
0
 public function setUp()
 {
     global $app_strings, $app_list_strings;
     $app_strings = return_application_language($GLOBALS['current_language']);
     $app_list_strings = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->contact = SugarTestContactUtilities::createContact();
     $this->account = SugarTestAccountUtilities::createAccount();
     $override_data = array('parent_type' => 'Accounts', 'parent_id' => $this->account->id);
     $this->email = SugarTestEmailUtilities::createEmail('', $override_data);
 }
Example #22
0
 public function setUp()
 {
     $this->markTestIncomplete('This test will fail when the entire suite is run.  Probably needs mock objects for the list view objects');
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Users');
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['action'] = 'index';
     $GLOBALS['module'] = 'Users';
     $_REQUEST['module'] = 'Users';
 }
Example #23
0
 function setUp()
 {
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     global $sugar_config;
     $this->sugar_config = $sugar_config;
     $this->sugarView = new Bug45181TestSugarViewMock();
     $this->sugarView->module = 'Contacts';
     $this->sugarView->action = 'EditView';
     if (is_file('memory_usage.log')) {
         unlink('memory_usage.log');
     }
 }
Example #24
0
 public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['module'] = 'Imports';
     $_REQUEST['module'] = 'Imports';
     $_REQUEST['import_module'] = 'Accounts';
     $_REQUEST['action'] = 'last';
     $_REQUEST['type'] = '';
     $_REQUEST['has_header'] = 'off';
     sugar_touch('upload/import/status_' . $GLOBALS['current_user']->id . '.csv');
 }
Example #25
0
 public function setUp()
 {
     require 'include/modules.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     global $current_user;
     $this->beans = array();
     $this->old_user = $current_user;
     $current_user = $this->_user = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
 }
Example #26
0
 function isInMultiselectbox($value, $search)
 {
     global $language;
     $app_strings = return_application_language($language);
     $Values = explode(" |##| ", $value);
     if (in_array($search, $Values)) {
         $s = $app_strings["LBL_YES"];
     } else {
         $s = $app_strings["LBL_NO"];
     }
     return $s;
 }
Example #27
0
 public function setUp()
 {
     parent::setUp();
     $GLOBALS['action'] = 'async';
     $GLOBALS['module'] = 'Administration';
     $GLOBALS['app_strings'] = return_application_language('en_us');
     $GLOBALS['app_list_strings'] = return_app_list_strings_language('en_us');
     $GLOBALS['mod_strings'] = return_module_language('en_us', 'Administration');
     $GLOBALS['db'] = DBManagerFactory::getInstance();
     $GLOBALS['current_user'] = new User();
     $GLOBALS['current_user']->retrieve('1');
 }
Example #28
0
 public function setUp()
 {
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->contact = SugarTestContactUtilities::createContact();
     $this->contact->salutation = 'Ms.';
     $this->contact->first_name = 'Lady';
     $this->contact->last_name = 'Gaga';
     //Save contact with salutation
     $this->contact->save();
 }
Example #29
0
 /**
  * This function loads various items when the user is not logged in
  */
 protected function loadGuestEnvironment()
 {
     global $current_language;
     $current_language = $GLOBALS['sugar_config']['default_language'];
     if (!empty($GLOBALS['HTTP_RAW_POST_DATA'])) {
         $postContents = json_decode($GLOBALS['HTTP_RAW_POST_DATA'], true);
         if (!empty($postContents['current_language'])) {
             $current_language = $postContents['current_language'];
         }
     }
     $GLOBALS['app_strings'] = return_application_language($current_language);
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($current_language);
 }
Example #30
0
 /**
  * Constructs the code and message of this Exception based on a set of rules
  * explained on the description of the class.
  *
  * @param array|null $args
  *   (optional) An array of arguments to be printed on the <EXCEPTION_NAME>
  *   string.
  * @param Exception $previous
  *   (optional) The previous exception used for the exception chaining.
  */
 public function __construct(array $args = null, Exception $previous = null)
 {
     global $sugar_config;
     global $app_strings;
     global $mod_strings;
     global $current_language;
     if (is_null($current_language)) {
         $current_language = $sugar_config['default_language'];
     }
     if (is_null($app_strings)) {
         $app_strings = return_application_language($current_language);
     }
     $messageLbl = get_class($this);
     $messageLbl = strtoupper(preg_replace('/(?<=[a-z0-9])([A-Z])/', '_$1', $messageLbl));
     if (!empty($messageLbl) && isset($mod_strings) && isset($mod_strings[$messageLbl])) {
         $messageText = $mod_strings[$messageLbl];
     } else {
         if (!empty($messageLbl) && isset($app_strings[$messageLbl])) {
             $messageText = $app_strings[$messageLbl];
         } else {
             $messageText = '';
         }
     }
     $numArgs = count($args);
     if ($numArgs > 0) {
         foreach ($args as $key => $arg) {
             if (is_array($arg)) {
                 $args[$key] = var_export($arg, true);
             }
         }
         if ($messageLbl == 'INSULIN_EXCEPTION' && !empty($args[0]) || empty($messageText)) {
             if ($numArgs > 1) {
                 $messageText = var_export($args, true);
             } else {
                 $messageText = $args[0];
             }
         } else {
             $messageText = vsprintf($messageText, $args);
         }
     }
     if (version_compare(PHP_VERSION, '5.3') >= 0) {
         parent::__construct($messageText, 0, $previous);
     } else {
         parent::__construct($messageText, 0);
     }
     /**
      * @see https://bugs.php.net/bug.php?id=39615
      *   Allowing a non-numeric $code in the Exception constructor seems like the right solution.
      */
     $this->code = $messageLbl;
 }