info('Deleting Relationship Cache. Relationships will automatically refresh.'); echo "
"; $log->info('Rebuilding everything.'); require_once('ModuleInstall/ModuleInstaller.php'); $mi = new ModuleInstaller(); $mi->rebuild_all(); $query = "DELETE FROM versions WHERE name='Rebuild Extensions'"; $log->info($query); $db->query($query); // insert a new database row to show the rebuild extensions is done $id = create_guid(); $gmdate = TimeDate::getInstance()->nowDb(); $date_entered = db_convert("'$gmdate'", 'datetime'); $query = 'INSERT INTO versions (id, deleted, date_entered, date_modified, modified_user_id, created_by, name, file_version, db_version) ' . "VALUES ('$id', '0', $date_entered, $date_entered, '1', '1', 'Rebuild Extensions', '4.0.0', '4.0.0')"; $log->info($query); $db->query($query); } unset($_SESSION['rebuild_relationships']); unset($_SESSION['rebuild_extensions']); $log =& $GLOBALS['log']; $db =& $GLOBALS['db']; // process commands if( !isset($_REQUEST['mode']) || ($_REQUEST['mode'] == "") ){ die($mod_strings['ERR_UW_NO_MODE']); } $mode = $_REQUEST['mode']; if( !isset($_REQUEST['version']) ){ die($mod_strings['ERR_UW_NO_MODE']); } $version = $_REQUEST['version']; if( !isset($_REQUEST['copy_count']) || ($_REQUEST['copy_count'] == "") ){ die($mod_strings['ERR_UW_NO_FILES']); } if( !isset($_REQUEST['unzip_dir']) || ($_REQUEST['unzip_dir'] == "") ){ die($mod_strings['ERR_UW_NO_TEMP_DIR']); } $unzip_dir = $_REQUEST['unzip_dir']; if(empty($_REQUEST['install_file'])){ die($mod_strings['ERR_UW_NO_INSTALL_FILE']); } $install_file = hashToFile($_REQUEST['install_file'] ); $install_type = getInstallType( $install_file ); $id_name = ''; if(isset($_REQUEST['id_name'])){ $id_name = $_REQUEST['id_name']; } $s_manifest = ''; if(isset($_REQUEST['s_manifest'])){ $s_manifest = $_REQUEST['s_manifest']; } $previous_version = ''; if(isset($_REQUEST['previous_version'])){ $previous_version = $_REQUEST['previous_version']; } $previous_id = ''; if(isset($_REQUEST['previous_id'])){ $previous_id = $_REQUEST['previous_id']; } if( $install_type != "module" ){ if( !isset($_REQUEST['zip_from_dir']) || ($_REQUEST['zip_from_dir'] == "") ){ $zip_from_dir = "."; } else{ $zip_from_dir = $_REQUEST['zip_from_dir']; } if( !isset($_REQUEST['zip_to_dir']) || ($_REQUEST['zip_to_dir'] == "") ){ $zip_to_dir = "."; } else{ $zip_to_dir = $_REQUEST['zip_to_dir']; } } $remove_tables = 'true'; if(isset($_REQUEST['remove_tables'])){ $remove_tables = $_REQUEST['remove_tables']; } $overwrite_files = true; if(isset($_REQUEST['radio_overwrite'])){ $overwrite_files = (($_REQUEST['radio_overwrite'] == 'do_not_overwrite') ? false : true); } //rrs $author = ''; $is_uninstallable = true; $name = ''; $description = ''; if($install_type == 'module'){ $is_uninstallable = $_REQUEST['is_uninstallable']; $name = $_REQUEST['name']; $description = $_REQUEST['description']; } $file_action = ""; $uh_status = ""; $rest_dir = clean_path( remove_file_extension($install_file)."-restore"); $files_to_handle = array(); if(!empty($GLOBALS['sugar_config']['moduleInstaller']['packageScan']) && $install_type != 'patch'){ require_once('ModuleInstall/ModuleScanner.php'); $ms = new ModuleScanner(); $ms->scanPackage($unzip_dir); if($ms->hasIssues()){ $ms->displayIssues(); sugar_cleanup(true); } } // // execute the PRE scripts // if($install_type == 'patch' || $install_type == 'module') { switch($mode) { case 'Install': $file = "$unzip_dir/" . constant('SUGARCRM_PRE_INSTALL_FILE'); if(is_file($file)) { print("{$mod_strings['LBL_UW_INCLUDING']}: $file
\n"); include($file); pre_install(); } break; case 'Uninstall': $file = "$unzip_dir/" . constant('SUGARCRM_PRE_UNINSTALL_FILE'); if(is_file($file)) { print("{$mod_strings['LBL_UW_INCLUDING']}: $file
\n"); include($file); pre_uninstall(); } break; default: break; } } // // perform the action // for( $iii = 0; $iii < $_REQUEST['copy_count']; $iii++ ){ if( isset($_REQUEST["copy_" . $iii]) && ($_REQUEST["copy_" . $iii] != "") ){ $file_to_copy = $_REQUEST["copy_" . $iii]; $src_file = clean_path( "$unzip_dir/$zip_from_dir/$file_to_copy" ); $sugar_home_dir = getCwd(); $dest_file = clean_path( "$sugar_home_dir/$zip_to_dir/$file_to_copy" ); if($zip_to_dir != '.') $rest_file = clean_path("$rest_dir/$zip_to_dir/$file_to_copy"); else $rest_file = clean_path("$rest_dir/$file_to_copy"); switch( $mode ){ case "Install": mkdir_recursive( dirname( $dest_file ) ); if($install_type=="patch" && is_file($dest_file)) { if(!is_dir(dirname( $rest_file ))) mkdir_recursive( dirname( $rest_file ) ); copy( $dest_file, $rest_file); sugar_touch( $rest_file, filemtime($dest_file) ); } if( !copy( $src_file, $dest_file ) ){ die( $mod_strings['ERR_UW_COPY_FAILED'].$src_file.$mod_strings['LBL_TO'].$dest_file); } $uh_status = "installed"; break; case "Uninstall": if($install_type=="patch" && is_file($rest_file)) { copy( $rest_file, $dest_file); sugar_touch( $dest_file, filemtime($rest_file) ); } elseif(file_exists($dest_file) && !unlink($dest_file)) { die($mod_strings['ERR_UW_REMOVE_FAILED'].$dest_file); } $uh_status = "uninstalled"; break; default: die("{$mod_strings['LBL_UW_OP_MODE']} '$mode' {$mod_strings['ERR_UW_NOT_RECOGNIZED']}." ); } $files_to_handle[] = clean_path( "$zip_to_dir/$file_to_copy" ); } } switch( $install_type ){ case "langpack": if( !isset($_REQUEST['new_lang_name']) || ($_REQUEST['new_lang_name'] == "") ){ die($mod_strings['ERR_UW_NO_LANG']); } if( !isset($_REQUEST['new_lang_desc']) || ($_REQUEST['new_lang_desc'] == "") ){ die($mod_strings['ERR_UW_NO_LANG_DESC']); } if( $mode == "Install" || $mode=="Enable" ){ $sugar_config['languages'] = $sugar_config['languages'] + array( $_REQUEST['new_lang_name'] => $_REQUEST['new_lang_desc'] ); } else if( $mode == "Uninstall" || $mode=="Disable" ){ $new_langs = array(); $old_langs = $sugar_config['languages']; foreach( $old_langs as $key => $value ){ if( $key != $_REQUEST['new_lang_name'] ){ $new_langs += array( $key => $value ); } } $sugar_config['languages'] = $new_langs; $default_sugar_instance_lang = 'en_us'; if($current_language == $_REQUEST['new_lang_name']){ $_SESSION['authenticated_user_language'] =$default_sugar_instance_lang; $lang_changed_string = $mod_strings['LBL_CURRENT_LANGUAGE_CHANGE'].$sugar_config['languages'][$default_sugar_instance_lang].'
'; } if($sugar_config['default_language'] == $_REQUEST['new_lang_name']){ $cfg = new Configurator(); $cfg->config['languages'] = $new_langs; $cfg->config['default_language'] = $default_sugar_instance_lang; $cfg->handleOverride(); $lang_changed_string .= $mod_strings['LBL_DEFAULT_LANGUAGE_CHANGE'].$sugar_config['languages'][$default_sugar_instance_lang].'
'; } } ksort( $sugar_config ); if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){ die($mod_strings['ERR_UW_CONFIG_FAILED']); } break; case "module": require_once( "ModuleInstall/ModuleInstaller.php" ); $mi = new ModuleInstaller(); switch( $mode ){ case "Install": //here we can determine if this is an upgrade or a new version if(!empty($previous_version)){ $mi->install( "$unzip_dir", true, $previous_version); }else{ $mi->install( "$unzip_dir" ); } $file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE'); if(is_file($file)) { print("{$mod_strings['LBL_UW_INCLUDING']}: $file
\n"); include($file); post_install(); } break; case "Uninstall": if($remove_tables == 'false') $GLOBALS['mi_remove_tables'] = false; else $GLOBALS['mi_remove_tables'] = true; $mi->uninstall( "$unzip_dir" ); break; case "Disable": if(!$overwrite_files) $GLOBALS['mi_overwrite_files'] = false; else $GLOBALS['mi_overwrite_files'] = true; $mi->disable( "$unzip_dir" ); break; case "Enable": if(!$overwrite_files) $GLOBALS['mi_overwrite_files'] = false; else $GLOBALS['mi_overwrite_files'] = true; $mi->enable( "$unzip_dir" ); break; default: break; } break; case "full": // purposely flow into "case: patch" case "patch": switch($mode) { case 'Install': $file = "$unzip_dir/" . constant('SUGARCRM_POST_INSTALL_FILE'); if(is_file($file)) { print("{$mod_strings['LBL_UW_INCLUDING']}: $file
\n"); include($file); post_install(); } UWrebuild(); break; case 'Uninstall': $file = "$unzip_dir/" . constant('SUGARCRM_POST_UNINSTALL_FILE'); if(is_file($file)) { print("{$mod_strings['LBL_UW_INCLUDING']}: $file
\n"); include($file); post_uninstall(); } if(is_dir($rest_dir)) { rmdir_recursive($rest_dir); } UWrebuild(); break; default: break; } require( "sugar_version.php" ); $sugar_config['sugar_version'] = $sugar_version; ksort( $sugar_config ); if( !write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ) { die($mod_strings['ERR_UW_UPDATE_CONFIG']); } break; default: break; } switch( $mode ){ case "Install": $file_action = "copied"; // if error was encountered, script should have died before now $new_upgrade = new UpgradeHistory(); //determine if this module has already been installed given the unique_key to //identify the module // $new_upgrade->checkForExisting($unique_key); if(!empty($previous_id)){ $new_upgrade->id = $previous_id; $uh = new UpgradeHistory(); $uh->retrieve($previous_id); if(is_file($uh->filename)) { unlink($uh->filename); } } $new_upgrade->filename = $install_file; $new_upgrade->md5sum = md5_file( $install_file ); $new_upgrade->type = $install_type; $new_upgrade->version = $version; $new_upgrade->status = "installed"; $new_upgrade->name = $name; $new_upgrade->description = $description; $new_upgrade->id_name = $id_name; $new_upgrade->manifest = $s_manifest; $new_upgrade->save(); //Check if we need to show a page for the user to finalize their install with. if (is_file("$unzip_dir/manifest.php")) { include("$unzip_dir/manifest.php"); if (!empty($manifest['post_install_url'])) { $url_conf = $manifest['post_install_url']; if (is_string($url_conf)) $url_conf = array('url' => $url_conf); if (isset($url_conf['type']) && $url_conf['type'] == 'popup') { echo ''; } else { echo ''; } } } break; case "Uninstall": $file_action = "removed"; $uh = new UpgradeHistory(); $the_md5 = md5_file( $install_file ); $md5_matches = $uh->findByMd5( $the_md5 ); if( sizeof( $md5_matches ) == 0 ){ die( "{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} $install_file." ); } foreach( $md5_matches as $md5_match ){ $md5_match->delete(); } break; case "Disable": $file_action = "disabled"; $uh = new UpgradeHistory(); $the_md5 = md5_file( $install_file ); $md5_matches = $uh->findByMd5( $the_md5 ); if( sizeof( $md5_matches ) == 0 ){ die( "{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} $install_file." ); } foreach( $md5_matches as $md5_match ){ $md5_match->enabled = 0; $md5_match->save(); } break; case "Enable": $file_action = "enabled"; $uh = new UpgradeHistory(); $the_md5 = md5_file( $install_file ); $md5_matches = $uh->findByMd5( $the_md5 ); if( sizeof( $md5_matches ) == 0 ){ die( "{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} $install_file." ); } foreach( $md5_matches as $md5_match ){ $md5_match->enabled = 1; $md5_match->save(); } break; } // present list to user ?>
"; print( getUITextForType($install_type) . " ". getUITextForMode($mode) . " ". $mod_strings['LBL_UW_SUCCESSFULLY']); echo "
"; echo "
"; print( "
" ); echo ""; echo "
"; if(isset($lang_changed_string)) print($lang_changed_string); if ($install_type != "module" && $install_type != "langpack"){ if( sizeof( $files_to_handle ) > 0 ){ echo '
Show Details
Hide Details

'; print( "{$mod_strings['LBL_UW_FOLLOWING_FILES']} $file_action:
\n" ); print( "\n" ); echo '
'; } else if( $mode != 'Disable' && $mode !='Enable' ){ print( "{$mod_strings['LBL_UW_NO_FILES_SELECTED']} $file_action.
\n" ); } print($mod_strings['LBL_UW_UPGRADE_SUCCESSFUL']); print( "\n" ); } ?>
info( "Upgrade Wizard patches" ); ?>