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. foreach ($children as $child) { if (access::can("view", $child) && access::can("edit", $child)) { // Assuming the user can view/edit the current item, loop // through each tag that was submitted and apply it to // the current item. foreach (split(",", $this->input->post("name")) as $tag_name) { $tag_name = trim($tag_name); if ($tag_name) { tag::add($child, $tag_name); } } } } // Redirect back to the album. $item = ORM::factory("item", $this->input->post("item_id")); url::redirect(url::abs_site("{$item->type}s/{$item->id}")); } }