Skip to content

Commit

Permalink
MDL-32037: MDL-32037: After displaying error message filepicker could…
Browse files Browse the repository at this point in the history
… not send proper request to server

We need to make sure that code executed on error does not create more requests and
especially does not create the same request that resulted with error. So now by default
filepicker will clear the right side of the window if repository_ajax.php returned an
error.
Also fixed an 'invalidsesskey' error string.
  • Loading branch information
marinaglancy committed Mar 16, 2012
1 parent a2b30aa commit a5159b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion repository/filepicker.js
Expand Up @@ -150,7 +150,11 @@ M.core_filepicker.init = function(Y, options) {
// error checking
if (data && data.error) {
scope.print_msg(data.error, 'error');
scope.list();
if (args.onerror) {
args.onerror(id,data,p);
} else {
Y.one(panel_id).set('innerHTML', '');
}
return;
} else if (data && data.event) {
switch (data.event) {
Expand Down Expand Up @@ -690,6 +694,9 @@ M.core_filepicker.init = function(Y, options) {
client_id: client_id,
repository_id: repository_id,
'params': params,
onerror: function(id, obj, args) {
scope.view_files();
},
callback: function(id, obj, args) {
if (scope.options.editor_target && scope.options.env=='editor') {
scope.options.editor_target.value=obj.url;
Expand Down Expand Up @@ -1200,6 +1207,9 @@ M.core_filepicker.init = function(Y, options) {
params: {'savepath':scope.options.savepath},
repository_id: scope.active_repo.id,
form: {id: id, upload:true},
onerror: function(id, o, args) {
scope.create_upload_form(data);
},
callback: function(id, o, args) {
if (scope.options.editor_target&&scope.options.env=='editor') {
scope.options.editor_target.value=o.url;
Expand Down
2 changes: 1 addition & 1 deletion repository/repository_ajax.php
Expand Up @@ -66,7 +66,7 @@
}

if (!confirm_sesskey()) {
$err->error = get_string('invalidsesskey');
$err->error = get_string('invalidsesskey', 'error');
die(json_encode($err));
}

Expand Down

0 comments on commit a5159b8

Please sign in to comment.