item_id = $item_data; $newnote->x1 = $str_x1; $newnote->y1 = $str_y1; $newnote->x2 = $str_x2; $newnote->y2 = $str_y2; $newnote->title = $str_face_title; $newnote->description = $str_face_description; $newnote->save(); } else { // Check to see if the tag already has a face associated with it. $existingFace = ORM::factory("items_face") ->where("tag_id", "=", $tag_data) ->where("item_id", "=", $item_data) ->find_all(); if (count($existingFace) == 0) { // Save the new face to the database. $newface = ORM::factory("items_face"); $newface->tag_id = $tag_data; $newface->item_id = $item_data; $newface->x1 = $str_x1; $newface->y1 = $str_y1; $newface->x2 = $str_x2; $newface->y2 = $str_y2; $newface->description = $str_face_description; $newface->save(); } else { // Update the coordinates of an existing face. $updatedFace = ORM::factory("items_face", $existingFace[0]->id); $updatedFace->x1 = $str_x1; $updatedFace->y1 = $str_y1; $updatedFace->x2 = $str_x2; $updatedFace->y2 = $str_y2; $updatedFace->description = $str_face_description; $updatedFace->save(); } } message::success(t("Annotation saved.")); url::redirect($redir_uri); return; } public function delete() { // Prevent Cross Site Request Forgery access::verify_csrf(); //Get form data $noteid = $_POST["noteid"]; $notetype = $_POST["notetype"]; $redir_uri = $_POST["currenturl"]; if ($noteid == "" || $notetype == "") { message::error(t("Please select a tag or note to delete.")); url::redirect($redir_uri); return; } if ($notetype == "face") { db::build()->delete("items_faces")->where("id", "=", $noteid)->execute(); message::success(t("Annotation deleted.")); } elseif ($notetype == "note") { db::build()->delete("items_notes")->where("id", "=", $noteid)->execute(); message::success(t("Annotation deleted.")); } else { message::error(t("Please select a tag or note to delete.")); } url::redirect($redir_uri); } }