summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery.php16
-rw-r--r--modules/gallery/helpers/gallery_event.php15
-rw-r--r--modules/gallery/helpers/gallery_installer.php35
3 files changed, 64 insertions, 2 deletions
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() {