2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
42 * Reserved. Contributor(s): ______________________________________..
43 * *******************************************************************************/
44 logThis('[At end.php]');
49 if($unzip_dir == null ) {
50 $unzip_dir = $_SESSION['unzip_dir'];
53 //First repair the databse to ensure it is up to date with the new vardefs/tabledefs
54 logThis('About to repair the database.', $path);
55 //Use Repair and rebuild to update the database.
56 global $dictionary, $beanFiles;
58 require_once('modules/Trackers/TrackerManager.php');
59 $trackerManager = TrackerManager::getInstance();
60 $trackerManager->pause();
61 $trackerManager->unsetMonitors();
63 require_once("modules/Administration/QuickRepairAndRebuild.php");
64 $rac = new RepairAndClear();
66 $rac->rebuildExtensions();
67 //bug: 44431 - defensive check to ensure the method exists since upgrades to 6.2.0 may not have this method define yet.
68 if(method_exists($rac, 'clearExternalAPICache'))
70 $rac->clearExternalAPICache();
73 $repairedTables = array();
75 foreach ($beanFiles as $bean => $file) {
76 if(file_exists($file)){
78 unset($GLOBALS['dictionary'][$bean]);
79 $focus = new $bean ();
80 if (($focus instanceOf SugarBean))
82 if(!isset($repairedTables[$focus->table_name]))
84 $sql = $GLOBALS['db']->repairTable($focus, true);
87 logThis('Running sql:' . $sql, $path);
89 $repairedTables[$focus->table_name] = true;
92 //Check to see if we need to create the audit table
93 if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){
94 logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
95 $focus->create_audit_table();
101 $olddictionary = $dictionary;
104 include ('modules/TableDictionary.php');
105 foreach ($dictionary as $meta) {
106 $tablename = $meta['table'];
107 if (isset($repairedTables[$tablename])) continue;
108 $fielddefs = $meta['fields'];
109 $indices = $meta['indices'];
110 $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
113 logThis('Running sql:' . $sql, $path);
115 $repairedTables[$tablename] = true;
118 $dictionary = $olddictionary;
120 logThis('database repaired', $path);
122 $ce_to_pro_ent = isset($_SESSION['upgrade_from_flavor']) && ($_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarPro' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarEnt' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarCorp' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarUlt');
125 logThis(" Start Rebuilding the config file again", $path);
127 //check and set the logger before rebuilding config
128 if(!isset($sugar_config['logger'])){
129 $sugar_config['logger'] =array (
134 'name' => 'sugarcrm',
135 'dateFormat' => '%c',
138 'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
142 //for upgraded version, set default lead conversion activity option to 'copy'
143 if(!isset($sugar_config['lead_conv_activity_opt'])) {
144 $sugar_config['lead_conv_activity_opt'] = 'copy';
147 if(!rebuildConfigFile($sugar_config, $sugar_version)) {
148 logThis('*** WARNING: could not write config.php!', $path);
150 logThis(" Finish Rebuilding the config file again", $path);
152 set_upgrade_progress('end','in_progress');
155 if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
156 if($_SESSION['current_db_version'] != $_SESSION['target_db_version']){
157 logThis("Upgrading multienum data", $path);
158 if(file_exists("$unzip_dir/scripts/upgrade_multienum_data.php")) {
159 require_once("$unzip_dir/scripts/upgrade_multienum_data.php");
160 upgrade_multienum_data();
165 //keeping separate. making easily visible and readable
166 if($_SESSION['current_db_version'] == $_SESSION['target_db_version']){
167 $_REQUEST['upgradeWizard'] = true;
169 include('modules/ACL/install_actions.php');
170 include_once('include/Smarty/internals/core.write_file.php');
172 $db =& DBManagerFactory::getInstance();
174 //Also set license information
175 $admin = new Administration();
176 $category = 'license';
178 $admin->saveSetting($category, 'users', $value);
179 $key = array('num_lic_oc','key','expire_date');
182 $admin->saveSetting($category, $k, $value);
188 // Mark the instance as having gone thru the admin wizard
189 $admin = new Administration();
190 $admin->saveSetting('system','adminwizard',1);
192 /////////////////////////Old Logger settings///////////////////////////////////////
193 ///////////////////////////////////////////////////////////////////////////////
194 if(file_exists('modules/Configurator/Configurator.php')){
195 require_once('include/utils/array_utils.php');
196 require_once('modules/Configurator/Configurator.php');
197 $Configurator = new Configurator();
198 $Configurator->parseLoggerSettings();
200 //unset the logger previously instantiated
201 if(file_exists('include/SugarLogger/LoggerManager.php')){
203 unset($GLOBALS['log']);
204 $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
209 logThis('Begin upgrade_connectors', $path);
210 upgrade_connectors();
211 logThis('End upgrade_connectors', $path);
214 // Enable the InsideView connector by default
215 if($_SESSION['current_db_version'] < '621' && function_exists('upgradeEnableInsideViewConnector')) {
216 upgradeEnableInsideViewConnector();
220 if ($_SESSION['current_db_version'] < '620' && ($sugar_config['dbconfig']['db_type'] == 'mssql' || $sugar_config['dbconfig']['db_type'] == 'oci8'))
222 repair_long_relationship_names($path);
226 //Global search support
228 if($_SESSION['current_db_version'] < '620' && function_exists('add_unified_search_to_custom_modules_vardefs'))
230 logThis('Add global search for custom modules start .', $path);
231 add_unified_search_to_custom_modules_vardefs();
232 logThis('Add global search for custom modules finished .', $path);
236 //Upgrade system displayed tabs and subpanels
237 if(function_exists('upgradeDisplayedTabsAndSubpanels'))
239 upgradeDisplayedTabsAndSubpanels($_SESSION['current_db_version']);
243 //Unlink files that have been removed
244 if(function_exists('unlinkUpgradeFiles'))
246 unlinkUpgradeFiles($_SESSION['current_db_version']);
249 if(function_exists('rebuildSprites') && function_exists('imagecreatetruecolor'))
251 rebuildSprites(true);
254 //Run repairUpgradeHistoryTable
255 if($_SESSION['current_db_version'] < '650' && function_exists('repairUpgradeHistoryTable'))
257 repairUpgradeHistoryTable();
260 require_once('modules/Administration/upgrade_custom_relationships.php');
261 upgrade_custom_relationships();
263 require_once('modules/UpgradeWizard/uw_utils.php');
266 if($_SESSION['current_db_version'] < '620')
268 upgradeDateTimeFields($path);
269 upgradeDocumentTypeFields($path);
274 logThis('Start Updating the license ', $path);
277 check_now(get_sugarbeat());
279 logThis('End Updating the license ', $path);
281 set_upgrade_progress('end','done');
283 logThis('Cleaning up the session. Goodbye.');
285 logThis('Cleaning up the session. Goodbye.');
287 // flag to say upgrade has completed
288 $_SESSION['upgrade_complete'] = true;
290 //Clear any third party caches
291 sugar_cache_reset_full();
293 //add the clean vardefs here
294 if(!class_exists('VardefManager')){
297 VardefManager::clearVardef();
299 require_once('include/TemplateHandler/TemplateHandler.php');
300 TemplateHandler::clearAll();
302 //also add the cache cleaning here.
303 if(function_exists('deleteCache')){
308 global $current_language;
310 if(!isset($current_language) || ($current_language == null)){
311 $current_language = 'en_us';
313 if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
314 $current_language = $GLOBALS['current_language'];
316 $mod_strings = return_module_language($current_language, 'UpgradeWizard');
320 $httpHost = $_SERVER['HTTP_HOST']; // cn: 8472 - HTTP_HOST includes port in some cases
321 if($colon = strpos($httpHost, ':')) {
322 $httpHost = substr($httpHost, 0, $colon);
324 $parsedSiteUrl = parse_url($sugar_config['site_url']);
325 $host = ($parsedSiteUrl['host'] != $httpHost) ? $httpHost : $parsedSiteUrl['host'];
327 // aw: 9747 - use SERVER_PORT for users who don't plug in the site_url at install correctly
328 if ($_SERVER['SERVER_PORT'] != 80){
329 $port = ":".$_SERVER['SERVER_PORT'];
331 else if (isset($parsedSiteUrl['port']) && $parsedSiteUrl['port'] != 80){
332 $port = ":".$parsedSiteUrl['port'];
337 $path = $parsedSiteUrl['path'];
338 $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}/index.php";
341 <table cellpadding="3" cellspacing="0" border="0">
347 {$mod_strings['LBL_UW_END_LOGOUT_PRE2']}
350 <b>{$mod_strings['LBL_UW_END_LOGOUT_PRE']}</b> {$mod_strings['LBL_UW_END_LOGOUT']}
357 function deleteCacheAjax(){
358 //AJAX call for checking the file size and comparing with php.ini settings.
360 success:function(r) {
361 //alert(r.responseText);
364 postData = '&module=UpgradeWizard&action=deleteCache&to_pdf=1';
365 YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, postData);
372 $showRecheck = false;
381 $_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
382 unset($_SESSION['current_db_version']);
383 unset($_SESSION['target_db_version']);