where("parent_id", $this->input->post("item_id")) ->where("type !=", "album") ->find_all(); // 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}")); } }