1
0

Version 4 beta 1:

- Implemented user notification (I need testers for this since for some reason my server is not sending mails with PHPs mail-function so I couldn't test)
- Users can decide if they want to receive notifications by editing their profile
- Admin can decide if notifications is switched on by default for new users and users who have not saved this setting
- Guest user is now hidden when adding an annotation
- Added admin option allowing to convert a user annotation to a tag or note annotation when deleting a user
- Added admin option to remove orphaned annotations
- Fixed borders not showing when hovering over an annotation area when having borders switched off on photo hover
- Fixed issue on user page where sometime only one photo would be shown x-times
- Fixed pagination on user profile pages
This commit is contained in:
hukoeth 2010-09-05 22:27:38 +02:00 committed by Bharat Mediratta
parent 44533159e5
commit 55d9bc4986
12 changed files with 537 additions and 135 deletions

View File

@ -21,6 +21,70 @@ 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 user 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();
foreach ($tag_annotations as $tag_annotation) {
//Check if there are already user annotations of the target user on photo
$user_annotations = ORM::factory("items_user")
->where("item_id", "=", $tag_annotation->item_id)
->where("user_id", "=", $targetuser->id)
->find_all();
if (count($user_annotations) > 1) {
//If there are more than one existing annotations, delete all and create a new one
foreach ($user_annotations as $user_annotation) {
$user_annotation->delete();
}
$target_annotation = ORM::factory("items_user");
} elseif (count($user_annotations) == 1) {
//If there is only one existing annotation, load it and update it
$target_annotation = ORM::factory("items_user", $user_annotations[0]->id);
} else {
//If there are no existing annotations create one
$target_annotation = ORM::factory("items_user");
}
//Save values from tag annotation to user annotation and save it
$target_annotation->user_id = $targetuser->id;
$target_annotation->item_id = $tag_annotation->item_id;
$target_annotation->x1 = $tag_annotation->x1;
$target_annotation->y1 = $tag_annotation->y1;
$target_annotation->x2 = $tag_annotation->x2;
$target_annotation->y2 = $tag_annotation->y2;
$target_annotation->description = $tag_annotation->description;
$target_annotation->save();
//Delete the old annotation
$tag_annotation->delete();
}
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);
}
public function handler() {
access::verify_csrf();
@ -47,6 +111,12 @@ class Admin_Photoannotation_Controller extends Admin_Controller {
"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", "onuserdelete", $form->onuserdelete->onuserdelete->value);
message::success(t("Your settings have been saved."));
url::redirect("admin/photoannotation");
}
@ -55,11 +125,120 @@ class Admin_Photoannotation_Controller extends Admin_Controller {
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->submit("submit")->value(t("Convert"));
return $form;
}
private function _get_form() {
$form = new Forge("admin/photoannotation/handler", "", "post", array("id" => "g-admin-form"));
$group = $form->group("hoverphoto")->label(t("Hovering over the photo"));
@ -89,6 +268,15 @@ class Admin_Photoannotation_Controller extends Admin_Controller {
->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 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 = $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;
}

View File

@ -173,10 +173,37 @@ class photoannotation_Controller extends Controller {
$item_old_user->delete();
}
$item_user = ORM::factory("items_user");
} elseif (count($item_old_users) > 0) {
} elseif (count($item_old_users) == 1) {
$item_user = ORM::factory("items_user", $item_old_users[0]->id);
} else {
$item_user = ORM::factory("items_user");
if (!module::get_var("photoannotation", "nonotifications", false)) {
$notification_settings = ORM::factory("photoannotation_notification")->where("user_id", "=", $user_id)->find();
if (!$notification_settings->loaded()) {
$notify = module::get_var("photoannotation", "notificationoptout", false);
$notification_settings = ORM::factory("photoannotation_notification");
$notification_settings->user_id = $user_id;
$notification_settings->newtag = $notify;
$notification_settings->comment = $notify;
$notification_settings->save();
}
if ($notification_settings->newtag) {
$user_recipient = ORM::factory("user")->where("id", "=", $user_id)->find();
if ($user_recipient->email != "") {
$recipient = $user_recipient->email;
$subject = t("Somebody has tagged a photo of you");
$item_notify = ORM::factory("item")->where("id", "=", $item_id)->find();
$body = t("Please visit <a href=\"%url\">the gallery</a> to view the photo.", array("url" => $item_notify->resize_url(true)));
Sendmail::factory()
->to($recipient)
->subject($subject)
->header("Mime-Version", "1.0")
->header("Content-type", "text/html; charset=utf-8")
->message($body)
->send();
}
}
}
}
$item_user->user_id = $user_id;
$item_user->item_id = $item_id;
@ -223,4 +250,17 @@ class photoannotation_Controller extends Controller {
$item_note->description = $description;
$item_note->save();
}
private function _send_tag_created($user_id, $item_id) {
$recipient = ORM::factory("user", $user_id);
if ($recipient->email) {
Sendmail::factory()
->to($recipient->email)
->subject($t("Someone has tagged a photo with you on it"))
->header("Mime-Version", "1.0")
->header("Content-Type", "text/html; charset=UTF-8")
->message($text)
->send();
}
}
}

