diff options
Diffstat (limited to 'modules/photoannotation/controllers')
| -rw-r--r-- | modules/photoannotation/controllers/admin_photoannotation.php | 312 | ||||
| -rw-r--r-- | modules/photoannotation/controllers/photoannotation.php | 251 | 
2 files changed, 563 insertions, 0 deletions
| diff --git a/modules/photoannotation/controllers/admin_photoannotation.php b/modules/photoannotation/controllers/admin_photoannotation.php new file mode 100644 index 00000000..dc7436f6 --- /dev/null +++ b/modules/photoannotation/controllers/admin_photoannotation.php @@ -0,0 +1,312 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ +class Admin_Photoannotation_Controller extends Admin_Controller { +  public function index() { +    print $this->_get_view(); +  } +   +  public function converter() { +    print $this->_get_converter_view(); +  } +   +  public function tagsmaintanance($delete) { +    print $this->_get_tagsmaintanance_view($delete); +  } + +  public function converthandler() { +    access::verify_csrf(); +    $form = $this->_get_converter_form(); +    if ($form->validate()) { +      //Load the source tag +      $sourcetag = ORM::factory("tag", $form->sourcetag->value); +      if (!$sourcetag->loaded()) { +        message::error(t("The specified tag could not be found")); +        url::redirect("admin/photoannotation/converter"); +      } +      //Load the target user +      $targetuser = ORM::factory("user", $form->targetuser->value); +      if (!$targetuser->loaded()) { +        message::error(t("The specified person could not be found")); +        url::redirect("admin/photoannotation/converter"); +      } +      //Load all existing tag annotations +      $tag_annotations = ORM::factory("items_face")->where("tag_id", "=", $sourcetag->id)->find_all(); +      //Disable user notifications so that users don't get flooded with mails +      $old_notification_setting = module::get_var("photoannotation", "nonotifications", false); +      module::set_var("photoannotation", "nonotifications", true, true); +      foreach ($tag_annotations as $tag_annotation) { +        photoannotation::saveuser($targetuser->id, $tag_annotation->item_id, $tag_annotation->x1, $tag_annotation->y1, $tag_annotation->x2, $tag_annotation->y2, $tag_annotation->description); +        //Delete the old annotation +        $tag_annotation->delete(); +      } +      //Remove and delete old tag +      if ($form->deletetag->value) { +        $this->_remove_tag($sourcetag, true); +      } elseif ($form->removetag->value) { +        $this->_remove_tag($sourcetag, false); +      } +      module::set_var("photoannotation", "nonotifications", $old_notification_setting, true); +      message::success(t("%count tag annotations (%tagname) have been converted to user annotations (%username)", array("count" => count($tag_annotations), "tagname" => $sourcetag->name, "username" => $targetuser->display_name()))); +      url::redirect("admin/photoannotation/converter"); +    } +    print $this->_get_converter_view($form); +  } +   +  private function _remove_tag($tag, $delete) { +    $name = $tag->name; +    db::build()->delete("items_tags")->where("tag_id", "=", $tag->id)->execute(); +    if ($delete) { +      $tag->delete(); +    } +  } + +  public function handler() { +    access::verify_csrf(); + +    $form = $this->_get_form(); +    if ($form->validate()) { +      module::set_var( +        "photoannotation", "noborder", $form->hoverphoto->noborder->value, true); +      module::set_var( +        "photoannotation", "bordercolor", $form->hoverphoto->bordercolor->value); +      module::set_var( +        "photoannotation", "noclickablehover", $form->hoverclickable->noclickablehover->value, true); +      module::set_var( +        "photoannotation", "clickablehovercolor", $form->hoverclickable->clickablehovercolor->value); +      module::set_var( +        "photoannotation", "nohover", $form->hovernoclickable->nohover->value, true); +      module::set_var( +        "photoannotation", "hovercolor", $form->hovernoclickable->hovercolor->value); +      module::set_var( +        "photoannotation", "showusers", $form->legendsettings->showusers->value, true); +      module::set_var( +        "photoannotation", "showfaces", $form->legendsettings->showfaces->value, true); +      module::set_var( +        "photoannotation", "shownotes", $form->legendsettings->shownotes->value, true); +      module::set_var( +        "photoannotation", "fullname", $form->legendsettings->fullname->value, true); +      module::set_var( +        "photoannotation", "nonotifications", $form->notifications->nonotifications->value, true); +      module::set_var( +        "photoannotation", "notificationoptout", $form->notifications->notificationoptout->value, true); +      module::set_var( +        "photoannotation", "allowguestsearch", $form->notifications->allowguestsearch->value, true); +      module::set_var( +        "photoannotation", "newtagsubject", strip_tags($form->newtagmail->newtagsubject->value)); +      module::set_var( +        "photoannotation", "newtagbody", strip_tags($form->newtagmail->newtagbody->value)); +      module::set_var( +        "photoannotation", "newcommentsubject", strip_tags($form->newcommentmail->newcommentsubject->value)); +      module::set_var( +        "photoannotation", "newcommentbody", strip_tags($form->newcommentmail->newcommentbody->value)); +      module::set_var( +        "photoannotation", "updatedcommentsubject", strip_tags($form->updatedcommentmail->updatedcommentsubject->value)); +      module::set_var( +        "photoannotation", "updatedcommentbody", strip_tags($form->updatedcommentmail->updatedcommentbody->value)); +      module::set_var( +        "photoannotation", "onuserdelete", $form->onuserdelete->onuserdelete->value); +      message::success(t("Your settings have been saved.")); +      url::redirect("admin/photoannotation"); +    } +    print $this->_get_view($form); +  } + +  private function _get_view($form=null) { +    $v = new Admin_View("admin.html"); +    $v->page_title = t("Photo annotation"); +    $v->content = new View("admin_photoannotation.html"); +    $v->content->form = empty($form) ? $this->_get_form() : $form; +    return $v; +  } + +  private function _get_converter_view($form=null) { +    $v = new Admin_View("admin.html"); +    $v->page_title = t("Photo annotation converter"); +    $v->content = new View("admin_photoannotation_converter.html"); +    $v->content->form = empty($form) ? $this->_get_converter_form() : $form; +    return $v; +  } + +  private function _get_tagsmaintanance_view($delete = false) { +    $tag_orpanes_count = 0; +    $user_orphanes_count = 0; +    $item_orphanes_count = 0; +    $tag_orpanes_deleted = 0; +    $user_orphanes_deleted = 0; +    $item_orphanes_deleted = 0; +    //check all tag annotations +    $tag_annotations = ORM::factory("items_face")->find_all(); +    foreach ($tag_annotations as $tag_annotation) { +      $check_tag = ORM::factory("tag")->where("id", "=", $tag_annotation->tag_id)->find(); +      if (!$check_tag->loaded()) { +        if ($delete) { +          $tag_annotation->delete(); +          $tag_orpanes_deleted++; +        } else { +          $tag_orpanes_count++; +        } +      } else { +        $check_item = ORM::factory("item")->where("id", "=", $tag_annotation->item_id)->find(); +        if (!$check_item->loaded()) { +          if ($delete) { +            $tag_annotation->delete(); +            $item_orpanes_deleted++; +          } else { +            $item_orpanes_count++; +          } +        } +      } +    } +    //check all user annotations +    $user_annotations = ORM::factory("items_user")->find_all(); +    foreach ($user_annotations as $user_annotation) { +      $check_user = ORM::factory("user")->where("id", "=", $user_annotation->user_id)->find(); +      if (!$check_user->loaded()) { +        if ($delete) { +          $user_annotation->delete(); +          $user_orpanes_deleted++; +        } else { +          $user_orphanes_count++; +        } +      } else { +        $check_item = ORM::factory("item")->where("id", "=", $user_annotation->item_id)->find(); +        if (!$check_item->loaded()) { +          if ($delete) { +            $user_annotation->delete(); +            $item_orpanes_deleted++; +          } else { +            $item_orpanes_count++; +          } +        } +      } +    } +     +    //check all user annotations +    $note_annotations = ORM::factory("items_note")->find_all(); +    foreach ($note_annotations as $note_annotation) { +      $check_item = ORM::factory("item")->where("id", "=", $note_annotation->item_id)->find(); +      if (!$check_item->loaded()) { +        if ($delete) { +          $note_annotation->delete(); +          $item_orpanes_deleted++; +        } else { +          $item_orpanes_count++; +        } +      } +    } +    $v = new Admin_View("admin.html"); +    $v->page_title = t("Photo annotation tags maintanance"); +    $v->content = new View("admin_photoannotation_tagsmaintanance.html"); +    $v->content->tag_orpanes_count = $tag_orpanes_count; +    $v->content->user_orphanes_count = $user_orphanes_count; +    $v->content->item_orphanes_count = $item_orphanes_count; +    $v->content->tag_orpanes_deleted =  $tag_orpanes_deleted; +    $v->content->user_orphanes_deleted = $user_orphanes_deleted; +    $v->content->item_orphanes_deleted = $item_orphanes_deleted; +    $v->content->dodeletion = $delete; +    return $v; +  } +   +  private function _get_converter_form() { +    //get all tags +    $tags = ORM::factory("tag")->order_by("name", "ASC")->find_all(); +    foreach ($tags as $tag) { +      $tag_array[$tag->id] = $tag->name; +    } +    //get all users +    $users = ORM::factory("user")->order_by("name", "ASC")->find_all(); +    foreach ($users as $user) { +      $user_array[$user->id] = $user->display_name(); +    } +    $form = new Forge("admin/photoannotation/converthandler", "", "post", array("id" => "g-admin-form")); +    $form->dropdown("sourcetag")->label(t("Select tag")) +      ->options($tag_array);	 +    $form->dropdown("targetuser")->label(t("Select user")) +      ->options($user_array);	 +    $form->checkbox("deletetag")->label(t("Delete the tag after conversion."));	 +    $form->checkbox("removetag")->label(t("Remove the tag from photos after conversion."));	 +    $form->submit("submit")->value(t("Convert")); +    return $form; +  } + +  private function _get_form() { +    if (module::is_active("comment")) { +      $comment_required = ""; +    } else { +      $comment_required = " (comment module required)"; +    } +    $form = new Forge("admin/photoannotation/handler", "", "post", array("id" => "g-admin-form")); +    $group = $form->group("hoverphoto")->label(t("Hovering over the photo")); +    $group->checkbox("noborder")->label(t("Don't show borders.")) +      ->checked(module::get_var("photoannotation", "noborder", false));	 +    $group->input("bordercolor")->label(t('Border color')) +      ->value(module::get_var("photoannotation", "bordercolor", "000000")) +      ->rules("valid_alpha_numeric|length[6]"); +    $group = $form->group("hoverclickable")->label(t("Hovering over a clickable annotation")); +    $group->checkbox("noclickablehover")->label(t("Don't show borders.")) +      ->checked(module::get_var("photoannotation", "noclickablehover", false));	 +    $group->input("clickablehovercolor")->label(t('Border color')) +      ->value(module::get_var("photoannotation", "clickablehovercolor", "00AD00")) +      ->rules("valid_alpha_numeric|length[6]"); +    $group = $form->group("hovernoclickable")->label(t("Hovering over a non-clickable annotation")); +    $group->checkbox("nohover")->label(t("Don't show borders.")) +      ->checked(module::get_var("photoannotation", "nohover", false));	 +    $group->input("hovercolor")->label(t('Border color')) +      ->value(module::get_var("photoannotation", "hovercolor", "990000")) +      ->rules("valid_alpha_numeric|length[6]"); +    $group = $form->group("legendsettings")->label(t("Legend settings")); +    $group->checkbox("showusers")->label(t("Show user annotations below photo.")) +      ->checked(module::get_var("photoannotation", "showusers", false));	 +    $group->checkbox("showfaces")->label(t("Show tag annotations below photo.")) +      ->checked(module::get_var("photoannotation", "showfaces", false));	 +    $group->checkbox("shownotes")->label(t("Show note annotations below photo.")) +      ->checked(module::get_var("photoannotation", "shownotes", false));	 +    $group->checkbox("fullname")->label(t("Show full name of a user instead of the username on annotations (username will be dispayed for users without a full name).")) +      ->checked(module::get_var("photoannotation", "fullname", false));	 +    $group = $form->group("notifications")->label(t("Notification and people cloud settings")); +    $group->checkbox("nonotifications")->label(t("Disable user notifications.")) +      ->checked(module::get_var("photoannotation", "nonotifications", false));	 +    $group->checkbox("notificationoptout")->label(t("Notify users by default (only applies to new users and user who have not saved their profile after installing this module).")) +      ->checked(module::get_var("photoannotation", "notificationoptout", false));	 +    $group->checkbox("allowguestsearch")->label(t("Show people cloud and allow people search for guests.")) +      ->checked(module::get_var("photoannotation", "allowguestsearch", false));	 +    $group = $form->group("newtagmail")->label(t("Customize the mail sent to users when a user annotation is created")); +    $group->input("newtagsubject")->label(t("Subject")) +      ->value(module::get_var("photoannotation", "newtagsubject", "Someone tagged a photo of you"));	 +    $group->textarea("newtagbody")->label(t("Body (allowed placeholders: %name = name of the recipient, %url = link to the item that was tagged)")) +      ->value(module::get_var("photoannotation", "newtagbody", "Hello %name, please visit %url to view the photo."));	 +    $group = $form->group("newcommentmail")->label(t("Customize the mail sent to users when a comment is added". $comment_required)); +    $group->input("newcommentsubject")->label(t("Subject")) +      ->value(module::get_var("photoannotation", "newcommentsubject", "Someone added a comment to photo of you"));	 +    $group->textarea("newcommentbody")->label(t("Body (allowed placeholders: %name = name of the recipient, %url = link to the item that was commented on)")) +      ->value(module::get_var("photoannotation", "newcommentbody", "Hello %name, please visit %url to read the comment."));	 +    $group = $form->group("updatedcommentmail")->label(t("Customize the mail sent to users when a comment is updated". $comment_required)); +    $group->input("updatedcommentsubject")->label(t("Subject")) +      ->value(module::get_var("photoannotation", "updatedcommentsubject", "Someone updated a comment to photo of you"));	 +    $group->textarea("updatedcommentbody")->label(t("Body (allowed placeholders: %name = name of the recipient, %url = link to the item that was commented on)")) +      ->value(module::get_var("photoannotation", "updatedcommentbody", "Hello %name, please visit %url to read the comment."));	 +    $group = $form->group("onuserdelete")->label(t("Auto conversion settings")); +    $group->dropdown("onuserdelete")->label(t("When deleting a user do the following with all annotations associated with this user")) +      ->options(array("0" => t("Delete annotation"), "1" => t("Convert to tag annotation"), "2" =>  t("Convert to note annotation"))) +      ->selected(module::get_var("photoannotation", "onuserdelete", "0"));	 +    $form->submit("submit")->value(t("Save")); +    return $form; +  } +} diff --git a/modules/photoannotation/controllers/photoannotation.php b/modules/photoannotation/controllers/photoannotation.php new file mode 100644 index 00000000..ed6083e5 --- /dev/null +++ b/modules/photoannotation/controllers/photoannotation.php @@ -0,0 +1,251 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2010 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ +class photoannotation_Controller extends Controller { +  public function showuser() { +    if (identity::active_user()->guest && !module::get_var("photoannotation", "allowguestsearch", false)) { +      message::error(t("You have to log in to perform a people search.")); +      url::redirect(url::site()); +      return; +    } +    $form = photoannotation::get_user_search_form("g-user-cloud-form"); +    $user_id = Input::instance()->get("name", ""); +    if ($user_id == "") { +      $user_id = Input::instance()->post("name", ""); +    } +    $getuser = photoannotation::getuser($user_id); +    if ($getuser->found) { +      url::redirect(user_profile::url($getuser->user->id)); +      return; +    } +    $page_size = module::get_var("gallery", "page_size", 9); +    $page = Input::instance()->get("page", 1); +    $offset = ($page - 1) * $page_size; + +    // Make sure that the page references a valid offset +    if ($page < 1) { +      $page = 1; +    } +    list ($count, $result) = photoannotation::search_user($user_id, $page_size, $offset); +    $max_pages = max(ceil($count / $page_size), 1); +    if ($page > 1) { +      $previous_page_url = url::site("photoannotation/showuser?name=". $user_id ."&page=". ($page - 1)); +    } +    if ($page < $max_pages) { +      $next_page_url = url::site("photoannotation/showuser?name=". $user_id ."&page=". ($page + 1)); +    } +    if ($user_id == "") { +      $user_id = "*"; +    } +    $template = new Theme_View("page.html", "other", "usersearch"); +    $template->set_global("position", $page); +    $template->set_global("total", $max_pages); +    $template->content = new View("photoannotation_user_search.html");       +    $template->content->search_form = photoannotation::get_user_search_form(g-user-search-form);  +    $template->content->users = $result; +    $template->content->q = $user_id; +    $template->content->count = $count; +    $template->content->paginator = new View("paginator.html");       +    $template->content->paginator->previous_page_url = $previous_page_url; +    $template->content->paginator->next_page_url = $next_page_url;       +    print $template; +  } + +  public function save($item_id) { +    // Prevent Cross Site Request Forgery +    access::verify_csrf(); +    //Get form data +    $item = ORM::factory("item", $item_id); +    $annotate_id = $_POST["noteid"];   +    $notetype = $_POST["notetype"];  +    $str_y1 = $_POST["top"]; +    $str_x1 = $_POST["left"]; +    $str_y2 = $_POST["height"] + $str_y1;  //Annotation uses area size, tagfaces uses positions +    $str_x2 = $_POST["width"] + $str_x1;  //Annotation uses area size, tagfaces uses positions +    $item_title = $_POST["text"]; +    $tag_data = $_POST["tagsList"]; +    $user_id = ""; +    $user_id = $_POST["userlist"]; +    $description = $_POST["desc"]; +    $redir_uri = url::abs_site("{$item->type}s/{$item->id}"); +    //If this is a user then get the id +    if ($user_id != "") { +      $getuser = photoannotation::getuser($user_id); +      if (!$getuser->found) { +        message::error(t("Could not find anyone with the name %user.", array("user" => $user_id))); +        url::redirect($redir_uri); +        return; +      } +      if ($getuser->isguest) { +        message::error(t("You cannot create an annotation for the guest user.")); +        url::redirect($redir_uri); +        return; +      } +      $user_id = $getuser->user->id; +    } +     +    //Add tag to item, create tag if not exists +    if ($tag_data != "") { +      $tag = ORM::factory("tag")->where("name", "=", $tag_data)->find(); +      if (!$tag->loaded()) { +        $tag->name = $tag_data; +        $tag->count = 0; +      } +      $tag->add($item); +      $tag->count++; +      $tag->save(); +      $tag_data = $tag->id; +    } else { +      $tag_data = ""; +    } +    //Save annotation +    if ($annotate_id == "new") {   //This is a new annotation +      if ($user_id != "") {              //Save user +        photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +      } elseif ($tag_data != "") {         //Save face +         photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +      } elseif ($item_title != "") {   //Save note +        photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +      } else {                            //Something's wrong +        message::error(t("Please select a person or tag or specify a title.")); +        url::redirect($redir_uri); +        return; +      } +    } else {    //This is an update to an existing annotation +      switch ($notetype) { +        case "user":   //the original annotation is a user +          $updateduser = ORM::factory("items_user")    //load the existing user +                            ->where("id", "=", $annotate_id) +                            ->find(); +          if ($user_id != "") {              //Conversion user -> user +            photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +          } elseif ($tag_data != "") {         //Conversion user -> face +            photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updateduser->delete();   //delete old user +          } elseif ($item_title != "") {   //Conversion user -> note +            photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updateduser->delete();   //delete old user +          } else {                            //Somethings wrong +            message::error(t("Please select a person or tag or specify a title.")); +            url::redirect($redir_uri); +            return; +          } +          break; +        case "face":   //the original annotation is a face +          $updatedface = ORM::factory("items_face")    //load the existing user +                            ->where("id", "=", $annotate_id) +                            ->find(); +          if ($user_id != "") {              //Conversion face -> user +            photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updatedface->delete();   //delete old face +          } elseif ($tag_data != "") {         //Conversion face -> face +            photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id); +          } elseif ($item_title != "") {   //Conversion face -> note +            photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updatedface->delete();   //delete old face +          } else {                            //Somethings wrong +            message::error(t("Please select a person or tag or specify a title.")); +            url::redirect($redir_uri); +            return; +          } +          break; +        case "note":   //the original annotation is a note +          $updatednote = ORM::factory("items_note")    //load the existing user +                            ->where("id", "=", $annotate_id) +                            ->find(); +          if ($user_id != "") {              //Conversion note -> user +            photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updatednote->delete();   //delete old note +          } elseif ($tag_data != "") {         //Conversion note -> face +            photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); +            $updatednote->delete();   //delete old note +          } elseif ($item_title != "") {   //Conversion note -> note +            photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id); +          } else {                            //Somethings wrong +            message::error(t("Please select a person or tag or specify a title.")); +            url::redirect($redir_uri); +            return; +          } +          break; +        default: +          message::error(t("Please select a person or tag or specify a title.")); +          url::redirect($redir_uri); +          return; +      } +    } +    message::success(t("Annotation saved.")); +    url::redirect($redir_uri); +    return; +  } +   +  public function delete($item_data) { +    // Prevent Cross Site Request Forgery +    access::verify_csrf(); + +    //Get form data +    $item = ORM::factory("item", $item_data); +    $noteid = $_POST["noteid"]; +    $notetype = $_POST["notetype"]; +    $redir_uri = url::abs_site("{$item->type}s/{$item->id}"); +     +    if ($noteid == "") { +      message::error(t("Please select a tag or note to delete.")); +      url::redirect($redir_uri); +      return; +    } +    switch ($notetype) { +      case "user": +        db::build()->delete("items_users")->where("id", "=", $noteid)->execute(); +        break; +      case "face": +        db::build()->delete("items_faces")->where("id", "=", $noteid)->execute(); +        break; +      case "note": +        db::build()->delete("items_notes")->where("id", "=", $noteid)->execute(); +        break; +      default: +        message::error(t("Please select a tag or note to delete.")); +        url::redirect($redir_uri); +        return; +    } +    message::success(t("Annotation deleted.")); +    url::redirect($redir_uri); +  } +   +  public function autocomplete() { +    if (!identity::active_user()->guest || module::get_var("photoannotation", "allowguestsearch", false)) { +      $users = array(); +      $user_parts = explode(",", Input::instance()->get("q")); +      $limit = Input::instance()->get("limit"); +      $user_part = ltrim(end($user_parts)); +      $user_list = ORM::factory("user") +        ->where("name", "LIKE", "{$user_part}%") +        ->or_where("full_name", "LIKE", "{$user_part}%") +        ->order_by("full_name", "ASC") +        ->limit($limit) +        ->find_all(); +      foreach ($user_list as $user) { +        if ($user->name != "guest") { +          $users[] = $user->display_name() ." (". $user->name .")"; +        } +      } +      print implode("\n", $users); +    } +  } +} | 
