diff options
Diffstat (limited to 'core/helpers')
-rw-r--r-- | core/helpers/batch.php | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/core/helpers/batch.php b/core/helpers/batch.php index 98523f30..23c9e196 100644 --- a/core/helpers/batch.php +++ b/core/helpers/batch.php @@ -17,24 +17,24 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - class batch_Core { - static function operation($name, $item) { - if (!self::in_progress($name)) { - Session::instance()->set("operation_$name", "1"); - module::event("operation", $name, $item); - } + static function start() { + $session = Session::instance(); + $session->set("batch_level", $session->get("batch_level", 0) + 1); } - static function end_operation($name) { - if (self::in_progress($name)) { - module::event("end_operation", $name); - Session::instance()->set("operation_$name", null); + static function stop($name) { + $session = Session::instance(); + $batch_level = $session->get("batch_level", 0) - 1; + if ($batch_level > 0) { + $session->set("batch_level", $batch_level); + } else { + $session->delete("batch_level"); + module::event("batch_complete"); } } static function in_progress($name) { - $value = Session::instance()->get("operation_$name", null); - return !empty($value); + return Session::instance()->get("batch_level", 0) > 0; } } |