From daf1d8a66c68e88f0e145869f4dc600cdd95da43 Mon Sep 17 00:00:00 2001 From: hukoeth Date: Thu, 9 Sep 2010 22:14:18 +0800 Subject: [PATCH] Fixed typo in admin area Added option to hide the user cloud for guests Don't send notification mail on new comment when notification module is active and user is watching item --- .../controllers/admin_photoannotation.php | 10 +++++++--- .../controllers/photoannotation.php | 11 ++++++++--- .../helpers/photoannotation.php | 12 ++++++++++++ .../helpers/photoannotation_block.php | 18 ++++++++++-------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/photoannotation/controllers/admin_photoannotation.php b/modules/photoannotation/controllers/admin_photoannotation.php index 2ce1d7cf..2aaf5838 100644 --- a/modules/photoannotation/controllers/admin_photoannotation.php +++ b/modules/photoannotation/controllers/admin_photoannotation.php @@ -89,6 +89,8 @@ class Admin_Photoannotation_Controller extends Admin_Controller { "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( @@ -251,19 +253,21 @@ class Admin_Photoannotation_Controller extends Admin_Controller { ->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 face annotation below photo.")) + $group->checkbox("showusers")->label(t("Show user annotations below photo.")) ->checked(module::get_var("photoannotation", "showusers", false)); - $group->checkbox("showfaces")->label(t("Show face annotation below photo.")) + $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 settings")); + $group = $form->group("notifications")->label(t("Notification and user 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 user cloud and allow user 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")); diff --git a/modules/photoannotation/controllers/photoannotation.php b/modules/photoannotation/controllers/photoannotation.php index c83cbee9..1431a311 100644 --- a/modules/photoannotation/controllers/photoannotation.php +++ b/modules/photoannotation/controllers/photoannotation.php @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class photoannotation_Controller extends Controller { - public function showuser($item_id) { + 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 user 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 == "") { @@ -40,10 +45,10 @@ class photoannotation_Controller extends Controller { 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/". $item_id ."?name=". $user_id ."&page=". ($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/". $item_id ."?name=". $user_id ."&page=". ($page + 1)); + $next_page_url = url::site("photoannotation/showuser?name=". $user_id ."&page=". ($page + 1)); } if ($user_id == "") { $user_id = "*"; diff --git a/modules/photoannotation/helpers/photoannotation.php b/modules/photoannotation/helpers/photoannotation.php index cd58f554..13ec4078 100644 --- a/modules/photoannotation/helpers/photoannotation.php +++ b/modules/photoannotation/helpers/photoannotation.php @@ -171,6 +171,12 @@ class photoannotation_Core { case "newcomment": //Only send if user has this option enabled if ($notification_settings->comment) { + //Don't send if the notification module is active and the user is watching this item + if (module::is_active("notification")) { + if (notification::is_watching($item, $recipient)) { + return false; + } + } //Get subject and body and send the mail $subject = module::get_var("photoannotation", "newcommentsubject", "Someone added a comment to photo of you"); $body = module::get_var("photoannotation", "newcommentbody", "Hello %name, please visit %url to read the comment."); @@ -181,6 +187,12 @@ class photoannotation_Core { case "updatecomment": //Only send if user has this option enabled if ($notification_settings->comment) { + //Don't send if the notification module is active and the user is watching this item + if (module::is_active("notification")) { + if (notification::is_watching($item, $recipient)) { + return false; + } + } //Get subject and body and send the mail $subject = module::get_var("photoannotation", "updatedcommentsubject", "Someone updated a comment to photo of you"); $body = module::get_var("photoannotation", "updatedcommentbody", "Hello %name, please visit %url to read the comment."); diff --git a/modules/photoannotation/helpers/photoannotation_block.php b/modules/photoannotation/helpers/photoannotation_block.php index 250d1eaa..6facc671 100644 --- a/modules/photoannotation/helpers/photoannotation_block.php +++ b/modules/photoannotation/helpers/photoannotation_block.php @@ -24,15 +24,17 @@ class photoannotation_block_Core { static function get($block_id, $theme) { $block = ""; - switch ($block_id) { - case "photoannotation": - $block = new Block(); - $block->css_id = "g-photoannotation"; - $block->title = t("Users"); - $block->content = new View("photoannotation_block.html"); - $block->content->cloud = photoannotation::cloud(30); - $block->content->form = photoannotation::get_user_search_form("g-user-cloud-form"); + if (!identity::active_user()->guest || module::get_var("photoannotation", "allowguestsearch", false)) { + switch ($block_id) { + case "photoannotation": + $block = new Block(); + $block->css_id = "g-photoannotation"; + $block->title = t("Users"); + $block->content = new View("photoannotation_block.html"); + $block->content->cloud = photoannotation::cloud(30); + $block->content->form = photoannotation::get_user_search_form("g-user-cloud-form"); } + } return $block; } } \ No newline at end of file