From 5052bfd97a2ef490789202ec29c8d693f8f8aa5f Mon Sep 17 00:00:00 2001 From: rWatcher Date: Wed, 30 Sep 2009 14:13:30 -0400 Subject: [PATCH] Added an option for tagging items in sub albums. --- modules/batchtag/controllers/batchtag.php | 22 ++++++++++++++++----- modules/batchtag/helpers/batchtag_theme.php | 5 +++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/batchtag/controllers/batchtag.php b/modules/batchtag/controllers/batchtag.php index fc17f594..e4bbbf73 100644 --- a/modules/batchtag/controllers/batchtag.php +++ b/modules/batchtag/controllers/batchtag.php @@ -24,11 +24,23 @@ class BatchTag_Controller extends Controller { // Prevent Cross Site Request Forgery access::verify_csrf(); - // Generate an array of all non-album items in the current album. - $children = ORM::factory("item") - ->where("parent_id", $this->input->post("item_id")) - ->where("type !=", "album") - ->find_all(); + // Figure out if the contents of sub-albums should also be tagged + $str_tag_subitems = Input::instance()->post("tag_subitems"); + + $children = ""; + if ($str_tag_subitems == false) { + // Generate an array of all non-album items in the current album. + $children = ORM::factory("item") + ->where("parent_id", $this->input->post("item_id")) + ->where("type !=", "album") + ->find_all(); + } else { + // Generate an array of all non-album items in the current album + // and any sub albums. + $children = ORM::factory("item", $this->input->post("item_id")) + ->where("type !=", "album") + ->descendants(); + } // Loop through each item in the album and make sure the user has // access to view and edit it. diff --git a/modules/batchtag/helpers/batchtag_theme.php b/modules/batchtag/helpers/batchtag_theme.php index bb9a08cb..a3457be2 100644 --- a/modules/batchtag/helpers/batchtag_theme.php +++ b/modules/batchtag/helpers/batchtag_theme.php @@ -43,6 +43,11 @@ class batchtag_theme_Core { $label = t("Tag everything in this album:"); $group = $form->group("add_tag")->label("Add Tag"); $group->input("name")->label($label)->rules("required|length[1,64]"); + $group->checkbox("tag_subitems") + ->label(t("Include sub-albums?")) + ->value(true) + ->checked(false); + $group->hidden("item_id")->value($item->id); $group->submit("")->value(t("Add Tag")); $block->content->form = $form;