Added a lot of changes in update manager online open to integrate with mr

This commit is contained in:
Arturo Gonzalez 2017-03-16 18:07:19 +01:00 committed by daniel
parent cadfc0a30f
commit ff596fa797
4 changed files with 205 additions and 138 deletions

View File

@ -78,8 +78,6 @@ if (is_ajax ()) {
$file_dest = $config["homedir"] . "/extras/mr/updated/$number.sql";
chmod($file, 0777);
chmod($config["homedir"] . "/extras/mr/updated", 0777);
if (copy($file, $file_dest)) {
unlink($file);
}

View File

@ -37,6 +37,7 @@ $update_last_free_package = (bool)get_parameter('update_last_free_package');
$check_update_free_package = (bool)get_parameter('check_update_free_package');
$install_free_package = (bool)get_parameter('install_free_package');
$search_minor = (bool)get_parameter('search_minor');
$unzip_free_package = (bool)get_parameter('$unzip_free_package');
if ($upload_file) {
ob_clean();
@ -377,7 +378,6 @@ if ($update_last_free_package) {
$accept = (boolean)get_parameter('accept', false);
$package_url = base64_decode($package);
if ($accept) {
$params = array('action' => 'get_package',
'license' => $license,
'limit_count' => $users,
@ -458,13 +458,6 @@ if ($update_last_free_package) {
array('token' => 'progress_update_status'));
}
}
}
else {
$return["in_progress"] = false;
$return["message"] = __("Package rejected.");
echo json_encode($return);
}
return;
}
@ -509,19 +502,32 @@ if ($check_update_free_package) {
return;
}
if ($install_free_package) {
if ($unzip_free_package) {
$version = get_parameter('version', '');
$result = update_manager_starting_update();
if ($result) {
$return["status"] = "correct";
$return["message"]= __("The package is extracted.");
}
else {
$return["status"] = "error";
$return["message"]= __("Error in package extraction.");
}
echo json_encode($return);
}
if ($install_free_package) {
$version = get_parameter('version', '');
if ($result)
update_manager_set_current_package($version);
sleep(3);
$return["status"] = "success";
$return["message"]= __("The package is installed.");
echo json_encode($return);

View File

@ -604,11 +604,7 @@ function update_manager_remote_read_messages ($id_message) {
return $result['success'];
}
/**
* The update copy entirire the tgz or fail (leave some parts copies and some part not).
* This does make any thing with the BD.
*/
function update_manager_starting_update() {
function update_manager_extract_package() {
global $config;
$path_package = $config['attachment_store'] .
@ -636,8 +632,11 @@ function update_manager_starting_update() {
$extracted = false;
}
}
$return = true;
if($extracted === false) {
$return = false;
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
// unsupported OS
echo "This OS [" . PHP_OS . "] does not support direct extraction of tgz files. Upgrade PHP version to be > 5.5.0";
@ -669,7 +668,20 @@ function update_manager_starting_update() {
array('value' => 50),
array('token' => 'progress_update'));
return $return;
}
/**
* The update copy entirire the tgz or fail (leave some parts copies and some part not).
* This does make any thing with the BD.
*/
function update_manager_starting_update() {
global $config;
$path_package = $config['attachment_store'] .
"/downloads/last_package.tgz";
$full_path = $config['attachment_store'] . "/downloads/unix";
$homedir = $config['homedir'];

View File

@ -844,6 +844,100 @@ function update_last_package(package, version, homeurl) {
$("#box_online .loading").show();
$("#box_online .download_package").show();
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['update_last_free_package'] = 1;
parameters['package'] = package;
parameters['version'] = version;
parameters['accept'] = 0;
jQuery.post(
home_url + "ajax.php",
parameters,
function (data) {
if (data['in_progress']) {
$("#box_online .loading").hide();
$("#box_online .download_package").hide();
$("#box_online .content").html(data['message']);
var parameters2 = {};
parameters2['page'] = 'include/ajax/update_manager.ajax';
parameters2['unzip_free_package'] = 1;
parameters2['package'] = package;
parameters2['version'] = version;
jQuery.post(
home_url + "ajax.php",
parameters2,
function (data) {
if (data['correct']) {
$("#box_online .loading").hide();
$("#box_online .download_package").hide();
$("#box_online .content").html(data['message']);
install_free_package_prev_step(package, version, homeurl);
}
else {
$("#box_online .content").html(data['message']);
}
},
"json"
);
}
else {
$("#box_online .content").html(data['message']);
}
},
"json"
);
}
function check_progress_update(homeurl) {
var home_url = (typeof homeurl !== 'undefined') ? homeurl + '/' : '';
if (stop_check_progress) {
return;
}
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['check_update_free_package'] = 1;
jQuery.post(
home_url + "ajax.php",
parameters,
function (data) {
if (stop_check_progress) {
return;
}
if (data['correct']) {
if (data['end']) {
//$("#box_online .content").html(data['message']);
}
else {
$("#box_online .progressbar").show();
$("#box_online .progressbar .progressbar_img").attr('src',
data['progressbar']);
setTimeout(function () {
check_progress_update(homeurl);
}, 1000);
}
}
else {
correct_install_progress = false;
$("#box_online .content").html(data['message']);
}
},
"json"
);
}
function install_free_package_prev_step(package, version, homeurl) {
$("<div id='pkg_apply_dialog' class='dialog ui-dialog-content' title='" + package_available + "'></div>").dialog ({
resizable: true,
draggable: true,
@ -1244,49 +1338,6 @@ function update_last_package(package, version, homeurl) {
$('#pkg_apply_dialog').dialog('open');
}
function check_progress_update(homeurl) {
var home_url = (typeof homeurl !== 'undefined') ? homeurl + '/' : '';
if (stop_check_progress) {
return;
}
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['check_update_free_package'] = 1;
jQuery.post(
home_url + "ajax.php",
parameters,
function (data) {
if (stop_check_progress) {
return;
}
if (data['correct']) {
if (data['end']) {
//$("#box_online .content").html(data['message']);
}
else {
$("#box_online .progressbar").show();
$("#box_online .progressbar .progressbar_img").attr('src',
data['progressbar']);
setTimeout(function () {
check_progress_update(homeurl);
}, 1000);
}
}
else {
correct_install_progress = false;
$("#box_online .content").html(data['message']);
}
},
"json"
);
}
function install_free_package(package, version, homeurl) {
var home_url = (typeof homeurl !== 'undefined') ? homeurl + '/' : '';