Exemplo n.º 1
0
    }
    $repairedTables[$tablename] = true;
}
$dictionary = $olddictionary;
logThis('database repaired', $path);
$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');
logThis(" Start Rebuilding the config file again", $path);
//check and set the logger before rebuilding config
if (!isset($sugar_config['logger'])) {
    $sugar_config['logger'] = array('level' => 'fatal', 'file' => array('ext' => '.log', 'name' => 'sugarcrm', 'dateFormat' => '%c', 'maxSize' => '10MB', 'maxLogs' => 10, 'suffix' => '%m_%Y'));
}
//for upgraded version, set default lead conversion activity option to 'copy'
if (!isset($sugar_config['lead_conv_activity_opt'])) {
    $sugar_config['lead_conv_activity_opt'] = 'copy';
}
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
    logThis('*** WARNING: could not write config.php!', $path);
}
logThis(" Finish Rebuilding the config file again", $path);
set_upgrade_progress('end', 'in_progress');
if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) {
    if ($_SESSION['current_db_version'] != $_SESSION['target_db_version']) {
        logThis("Upgrading multienum data", $path);
        if (file_exists("{$unzip_dir}/scripts/upgrade_multienum_data.php")) {
            require_once "{$unzip_dir}/scripts/upgrade_multienum_data.php";
            upgrade_multienum_data();
        }
    }
    //keeping separate. making easily visible and readable
    if ($_SESSION['current_db_version'] == $_SESSION['target_db_version']) {
        $_REQUEST['upgradeWizard'] = true;
Exemplo n.º 2
0
/**
 * 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.');
}
Exemplo n.º 3
0
/**
 * Checks if a locale name format is part of the default list, if not adds it to the config
 * @param $name_format string a local name format string such as 's f l'
 * @return bool true on successful write to config file, false on failure;
 */
function upgradeLocaleNameFormat($name_format)
{
    global $sugar_config, $sugar_version;
    $localization = new Localization();
    $localeConfigDefaults = $localization->getLocaleConfigDefaults();
    $uw_strings = return_module_language($GLOBALS['current_language'], 'UpgradeWizard');
    if (empty($sugar_config['name_formats'])) {
        $sugar_config['name_formats'] = $localeConfigDefaults['name_formats'];
        if (!rebuildConfigFile($sugar_config, $sugar_version)) {
            $errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
        }
    }
    if (!in_array($name_format, $sugar_config['name_formats'])) {
        $new_config = sugarArrayMerge($sugar_config['name_formats'], array($name_format => $name_format));
        $sugar_config['name_formats'] = $new_config;
        if (!rebuildConfigFile($sugar_config, $sugar_version)) {
            $errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
            return false;
        }
    }
    return true;
}
Exemplo n.º 4
0
$btn_rebuild_config = $mod_strings['BTN_REBUILD_CONFIG'];
$disable_config_rebuild = 'disabled="disabled"';
// check the status of the config file
if (is_writable('config.php')) {
    $config_check = $mod_strings['MSG_CONFIG_FILE_READY_FOR_REBUILD'];
    $disable_config_rebuild = '';
    $config_file_ready = true;
} else {
    $config_check = $mod_strings['MSG_MAKE_CONFIG_FILE_WRITABLE'];
}
// only do the rebuild if config file checks out and user has posted back
if (!empty($_POST['perform_rebuild']) && $config_file_ready) {
    // retrieve configuration from file so that contents of config_override.php
    // is not merged (bug #54403)
    $clean_config = loadCleanConfig();
    if (rebuildConfigFile($clean_config, $sugar_version)) {
        $config_check = $mod_strings['MSG_CONFIG_FILE_REBUILD_SUCCESS'];
        $disable_config_rebuild = 'disabled="disabled"';
    } else {
        $config_check = $mod_strings['MSG_CONFIG_FILE_REBUILD_FAILED'];
    }
}
/////////////////////////////////////////////////////////////////////
// TEMPLATE ASSIGNING
$xtpl = new XTemplate('modules/Administration/RebuildConfig.html');
$xtpl->assign('LBL_CONFIG_CHECK', $mod_strings['LBL_CONFIG_CHECK']);
$xtpl->assign('CONFIG_CHECK', $config_check);
$xtpl->assign('LBL_PERFORM_REBUILD', $lbl_rebuild_config);
$xtpl->assign('DISABLE_CONFIG_REBUILD', $disable_config_rebuild);
$xtpl->assign('BTN_PERFORM_REBUILD', $btn_rebuild_config);
$xtpl->parse('main');
Exemplo n.º 5
0
 /**
  * Tests that bad Locale Name Format strings from global preference do not get added to the config
  * @param $name_format invalid name format from data provider
  * @dataProvider badLocaleNameFormatProvider
  * @depends testCheckReturnsFalseForInvalidNameFormats
  */
 public function testInvalidGlobalPreferenceForLocaleNameFormatUpgrade($name_format)
 {
     global $sugar_config, $sugar_version;
     $this->assertFileNotExists($this->loc->invalidNameFormatUpgradeFilename);
     $this->assertNotSame($name_format, $sugar_config['default_locale_name_format']);
     $sugar_config['default_locale_name_format'] = $name_format;
     if (!rebuildConfigFile($sugar_config, $sugar_version)) {
         $errors[] = $mod_strings['ERR_UW_CONFIG_WRITE'];
         $this->fail("Could not rebuild config file, please check your installation.");
     }
     upgradeUserPreferences();
     $this->assertNotSame($name_format, $sugar_config['default_locale_name_format']);
     require 'config.php';
     $coreDefaults = $this->loc->getLocaleConfigDefaults();
     $this->assertSame($coreDefaults['default_locale_name_format'], $sugar_config['default_locale_name_format']);
     $this->assertFileExists($this->loc->invalidNameFormatUpgradeFilename);
 }
 /**
  * Only meant to be ran from the scope of the main module. Uses $currentModule.
  */
 public static function change()
 {
     if (empty($_REQUEST['key'])) {
         header('HTTP/1.1 400 Bad Request');
         $response = "Key is required.";
         $json = getJSONobj();
         echo $json->encode($response);
         exit;
     }
     if (empty($_REQUEST['user_count'])) {
         header('HTTP/1.1 400 Bad Request');
         $response = "User count is required.";
         $json = getJSONobj();
         echo $json->encode($response);
         exit;
     }
     global $currentModule;
     //load license validation config
     require 'modules/' . $currentModule . '/license/config.php';
     $data = array('key' => $key, 'user_count' => $_REQUEST['user_count']);
     $response = SugarOutfitters_API::call($currentModule, 'key/change', $data);
     //if it is not a 200 response assume a 400. Good enough for this purpose.
     if (empty($response['success']) || $response['success'] !== true) {
         header('HTTP/1.1 400 Bad Request');
         $GLOBALS['log']->fatal('AddonBoilerplateOutfittersLicense::change() failed: ' . print_r($response, true));
     } else {
         require_once 'modules/Administration/Administration.php';
         global $sugar_config, $sugar_version;
         $sugar_config['outfitters_licenses'][$outfitters_config['shortname']] = $_REQUEST['key'];
         rebuildConfigFile($sugar_config, $sugar_version);
     }
     $json = getJSONobj();
     echo $json->encode($response['result']);
     exit;
 }