From 23b566e5921d5b8bd5a957ecd2d601e556f658a0 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta <bharat@menalto.com>
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 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'installer/install.sql')

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');
-- 
cgit v1.2.3


From 5e316f78c6d73fcba9b39c0f9033f1d670de83cb Mon Sep 17 00:00:00 2001
From: Bharat Mediratta <bharat@menalto.com>
Date: Thu, 16 Sep 2010 15:17:00 -0700
Subject: Restrict viewing user profile pages to registered users only, but
 provide a "show_user_profiles_to" setting to allow admins to open it up to
 everybody (choices there are "registered_users", "admin_users" or
 "everybody").  Fixes ticket #1378.

---
 installer/install.sql                         |  5 ++--
 modules/gallery/controllers/user_profile.php  | 39 +++++++++++++++++++++++++++
 modules/gallery/helpers/gallery_installer.php | 10 ++++---
 modules/gallery/module.info                   |  2 +-
 4 files changed, 50 insertions(+), 6 deletions(-)

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index 7a40918d..05dfcb5e 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',38,1);
+INSERT INTO {modules} VALUES (1,1,'gallery',39,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);
@@ -395,7 +395,7 @@ CREATE TABLE {vars} (
   `value` text,
   PRIMARY KEY (`id`),
   UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=49 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
 /*!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');
@@ -422,6 +422,7 @@ 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,'gallery','show_user_profiles_to','registered_users');
 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\";}}');
diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php
index e992655b..4922416c 100644
--- a/modules/gallery/controllers/user_profile.php
+++ b/modules/gallery/controllers/user_profile.php
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  */
 class User_Profile_Controller extends Controller {
+
   public function show($id) {
     // If we get here, then we should have a user id other than guest.
     $user = identity::lookup_user($id);
@@ -25,6 +26,10 @@ class User_Profile_Controller extends Controller {
       throw new Kohana_404_Exception();
     }
 
+    if (!$this->_can_view_profile_pages($user)) {
+      throw new Kohana_404_Exception();
+    }
+
     $v = new Theme_View("page.html", "other", "profile");
     $v->page_title = t("%name Profile", array("name" => $user->display_name()));
     $v->content = new View("user_profile.html");
@@ -44,12 +49,20 @@ class User_Profile_Controller extends Controller {
 
   public function contact($id) {
     $user = identity::lookup_user($id);
+    if (!$this->_can_view_profile_pages($user)) {
+      throw new Kohana_404_Exception();
+    }
+
     print user_profile::get_contact_form($user);
   }
 
   public function send($id) {
     access::verify_csrf();
     $user = identity::lookup_user($id);
+    if (!$this->_can_view_profile_pages($user)) {
+      throw new Kohana_404_Exception();
+    }
+
     $form = user_profile::get_contact_form($user);
     if ($form->validate()) {
       Sendmail::factory()
@@ -66,4 +79,30 @@ class User_Profile_Controller extends Controller {
       json::reply(array("result" => "error", "html" => (string)$form));
     }
   }
+
+  private function _can_view_profile_pages($user) {
+    if (!$user->loaded()) {
+      return false;
+    }
+
+    if ($user->id == identity::active_user()->id) {
+      // You can always view your own profile
+      return true;
+    }
+
+    switch (module::get_var("gallery", "show_user_profiles_to")) {
+    case "admin_users":
+      return identity::active_user()->admin;
+
+    case "registered_users":
+      return !identity::active_user()->guest;
+
+    case "everybody":
+      return true;
+
+    default:
+      // Fail in private mode on an invalid setting
+      return false;
+    }
+  }
 }
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index c23bcca8..444d307b 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -302,14 +302,13 @@ 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");
-
-    // 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_var("gallery", "show_user_profiles_to", "registered_users");
 
-    module::set_version("gallery", 38);
+    module::set_version("gallery", 39);
   }
 
   static function upgrade($version) {
@@ -627,6 +626,11 @@ class gallery_installer {
       }
       module::set_version("gallery", $version = 38);
     }
+
+    if ($version == 38) {
+      module::set_var("gallery", "show_user_profiles_to", "registered_users");
+      module::set_version("gallery", $version = 39);
+    }
   }
 
   static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index cc3b2723..5791f79d 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
 name = "Gallery 3"
 description = "Gallery core application"
-version = 38
+version = 39
-- 
cgit v1.2.3


From 3e1743b21fd35b9d6d540e827292f1f4f006b531 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta <bharat@menalto.com>
Date: Thu, 16 Sep 2010 20:43:48 -0700
Subject: Add a module variable containing extra paths to search for binaries.
 Fixes ticket #1384.

---
 installer/install.sql                         | 5 +++--
 modules/gallery/helpers/gallery_installer.php | 8 +++++++-
 modules/gallery/helpers/graphics.php          | 3 ++-
 modules/gallery/helpers/movie.php             | 3 ++-
 modules/gallery/module.info                   | 2 +-
 5 files changed, 15 insertions(+), 6 deletions(-)

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index 05dfcb5e..52654faf 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',39,1);
+INSERT INTO {modules} VALUES (1,1,'gallery',40,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);
@@ -395,7 +395,7 @@ CREATE TABLE {vars} (
   `value` text,
   PRIMARY KEY (`id`),
   UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=51 DEFAULT CHARSET=utf8;
 /*!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');
@@ -423,6 +423,7 @@ 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,'gallery','show_user_profiles_to','registered_users');
+INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin');
 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\";}}');
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 444d307b..83961d6b 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -307,8 +307,9 @@ class gallery_installer {
     module::set_var("gallery", "email_line_length", 70);
     module::set_var("gallery", "email_header_separator", serialize("\n"));
     module::set_var("gallery", "show_user_profiles_to", "registered_users");
+    module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
 
-    module::set_version("gallery", 39);
+    module::set_version("gallery", 40);
   }
 
   static function upgrade($version) {
@@ -631,6 +632,11 @@ class gallery_installer {
       module::set_var("gallery", "show_user_profiles_to", "registered_users");
       module::set_version("gallery", $version = 39);
     }
+
+    if ($version == 39) {
+      module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
+      module::set_version("gallery", $version = 40);
+    }
   }
 
   static function uninstall() {
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index bb085ea5..2868a28d 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -314,9 +314,10 @@ class graphics_Core {
       $toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
     } else {
       $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
+      $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);
 
       putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
-             ":/usr/local/bin:/opt/local/bin:/opt/bin");
+             ":" . $extra_binary_paths);
 
       // @todo: consider refactoring the two segments below into a loop since they are so
       // similar.
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 3e55eefe..50339541 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -86,9 +86,10 @@ class movie_Core {
   static function find_ffmpeg() {
     if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
       $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
+      $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);
 
       putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
-             ":/usr/local/bin:/opt/local/bin:/opt/bin");
+             ":" . $extra_binary_paths);
       if (function_exists("exec")) {
         $ffmpeg_path = exec("which ffmpeg");
       }
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 5791f79d..1155ddf7 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
 name = "Gallery 3"
 description = "Gallery core application"
-version = 39
+version = 40
-- 
cgit v1.2.3