View File

@ -1,91 +0,0 @@
<?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_Core {
static function add($item, $tag_title, $description, $x1, $y1, $x2, $y2, $bTag) {
if ( !$bTag && !empty($tag_title) ) {
try {
//we are trying to add a note
$newnote = ORM::factory("items_note");
$newnote->item_id = $item->id;
$newnote->x1 = $x1;
$newnote->y1 = $y1;
$newnote->x2 = $x2;
$newnote->y2 = $y2;
$newnote->title = $tag_title;
$newnote->description = $description;
$newnote->save();
} catch (Exception $e) {
Kohana_Log::add("error", "Error adding note annotation.\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
} elseif ( $bTag && !empty($tag_title) ) {
try {
//we are adding a tag
//first find the tag
$tag = ORM::factory("tag")->where("name", "=", $tag_title)->find();
//tag was not found
if (!$tag->loaded()) {
$tag->name = $tag_title;
$tag->count = 0;
}
$tag->add($item);
$tag->count++;
$tag->save();
//check if the tag is attached to the item
// if the tag isn't attached, attach it
//check if the face is already tagged
$existingFace = ORM::factory("items_face")
->where("tag_id", "=", $tag->id)
->where("item_id", "=", $item->id)
->find_all();
if (count($existingFace) == 0) {
// Save the new face to the database.
$newface = ORM::factory("items_face");
$newface->tag_id = $tag->id;
$newface->item_id = $item->id;
$newface->x1 = $x1;
$newface->y1 = $y1;
$newface->x2 = $x2;
$newface->y2 = $y2;
$newface->description = $description;
$newface->save();
} else {
// Update the coordinates of an existing face.
$updatedFace = ORM::factory("items_face", $existingFace[0]->id);
$updatedFace->x1 = $x1;
$updatedFace->y1 = $y1;
$updatedFace->x2 = $x2;
$updatedFace->y2 = $y2;
$updatedFace->description = $description;
$updatedFace->save();
}
} catch (Exception $e) {
Kohana_Log::add("error", "Error adding note annotation.\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
} else {
throw new exception("@todo MISSING_TAG_OR_DESCRIPTION");
}
}
}
?>

View File

@ -89,8 +89,70 @@ class photoannotation_event_Core {
->where("user_id", "=", $old->id)
->find_all();
if (count($existingFaces) > 0) {
$onuserdelete = module::get_var("photoannotation", "onuserdelete", "0");
if (module::get_var("photoannotation", "fullname", false)) {
$new_tag_name = $old->display_name();
} else {
$new_tag_name = $old->name;
}
switch ($onuserdelete) {
case "1":
//convert to tag
$tag = ORM::factory("tag")->where("name", "=", $new_tag_name)->find();
if (!$tag->loaded()) {
$tag->name = $new_tag_name;
$tag->count = 0;
}
foreach ($existingFaces as $existingFace) {
$item = ORM::factory("item")->where("id", "=", $existingFace->item_id)->find();
$tag->add($item);
$tag->count++;
$tag->save();
$new_items_tag = ORM::factory("items_face");
$new_items_tag->item_id = $existingFace->item_id;
$new_items_tag->tag_id = $tag->id;
$new_items_tag->x1 = $existingFace->x1;
$new_items_tag->y1 = $existingFace->y1;
$new_items_tag->x2 = $existingFace->x2;
$new_items_tag->y2 = $existingFace->y2;
$new_items_tag->description = $existingFace->description;
$new_items_tag->save();
}
break;
case "2":
//convert to note
foreach ($existingFaces as $existingFace) {
$item = ORM::factory("item")->where("id", "=", $existingFace->item_id)->find();
$new_items_tag = ORM::factory("items_note");
$new_items_tag->item_id = $existingFace->item_id;
$new_items_tag->title = $new_tag_name;
$new_items_tag->x1 = $existingFace->x1;
$new_items_tag->y1 = $existingFace->y1;
$new_items_tag->x2 = $existingFace->x2;
$new_items_tag->y2 = $existingFace->y2;
$new_items_tag->description = $existingFace->description;
$new_items_tag->save();
}
}
db::build()->delete("items_users")->where("user_id", "=", $old->id)->execute();
}
// Delete notification settings
$notification_settings = ORM::factory("photoannotation_notification")
->where("user_id", "=", $old->id)
->find();
if ($notification_settings->loaded()) {
$notification_settings->delete();
}
}
static function user_created($user) {
// Write notification settings
$notify = module::get_var("photoannotation", "notificationoptout", false);
$notification_settings = ORM::factory("photoannotation_notification");
$notification_settings->user_id = $user->id;
$notification_settings->newtag = $notify;
$notification_settings->comment = $notify;
$notification_settings->save();
}
static function admin_menu($menu, $theme) {
@ -102,7 +164,7 @@ class photoannotation_event_Core {
}
static function show_user_profile($data) {
$view = new View("dynamic.html");
$view = new Theme_View("dynamic.html", "collection", "userprofiles");
//load thumbs
$item_users = ORM::factory("items_user")->where("user_id", "=", $data->user->id)->find_all();
$children_count = count($item_users);
@ -110,7 +172,7 @@ class photoannotation_event_Core {
$item_thumb = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->where("id", ">=", $item_user->item_id)
->where("id", "=", $item_user->item_id)
->find();
$item_thumbs[] = $item_thumb;
}
@ -118,13 +180,23 @@ class photoannotation_event_Core {
$page = (int) Input::instance()->get("page", "1");
$offset = ($page-1) * $page_size;
$max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
if ($page < 1) {
url::redirect($album->abs_url());
} else if ($page > $max_pages) {
url::redirect($album->abs_url("page=$max_pages"));
}
if ($page < $max_pages) {
$next_page_url = url::site("user_profile/show/". $data->user->id ."?page=". ($page + 1));
$view->set_global("next_page_url", $next_page_url);
$view->set_global("first_page_url", url::site("user_profile/show/". $data->user->id ."?page=". $max_pages));
}
if ($page > 1) {
$view->set_global("previous_page_url", url::site("user_profile/show/". $data->user->id ."?page=". ($page - 1)));
$view->set_global("first_page_url", url::site("user_profile/show/". $data->user->id ."?page=1"));
}
$view->set_global("page", $page);
$view->set_global("max_pages", $max_pages);
$view->set_global("page_size", $page_size);
@ -136,6 +208,111 @@ class photoannotation_event_Core {
$data->content[] = (object)array("title" => t("Photos"), "view" => $view);
}
}
static function user_edit_form($user, $form) {
// Allow users to modify notification settings.
if (!module::get_var("photoannotation", "nonotifications", false)) {
$notification_settings = ORM::factory("photoannotation_notification")->where("user_id", "=", $user->id)->find();
if (!$notification_settings->loaded()) {
$notify = module::get_var("photoannotation", "notificationoptout", false);
$notification_settings = ORM::factory("photoannotation_notification");
$notification_settings->user_id = $user->id;
$notification_settings->newtag = $notify;
$notification_settings->comment = $notify;
$notification_settings->save();
}
$user_notification = $form->edit_user->group("edit_notification")->label("Tag notifications");
$user_notification->checkbox("photoannotation_newtag")->label(t("Notify me when a tag is added to a photo with me"))
->checked($notification_settings->newtag);
$user_notification->checkbox("photoannotation_comment")->label(t("Notify me if someone comments on a photo with me on it"))
->checked($notification_settings->comment);
}
}
static function user_edit_form_completed($user, $form) {
// Save notification settings.
if (!module::get_var("photoannotation", "nonotifications", false)) {
$notification_settings = ORM::factory("photoannotation_notification")->where("user_id", "=", $user->id)->find();
if (!$notification_settings->loaded()) {
$notification_settings->user_id = $user->id;
}
$notification_settings->newtag = $form->edit_user->edit_notification->photoannotation_newtag->value;
$notification_settings->comment = $form->edit_user->edit_notification->photoannotation_comment->value;
$notification_settings->save();
}
}
static function comment_created($comment) {
//@todo: clean this up
$comment = ORM::factory("comment")->where("id", "=", "52")->find();
if (!module::get_var("photoannotation", "nonotifications", false)) {
$item_users = ORM::factory("items_user")->where("item_id", "=", $comment->item_id)->find_all();
if (count($item_users) > 0) {
foreach ($item_users as $item_user) {
$notification_settings = ORM::factory("photoannotation_notification")->where("user_id", "=", $item_user-user_id)->find();
if (!$notification_settings->loaded()) {
$notify = module::get_var("photoannotation", "notificationoptout", false);
$notification_settings = ORM::factory("photoannotation_notification");
$notification_settings->user_id = $item_user-user_id;
$notification_settings->newtag = $notify;
$notification_settings->comment = $notify;
$notification_settings->save();
}
if ($notification_settings->newtag) {
$user_recipient = ORM::factory("user")->where("id", "=", $item_user-user_id)->find();
if ($user_recipient->email != "") {
$recipient = $user_recipient->email;
$subject = t("Somebody has commented on a photo of you");
$item_notify = ORM::factory("item")->where("id", "=", $comment->item_id)->find();
$body = t("Please visit <a href=\"%url\">the gallery</a> to view the photo.", array("url" => $item_notify->resize_url(true)));
Sendmail::factory()
->to($recipient)
->subject($subject)
->header("Mime-Version", "1.0")
->header("Content-type", "text/html; charset=utf-8")
->message($body)
->send();
}
}
}
}
}
}
static function comment_updated($comment) {
//@todo: clean this up
$comment = ORM::factory("comment")->where("id", "=", "52")->find();
if (!module::get_var("photoannotation", "nonotifications", false)) {
$item_users = ORM::factory("items_user")->where("item_id", "=", $comment->item_id)->find_all();
if (count($item_users) > 0) {
foreach ($item_users as $item_user) {
$notification_settings = ORM::factory("photoannotation_notification")->where("user_id", "=", $item_user-user_id)->find();
if (!$notification_settings->loaded()) {
$notify = module::get_var("photoannotation", "notificationoptout", false);
$notification_settings = ORM::factory("photoannotation_notification");
$notification_settings->user_id = $item_user-user_id;
$notification_settings->newtag = $notify;
$notification_settings->comment = $notify;
$notification_settings->save();
}
if ($notification_settings->newtag) {
$user_recipient = ORM::factory("user")->where("id", "=", $item_user-user_id)->find();
if ($user_recipient->email != "") {
$recipient = $user_recipient->email;
$subject = t("Somebody has updated a commented on a photo of you");
$item_notify = ORM::factory("item")->where("id", "=", $comment->item_id)->find();
$body = t("Please visit <a href=\"%url\">the gallery</a> to view the photo.", array("url" => $item_notify->resize_url(true)));
Sendmail::factory()
->to($recipient)
->subject($subject)
->header("Mime-Version", "1.0")
->header("Content-type", "text/html; charset=utf-8")
->message($body)
->send();
}
}
}
}
}
}
}

View File

@ -56,6 +56,14 @@ class photoannotation_installer {
`description` varchar(2048) default NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {photoannotation_notifications} (
`id` int(9) NOT NULL auto_increment,
`user_id` int(9) NOT NULL unique,
`newtag` int(2) default NULL,
`comment` int(2) default NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
// Set the module's version number.
module::set_version("photoannotation", 3);
@ -80,6 +88,16 @@ class photoannotation_installer {
DEFAULT CHARSET=utf8;");
module::set_version("photoannotation", $version = 3);
}
if ($version == 3) {
$db->query("CREATE TABLE IF NOT EXISTS {photoannotation_notifications} (
`id` int(9) NOT NULL auto_increment,
`user_id` int(9) NOT NULL unique,
`newtag` int(2) default NULL,
`comment` int(2) default NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
module::set_version("photoannotation", $version = 4);
}
}
static function deactivate() {
@ -94,6 +112,7 @@ class photoannotation_installer {
$db->query("DROP TABLE IF EXISTS {items_faces};");
$db->query("DROP TABLE IF EXISTS {items_notes};");
$db->query("DROP TABLE IF EXISTS {items_users};");
$db->query("DROP TABLE IF EXISTS {photoannotation_notifications};");
module::delete("photoannotation");
}
}

View File

@ -33,6 +33,11 @@ class photoannotation_theme_Core {
$v .= ".photoannotation-edit-button {\n
border:1px solid ". $bordercolor ." !important;\n
}";
if ($noborder) {
$border_thickness = "2px";
} else {
$border_thickness = "1px";
}
if (!$noborder || !$noeditablehover || !$nohover) {
if (!$noborder) {
$v .= ".image-annotate-area {\n
@ -45,13 +50,13 @@ class photoannotation_theme_Core {
if (!$noclickablehover) {
$clickablehovercolor = "#". module::get_var("photoannotation", "clickablehovercolor", "00AD00");
$v .= ".image-annotate-area-editable-hover div {\n
border-color: ". $clickablehovercolor ." !important;\n
border: ". $border_thickness ." solid ". $clickablehovercolor ." !important;\n
}\n";
}
if (!$nohover) {
$hovercolor = "#". module::get_var("photoannotation", "hovercolor", "990000");
$v .= ".image-annotate-area-hover div {\n
border-color: ". $hovercolor ." !important;\n
border: ". $border_thickness ." solid ". $hovercolor ." !important;\n
}\n";
}
}

View File

@ -0,0 +1,21 @@
<?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_Notification_Model extends ORM {
}

View File

@ -1,3 +1,3 @@
name = "Photo Annotation"
description = "Allows you to assign tags and notes to areas on your photos. This module is partially compatible with the TagFaces module by rWatcher. This means that notes and faces that you create in either one will be shown and are editable by the other module as well. If you added users to an annotation area though they will only be displayed with the Photo Annotation module. You cannot run both modules at the same time."
version = 3
version = 4

View File

@ -1,12 +1,12 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-photoannotation">
<h2><?= t("Photo annotation administration") ?></h2>
<h1><?= t("Photo annotation administration") ?></h1>
<h3><?= t("Notes:") ?></h3>
<p><?= t("This module is partially compatible with the <a href=\"http://codex.gallery2.org/Gallery3:Modules:tagfaces\">TagFaces module</a> by rWatcher.<br />
<p><?= t("This module is partially compatible with the <a href=\"%url\">TagFaces module</a> by rWatcher.<br />
This means that notes and faces that you create in either one will be shown and are editable by the other module as well. If you added users to an annotation area though they will only be displayed with the Photo Annotation module.<br />
You cannot have both active at the same time.<br /><br />
If you decide to show annotations below the photo but they are displayed below the comments section (or any other data),
please download and install the <a href=\"http://codex.gallery2.org/Gallery3:Modules:moduleorder\">Module order module</a>.") ?></p>
You cannot have both active at the same time.", array("tagfaces" => "http://codex.gallery2.org/Gallery3:Modules:tagfaces")) ?>
<br /><br /><?= t("<a href=\"%url\">Convert existing tag annotations to user annotations</a>", array("url" => url::site("admin/photoannotation/converter/"))) ?>
<br /><?= t("<a href=\"%url\">Check for orphaned annotations</a>", array("url" => url::site("admin/photoannotation/tagsmaintanance/"))) ?></p>
<?= $form ?>
</div>
<script type="text/javascript">

View File

@ -0,0 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-photoannotation">
<h1><?= t("Photo annotation converter") ?></h1>
<h3><?= t("Notes:") ?></h3>
<p><?= t("Here you can convert existing annotations with tags associated with them to annotations with users.") ?><br /><br />
<?= t("Please be aware that if a photo has already the same user associated with an annotation this annotation will be updated instead of a new one being created. If a photo has more than one annotation associated with the specified tag only one area will be converted and all other annotations with this tag will be removed.") ?>
<br /><?= t("<a href=\"%url\">Back to photo annotation settings</a>", array("url" => url::site("admin/photoannotation/"))) ?>
<br /><?= t("<a href=\"%url\">Check for orphaned annotations</a>", array("url" => url::site("admin/photoannotation/tagsmaintanance/"))) ?></p>
<?= $form ?>
</div>

View File

@ -0,0 +1,27 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-photoannotation">
<h1><?= t("Photo annotation tags maintanance") ?></h1>
<h3><?= t("Notes:") ?></h3>
<p><?= t("When deleting a tag this might leave orphaned tag annotations.") ?>
<br /><br /><?= t("<a href=\"%url\">Back to photo annotation settings</a>", array("url" => url::site("admin/photoannotation/"))) ?>
<br /><?= t("<a href=\"%url\">Convert existing tag annotations to user annotations</a>", array("url" => url::site("admin/photoannotation/converter/"))) ?></p>
<? if ($dodeletion): ?>
<h3><?= t("Maintanance results") ?></h3>
<p><?= t("%user_orphanes_deleted annotations without a user have been deleted.", array("user_orphanes_deleted" => $user_orphanes_deleted)) ?>
<br><?= t("%tag_orpanes_deleted annotations without a tag have been deleted.", array("tag_orpanes_deleted" => $tag_orpanes_deleted)) ?>
<br><?= t("%item_orphanes_deleted annotations without a photo have been deleted.", array("item_orphanes_deleted" => $item_orphanes_deleted)) ?>
</p>
<?= t("<a href=\"%url\" class=\"submit ui-state-default ui-corner-all\" style=\"padding: 5px;\">Back</a>", array("url" => url::site("admin/photoannotation/"))) ?>
<? else: ?>
<h3><?= t("Orphaned annotations") ?></h3>
<p><?= t("%user_orphanes_count annotations without a user found.", array("user_orphanes_count" => $user_orphanes_count)) ?>
<br><?= t("%tag_orpanes_count annotations without a tag found.", array("tag_orpanes_count" => $tag_orpanes_count)) ?>
<br><?= t("%item_orphanes_count annotations without a photo found.", array("item_orphanes_count" => $item_orphanes_count)) ?>
</p>
<? if ($user_orphanes_count == 0 && $tag_orpanes_count == 0 && $item_orphanes_count == 0): ?>
<?= t("<a href=\"%url\" class=\"submit ui-state-default ui-corner-all\" style=\"padding: 5px;\">Back</a>", array("url" => url::site("admin/photoannotation/"))) ?>
<? else: ?>
<?= t("<a href=\"%url\" class=\"submit ui-state-default ui-corner-all\" style=\"padding: 5px;\">Remove all</a>", array("url" => url::site("admin/photoannotation/tagsmaintanance/true"))) ?>
<? endif ?>
<? endif ?>
</div>

View File

@ -36,24 +36,26 @@
$jscode = "notes: [ ";
foreach ($existingUsers as $oneUser) {
$oneTag = ORM::factory("user", $oneUser->user_id);
if ($fullname && ($oneTag->full_name != "")) {
$user_text = $oneTag->full_name;
} else {
$user_text = $oneTag->name;
if ($oneTag->loaded()) {
if ($fullname && ($oneTag->full_name != "")) {
$user_text = $oneTag->full_name;
} else {
$user_text = $oneTag->name;
}
if ($showusers) {
$legend_users .= "<span id=\"photoannotation-legend-user-". $oneUser->id . "\"><a href=\"". user_profile::url($oneUser->user_id) ."\">". html::clean($user_text) ."</a></span>, ";
}
$jscode .= "{ \"top\": ". $oneUser->y1 .",\n";
$jscode .= "\"left\": ". $oneUser->x1 .",\n";
$jscode .= "\"width\": ". ($oneUser->x2 - $oneUser->x1) .",\n";
$jscode .= "\"height\": ". ($oneUser->y2 - $oneUser->y1) .",\n";
$jscode .= "\"text\": \"". html::clean($user_text) ."\",\n";
$jscode .= "\"description\": \"". html::clean($oneUser->description) ."\",\n";
$jscode .= "\"noteid\": ". $oneUser->id .",\n";
$jscode .= "\"notetype\": \"user\",\n";
$jscode .= "\"editable\": true,\n";
$jscode .= "\"url\": \"". user_profile::url($oneUser->user_id) ."\" },\n";
}
if ($showusers) {
$legend_users .= "<span id=\"photoannotation-legend-user-". $oneUser->id . "\"><a href=\"". user_profile::url($oneUser->user_id) ."\">". html::clean($user_text) ."</a></span>, ";
}
$jscode .= "{ \"top\": ". $oneUser->y1 .",\n";
$jscode .= "\"left\": ". $oneUser->x1 .",\n";
$jscode .= "\"width\": ". ($oneUser->x2 - $oneUser->x1) .",\n";
$jscode .= "\"height\": ". ($oneUser->y2 - $oneUser->y1) .",\n";
$jscode .= "\"text\": \"". html::clean($user_text) ."\",\n";
$jscode .= "\"description\": \"". html::clean($oneUser->description) ."\",\n";
$jscode .= "\"noteid\": ". $oneUser->id .",\n";
$jscode .= "\"notetype\": \"user\",\n";
$jscode .= "\"editable\": true,\n";
$jscode .= "\"url\": \"". user_profile::url($oneUser->user_id) ."\" },\n";
}
if ($legend_users != "") {
$legend_users = trim($legend_users, ", ");
@ -61,19 +63,21 @@
}
foreach ($existingFaces as $oneFace) {
$oneTag = ORM::factory("tag", $oneFace->tag_id);
if ($showfaces) {
$legend_faces .= "<span id=\"photoannotation-legend-face-". $oneFace->id . "\"><a href=\"". $oneTag->url() ."\">". html::clean($oneTag->name) ."</a></span>, ";
if ($oneTag->loaded()) {
if ($showfaces) {
$legend_faces .= "<span id=\"photoannotation-legend-face-". $oneFace->id . "\"><a href=\"". $oneTag->url() ."\">". html::clean($oneTag->name) ."</a></span>, ";
}
$jscode .= "{ \"top\": ". $oneFace->y1 .",\n";
$jscode .= "\"left\": ". $oneFace->x1 .",\n";
$jscode .= "\"width\": ". ($oneFace->x2 - $oneFace->x1) .",\n";
$jscode .= "\"height\": ". ($oneFace->y2 - $oneFace->y1) .",\n";
$jscode .= "\"text\": \"". html::clean($oneTag->name) ."\",\n";
$jscode .= "\"description\": \"". html::clean($oneFace->description) ."\",\n";
$jscode .= "\"noteid\": ". $oneFace->id .",\n";
$jscode .= "\"notetype\": \"face\",\n";
$jscode .= "\"editable\": true,\n";
$jscode .= "\"url\": \"". $oneTag->url() ."\" },\n";
}
$jscode .= "{ \"top\": ". $oneFace->y1 .",\n";
$jscode .= "\"left\": ". $oneFace->x1 .",\n";
$jscode .= "\"width\": ". ($oneFace->x2 - $oneFace->x1) .",\n";
$jscode .= "\"height\": ". ($oneFace->y2 - $oneFace->y1) .",\n";
$jscode .= "\"text\": \"". html::clean($oneTag->name) ."\",\n";
$jscode .= "\"description\": \"". html::clean($oneFace->description) ."\",\n";
$jscode .= "\"noteid\": ". $oneFace->id .",\n";
$jscode .= "\"notetype\": \"face\",\n";
$jscode .= "\"editable\": true,\n";
$jscode .= "\"url\": \"". $oneTag->url() ."\" },\n";
}
if ($legend_faces != "") {
$legend_faces = trim($legend_faces, ", ");
@ -113,7 +117,9 @@
} else {
$user_text = $user->name;
}
$users_arraystring .= "{'name':'". html::clean($user_text) ."','id':'". $user->id ."'},";
if ($user->name != "guest") {
$users_arraystring .= "{'name':'". html::clean($user_text) ."','id':'". $user->id ."'},";
}
}
$users_arraystring = trim($users_arraystring, ",");
$users_arraystring .= " ],";