diff options
author | Mike Miller <github@mikeage.net> | 2013-01-23 21:59:02 +0200 |
---|---|---|
committer | Mike Miller <github@mikeage.net> | 2013-01-23 22:58:45 +0200 |
commit | 80d6a895edb1cfc3dd0bcacd0d2c63b40c04670c (patch) | |
tree | 3dceec97ab1071c9409323227337ec16f821b940 /modules/organize/controllers | |
parent | 1927dd00e42062a98855d121ec8427b25d74d015 (diff) |
#1952 Add bulk tagging to the Organize module.
Allow a user to highlight one or more items (images, videos, or albums), and enter a tag (or tags, comma delimited) and apply it to all of the selected items. The code is based on the batchtag module.
If the tags module is not enabled, no changes to the Organize UI will be shown.
Diffstat (limited to 'modules/organize/controllers')
-rw-r--r-- | modules/organize/controllers/organize.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index b0c13e7d..b0158278 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -182,6 +182,28 @@ class Organize_Controller extends Controller { json::reply(null); } + function tag() { + access::verify_csrf(); + $input = Input::instance(); + + foreach (explode(",", $input->post("item_ids")) as $item_id) { + $item = ORM::factory("item", $item_id); + if (access::can("edit", $item)) { + // Assuming the user can view/edit the current item, loop + // through each tag that was submitted and apply it to + // the current item. + foreach (explode(",", $input->post("tag_names")) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + tag::add($item, $tag_name); + } + } + } + } + + json::reply(null); + } + private function _get_tree($item, $selected) { $tree = array(); $children = $item->viewable() |