Commit 61da923e authored by Penny Leach's avatar Penny Leach
Browse files

Fixing bugs in import and added earlier quota check

parent 3778367a
......@@ -310,7 +310,8 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
global $REMOTEWWWROOT;
require_once('import.php');
if (!$user = find_remote_user($username, $REMOTEWWWROOT)) {
list ($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
if (!$user) {
throw new ImportException("Could not find user $username for $REMOTEWWWROOT");
}
......@@ -336,6 +337,16 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
throw new ImportException('Invalid importdata: ' . $e->getMessage());
}
if (!array_key_exists('totalsize', $importdata)) {
throw new ImportException('Invalid importdata: missing totalsize');
}
if (!$user->quota_allowed($importdata['totalsize'])) {
$e = new ImportException('Exceeded user quota');
$e->set_log_off();
throw $e;
}
$queue->data = serialize($importdata);
update_record('import_queue', $queue);
......
......@@ -275,7 +275,7 @@ class FilesImporter extends Importer {
$savedfiles = array(); // to put files into so we can delete them should we encounter an exception
foreach ($this->files as $f) {
try {
$data = array(
$data = (object)array(
'title' => $f->wantsfilename,
'description' => $f->wantsfilename . ' (' . get_string('importedfrom', 'mahara', $this->get('importertransport')->get_description()) . ')',
'parent' => $dir,
......
Supports Markdown
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