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 // creating full text search logic hooks
54 // this will be merged into application/Ext/LogicHooks/logichooks.ext.php
55 // when rebuild_extensions is called
56 logThis(' Writing FTS hooks');
57 if (!function_exists('createFTSLogicHook')) {
58 $customFileLoc = create_custom_directory('Extension/application/Ext/LogicHooks/SugarFTSHooks.php');
59 $fp = sugar_fopen($customFileLoc, 'wb');
62 if (!isset(\$hook_array) || !is_array(\$hook_array)) {
63 \$hook_array = array();
65 if (!isset(\$hook_array['after_save']) || !is_array(\$hook_array['after_save'])) {
66 \$hook_array['after_save'] = array();
68 \$hook_array['after_save'][] = array(1, 'fts', 'include/SugarSearchEngine/SugarSearchEngineQueueManager.php', 'SugarSearchEngineQueueManager', 'populateIndexQueue');
71 fwrite($fp,$contents);
74 createFTSLogicHook('Extension/application/Ext/LogicHooks/SugarFTSHooks.php');
77 //First repair the databse to ensure it is up to date with the new vardefs/tabledefs
78 logThis('About to repair the database.', $path);
79 //Use Repair and rebuild to update the database.
80 global $dictionary, $beanFiles;
82 require_once('modules/Trackers/TrackerManager.php');
83 $trackerManager = TrackerManager::getInstance();
84 $trackerManager->pause();
85 $trackerManager->unsetMonitors();
87 require_once("modules/Administration/QuickRepairAndRebuild.php");
88 $rac = new RepairAndClear();
90 $rac->rebuildExtensions();
91 //bug: 44431 - defensive check to ensure the method exists since upgrades to 6.2.0 may not have this method define yet.
92 if(method_exists($rac, 'clearExternalAPICache'))
94 $rac->clearExternalAPICache();
97 $repairedTables = array();
99 foreach ($beanFiles as $bean => $file) {
100 if(file_exists($file)){
101 require_once ($file);
102 unset($GLOBALS['dictionary'][$bean]);
103 $focus = new $bean ();
104 if (($focus instanceOf SugarBean))
106 if(!isset($repairedTables[$focus->table_name]))
108 $sql = $GLOBALS['db']->repairTable($focus, true);
111 logThis('Running sql:' . $sql, $path);
113 $repairedTables[$focus->table_name] = true;
116 //Check to see if we need to create the audit table
117 if($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())){
118 logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
119 $focus->create_audit_table();
125 $olddictionary = $dictionary;
128 include ('modules/TableDictionary.php');
129 foreach ($dictionary as $meta) {
130 $tablename = $meta['table'];
131 if (isset($repairedTables[$tablename])) continue;
132 $fielddefs = $meta['fields'];
133 $indices = $meta['indices'];
134 $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
137 logThis('Running sql:' . $sql, $path);
139 $repairedTables[$tablename] = true;
142 $dictionary = $olddictionary;
144 logThis('database repaired', $path);
146 $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');
149 logThis(" Start Rebuilding the config file again", $path);
151 //check and set the logger before rebuilding config
152 if(!isset($sugar_config['logger'])){
153 $sugar_config['logger'] =array (
158 'name' => 'sugarcrm',
159 'dateFormat' => '%c',
162 'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
166 //for upgraded version, set default lead conversion activity option to 'copy'
167 if(!isset($sugar_config['lead_conv_activity_opt'])) {
168 $sugar_config['lead_conv_activity_opt'] = 'copy';
171 if(!rebuildConfigFile($sugar_config, $sugar_version)) {
172 logThis('*** WARNING: could not write config.php!', $path);
174 logThis(" Finish Rebuilding the config file again", $path);
176 set_upgrade_progress('end','in_progress');
179 if(isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])){
180 if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '!='))
185 //keeping separate. making easily visible and readable
186 if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '='))
188 $_REQUEST['upgradeWizard'] = true;
190 include('modules/ACL/install_actions.php');
191 include_once('include/Smarty/internals/core.write_file.php');
193 $db =& DBManagerFactory::getInstance();
195 //Also set license information
196 $admin = new Administration();
197 $category = 'license';
199 $admin->saveSetting($category, 'users', $value);
200 $key = array('num_lic_oc','key','expire_date');
203 $admin->saveSetting($category, $k, $value);
209 // Mark the instance as having gone thru the admin wizard
210 $admin = new Administration();
211 $admin->saveSetting('system','adminwizard',1);
213 /////////////////////////Old Logger settings///////////////////////////////////////
214 ///////////////////////////////////////////////////////////////////////////////
215 if(file_exists('modules/Configurator/Configurator.php')){
216 require_once('include/utils/array_utils.php');
217 require_once('modules/Configurator/Configurator.php');
218 $Configurator = new Configurator();
219 $Configurator->parseLoggerSettings();
221 //unset the logger previously instantiated
222 if(file_exists('include/SugarLogger/LoggerManager.php')){
224 unset($GLOBALS['log']);
225 $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
230 logThis('Begin upgrade_connectors', $path);
231 upgrade_connectors();
232 logThis('End upgrade_connectors', $path);
235 //Unlink files that have been removed
236 if(function_exists('unlinkUpgradeFiles'))
238 unlinkUpgradeFiles($_SESSION['current_db_version']);
241 if(function_exists('rebuildSprites') && function_exists('imagecreatetruecolor'))
243 rebuildSprites(true);
246 //Run repairUpgradeHistoryTable
247 if (version_compare($_SESSION['current_db_version'], '6.5.0', '<') && function_exists('repairUpgradeHistoryTable'))
249 repairUpgradeHistoryTable();
252 require_once('modules/Administration/upgrade_custom_relationships.php');
253 upgrade_custom_relationships();
255 require_once('modules/UpgradeWizard/uw_utils.php');
258 logThis('Start Updating the license ', $path);
261 check_now(get_sugarbeat());
263 logThis('End Updating the license ', $path);
265 set_upgrade_progress('end','done');
267 logThis('Cleaning up the session. Goodbye.');
269 logThis('Cleaning up the session. Goodbye.');
271 // flag to say upgrade has completed
272 $_SESSION['upgrade_complete'] = true;
274 //Clear any third party caches
275 sugar_cache_reset_full();
277 //add the clean vardefs here
278 if(!class_exists('VardefManager')){
281 VardefManager::clearVardef();
283 require_once('include/TemplateHandler/TemplateHandler.php');
284 TemplateHandler::clearAll();
286 //also add the cache cleaning here.
287 if(function_exists('deleteCache')){
292 global $current_language;
294 if(!isset($current_language) || ($current_language == null)){
295 $current_language = 'en_us';
297 if(isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)){
298 $current_language = $GLOBALS['current_language'];
300 $mod_strings = return_module_language($current_language, 'UpgradeWizard');
304 $httpHost = $_SERVER['HTTP_HOST']; // cn: 8472 - HTTP_HOST includes port in some cases
305 if($colon = strpos($httpHost, ':')) {
306 $httpHost = substr($httpHost, 0, $colon);
308 $parsedSiteUrl = parse_url($sugar_config['site_url']);
309 $host = ($parsedSiteUrl['host'] != $httpHost) ? $httpHost : $parsedSiteUrl['host'];
311 // aw: 9747 - use SERVER_PORT for users who don't plug in the site_url at install correctly
312 if ($_SERVER['SERVER_PORT'] != 80){
313 $port = ":".$_SERVER['SERVER_PORT'];
315 else if (isset($parsedSiteUrl['port']) && $parsedSiteUrl['port'] != 80){
316 $port = ":".$parsedSiteUrl['port'];
321 $path = $parsedSiteUrl['path'];
322 $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}/index.php";
325 check_now(get_sugarbeat());
329 <table cellpadding="3" cellspacing="0" border="0">
335 {$mod_strings['LBL_UW_END_LOGOUT_PRE2']}
338 <b>{$mod_strings['LBL_UW_END_LOGOUT_PRE']}</b> {$mod_strings['LBL_UW_END_LOGOUT']}
345 function deleteCacheAjax(){
346 //AJAX call for checking the file size and comparing with php.ini settings.
348 success:function(r) {
349 //alert(r.responseText);
352 postData = '&module=UpgradeWizard&action=deleteCache&to_pdf=1';
353 YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, postData);
360 $showRecheck = false;
369 $_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
370 unset($_SESSION['current_db_version']);
371 unset($_SESSION['target_db_version']);