From 23b0abb9742d3418484fe8d01609f6849d7960ce Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 4 Mar 2009 08:51:49 +0000 Subject: 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. --- core/controllers/scaffold.php | 10 ++++------ core/controllers/simple_uploader.php | 8 +++++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php index bd4c1f22..76b4ff71 100644 --- a/core/controllers/scaffold.php +++ b/core/controllers/scaffold.php @@ -201,8 +201,7 @@ class Scaffold_Controller extends Template_Controller { throw new Exception("@todo BAD_ALBUM"); } - batch::operation("add", $parent); - + batch::start(); cookie::set("add_photos_path", $path); $photo_count = 0; foreach (glob("$path/*.[Jj][Pp][Gg]") as $file) { @@ -210,7 +209,7 @@ class Scaffold_Controller extends Template_Controller { photo::create($parent, $file, basename($file), basename($file)); $photo_count++; } - batch::end_operation("add"); + batch::stop(); if ($photo_count > 0) { log::success("content", "(scaffold) Added $photo_count photos", @@ -227,8 +226,7 @@ class Scaffold_Controller extends Template_Controller { $test_images = glob(APPPATH . "tests/images/*.[Jj][Pp][Gg]"); - batch::operation("add", ORM::factory("item", 1)); - + batch::start(); $album_count = $photo_count = 0; for ($i = 0; $i < $count; $i++) { set_time_limit(30); @@ -252,7 +250,7 @@ class Scaffold_Controller extends Template_Controller { $photo_count++; } } - batch::end_operation("add"); + batch::stop(); 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 38eb5c38..0e2368e2 100644 --- a/core/controllers/simple_uploader.php +++ b/core/controllers/simple_uploader.php @@ -40,6 +40,10 @@ class Simple_Uploader_Controller extends Controller { print $v; } + public function start() { + batch::start(); + } + public function add_photo($id) { $album = ORM::factory("item", $id); access::required("edit", $album); @@ -48,7 +52,6 @@ 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::operation("add", $album); $temp_filename = upload::save("file"); $title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $path_info = pathinfo($temp_filename); @@ -65,8 +68,7 @@ class Simple_Uploader_Controller extends Controller { } public function finish() { - batch::end_operation("add"); - + batch::stop(); print json_encode(array("result" => "success")); } } -- cgit v1.2.3