public function run() { if (!$this->toFlavor('pro')) { return; } if (!version_compare($this->from_version, '7.0', "<")) { return; } require_once 'modules/Forecasts/ForecastsDefaults.php'; ForecastsDefaults::setupForecastSettings(true, $this->from_version, $this->to_version); ForecastsDefaults::upgradeColumns(); }
/** * @param array $config The Current Forecast Config */ protected function handle6to7($config) { $columns = array_unique(array_merge(ForecastsDefaults::getWorksheetColumns($this->from_flavor), array('likely_case', 'best_case', 'worst_case'))); $map = array('likely_case' => 'show_worksheet_likely', 'best_case' => 'show_worksheet_best', 'worst_case' => 'show_worksheet_worst'); $final = array(); foreach ($columns as $val) { if (!isset($map[$val]) || $config[$map[$val]] == 1) { $final[] = $val; } } // save the columns to the worksheet list viewdefs $this->client->setWorksheetColumns($this->api, $final, $config['forecast_by']); unset($this->api, $this->client); }
/** * Return the bean for what we are forecasting by * * @return RevenueLineItem|Opportunity|SugarBean */ protected function getForecastByBean() { if (!static::$forecastByBean instanceof SugarBean) { /* @var $admin Administration */ $admin = BeanFactory::getBean('Administration'); $settings = $admin->getConfigForModule('Forecasts'); // if we don't have the forecast_by from the db, grab the defaults that we use on set. if (empty($settings['forecast_by'])) { require_once 'modules/Forecasts/ForecastsDefaults.php'; $settings = ForecastsDefaults::getDefaults(); } $bean = $settings['forecast_by']; static::$forecastByBean = BeanFactory::getBean($bean); } return static::$forecastByBean; }
logThis('End upgrade_connectors', $path); //Unlink files that have been removed if (function_exists('unlinkUpgradeFiles')) { unlinkUpgradeFiles($sugar_version, $path); } if (function_exists('rebuildSprites') && function_exists('imagecreatetruecolor')) { rebuildSprites(true); } //Patch for bug57431 : Module name isn't updated in portal layout editor updateRenamedModulesLabels(); //setup forecast defualt settings if (version_compare($sugar_version, '6.7.0', '<')) { require_once clean_path($unzip_dir . '/scripts/upgrade_utils.php'); require_once $unzip_dir . '/' . $zip_from_dir . '/modules/Forecasts/ForecastsDefaults.php'; ForecastsDefaults::setupForecastSettings(true, $sugar_version, getUpgradeVersion()); ForecastsDefaults::upgradeColumns(); // do the config update to add the 'support' platform to any config with the category of 'portal' updatePortalConfigToContainPlatform(); } // Bug 57216 - Upgrade wizard dying on metadata upgrader because needed files were // already called but news needed to replace them. This moves the metadata upgrader // later in the process - rgonzalez logThis('Checking for mobile/portal metadata upgrade...'); // 6.6 metadata enhancements for portal and wireless, should only be // handled for upgrades FROM pre-6.6 to a version POST 6.6 and MUST be // handled AFTER inclusion of the upgrade package files if (!didThisStepRunBefore('commit', 'upgradePortalMobileMetadata')) { if (version_compare($sugar_version, '6.6.0', '<')) { if (file_exists('modules/UpgradeWizard/SidecarUpdate/SidecarMetaDataUpgrader.php')) { set_upgrade_progress('commit', 'in_progress', 'upgradePortalMobileMetadata', 'in_progress'); logThis('Sidecar Upgrade: Preparing to upgrade metadata to 6.6.0 compatibility through the silent upgrader ...');
echo "<b>{$mod_strings['LBL_PERFORM_CREATE_DEFAULT']}</b><br>"; echo "<br>"; installLog("Begin creating Defaults"); installerHook('pre_createDefaultSettings'); if ($new_config) { installLog("insert defaults into config table"); insert_default_settings(); } installerHook('post_createDefaultSettings'); echo $line_entry_format . $mod_strings['LBL_PERFORM_LICENSE_SETTINGS'] . $line_exit_format; installLog($mod_strings['LBL_PERFORM_LICENSE_SETTINGS']); update_license_settings($_SESSION['setup_license_key_users'], $_SESSION['setup_license_key_expire_date'], $_SESSION['setup_license_key'], $_SESSION['setup_num_lic_oc']); echo $mod_strings['LBL_PERFORM_DONE']; //Install forecasts configuration require_once 'modules/Forecasts/ForecastsDefaults.php'; $forecast_config = ForecastsDefaults::setupForecastSettings(); //Install Opportunities configuration require_once 'modules/Opportunities/OpportunitiesDefaults.php'; $opps_config = OpportunitiesDefaults::setupOpportunitiesSettings(); unset($opps_config); installerHook('pre_createUsers'); if ($new_tables) { echo $line_entry_format . $mod_strings['LBL_PERFORM_DEFAULT_USERS'] . $line_exit_format; installLog($mod_strings['LBL_PERFORM_DEFAULT_USERS']); create_default_users(); echo $mod_strings['LBL_PERFORM_DONE']; } else { echo $line_entry_format . $mod_strings['LBL_PERFORM_ADMIN_PASSWORD'] . $line_exit_format; installLog($mod_strings['LBL_PERFORM_ADMIN_PASSWORD']); $db->setUserName($setup_db_sugarsales_user); $db->setUserPassword($setup_db_sugarsales_password);
/** * Handle setting the default worksheet_columns back into the db. * * @param String $forecast_by The Module that we are currently forecasting by */ public function setDefaultWorksheetColumns($forecast_by) { SugarAutoLoader::load('modules/Forecasts/ForecastsDefaults.php'); $edition = $forecast_by === 'RevenueLineItems' ? 'ent' : 'pro'; $columns = ForecastsDefaults::getWorksheetColumns($edition); // we need to check the setting for best and worst $settings = Forecast::getSettings(true); if ($settings['show_worksheet_best'] != 1) { // remove best since it's include by default foreach ($columns as $i => $column) { if ($column === 'best_case') { unset($columns[$i]); break; } } } if ($settings['show_worksheet_worst'] == 1) { // add worse_Case since it's not include by default $columns[] = 'worst_case'; } /* @var $admin Administration */ $admin = BeanFactory::getBean('Administration'); $admin->saveSetting('Forecasts', 'worksheet_columns', json_encode($columns), 'base'); // update the metadata $this->updateConfigWorksheetColumnsMetadata($forecast_by); // now write out the correct list view $this->setWorksheetColumns('base', $columns, $forecast_by); }
/** * @param Administration $admin * @param array $forecastsSettings * @param RestService $api * @throws SugarApiExceptionInvalidHash */ protected function compareSettingsToDefaults(Administration $admin, $forecastsSettings, $api) { $defaultConfig = ForecastsDefaults::getDefaults(); $missing_config = array_diff(array_keys($defaultConfig), array_keys($forecastsSettings)); if (!empty($missing_config)) { foreach ($missing_config as $config) { $val = $defaultConfig[$config]; if (is_array($val)) { $val = json_encode($val); } $admin->saveSetting('Forecasts', $config, $val, $api->platform); } MetaDataManager::refreshModulesCache(array("Forecasts")); MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CONFIG)); throw new SugarApiExceptionInvalidHash(); } }