Exemplo n.º 1
0
function set_upgrade_progress($currStep, $currState, $currStepSub = '', $currStepSubState = '')
{
    $upgrade_progress_dir = sugar_cached('upgrades/temp');
    if (!is_dir($upgrade_progress_dir)) {
        mkdir_recursive($upgrade_progress_dir);
    }
    $upgrade_progress_file = $upgrade_progress_dir . '/upgrade_progress.php';
    if (file_exists($upgrade_progress_file)) {
        include $upgrade_progress_file;
    } else {
        if (function_exists('sugar_fopen')) {
            sugar_fopen($upgrade_progress_file, 'w+');
        } else {
            fopen($upgrade_progress_file, 'w+');
        }
    }
    if (!isset($upgrade_config) || $upgrade_config == null) {
        $upgrade_config = array();
        $upgrade_config[1]['upgrade_vars'] = array();
    }
    if (!is_array($upgrade_config[1]['upgrade_vars'])) {
        $upgrade_config[1]['upgrade_vars'] = array();
    }
    if ($currStep != null && $currState != null) {
        if (sizeof($upgrade_config) > 0) {
            if ($currStepSub != null && $currStepSubState != null) {
                //check if new status to be set or update
                //get the latest in array. since it has sub components prepare an array
                if (!empty($upgrade_config[sizeof($upgrade_config)][$currStep]) && is_array($upgrade_config[sizeof($upgrade_config)][$currStep])) {
                    $latestStepSub = currSubStep($upgrade_config[sizeof($upgrade_config)][$currStep]);
                    if ($latestStepSub == $currStepSub) {
                        $upgrade_config[sizeof($upgrade_config)][$currStep][$latestStepSub] = $currStepSubState;
                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
                    } else {
                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStepSub] = $currStepSubState;
                        $upgrade_config[sizeof($upgrade_config)][$currStep][$currStep] = $currState;
                    }
                } else {
                    $currArray = array();
                    $currArray[$currStep] = $currState;
                    $currArray[$currStepSub] = $currStepSubState;
                    $upgrade_config[sizeof($upgrade_config) + 1][$currStep] = $currArray;
                }
            } else {
                //get the current upgrade progress
                $latestStep = get_upgrade_progress();
                //set the upgrade progress
                if ($latestStep == $currStep) {
                    //update the current step with new progress status
                    $upgrade_config[sizeof($upgrade_config)][$latestStep] = $currState;
                } else {
                    //it's a new step
                    $upgrade_config[sizeof($upgrade_config) + 1][$currStep] = $currState;
                }
                // now check if there elements within array substeps
            }
        } else {
            //set the upgrade progress  (just starting)
            $upgrade_config[sizeof($upgrade_config) + 1][$currStep] = $currState;
        }
        if (is_writable($upgrade_progress_file) && write_array_to_file("upgrade_config", $upgrade_config, $upgrade_progress_file)) {
            //writing to the file
        }
    }
}
Exemplo n.º 2
0
        /* END TEMP FIX */
        // Upgrading from 5.0 upwards and upload not performed yet.
        $steps = array('files' => array('start', 'systemCheck', 'upload', 'preflight', 'commit', 'layouts', 'end', 'cancel'), 'desc' => array($mod_strings['LBL_UW_TITLE_START'], $mod_strings['LBL_UW_TITLE_SYSTEM_CHECK'], $mod_strings['LBL_UPLOAD_UPGRADE'], $mod_strings['LBL_UW_TITLE_PREFLIGHT'], $mod_strings['LBL_UW_TITLE_COMMIT'], $mod_strings['LBL_UW_TITLE_LAYOUTS'], $mod_strings['LBL_UW_TITLE_END'], $mod_strings['LBL_UW_TITLE_CANCEL']));
    }
}
$upgradeStepFile = '';
if (isset($_REQUEST['step']) && $_REQUEST['step'] != null) {
    if ($_REQUEST['step'] == -1) {
        $_REQUEST['step'] = count($steps['files']) - 1;
    } elseif ($_REQUEST['step'] >= count($steps['files'])) {
        $_REQUEST['step'] = 0;
    }
    $upgradeStepFile = $steps['files'][$_REQUEST['step']];
} else {
    //check if upgrade was run before. If so then resume from there
    $previouUpgradeRun = get_upgrade_progress();
    if ($previouUpgradeRun != null) {
        //echo 'Previous run '.$previouUpgradeRun.'</br>';
        $upgradeStepFile = $previouUpgradeRun;
        //reset REQUEST
        for ($i = 0; $i < sizeof($steps['files']); $i++) {
            if ($steps['files'][$i] == $previouUpgradeRun) {
                $_REQUEST['step'] = $i;
                break;
            }
        }
    } else {
        // first time through - kill off old sessions
        unset($_SESSION['step']);
        $_REQUEST['step'] = 0;
        $upgradeStepFile = $steps['files'][$_REQUEST['step']];