summaryrefslogtreecommitdiff
path: root/modules/organize/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-01-23 14:07:59 -0800
committerBharat Mediratta <bharat@menalto.com>2013-01-23 14:07:59 -0800
commit937102e888dc7a5172fa97af5e5b6c4e35aa886d (patch)
treec7040459974aa37f3d2048d51dd71dcb082143c9 /modules/organize/controllers
parentd928064f0b7b4f12ce1371d7e0e61f6832f09a01 (diff)
parent80d6a895edb1cfc3dd0bcacd0d2c63b40c04670c (diff)
Merge pull request #97 from mikeage/organize_tag2
Add batch tagging via the organize module
Diffstat (limited to 'modules/organize/controllers')
-rw-r--r--modules/organize/controllers/organize.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index f090b8a9..97280489 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()