diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-01 19:11:01 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-01 19:11:01 +0000 |
commit | 512a532650670fa38fd4ef79f124ce237e4474a7 (patch) | |
tree | c5230dce813e9f96ff127de5dbb535b2ef046cef /core/controllers | |
parent | bed1bb48f33c1c20decb6b592b1d713f5c9fb48e (diff) |
Simplify the batch api by having the core event handlers for
start_batch and end_batch add and remove the batch id from the
session. Modules wishing to do batch processing, just need to fire
the start_batch and end_batch events. Other modules that need to be
aware of batches (i.e. notifications) just check the session for "batch_id".
Diffstat (limited to 'core/controllers')
-rw-r--r-- | core/controllers/scaffold.php | 8 | ||||
-rw-r--r-- | core/controllers/simple_uploader.php | 13 |
2 files changed, 7 insertions, 14 deletions
diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php index 2cdff2d3..45242b8c 100644 --- a/core/controllers/scaffold.php +++ b/core/controllers/scaffold.php @@ -219,7 +219,7 @@ class Scaffold_Controller extends Template_Controller { } $batch_id = mt_rand(); - module::event("start_add_batch", $batch_id); + module::event("start_batch"); cookie::set("add_photos_path", $path); $photo_count = 0; foreach (glob("$path/*.[Jj][Pp][Gg]") as $file) { @@ -227,7 +227,7 @@ class Scaffold_Controller extends Template_Controller { photo::create($parent, $file, basename($file), basename($file)); $photo_count++; } - module::event("end_add_batch", $batch_id); + module::event("end_batch"); if ($photo_count > 0) { log::success("content", "(scaffold) Added $photo_count photos", @@ -245,7 +245,7 @@ class Scaffold_Controller extends Template_Controller { $test_images = glob(APPPATH . "tests/images/*.[Jj][Pp][Gg]"); $batch_id = mt_rand(); - module::event("start_add_batch", $batch_id); + module::event("start_batch"); $album_count = $photo_count = 0; for ($i = 0; $i < $count; $i++) { set_time_limit(30); @@ -269,7 +269,7 @@ class Scaffold_Controller extends Template_Controller { $photo_count++; } } - module::event("end_add_batch", $batch_id); + module::event("end_batch"); if ($photo_count > 0) { log::success("content", "(scaffold) Added $photo_count photos"); diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php index 005071b0..5ae4bb2a 100644 --- a/core/controllers/simple_uploader.php +++ b/core/controllers/simple_uploader.php @@ -48,12 +48,7 @@ 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); - } + module::event("start_batch"); $temp_filename = upload::save("file"); $title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $path_info = pathinfo($temp_filename); @@ -70,10 +65,8 @@ 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); - } + module::event("end_batch"); + print json_encode(array("result" => "success")); } } |