static function available_tasks() { // Delete extra search_records Database::instance()->query("DELETE FROM {search_records} " . "WHERE {search_records}.`item_id` NOT IN " . "(SELECT `id` FROM {items})"); list($remaining, $total, $percent) = search::stats(); return array(Task_Definition::factory()->callback("search_task::update_index")->name(t("Update Search Index"))->description($remaining ? t2("1 photo or album needs to be scanned", "%count (%percent%) of your photos and albums need to be scanned", $remaining, array("percent" => 100 - $percent)) : t("Search data is up-to-date"))->severity($remaining ? log::WARNING : log::SUCCESS)); }
static function available_tasks() { // Delete extra exif_records Database::instance()->query("DELETE FROM {exif_records} " . "WHERE {exif_records}.`item_id` NOT IN " . "(SELECT `id` FROM {items} WHERE {items}.`type` = 'photo')"); list($remaining, $total, $percent) = exif::stats(); return array(Task_Definition::factory()->callback("exif_task::update_index")->name(t("Extract EXIF data"))->description($remaining ? t2("1 photo needs to be scanned", "%count (%percent%) of your photos need to be scanned", $remaining, array("percent" => 100 - $percent)) : t("EXIF data is up-to-date"))->severity($remaining ? log::WARNING : log::SUCCESS)); }
static function available_tasks() { // Delete extra exif_records db::build()->delete("exif_records")->where("item_id", "NOT IN", db::build()->select("id")->from("items")->where("type", "=", "photo"))->execute(); list($remaining, $total, $percent) = exif::stats(); return array(Task_Definition::factory()->callback("exif_task::update_index")->name(t("Extract Exif data"))->description($remaining ? t2("1 photo needs to be scanned", "%count (%percent%) of your photos need to be scanned", $remaining, array("percent" => 100 - $percent)) : t("Exif data is up-to-date"))->severity($remaining ? log::WARNING : log::SUCCESS)); }
public function test_data_create() { access::verify_csrf(); list($form, $errors) = $this->_get_test_data_form(); $post = new Validation($_POST); $post->add_rules("albums", "numeric"); $post->add_rules("photos", "numeric"); $post->add_rules("comments", "numeric"); $post->add_rules("tags", "numeric"); $post->add_callbacks("albums", array($this, "_set_default")); $post->add_callbacks("photos", array($this, "_set_default")); $post->add_callbacks("comments", array($this, "_set_default")); $post->add_callbacks("tags", array($this, "_set_default")); if ($post->validate()) { $task_def = Task_Definition::factory()->callback("developer_task::create_content")->description(t("Create test content"))->name(t("Create Test Data")); $total = $post->albums + $post->photos + $post->comments + $post->tags; $success_msg = t("Successfully generated test data"); $error_msg = t("Problems with test data generation was encountered"); $task = task::create($task_def, array("total" => $total, "batch" => (int) ceil($total / 10), "success_msg" => $success_msg, "current" => 0, "error_msg" => $error_msg, "albums" => $post->albums, "photos" => $post->photos, "comments" => $post->comments, "tags" => $post->tags)); batch::start(); print json_encode(array("result" => "started", "max_iterations" => $total + 5, "url" => url::site("admin/developer/run_task/{$task->id}?csrf=" . access::csrf_token()), "task" => $task->as_array())); } else { $v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()), arr::overwrite($errors, $post->errors())); print json_encode(array("result" => "error", "form" => $v->__toString())); } }
static function available_tasks() { $q = emboss::find_dirty(); $n = $q->count(); $description = $n == 0 ? t('All photo overlays are up to date') : t2('one Photo needs its emboss overlay updated', "{$n} Photos need their emboss overlay updated", $n); $tasks[] = Task_Definition::factory()->callback('emboss_task::update_overlays')->name(t('Update photo embossing'))->description($description)->severity($n > 0 ? log::WARNING : log::SUCCESS); return $tasks; }
static function available_tasks() { // Automatically delete extra exif_coordinates whenever the maintance screen is loaded. db::build()->delete("exif_coordinates")->where("item_id", "NOT IN", db::build()->select("id")->from("items"))->execute(); // Display an option on the maintance screen for scanning existing photos // for GPS data (in case photos were uploaded before the module was active). return array(Task_Definition::factory()->callback("exif_gps_task::update_gps_index")->name(t("Extract Exif GPS data"))->description(t("Scan all photos for missing GPS data"))->severity(log::SUCCESS)); }
static function available_tasks() { $dirty_count = graphics::find_dirty_images_query()->count_records(); $tasks = array(); $tasks[] = Task_Definition::factory()->callback("gallery_task::rebuild_dirty_images")->name(t("Rebuild Images"))->description($dirty_count ? t2("You have one out of date photo", "You have %count out of date photos", $dirty_count) : t("All your photos are up to date"))->severity($dirty_count ? log::WARNING : log::SUCCESS); $tasks[] = Task_Definition::factory()->callback("gallery_task::update_l10n")->name(t("Update translations"))->description(t("Download new and updated translated strings"))->severity(log::SUCCESS); return $tasks; }
static function available_tasks() { if (aws_s3::can_schedule()) { return array(Task_Definition::factory()->callback("aws_s3::schedule_full_sync")->name(t("Synchronise with Amazon S3"))->description(t("Schedule a task to synchronise your Gallery 3 data/images with your Amazon S3 bucket"))->severity(log::SUCCESS)->set_flags(Task_Definition::CAN_RUN_NOW)); } else { return array(Task_Definition::factory()->callback("aws_s3_task::manual_sync")->name(t("Synchronise with Amazon S3"))->description(t("Synchronise your Gallery 3 data/images with your Amazon S3 bucket"))->severity(log::SUCCESS)); } }
static function available_tasks() { // Delete extra search_records Database::instance()->query("DELETE `search_records`.* FROM `search_records` " . "LEFT JOIN `items` ON (`search_records`.`item_id` = `items`.`id`) " . "WHERE `items`.`id` IS NULL"); // Insert missing search_records Database::instance()->query("INSERT INTO `search_records`(`item_id`) (" . " SELECT `items`.`id` FROM `items` " . " LEFT JOIN `search_records` ON (`search_records`.`item_id` = `items`.`id`) " . " WHERE `search_records`.`id` IS NULL)"); list($remaining, $total, $percent) = self::_get_stats(); return array(Task_Definition::factory()->callback("search_task::update_index")->name(t("Update Search Index"))->description($remaining ? t("Search index is %percent% up-to-date", array("percent" => $percent)) : t("Search index is up to date"))->severity($remaining ? log::WARNING : log::SUCCESS)); }
static function available_tasks() { if (g2_import::is_configured()) { g2_import::init(); return array(Task_Definition::factory()->callback("g2_import_task::import")->name(t("Import from Gallery 2"))->description(t("Gallery %version detected", array("version" => g2_import::version())))->severity(log::SUCCESS)); } else { return array(); } }
static function available_tasks() { $dirty_count = graphics::find_dirty_images_query()->count_records(); $tasks = array(); $tasks[] = Task_Definition::factory()->callback("gallery_task::rebuild_dirty_images")->name(t("Rebuild Images"))->description($dirty_count ? t2("You have one out of date photo", "You have %count out of date photos", $dirty_count) : t("All your photos are up to date"))->severity($dirty_count ? log::WARNING : log::SUCCESS); $tasks[] = Task_Definition::factory()->callback("gallery_task::update_l10n")->name(t("Update translations"))->description(t("Download new and updated translated strings"))->severity(log::SUCCESS); $tasks[] = Task_Definition::factory()->callback("gallery_task::file_cleanup")->name(t("Remove old files"))->description(t("Remove expired files from the logs and tmp directory"))->severity(log::SUCCESS); $tasks[] = Task_Definition::factory()->callback("gallery_task::fix")->name(t("Fix your Gallery"))->description(t("Fix a variety of problems that might cause your Gallery to act strangely. Requires maintenance mode."))->severity(log::SUCCESS); return $tasks; }
static function available_tasks() { // Total up all non-guest users in the users table that don't have a corresponding record // in the users_space_usages table. // If the result is greater then 0, display a warning for this task so the admin knows // a user is missing and it should be run. $missing_users = ORM::factory("user")->where("users.guest", "=", "0")->join("users_space_usages", "users.id", "users_space_usages.owner_id", "LEFT OUTER")->and_where("users_space_usages.owner_id", "IS", NULL)->count_all(); $tasks = array(); $tasks[] = Task_Definition::factory()->callback("quotas_task::update_quotasdb")->name(t("Rebuild user quotas table"))->description(t("Recalculates each users space usage."))->severity($missing_users ? log::WARNING : log::SUCCESS); return $tasks; }
static function available_tasks() { // Check for any albums listed in albumpasswords but not idcaches. // If found, set the severity for this task to warning, as there's // obviously something missing from idcaches. $bad_albums = ORM::factory("items_albumpassword")->join("albumpassword_idcaches", "items_albumpasswords.id", "albumpassword_idcaches.password_id", "LEFT OUTER")->and_where("albumpassword_idcaches.password_id", "IS", NULL)->count_all(); $tasks = array(); $tasks[] = Task_Definition::factory()->callback("albumpassword_task::update_idcaches")->name(t("Rebuild Album Password ID Caches DB"))->description(t("Logs the contents of all protected albums into the db."))->severity($bad_albums ? log::WARNING : log::SUCCESS); $tasks[] = Task_Definition::factory()->callback("albumpassword_task::lowercase_passwords")->name(t("Fix Password DB Casing"))->description(t("Fixes case sensitivity issues."))->severity(log::SUCCESS); return $tasks; }
function startTask($operation, $id) { access::verify_csrf(); $items = $this->input->post("item"); $item = ORM::factory("item", $id); $definition = $this->_getOperationDefinition($item, $operation); $task_def = Task_Definition::factory()->callback("organize_task::run")->description($definition["description"])->name($definition["name"]); $task = task::create($task_def, array("items" => $items, "position" => 0, "target" => $id, "type" => $definition["type"], "batch" => ceil(count($items) * 0.1))); // @todo If there is only one item then call task_run($task->id); Maybe even change js so // we can call finish as well. batch::start(); print json_encode(array("result" => "started", "runningMsg" => $definition["runningMsg"], "pauseMsg" => "<div class=\"gWarning\">{$definition['pauseMsg']}</div>", "resumeMsg" => "<div class=\"gWarning\">{$definition['resumeMsg']}</div>", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "type" => $task->get("type"), "status" => $task->status, "state" => $task->state, "done" => $task->done))); }
/** * Begin the task of adding photos. */ public function start() { access::verify_csrf(); $item = ORM::factory("item", Input::instance()->get("item_id")); foreach (Input::instance()->post("paths") as $path) { if (server_add::is_valid_path($path)) { $paths[] = array($path, null); } } $task_def = Task_Definition::factory()->callback("Server_Add_Controller::add")->description(t("Add photos or movies from the local server"))->name(t("Add from server")); $task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths)); print json_encode(array("result" => "started", "status" => $task->status, "url" => url::site("server_add/run/{$task->id}?csrf=" . access::csrf_token()))); }
public function create() { access::verify_csrf(); $form = $this->_get_theme_form(); if ($form->validate()) { $session = Session::instance(); $extract_path = $session->get_once("theme_extract_path"); $v = new View("admin_themeroller_progress.html"); $task_def = Task_Definition::factory()->callback("themeroller_task::create_theme")->description(t("Generate theme from a themeroller archive"))->name(t("Generate theme")); $v->task = task::create($task_def, array("path" => $extract_path, "user_name" => SafeString::purify(identity::active_user()->name), "original_name" => SafeString::purify($form->theme->original->value), "theme_name" => SafeString::purify($form->theme->theme_name->value), "display_name" => SafeString::purify($form->theme->display_name->value), "description" => SafeString::purify($form->theme->description->value), "author_url" => SafeString::purify($form->theme->author_url->value), "info_url" => SafeString::purify($form->theme->info_url->value), "discuss_url" => SafeString::purify($form->theme->discuss_url->value), "is_admin" => $session->get("themeroller_is_admin"))); json::reply(array("html" => (string) $v)); } else { json::reply(array("result" => "error", "html" => (string) $form)); } }
static function available_tasks() { $version = ''; if (g1_import::is_configured()) { g1_import::init(); // Guard from common case where the import has been // completed and the original files have been removed. if (is_dir(g1_import::$album_dir)) { $version = g1_import::version(); } } if (g1_import::is_initialized()) { return array(Task_Definition::factory()->callback('g1_import_task::import')->name(t('Import from Gallery 1'))->description(t('Gallery %version detected', array('version' => $version)))->severity(log::SUCCESS)); } return array(); }
/** * Begin the task of adding photos. */ public function start() { access::verify_csrf(); $item = ORM::factory("item", Input::instance()->get("item_id")); $task_def = Task_Definition::factory()->callback("Server_Add_Controller::add")->description(t("Add photos or movies from the local server"))->name(t("Add from server")); $task = task::create($task_def, array("item_id" => $item->id)); foreach (Input::instance()->post("paths") as $path) { if (server_add::is_valid_path($path)) { $entry = ORM::factory("server_add_entry"); $entry->path = $path; $entry->is_directory = intval(is_dir($path)); $entry->parent_id = null; $entry->task_id = $task->id; $entry->save(); } } json::reply(array("result" => "started", "status" => (string) $task->status, "url" => url::site("server_add/run/{$task->id}?csrf=" . access::csrf_token()))); }
static function available_tasks() { $version = ''; g2_import::lower_error_reporting(); if (g2_import::is_configured()) { g2_import::init(); // Guard from common case where the import has been // completed and the original files have been removed. if (class_exists("GalleryCoreApi")) { $version = g2_import::version(); } } g2_import::restore_error_reporting(); if (g2_import::is_initialized()) { return array(Task_Definition::factory()->callback("g2_import_task::import")->name(t("Import from Gallery 2"))->description(t("Gallery %version detected", array("version" => $version)))->severity(log::SUCCESS)); } return array(); }
function start($id) { access::verify_csrf(); $paths = unserialize(module::get_var("server_add", "authorized_paths")); $input_files = $this->input->post("path"); $files = array(); $total_count = 0; foreach (array_keys($paths) as $valid_path) { $path_length = strlen($valid_path); foreach ($input_files as $key => $path) { if ($valid_path != $path && strpos($path, $valid_path) === 0) { $relative_path = substr(dirname($path), $path_length); $name = basename($path); $files[$valid_path][] = array("path" => $relative_path, "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file"); $total_count++; unset($input_files[$key]); } } } if ($total_count == 0) { print json_encode(array("result" => "success", "url" => "", "task" => array("id" => -1, "done" => 1, "percent_complete" => 100, "status" => t("No Eligible files, import cancelled")))); return; } $task_def = Task_Definition::factory()->callback("server_add_task::add_from_server")->description(t("Add photos or movies from the local server"))->name(t("Add from server")); $task = task::create($task_def, array("item_id" => $id, "next_path" => 0, "files" => $files, "counter" => 0, "position" => 0, "total" => $total_count)); batch::start(); print json_encode(array("result" => "started", "url" => url::site("server_add/add_photo/{$task->id}?csrf=" . access::csrf_token()), "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done))); }
static function available_tasks() { $tasks[] = Task_Definition::factory()->callback("tag_task::clean_up_tags")->name(t("Clean up tags"))->description(t("Correct tag counts and remove tags with no items"))->severity(log::SUCCESS); return $tasks; }
static function item_created($item) { if ($item->is_movie()) { transcode::log("Item created - is a movie. Let's create a transcode task or 2.."); $ffmpegPath = module::get_var("transcode", "ffmpeg_path"); $fileObj = self::_getVideoInfo($item->file_path()); transcode::log($fileObj); // Save our needed variables $srcFile = $item->file_path(); $srcWidth = transcode::makeMultipleTwo($fileObj->video->width); $srcHeight = transcode::makeMultipleTwo($fileObj->video->height); $aspect = $srcWidth / $srcHeight; $srcFPS = $fileObj->video->fps; $srcAR = $fileObj->audio->samplerate; if ($srcAR > 44100) { $srcAR = 44100; } $accepted_sample_rates = array(11025, 22050, 44100); if (!in_array($srcAR, $accepted_sample_rates)) { // if the input sample rate isn't an accepted rate, find the next lowest rate that is $below = true; $rate = 0; if ($srcAR < 11025) { $rate = 11025; } else { foreach ($accepted_sample_rates as $r) { transcode::log("testing audio rate '" . $r . "' against input rate '" . $srcAR . "'"); if ($r < $srcAR) { $rate = $r; } } } $srcAR = $rate; } $srcACodec = module::get_var("transcode", "audio_codec"); $heights = array(); if (module::get_var("transcode", "resolution_240p")) { array_push($heights, 240); } if (module::get_var("transcode", "resolution_360p")) { array_push($heights, 360); } if (module::get_var("transcode", "resolution_480p")) { array_push($heights, 480); } if (module::get_var("transcode", "resolution_576p")) { array_push($heights, 576); } if (module::get_var("transcode", "resolution_720p")) { array_push($heights, 720); } if (module::get_var("transcode", "resolution_1080p")) { array_push($heights, 1080); } if (!is_dir(VARPATH . "modules/transcode/flv/" . $item->id)) { @mkdir(VARPATH . "modules/transcode/flv/" . $item->id); } $xtraFlags = module::get_var("transcode", "ffmpeg_flags", ""); foreach ($heights as $destHeight) { transcode::log("srcHeight: " . $srcHeight . ", destheight: " . $destHeight); // don't bother upscaling, there's no advantage to it... if ($destHeight > $srcHeight) { continue; } $destFormat = module::get_var("transcode", "format", "flv"); $destWidth = floor($destHeight * $aspect); if ($destWidth % 2) { $destWidth = ceil($destHeight * $aspect); } transcode::log("destination resolution: " . $destWidth . "x" . $destHeight); $destFile = VARPATH . "modules/transcode/flv/" . $item->id . "/" . $destWidth . "x" . $destHeight . ".flv"; switch ($destHeight) { case 240: $destVB = 128; $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; case 360: $destVB = 384; $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; case 480: $destVB = 1024; $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; case 576: $destVB = 2048; $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; case 720: $destVB = 4096; $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; case 1080: $destVB = 8192; $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break; } $destVB *= 1024; $srcAB *= 1024; $cmd = $ffmpegPath . " " . "-i \"" . $srcFile . "\" "; if ($fileObj->audio->has) { $cmd .= "-y -acodec " . $srcACodec . " " . "-ar " . $srcAR . " " . "-ab " . $srcAB . " "; } else { $cmd .= "-an "; } $cmd .= "-vb " . $destVB . " " . "-f " . $destFormat . " " . "-s " . $destWidth . "x" . $destHeight . " " . $xtraFlags . " " . "\"" . $destFile . "\""; transcode::log($cmd); $task_def = Task_Definition::factory()->callback("transcode_task::transcode")->name("Video Transcode to " . $destWidth . "x" . $destHeight)->severity(log::SUCCESS); $task = task::create($task_def, array("ffmpeg_cmd" => $cmd, "width" => $destWidth, "height" => $destHeight, "item_id" => $item->id)); task::run($task->id); } } }
static function available_tasks() { $dirty_count = graphics::find_dirty_images_query()->count(); return array(Task_Definition::factory()->callback("core_task::rebuild_dirty_images")->name(t("Rebuild Images"))->description($dirty_count ? t2("You have one out-of-date photo", "You have %count out-of-date photo", $dirty_count) : t("All your images are up to date"))->severity($dirty_count ? log::WARNING : log::SUCCESS)); }
static function available_tasks() { return array(Task_Definition::factory()->callback("rescue_task::fix_mptt")->name(t("Fix Album/Photo hierarchy"))->description(t("Fix problems where your album/photo breadcrumbs are out of " . "sync with your actual hierarchy."))->severity(log::SUCCESS), Task_Definition::factory()->callback("rescue_task::fix_internet_addresses")->name(t("Fix internet addresses"))->description(t("Fix internet addresses broken when upgrading to Beta 3"))->severity(log::SUCCESS)); }
static function available_tasks() { return array(Task_Definition::factory()->callback("rescue_task::fix_internet_addresses")->name(t("Fix internet addresses"))->description(t("Fix internet addresses broken when upgrading to Beta 3"))->severity(log::SUCCESS)); }
static function schedule_item_sync($item) { if (!self::can_schedule()) { throw new Exception("Unable to initialize schedule"); } $item_id = null; if (is_object($item) && $item instanceof Item_Model) { $item_id = $item->id; } else { if (is_numeric($item)) { $item_id = $item; } else { throw new Exception("Un-intelligible item reference passed."); } } $task_def = Task_Definition::factory()->callback("aws_s3_task::upload_item")->name("Amazon S3 item upload (ID: " . $item_id . ")")->severity(log::SUCCESS); $task = task::create($task_def, array("item_id" => $item_id)); self::schedule_task($task); }
static function available_tasks() { return array(Task_Definition::factory()->callback("picasa_faces_task::import_faces")->name(t("Import faces from Picasa"))->description(t("Scan all albums for Picasa face data and add any faces that don't already exist"))->severity(log::SUCCESS)); }
static function available_tasks() { $tasks[] = Task_Definition::factory()->callback("date_tag_task::date_tag_all")->name(t("Add tags for dates"))->description(t("Add tags for dates of all images that have already been uploaded"))->severity(log::SUCCESS); return $tasks; }
static function available_tasks() { $tasks[] = Task_Definition::factory()->callback("auto_date_task::set_auto_date_all")->name(t("Set captured date for all unset items"))->description(t("Attempt to guess the captured date based on the filename (NULL capture dates only)"))->severity(log::SUCCESS); return $tasks; }
static function available_tasks() { return array(Task_Definition::factory()->callback("aws_s3_task::sync")->name(t("Syncronise with Amazon S3"))->description(t("Syncronise your Gallery 3 data/images with your Amazon S3 bucket"))->severity(log::SUCCESS)); }