Commit 22417b28 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

changes to file upload so it works with ajaxlogin

parent f1f359b9
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('IFRAME', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
// Upload a temporary file to attach to a blog post.
......@@ -39,7 +40,6 @@ $createid = param_variable('createid');
// Ignore possible file name clashes; they should be dealt with in the
// javascript on the edit blog post page.
safe_require('artefact', 'blog');
$attach = ArtefactTypeBlogPost::save_attachment_temporary('userfile', session_id() . $createid,
$result->uploadnumber);
......
// file.js
function ajaxlogin_iframe(form, crap) {
save_orig_data = false;
sendjsonrequest(
config.wwwroot + 'minilogin.php',
{'login_username': form.elements['login_username'].value, 'login_password': form.elements['login_password'].value, 'pieform_login': ''},
'POST',
function(data) {
removeElement('ajax-login-form');
removeElement('overlay');
config.sesskey = data.message;
uploader.getresult({"uploadnumber":$('uploadnumber').value,"message": get_string('timeouterror'),"problem": true});
},
function() {},
true
);
save_orig_data = true;
}
// The file browser part needs to be kept relatively separated from
// the file uploader because they are used slightly differently in the
// my files screen and the edit blog post screen
......@@ -608,7 +626,7 @@ function FileUploader(element, uploadscript, statevars, foldername, folderid, up
appendChildNodes(self.form,
INPUT({'type':'hidden', 'name':'parentfoldername', 'value':self.foldername}),
INPUT({'type':'hidden', 'name':'collideaction', 'value':collideaction}),
INPUT({'type':'hidden', 'name':'uploadnumber', 'value':self.nextupload}));
INPUT({'type':'hidden', 'id' : 'uploadnumber', 'name':'uploadnumber', 'value':self.nextupload}));
appendChildNodes(self.form,
INPUT({'type':'hidden', 'name':'parentfolder', 'value':self.folderid}));
......@@ -630,7 +648,10 @@ function FileUploader(element, uploadscript, statevars, foldername, folderid, up
}
this.getresult = function(data) {
if (!data.error) {
if (data.problem) {
var image = 'images/icon_problem.gif';
}
else if (!data.error) {
var image = 'images/success.gif';
}
else {
......
......@@ -83,6 +83,7 @@ $string['parentfolder'] = 'Parent folder';
$string['Preview'] = 'Preview';
$string['savechanges'] = 'Save changes';
$string['Size'] = 'Size';
$string['timeouterror'] = 'File upload failed: try uploading the file again';
$string['title'] = 'Name';
$string['titlefieldisrequired'] = 'The name field is required';
$string['Type'] = 'Type';
......
......@@ -126,6 +126,7 @@ class PluginArtefactFile extends PluginArtefact {
'nofilesfound',
'overwrite',
'savechanges',
'timeouterror',
'title',
'titlefieldisrequired',
'unlinkthisfilefromblogposts?',
......
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('IFRAME', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'file');
global $USER;
......@@ -94,7 +95,7 @@ $result->quota = $USER->get('quota');
$result->quotaused = $USER->get('quotaused');
$r = json_encode($result);
log_debug($r);
$frame = <<< EOF
<html><head><script>
<!--
......
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