Commit d1a67130 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

upgrade uses sendjsonrequest

parent 50f301a4
......@@ -103,13 +103,11 @@ $failurestring = get_string('upgradefailure', 'admin');
$javascript = <<<JAVASCRIPT
function installplugin(name) {
var d = loadJSONDoc('../upgrade.json.php', { 'name': name });
$(name + '.message').innerHTML = '<img src="{$loadingicon}" alt="{$loadingstring}" />';
d.addCallbacks(function (data) {
sendjsonrequest('../upgrade.json.php', { 'name': name }, 'GET', function (data) {
if (!data.error) {
var message = '{$successstring}' + data.message.newversion;
var message = '{$successstring}' + data.newversion;
$(name + '.message').innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
// move the whole thing into the list of installed plugins
// new parent node
......@@ -119,8 +117,8 @@ function installplugin(name) {
}
else {
var message = '';
if (data.message.errormessage) {
message = data.message.errormessage;
if (data.errormessage) {
message = data.errormessage;
}
else {
message = '{$failurestring}';
......@@ -128,10 +126,11 @@ function installplugin(name) {
$(name).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
}
},
function () {
message = '{$failurestring}';
$(name).innerHTML = message;
});
function () {
message = '{$failurestring}';
$(name).innerHTML = message;
},
true);
}
JAVASCRIPT;
......
......@@ -81,18 +81,21 @@ if (!empty($upgrade)) {
if (isset($upgrade->install)) {
$data['install'] = $upgrade->install;
}
$data['error'] = false;
json_reply(false, $data);
exit;
}
catch (Exception $e) {
list($texttrace, $htmltrace) = log_build_backtrace($e->getTrace());
$data['errormessage'] = $e->getMessage() . '<br>' . $htmltrace;
json_reply(true, $data);
$data['error'] = true;
json_reply('local', $data);
exit;
}
}
else {
json_reply(false, array('message' => string('nothingtoupgrade','admin')));
json_reply(false, array('error' => false,
'message' => string('nothingtoupgrade','admin')));
exit;
}
?>
......@@ -106,36 +106,36 @@ $js .= <<< EOJS
return;
}
var d = loadJSONDoc('upgrade.json.php', { 'name': element });
$(element).innerHTML = '<img src="{$loadingicon}" alt="{$loadingstring}" />';
d.addCallbacks(function (data) {
sendjsonrequest('upgrade.json.php', { 'name': element }, 'GET', function (data) {
if ( !data.error ) {
var message;
if (data.message.install) {
if (data.install) {
message = '{$installsuccessstring}';
}
else {
message = '{$successstring}';
}
message += data.message.newversion;
$(data.message.key).innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
message += data.newversion;
$(data.key).innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
}
else {
var message = '';
if (data.message.errormessage) {
message = data.message.errormessage;
if (data.errormessage) {
message = data.errormessage;
}
else {
message = '{$failurestring}';
}
$(data.message.key).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
$(data.key).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
}
processNext();
}, function () {
},
function () {
$(element).innerHTML = '<img src="{$failureicon}" alt=":(" /> {$failurestring}';
});
},
true);
}
addLoadEvent( processNext );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment