/** * handles post-install tasks */ function commitAjaxPostInstall($persistence) { global $mod_strings; global $sugar_config; global $sugar_version; if (empty($sugar_version)) { require 'sugar_version.php'; } // update versions info if (!updateVersions($sugar_version)) { echo $mod_strings['ERR_UW_COMMIT_UPDATE_VERSIONS']; } logThis('Starting post_install()...'); $postInstallResults = "<b>{$mod_strings['LBL_UW_COMMIT_POSTINSTALL_RESULTS']}</b><br />\n\t\t\t\t\t\t\t<a href='javascript:toggleNwFiles(\"postInstallResults\");'>{$mod_strings['LBL_UW_SHOW']}</a><br />\n\t\t\t\t\t\t\t<div id='postInstallResults' style='display:none'>"; $file = $persistence['unzip_dir'] . "/" . constant('SUGARCRM_POST_INSTALL_FILE'); if (is_file($file)) { include $file; ob_start(); post_install(); } require "sugar_version.php"; if (!rebuildConfigFile($sugar_config, $sugar_version)) { logThis('*** ERROR: could not write config.php! - upgrade will fail!'); $errors[] = $mod_strings['ERR_UW_CONFIG_WRITE']; } $res = ob_get_contents(); $postInstallResults .= empty($res) ? $mod_strings['LBL_UW_SUCCESS'] : $res; $postInstallResults .= "</div>"; ob_start(); echo $postInstallResults; ob_flush(); logThis('post_install() done.'); }
function commitPatch($unlink = false, $type = 'patch') { require_once 'ModuleInstall/ModuleInstaller.php'; require_once 'include/entryPoint.php'; global $mod_strings; global $base_upgrade_dir; global $base_tmp_upgrade_dir; global $db; $GLOBALS['db'] = $db; $errors = array(); $files = array(); global $current_user; $current_user = new User(); $current_user->is_admin = '1'; $old_mod_strings = $mod_strings; if (is_dir($base_upgrade_dir)) { $files = findAllFiles("{$base_upgrade_dir}/{$type}", $files); $mi = new ModuleInstaller(); $mi->silent = true; $mod_strings = return_module_language('en', "Administration"); foreach ($files as $file) { if (!preg_match('#.*\\.zip\\$#', $file)) { continue; } // handle manifest.php $target_manifest = remove_file_extension($file) . '-manifest.php'; include $target_manifest; $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir); unzip($file, $unzip_dir); if (file_exists("{$unzip_dir}/scripts/pre_install.php")) { require_once "{$unzip_dir}/scripts/pre_install.php"; pre_install(); } if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") { $zip_from_dir = $manifest['copy_files']['from_dir']; } $source = "{$unzip_dir}/{$zip_from_dir}"; $dest = getcwd(); copy_recursive($source, $dest); if (file_exists("{$unzip_dir}/scripts/post_install.php")) { require_once "{$unzip_dir}/scripts/post_install.php"; post_install(); } $new_upgrade = new UpgradeHistory(); $new_upgrade->filename = $file; $new_upgrade->md5sum = md5_file($file); $new_upgrade->type = $manifest['type']; $new_upgrade->version = $manifest['version']; $new_upgrade->status = "installed"; //$new_upgrade->author = $manifest['author']; $new_upgrade->name = $manifest['name']; $new_upgrade->description = $manifest['description']; $serial_manifest = array(); $serial_manifest['manifest'] = isset($manifest) ? $manifest : ''; $serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : ''; $serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : ''; $new_upgrade->manifest = base64_encode(serialize($serial_manifest)); $new_upgrade->save(); unlink($file); } //rof } //fi $mod_strings = $old_mod_strings; }
/////////////////////////////////////////////////////////////////////////////// //// HANDLE POSTINSTALL SCRIPTS if (empty($errors)) { logThis('Starting post_install()...', $path); $trackerManager = TrackerManager::getInstance(); $trackerManager->pause(); $trackerManager->unsetMonitors(); if (!didThisStepRunBefore('commit', 'post_install')) { $file = "{$unzip_dir}/" . constant('SUGARCRM_POST_INSTALL_FILE'); if (is_file($file)) { //set_upgrade_progress('commit','in_progress','post_install','in_progress'); $progArray['post_install'] = 'in_progress'; post_install_progress($progArray, 'set'); global $moduleList; include $file; post_install(); // cn: only run conversion if admin selects "Sugar runs SQL" if (!empty($_SESSION['allTables']) && $_SESSION['schema_change'] == 'sugar') { executeConvertTablesSql($_SESSION['allTables']); } //set process to done $progArray['post_install'] = 'done'; //set_upgrade_progress('commit','in_progress','post_install','done'); post_install_progress($progArray, 'set'); } } //clean vardefs logThis('Performing UWrebuild()...', $path); ob_start(); @UWrebuild(); ob_end_clean();
function get_required_upgrades($soapclient, $session) { global $sugar_config, $sugar_version; require_once 'vendor/nusoap//nusoap.php'; $errors = array(); $upgrade_history = new UpgradeHistory(); $upgrade_history->disable_row_level_security = true; $installeds = $upgrade_history->getAllOrderBy('date_entered ASC'); $history = array(); require_once 'soap/SoapError.php'; $error = new SoapError(); foreach ($installeds as $installed) { $history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array()); } $result = $soapclient->call('get_required_upgrades', array('session' => $session, 'client_upgrade_history' => $history, 'client_version' => $sugar_version)); $tempdir_parent = create_cache_directory("disc_client"); $temp_dir = tempnam($tempdir_parent, "sug"); sugar_mkdir($temp_dir, 0775); $upgrade_installed = false; if (empty($soapclient->error_str) && $result['error']['number'] == 0) { foreach ($result['upgrade_history_list'] as $upgrade) { $file_result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => $upgrade['filename'])); if (empty($soapclient->error_str) && $result['error']['number'] == 0) { if ($file_result['md5'] == $upgrade['md5']) { $newfile = write_encoded_file($file_result, $temp_dir); unzip($newfile, $temp_dir); global $unzip_dir; $unzip_dir = $temp_dir; if (file_exists("{$temp_dir}/manifest.php")) { require_once "{$temp_dir}/manifest.php"; global $manifest_arr; $manifest_arr = $manifest; if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') { if (file_exists("{$temp_dir}/scripts/pre_install.php")) { require_once "{$temp_dir}/scripts/pre_install.php"; pre_install(); } if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") { $zip_from_dir = $manifest['copy_files']['from_dir']; } $source = "{$temp_dir}/{$zip_from_dir}"; $dest = getcwd(); copy_recursive($source, $dest); if (file_exists("{$temp_dir}/scripts/post_install.php")) { require_once "{$temp_dir}/scripts/post_install.php"; post_install(); } //save newly installed upgrade $new_upgrade = new UpgradeHistory(); $new_upgrade->filename = $upgrade['filename']; $new_upgrade->md5sum = $upgrade['md5']; $new_upgrade->type = $upgrade['type']; $new_upgrade->version = $upgrade['version']; $new_upgrade->status = "installed"; $new_upgrade->save(); $upgrade_installed = true; } } } } } } return $upgrade_installed; }