Example #1
0
function DLM_update_001()
{
    global $_CONF, $_LANG_UPDATE;
    $retval = '';
    $pnum = '#001';
    $desc = DLM_check_001();
    if (!empty($desc)) {
        require_once $_CONF['path'] . 'plugins/downloads/install_defaults.php';
        require_once $_CONF['path_system'] . 'classes/config.class.php';
        if (function_exists('COM_versionCompare')) {
            DLM_update_ConfValues_addTabs();
        }
        DLM_updateSortOrder();
        $msg = sprintf($_LANG_UPDATE['process_completed'], $pnum);
        $retval .= '<p style="color:green">' . $msg . '</p>' . LB;
    } else {
        $msg = sprintf($_LANG_UPDATE['process_canceled'], $pnum);
        $retval .= '<p style="color:red">' . $msg . '</p>' . LB;
    }
    return $retval;
}
Example #2
0
/**
* Called by the plugin Editor to run the SQL Update for a plugin update
*/
function DLM_upgrade()
{
    global $_CONF, $_TABLES, $_DB_dbms;
    $pi_name = 'downloads';
    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = '{$pi_name}'");
    $func = "plugin_chkVersion_{$pi_name}";
    $code_version = $func();
    if ($installed_version == $code_version) {
        return true;
    }
    $func = "plugin_compatible_with_this_version_{$pi_name}";
    if (!$func($pi_name)) {
        return 3002;
    }
    if (version_compare($installed_version, '1.1.0') < 0) {
        require_once $_CONF['path'] . 'plugins/downloads/install_defaults.php';
        require_once $_CONF['path_system'] . 'classes/config.class.php';
        if (function_exists('COM_versionCompare')) {
            DLM_update_ConfValues_addTabs();
        }
        DLM_updateSortOrder();
    }
    $func = "plugin_autoinstall_{$pi_name}";
    $inst_parms = $func($pi_name);
    $pi_gl_version = $inst_parms['info']['pi_gl_version'];
    require_once $_CONF['path'] . 'plugins/downloads/sql/' . $_DB_dbms . '_updates.php';
    $current_version = $installed_version;
    if (version_compare($current_version, '1.1.0') < 0) {
        $current_version = '1.1.0';
    }
    $done = false;
    while (!$done) {
        switch ($current_version) {
            case '1.1.0':
                if (isset($_UPDATES[$current_version])) {
                    $_SQL = $_UPDATES[$current_version];
                    foreach ($_SQL as $sql) {
                        DB_query($sql);
                    }
                }
                $current_version = '1.2.0';
                break;
            default:
                $done = true;
                break;
        }
    }
    // Update the version numbers
    DB_query("UPDATE {$_TABLES['plugins']} " . "SET pi_version = '{$code_version}', pi_gl_version = '{$pi_gl_version}' " . "WHERE pi_name = '{$pi_name}'");
    COM_errorLog(ucfirst($pi_name) . " plugin was successfully updated to version {$code_version}.");
    return true;
}