summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/scaffold.php8
-rw-r--r--core/controllers/simple_uploader.php13
-rw-r--r--core/helpers/core_event.php12
-rw-r--r--modules/local_import/controllers/local_import.php13
4 files changed, 22 insertions, 24 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"));
}
}
diff --git a/core/helpers/core_event.php b/core/helpers/core_event.php
index e430319d..64cc9376 100644
--- a/core/helpers/core_event.php
+++ b/core/helpers/core_event.php
@@ -34,4 +34,16 @@ class core_event_Core {
static function item_before_delete($item) {
access::delete_item($item);
}
+
+ static function start_batch() {
+ $batch_id = Session::instance()->get("batch_id");
+ if (empty($batch_id)) {
+ $batch_id = mt_rand();
+ Session::instance()->set("batch_id", $batch_id);
+ }
+ }
+
+ static function end_batch() {
+ Session::instance()->delete("batch_id");
+ }
}
diff --git a/modules/local_import/controllers/local_import.php b/modules/local_import/controllers/local_import.php
index 2b8248a4..8fc183b7 100644
--- a/modules/local_import/controllers/local_import.php
+++ b/modules/local_import/controllers/local_import.php
@@ -65,12 +65,7 @@ class Local_Import_Controller extends Controller {
}
$path = $this->input->post("path");
- $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");
$source_path = $path[0];
for ($i = 1; $i < count($path); $i++) { // skip the first path
@@ -97,10 +92,8 @@ class Local_Import_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"));
}