diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-08-31 20:39:25 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-08-31 20:45:09 -0700 |
commit | e09c6dbd5e81c6c56e9c4f386ff431c0cfe9c2b0 (patch) | |
tree | cd54e690d98bd4d36b890fb0eaa5b799436cdbb4 /modules | |
parent | 438cea231d93c81adaccb0460327cc703a43da71 (diff) |
Patch for ticket #1216. Move the values that were in the sendmail config file and store them as gallery module variables. Requires a version number bump to 37.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/config/sendmail.php | 29 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 19 | ||||
-rw-r--r-- | modules/gallery/libraries/Sendmail.php | 10 | ||||
-rw-r--r-- | modules/gallery/module.info | 2 | ||||
-rw-r--r-- | modules/gallery/tests/Sendmail_Test.php | 16 |
5 files changed, 35 insertions, 41 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/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index d1bfa656..664fe127 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -302,7 +302,15 @@ 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 + $domain = Input::instance()->server("HTTP_HOST"); + module::set_var("gallery", "email_from", "admin@$domain"); + module::set_var("gallery", "email_reply_to", "public@$domain"); + module::set_var("gallery", "email_line_length", 70); + module::set_var("gallery", "email_header_separator", serialize("\n")); + + module::set_version("gallery", 37); } static function upgrade($version) { @@ -596,6 +604,15 @@ class gallery_installer { module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); module::set_version("gallery", $version = 36); } + + if ($version == 36) { + $domain = Input::instance()->server("HTTP_HOST"); + module::set_var("gallery", "email_from", "admin@$domain"); + module::set_var("gallery", "email_reply_to", "public@$domain"); + module::set_var("gallery", "email_line_length", 70); + module::set_var("gallery", "email_header_separator", serialize("\n")); + module::set_version("gallery", $version = 37); + } } static function uninstall() { diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php index ded7b2ef..0fa554b4 100644 --- a/modules/gallery/libraries/Sendmail.php +++ b/modules/gallery/libraries/Sendmail.php @@ -35,10 +35,12 @@ class Sendmail_Core { public function __construct() { $this->headers = array(); - $config = Kohana::config("sendmail"); - foreach ($config as $key => $value) { - $this->$key($value); - } + $domain = Input::instance()->server("HTTP_HOST"); + $this->from(module::get_var("gallery", "email_from", "admin@$domain")); + $this->reply_to(module::get_var("gallery", "email_reply_to", "public@$domain")); + $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" : deserialize($separator)); } public function __get($key) { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 44da9f2f..901158b5 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 = 37 diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php index b9406047..92974e5c 100644 --- a/modules/gallery/tests/Sendmail_Test.php +++ b/modules/gallery/tests/Sendmail_Test.php @@ -23,9 +23,10 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { } public function sendmail_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: public@$domain\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; $result = Sendmail_For_Test::factory() @@ -45,8 +46,9 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { } public function sendmail_reply_to_test() { + $domain = Input::instance()->server("HTTP_HOST"); $expected = "To: receiver@someemail.com\r\n" . - "From: from@gallery3.com\n" . + "From: admin@$domain\n" . "Reply-To: reply-to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; @@ -61,9 +63,10 @@ class Sendmail_Test extends Gallery_Unit_Test_Case { } public function sendmail_html_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\n" . + "From: admin@$domain\n" . + "Reply-To: public@$domain\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 +83,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" . + "From: admin@$domain\n" . + "Reply-To: public@$domain\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" . |