From ed8689f768f81d2c3ed8bee70c43d4f7c71c108e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 28 Dec 2008 23:48:15 +0000 Subject: Expand on the maintenance code to make it more robust and give the admin more control. You can now track running tasks, resume stalled tasks, cancel running tasks, and remove finished tasks. Added graphics::compose() as a placeholder for future watermark operations. Added CSRF protection to maintenance urls. --- core/helpers/graphics.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'core/helpers/graphics.php') diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 68aacaca..62bde88a 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -128,11 +128,18 @@ class graphics_Core { ->save($output_file); } + /** + * Stub. + * @todo implement this + */ + public static function compose($input_file, $output_file, $other_args) { + } + /** * Return a query result that locates all items with dirty images. * @return Database_Result Query result */ - private static function _find_dirty_images_query() { + public static function find_dirty_images_query() { return Database::instance()->query( "SELECT `id` FROM `items` " . "WHERE (`thumb_dirty` = 1 AND (`type` <> 'album' OR `right` - `left` > 1))" . @@ -147,12 +154,12 @@ class graphics_Core { $db = Database::instance(); $db->query("UPDATE `items` SET `thumb_dirty` = 1, `resize_dirty` = 1"); - $count = self::_find_dirty_images_query()->count(); + $count = self::find_dirty_images_query()->count(); if ($count) { message::warning( sprintf(_("%d of your photos are out of date. %sClick here to fix them%s"), $count, "", ""), "graphics_dirty"); } @@ -165,7 +172,7 @@ class graphics_Core { public static function rebuild_dirty_images($task) { $db = Database::instance(); - $result = self::_find_dirty_images_query(); + $result = self::find_dirty_images_query(); $remaining = $result->count(); $completed = $task->get("completed", 0); @@ -194,9 +201,9 @@ class graphics_Core { } $task->set("completed", $completed); - $task->done = ($remaining == 0); - - if ($task->done) { + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; message::clear_permanent("graphics_dirty"); } } -- cgit v1.2.3