mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-10 17:29:18 -04:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user