From e09c6dbd5e81c6c56e9c4f386ff431c0cfe9c2b0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 31 Aug 2010 20:39:25 -0700 Subject: 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. --- modules/gallery/helpers/gallery_installer.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') 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() { -- cgit v1.2.3 From 78c590ebaee738435260e3b0bf6cb8fb5431a08d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 31 Aug 2010 21:07:43 -0700 Subject: Don't use HTTP_HOST to get the hostname. We force that to "example.com" when we are using the CLI so we'll get inconsistent behavior between CLI and the web interface. For now hardcode it to be example.com so that it's clear. But to do it right we need an after_install step which actually fixes it up. And probably an after_upgrade step as well. --- installer/install.sql | 144 +++++++++++++------------- modules/gallery/helpers/gallery_installer.php | 10 +- 2 files changed, 76 insertions(+), 78 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/installer/install.sql b/installer/install.sql index 4cb02537..7440cc8f 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS {access_caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -13,11 +13,11 @@ CREATE TABLE {access_caches} ( PRIMARY KEY (`id`), KEY `item_id` (`item_id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_intents} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE {access_intents} ( `add_2` binary(1) DEFAULT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, @@ -46,10 +46,10 @@ CREATE TABLE {caches} ( KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {comments}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {comments} ( `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, @@ -75,10 +75,10 @@ CREATE TABLE {comments} ( `updated` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {failed_auths}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {failed_auths} ( `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, @@ -86,10 +86,10 @@ CREATE TABLE {failed_auths} ( `time` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {graphics_rules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -100,12 +100,12 @@ CREATE TABLE {graphics_rules} ( `target` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` char(64) DEFAULT NULL, @@ -113,25 +113,25 @@ CREATE TABLE {groups} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {incoming_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, @@ -143,10 +143,10 @@ CREATE TABLE {incoming_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {items}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items} ( `id` int(9) NOT NULL AUTO_INCREMENT, `album_cover_item_id` int(9) DEFAULT NULL, @@ -188,11 +188,11 @@ CREATE TABLE {items} ( KEY `weight` (`weight`), KEY `left_ptr` (`left_ptr`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items_tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, @@ -201,10 +201,10 @@ CREATE TABLE {items_tags} ( KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {logs}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {logs} ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(64) DEFAULT NULL, @@ -217,10 +217,10 @@ CREATE TABLE {logs} ( `user_id` int(9) DEFAULT '0', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {messages}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {messages} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) DEFAULT NULL, @@ -229,10 +229,10 @@ CREATE TABLE {messages} ( PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {modules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {modules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -243,7 +243,7 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`), KEY `weight` (`weight`) ) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',37,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',3,3); @@ -255,8 +255,8 @@ INSERT INTO {modules} VALUES (8,1,'search',1,8); INSERT INTO {modules} VALUES (9,1,'slideshow',2,9); INSERT INTO {modules} VALUES (10,1,'tag',2,10); DROP TABLE IF EXISTS {outgoing_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `base_revision` int(9) DEFAULT NULL, @@ -268,10 +268,10 @@ CREATE TABLE {outgoing_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {permissions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {permissions} ( `id` int(9) NOT NULL AUTO_INCREMENT, `display_name` varchar(64) DEFAULT NULL, @@ -279,14 +279,14 @@ CREATE TABLE {permissions} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {search_records} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -296,21 +296,21 @@ CREATE TABLE {search_records} ( KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, @@ -318,10 +318,10 @@ CREATE TABLE {tags} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tasks}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tasks} ( `id` int(9) NOT NULL AUTO_INCREMENT, `callback` varchar(128) DEFAULT NULL, @@ -336,10 +336,10 @@ CREATE TABLE {tasks} ( PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {themes}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {themes} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) DEFAULT NULL, @@ -347,12 +347,12 @@ CREATE TABLE {themes} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {user_access_keys}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {user_access_keys} ( `id` int(9) NOT NULL AUTO_INCREMENT, `user_id` int(9) NOT NULL, @@ -361,10 +361,10 @@ CREATE TABLE {user_access_keys} ( UNIQUE KEY `access_key` (`access_key`), UNIQUE KEY `user_id` (`user_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {users} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, @@ -382,12 +382,12 @@ CREATE TABLE {users} ( UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {vars} ( `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, @@ -396,7 +396,7 @@ CREATE TABLE {vars} ( PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) ) AUTO_INCREMENT=49 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 664fe127..d5264fcc 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,9 +304,8 @@ class gallery_installer { module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); // 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_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")); @@ -606,9 +605,8 @@ class gallery_installer { } 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_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); -- cgit v1.2.3 From 1f621d9827040d9730946a5804dd3d7269198ccc Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 1 Sep 2010 21:24:41 -0700 Subject: Refine the patch for #1216. If the admin user changes their email address update the sendmail from and reply_to fields in advanced settings. Also change this if the identity provider has changed. --- modules/gallery/helpers/gallery_event.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index df5394c9..66b250e9 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,11 @@ class gallery_event_Core { $data->content[] = (object) array("title" => t("User information"), "view" => $v); } + + static function user_change_email_form_completed($user, $form) { + if ($user->admin) { + module::set_var("gallery", "email_from", $user->email); + module::set_var("gallery", "email_reply_to", $user->email); + } + } } -- cgit v1.2.3 From 70c8572ea1b421458241b9b3b1cc85cb6bf35057 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 1 Sep 2010 22:19:44 -0700 Subject: Make RENAME TABLE operations idempotent so that in case there's a failure of some kind we can restart the upgrade and it'll continue. Fixes ticket #1325. --- modules/gallery/helpers/gallery_installer.php | 4 +++- modules/rest/helpers/rest_installer.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index d5264fcc..fa5113bf 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -550,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); } 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); } -- cgit v1.2.3 From 04f6646b0637d9cb221159b4931b184449a4dc1d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 1 Sep 2010 23:19:43 -0700 Subject: Hopefully the third and final patch for #1216. Set the default from and reply-to addresses to an empty string. The first time the user model is saved, set the sendmail from and reply-to addresses. Requires an update to gallery version 38. --- modules/gallery/helpers/gallery_event.php | 11 +++++++---- modules/gallery/helpers/gallery_installer.php | 20 +++++++++++++++++--- modules/gallery/libraries/Sendmail.php | 7 +++---- modules/gallery/module.info | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 66b250e9..8344c11c 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -550,10 +550,13 @@ class gallery_event_Core { } - static function user_change_email_form_completed($user, $form) { - if ($user->admin) { - module::set_var("gallery", "email_from", $user->email); - module::set_var("gallery", "email_reply_to", $user->email); + static function user_updated($original_user, $updated_user) { + if ($updated_user->admin) { + $email = module::get_var("gallery", "email_from", ""); + if (empty($email)) { + 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 d5264fcc..c6f19ad0 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,12 +304,12 @@ class gallery_installer { module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); // Sendmail configuration - module::set_var("gallery", "email_from", "admin@example.com"); - module::set_var("gallery", "email_reply_to", "public@example.com"); + 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", 37); + module::set_version("gallery", 38); } static function upgrade($version) { @@ -611,6 +611,20 @@ class gallery_installer { 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/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php index 0fa554b4..a93be736 100644 --- a/modules/gallery/libraries/Sendmail.php +++ b/modules/gallery/libraries/Sendmail.php @@ -35,12 +35,11 @@ class Sendmail_Core { public function __construct() { $this->headers = array(); - $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->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" : deserialize($separator)); + $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 901158b5..cc3b2723 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 37 +version = 38 -- cgit v1.2.3 From 7477f0119c39a71e05d3e6b2caad8418a7d41c83 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 1 Sep 2010 23:39:01 -0700 Subject: Explain wtf we're doing in user_updated. --- modules/gallery/helpers/gallery_event.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 8344c11c..5e44caef 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -551,6 +551,8 @@ class gallery_event_Core { } static function user_updated($original_user, $updated_user) { + // If no default from/reply-to email address is set, 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 (empty($email)) { -- cgit v1.2.3 From 23b566e5921d5b8bd5a957ecd2d601e556f658a0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 1 Sep 2010 23:52:19 -0700 Subject: One more adjustment for ticket #1216. The packaging process forces the default email address for admin to be unknown@unknown.com and when that happens the gallery_event::user_updated() event listener fires and sets the default values. This is hard to work around, so let's just roll with it and use unknown@unknown.com as our default placeholder. So now, if an admin sets their email address and the current values are unknown@unknown.com we adopt the admin's email address for the site's mail_from/reply_to fields. --- installer/install.sql | 8 ++++---- modules/gallery/helpers/gallery_event.php | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/installer/install.sql b/installer/install.sql index 7440cc8f..7a40918d 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -244,7 +244,7 @@ CREATE TABLE {modules} ( KEY `weight` (`weight`) ) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {modules} VALUES (1,1,'gallery',37,1); +INSERT INTO {modules} VALUES (1,1,'gallery',38,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',3,3); INSERT INTO {modules} VALUES (4,1,'organize',2,4); @@ -417,15 +417,15 @@ INSERT INTO {vars} VALUES (NULL,'gallery','date_time_format','Y-M-d H:i:s'); INSERT INTO {vars} VALUES (NULL,'gallery','favicon_url','lib/images/favicon.ico'); INSERT INTO {vars} VALUES (NULL,'gallery','date_format','Y-M-d'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_dashboard_center','a:3:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}}'); -INSERT INTO {vars} VALUES (NULL,'gallery','email_from','admin@example.com'); -INSERT INTO {vars} VALUES (NULL,'gallery','email_reply_to','public@example.com'); +INSERT INTO {vars} VALUES (NULL,'gallery','email_from','unknown@unknown.com'); +INSERT INTO {vars} VALUES (NULL,'gallery','email_reply_to','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','choose_default_tookit','1'); INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); INSERT INTO {vars} VALUES (NULL,'gallery','email_header_separator','s:1:\"\n\";'); +INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:9;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:10;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:11;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:12;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); -INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'rest','allow_guest_access','0'); INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 5e44caef..ec7d1882 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -551,11 +551,12 @@ class gallery_event_Core { } static function user_updated($original_user, $updated_user) { - // If no default from/reply-to email address is set, 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 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 (empty($email)) { + if ($email == "unknown@unknown.com") { module::set_var("gallery", "email_from", $updated_user->email); module::set_var("gallery", "email_reply_to", $updated_user->email); } -- cgit v1.2.3 From 2a86446249c4782287e1e6e472f422b851c2fb47 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Sep 2010 00:50:02 -0700 Subject: Handle the case of a completely private Gallery separately and just put up a login page, very similar to the way that the maintenance mode login page works. Fixes ticket #1056. --- modules/gallery/helpers/gallery.php | 16 ++++++++++++++++ modules/gallery/hooks/init_gallery.php | 1 + 2 files changed, 17 insertions(+) (limited to 'modules/gallery/helpers') 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 @@ -36,6 +36,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 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 -- cgit v1.2.3