/** main entry point for update wizard (called from /program/main_admin.php)
 *
 * This routine takes care of executing update routines for both the core
 * program and modules, themes, etc. It is called automagically whenever
 * the core program version in the database is different from the version
 * in the file {@lnk version.php} (see also {@link main_admin()}).
 *
 * It can also be called manually via 'job=update'. When no specific
 * task is specified, this routine shows the overview of versions for
 * core, modules, themes, etc. Whenever a component is NOT up to date,
 * an [Update] button is displayed. If a component IS up to date, we
 * simply display the word 'OK'. This implies that when everything is up
 * to date, the overview simply displays a list of OK's and the user
 * is 'free to go'.
 *
 * The actual updates for modules, themes, etc. is done via the various
 * subsystems themselves, e.g. by calling htmlpage_upgrade() in the file
 * /program/modules/htmlpage/htmlpage_install.php. The updates for the
 * core program are actually performed from this file right here, see
 * {@link update_core_2010120800()} below for an example.
 *
 * Note that we give a core update high priority: if the core
 * is not up to date, nothing will work, except updating the core.
 *
 * @param object &$output collects the html output
 * @return void results are returned as output in $output
 */
function job_update(&$output)
{
    global $CFG, $WAS_SCRIPT_NAME, $USER;
    $output->set_helptopic('update');
    $task = get_parameter_string('task', TASK_UPDATE_OVERVIEW);
    if ($task == TASK_UPDATE_OVERVIEW) {
        update_show_overview($output);
    } elseif ($task == TASK_UPDATE_CORE) {
        update_core($output);
        update_show_overview($output);
    } elseif (intval($CFG->version) != intval(WAS_VERSION)) {
        $output->add_message(t('update_core_warnning_core_goes_first', 'admin'));
        update_show_overview($output);
    } else {
        $key = get_parameter_string('key', '');
        switch ($task) {
            case TASK_INSTALL_LANGUAGE:
                install_language($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_LANGUAGE:
                update_language($output, $key);
                update_show_overview($output);
                break;
            case TASK_INSTALL_MODULE:
                install_module($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_MODULE:
                update_module($output, $key);
                update_show_overview($output);
                break;
            case TASK_INSTALL_THEME:
                install_theme($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_THEME:
                update_theme($output, $key);
                update_show_overview($output);
                break;
            default:
                $s = utf8_strlen($task) <= 50 ? $task : utf8_substr($task, 0, 44) . ' (...)';
                $message = t('task_unknown', 'admin', array('{TASK}' => htmlspecialchars($s)));
                $output->add_message($message);
                logger('tools: unknown task: ' . htmlspecialchars($s));
                update_show_overview($output);
                break;
        }
    }
}
Esempio n. 2
0
    } else {
        $_SESSION['inst_set'] = array_merge($_SESSION['inst_set'], array('host' => $_POST['host'], 'dbuser' => $_POST['dbuser'], 'dbpassword' => $_POST['dbpassword'], 'dbname' => $_POST['dbname'], 'tbpref' => $_POST['tbpref'] ? '0_' : '', 'sel_langs' => check_value('sel_langs'), 'sel_coas' => check_value('sel_coas')));
        if (install_connect_db()) {
            $_POST['Page'] = check_value('sel_langs') ? 3 : (check_value('sel_coas') ? 4 : 5);
        }
    }
    if (!file_exists($path_to_root . "/lang/installed_languages.inc")) {
        $installed_languages = array(0 => array('code' => 'C', 'name' => 'English', 'encoding' => 'iso-8859-1'));
        $dflt_lang = 'C';
        write_lang();
    }
} elseif (get_post('install_langs')) {
    $ret = true;
    if (isset($_POST['langs'])) {
        foreach ($_POST['langs'] as $package => $ok) {
            $ret &= install_language($package);
        }
    }
    if ($ret) {
        $_POST['Page'] = $_SESSION['inst_set']['sel_coas'] ? 4 : 5;
    }
} elseif (get_post('install_coas')) {
    $ret = true;
    $next_extension_id = 0;
    if (isset($_POST['coas'])) {
        foreach ($_POST['coas'] as $package => $ok) {
            $ret &= install_extension($package);
        }
    }
    if ($ret) {
        if (file_exists($path_to_root . '/installed_extensions.php')) {
Esempio n. 3
0
        // remove nonstadard language dir
        flush_dir($dirname, true);
        rmdir($dirname);
    }
}
//---------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    handle_delete($selected_id);
}
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') {
    if (check_data() && handle_submit($selected_id)) {
        $Mode = 'RESET';
    }
}
if ($id = find_submit('Update', false)) {
    install_language($id);
}
if (get_post('_CurDflt_update') || get_post('Refresh') && get_post('CurDflt', -1) != -1) {
    $new_lang = $installed_languages[get_post('CurDflt', 0)]['code'];
    if ($new_lang != $dflt_lang) {
        $dflt_lang = $new_lang;
        write_lang();
        $Ajax->activate('lang_tbl');
    }
}
if (get_post('_DisplayAll_update')) {
    $Ajax->activate('lang_tbl');
}
//---------------------------------------------------------------------------------------------
if (isset($_GET['popup']) || get_post('Add') || $Mode == 'Edit' || $Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') {
    display_language_edit($selected_id);