diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/config/sendmail.php | 29 | ||||
-rw-r--r-- | modules/gallery/controllers/uploader.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery.php | 16 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 15 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 35 | ||||
-rw-r--r-- | modules/gallery/hooks/init_gallery.php | 1 | ||||
-rw-r--r-- | modules/gallery/libraries/Sendmail.php | 9 | ||||
-rw-r--r-- | modules/gallery/module.info | 2 | ||||
-rw-r--r-- | modules/gallery/tests/Sendmail_Test.php | 22 | ||||
-rw-r--r-- | modules/gallery/views/form_uploadify.html.php | 6 | ||||
-rw-r--r-- | modules/rest/helpers/rest_installer.php | 4 |
11 files changed, 94 insertions, 58 deletions
diff --git a/modules/gallery/config/sendmail.php b/modules/gallery/config/sendmail.php deleted file mode 100644 index 65b1d59b..00000000 --- a/modules/gallery/config/sendmail.php +++ /dev/null @@ -1,29 +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. - */ -/** - * PHP Mail Configuration parameters - * from => email address that appears as the from address - * line-length => word wrap length (PHP documentations suggest no larger tha 70 characters - * reply-to => what goes into the reply to header - */ -$config["from"] = "admin@gallery3.com"; -$config["line_length"] = 70; -$config["reply_to"] = "public@gallery3.com"; -$config["header_separator"] = "\n"; diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index fb496f60..168e8b2d 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -103,11 +103,14 @@ class Uploader_Controller extends Controller { } public function status($success_count, $error_count) { - // The "errors" won't be properly pluralized :-/ - print t2("Uploaded %count photo (%error errors)", - "Uploaded %count photos (%error errors)", - $success_count, - array("error" => $error_count)); + if ($error_count) { + // The "errors" won't be properly pluralized :-/ + print t2("Uploaded %count photo (%error errors)", + "Uploaded %count photos (%error errors)", + $success_count, + array("error" => $error_count)); + } else { + print t2("Uploaded %count photo", "Uploaded %count photos", $success_count);} } public function finish() { diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 3f83b23d..924ee76a 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -37,6 +37,22 @@ class gallery_Core { } /** + * If the gallery is only available to registered users and the user is not logged in, present + * the login page. + */ + static function private_gallery() { + if (Router::$controller != "login" && + Router::$controller != "combined" && + identity::active_user()->guest && + !access::user_can(identity::guest(), "view", item::root())) { + Session::instance()->set("continue_url", url::abs_current()); + Router::$controller = "login"; + Router::$controller_path = MODPATH . "gallery/controllers/login.php"; + Router::$method = "html"; + } + } + + /** * This function is called when the Gallery is fully initialized. We relay it to modules as the * "gallery_ready" event. Any module that wants to perform an action at the start of every * request should implement the <module>_event::gallery_ready() handler. diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index df5394c9..ec7d1882 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -63,6 +63,8 @@ class gallery_event_Core { ->update("logs") ->set("user_id", $admin->id) ->execute(); + module::set_var("gallery", "email_from", $admin->email); + module::set_var("gallery", "email_reply_to", $admin->email); } static function group_created($group) { @@ -547,4 +549,17 @@ class gallery_event_Core { $data->content[] = (object) array("title" => t("User information"), "view" => $v); } + + static function user_updated($original_user, $updated_user) { + // If the default from/reply-to email address is set to the install time placeholder value + // of unknown@unknown.com then adopt the value from the first admin to set their own email + // address so that we at least have a valid address for the Gallery. + if ($updated_user->admin) { + $email = module::get_var("gallery", "email_from", ""); + if ($email == "unknown@unknown.com") { + module::set_var("gallery", "email_from", $updated_user->email); + module::set_var("gallery", "email_reply_to", $updated_user->email); + } + } + } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index d1bfa656..c23bcca8 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -302,7 +302,14 @@ class gallery_installer { module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); - module::set_version("gallery", 36); + + // Sendmail configuration + module::set_var("gallery", "email_from", ""); + module::set_var("gallery", "email_reply_to", ""); + module::set_var("gallery", "email_line_length", 70); + module::set_var("gallery", "email_header_separator", serialize("\n")); + + module::set_version("gallery", 38); } static function upgrade($version) { @@ -543,7 +550,9 @@ class gallery_installer { } if ($version == 26) { - $db->query("RENAME TABLE {failed_logins} TO {failed_auths}"); + if (in_array("failed_logins", Database::instance()->list_tables())) { + $db->query("RENAME TABLE {failed_logins} TO {failed_auths}"); + } module::set_version("gallery", $version = 27); } @@ -596,6 +605,28 @@ class gallery_installer { module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); module::set_version("gallery", $version = 36); } + + if ($version == 36) { + module::set_var("gallery", "email_from", "admin@example.com"); + module::set_var("gallery", "email_reply_to", "public@example.com"); + module::set_var("gallery", "email_line_length", 70); + module::set_var("gallery", "email_header_separator", serialize("\n")); + module::set_version("gallery", $version = 37); + } + + // Changed our minds and decided that the initial value should be empty + // But don't just reset it blindly, only do it if the value is version 37 default + if ($version == 37) { + $email = module::get_var("gallery", "email_from", ""); + if ($email == "admin@example.com") { + module::set_var("gallery", "email_from", ""); + } + $email = module::get_var("gallery", "email_reply_to", ""); + if ($email == "admin@example.com") { + module::set_var("gallery", "email_reply_to", ""); + } + module::set_version("gallery", $version = 38); + } } static function uninstall() { diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index 64e44b56..10a74733 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -38,6 +38,7 @@ Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); Event::add("system.post_routing", array("url", "parse_url")); Event::add("system.post_routing", array("gallery", "maintenance_mode")); +Event::add("system.post_routing", array("gallery", "private_gallery")); Event::add("system.shutdown", array("gallery", "shutdown")); // @todo once we convert to Kohana 2.4 this doesn't have to be here diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php index ded7b2ef..a93be736 100644 --- a/modules/gallery/libraries/Sendmail.php +++ b/modules/gallery/libraries/Sendmail.php @@ -35,10 +35,11 @@ class Sendmail_Core { public function __construct() { $this->headers = array(); - $config = Kohana::config("sendmail"); - foreach ($config as $key => $value) { - $this->$key($value); - } + $this->from(module::get_var("gallery", "email_from", "")); + $this->reply_to(module::get_var("gallery", "email_reply_to", "")); + $this->line_length(module::get_var("gallery", "email_line_length", 70)); + $separator = module::get_var("gallery", "email_header_separator", null); + $this->header_separator(empty($separator) ? "\n" : unserialize($separator)); } public function __get($key) { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 44da9f2f..cc3b2723 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 36 +version = 38 diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php index b9406047..aee6abf5 100644 --- a/modules/gallery/tests/Sendmail_Test.php +++ b/modules/gallery/tests/Sendmail_Test.php @@ -19,23 +19,18 @@ */ class Sendmail_Test extends Gallery_Unit_Test_Case { public function setup() { - Kohana_Config::instance()->set("sendmail.from", "from@gallery3.com"); + module::set_var("gallery", "email_from", "from@gallery3.com"); + module::set_var("gallery", "email_reply_to", "reply_to@gallery3.com"); } - public function sendmail_test() { + public function sendmail_basic_test() { $expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . - "Reply-To: public@gallery3.com\r\n" . + "Reply-To: reply_to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") - /* - * @todo figure out why this test fails so badly, when the following - * line is not supplied. It doesn't seem to be set by setup method - * as you would expect. - */ - ->from("from@gallery3.com") ->subject("Test Email Unit test") ->message("The mail message body") ->send() @@ -47,13 +42,13 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { public function sendmail_reply_to_test() { $expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . - "Reply-To: reply-to@gallery3.com\r\n" . + "Reply-To: reply_to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") ->subject("Test Email Unit test") - ->reply_to("reply-to@gallery3.com") + ->reply_to("reply_to@gallery3.com") ->message("The mail message body") ->send() ->send_text; @@ -63,7 +58,7 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { public function sendmail_html_message_test() { $expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . - "Reply-To: public@gallery3.com\n" . + "Reply-To: reply_to@gallery3.com\n" . "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=UTF-8\r\n" . "Subject: Test Email Unit test\r\n\r\n" . @@ -80,9 +75,10 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { } public function sendmail_wrapped_message_test() { + $domain = Input::instance()->server("HTTP_HOST"); $expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . - "Reply-To: public@gallery3.com\r\n" . + "Reply-To: reply_to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "This is a long message that needs to go\n" . "over forty characters If we get lucky we\n" . diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 36f5f284..893bb3b9 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -60,7 +60,7 @@ $("#g-add-photos-status ul").append( "<li id=\"q" + queueID + "\" class=\"g-success\">" + fileObj.name + " - " + <?= t("Completed")->for_js() ?> + "</li>"); - setTimeout(function() { $("#q" + queueID).slideUp("slow") }, 5000); + setTimeout(function() { $("#q" + queueID).slideUp("slow").remove() }, 5000); success_count++; update_status(); return true; @@ -87,8 +87,8 @@ .replace("__TYPE__", errorObj.type)); } $("#g-add-photos-status ul").append( - "<li class=\"g-error\">" + fileObj.name + msg + "</li>"); - $("#g-uploadify" + queueID).remove(); + "<li id=\"q" + queueID + "\" class=\"g-error\">" + fileObj.name + msg + "</li>"); + $("#g-uploadify").uploadifyCancel(queueID); error_count++; update_status(); }, diff --git a/modules/rest/helpers/rest_installer.php b/modules/rest/helpers/rest_installer.php index c2694a29..3c7fea4b 100644 --- a/modules/rest/helpers/rest_installer.php +++ b/modules/rest/helpers/rest_installer.php @@ -35,7 +35,9 @@ class rest_installer { static function upgrade($version) { $db = Database::instance(); if ($version == 1) { - $db->query("RENAME TABLE {user_access_tokens} TO {user_access_keys}"); + if (in_array("user_access_tokens", Database::instance()->list_tables())) { + $db->query("RENAME TABLE {user_access_tokens} TO {user_access_keys}"); + } module::set_version("rest", $version = 2); } |