summaryrefslogtreecommitdiff
path: root/modules/local_import
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-03-04 08:51:49 +0000
committerBharat Mediratta <bharat@menalto.com>2009-03-04 08:51:49 +0000
commit23b0abb9742d3418484fe8d01609f6849d7960ce (patch)
tree917e2816d561036055769c1723382ab0de4f6431 /modules/local_import
parentb493a534f2966e23eb0244654e8929320721da8e (diff)
Redefine the batch API to be very very simple. You call
batch::start() before starting a series of events, and batch::stop() when you're done. In batch mode, the notification module will store up pending notifications. When the batch job is complete, it'll send a single digested email to each user for all of her notifications. Updated the scaffold and local_import to use this. Haven't modified SimpleUploader yet.
Diffstat (limited to 'modules/local_import')
-rw-r--r--modules/local_import/controllers/local_import.php11
-rw-r--r--modules/local_import/js/local_import.js10
2 files changed, 15 insertions, 6 deletions
diff --git a/modules/local_import/controllers/local_import.php b/modules/local_import/controllers/local_import.php
index 64483fb0..8a6ee78a 100644
--- a/modules/local_import/controllers/local_import.php
+++ b/modules/local_import/controllers/local_import.php
@@ -53,6 +53,10 @@ class Local_Import_Controller extends Controller {
print $tree;
}
+ function start() {
+ batch::start();
+ }
+
function add_photo($id) {
access::verify_csrf();
@@ -69,11 +73,9 @@ class Local_Import_Controller extends Controller {
throw new Exception("@todo BAD_PATH");
}
- batch::operation("add", $parent);
-
$source_path = $path[0];
// The first path corresponds to the source directory so we can just skip it.
- for ($i = 1; $i < count($path); $i++) {
+ for ($i = 1; $i < count($path); $i++) {
$source_path .= "/$path[$i]";
$pathinfo = pathinfo($source_path);
set_time_limit(30);
@@ -97,8 +99,7 @@ class Local_Import_Controller extends Controller {
}
public function finish() {
- batch::end_operation("add");
-
+ batch::stop();
print json_encode(array("result" => "success"));
}
diff --git a/modules/local_import/js/local_import.js b/modules/local_import/js/local_import.js
index ba9f63b0..c9645bfc 100644
--- a/modules/local_import/js/local_import.js
+++ b/modules/local_import/js/local_import.js
@@ -66,10 +66,18 @@ function do_import(submit, event) {
var check_list = $("#gLocalImport :checkbox[checked]");
process_length = check_list.length;
current = 0;
+ var base_url = $("#gLocalImport form :hidden[name='base_url']")[0].value;
+ $.ajax({async: false,
+ success: function(data, textStatus) {
+ document.location.reload();
+ },
+ dataType: "json",
+ type: "POST",
+ url: base_url + "local_import/start"
+ });
$.each(check_list, function () {
process_checkbox(this);
});
- var base_url = $("#gLocalImport form :hidden[name='base_url']")[0].value;
$.ajax({async: false,
success: function(data, textStatus) {
document.location.reload();