diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-28 20:12:54 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-28 20:12:54 +0000 |
commit | bed1bb48f33c1c20decb6b592b1d713f5c9fb48e (patch) | |
tree | 24ede306b64a9cc56634680bb504b1092ccb6145 /core/controllers/simple_uploader.php | |
parent | c04ff8e02f01691dc2e325efc523e43f3aebaf95 (diff) |
The scaffolding, simple_uploader and local_import now call two new
events: start_add_batch and end_add_batch. The parameter is a batch
id which is generated on the first add request. The protocol is call
the add_photo as many times as required and then call finish when
done.
Also renamed the add method in local_import to add_photo so it is
consistent with simple_uploader
Diffstat (limited to 'core/controllers/simple_uploader.php')
-rw-r--r-- | core/controllers/simple_uploader.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php index b56bce16..005071b0 100644 --- a/core/controllers/simple_uploader.php +++ b/core/controllers/simple_uploader.php @@ -48,6 +48,12 @@ class Simple_Uploader_Controller extends Controller { $file_validation = new Validation($_FILES); $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]"); if ($file_validation->validate()) { + $batch_id = Session::instance()->get("batch_id"); + if (empty($batch_id)) { + $batch_id = mt_rand(); + module::event("start_add_batch", $batch_id); + Session::instance()->set("batch_id", $batch_id); + } $temp_filename = upload::save("file"); $title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $path_info = pathinfo($temp_filename); @@ -64,6 +70,10 @@ class Simple_Uploader_Controller extends Controller { } public function finish() { + $batch_id = Session::instance()->get_once("batch_id"); + if (!empty($batch_id)) { + module::event("end_add_batch", $batch_id); + } print json_encode(array("result" => "success")); } } |