[Pkg-owncloud-commits] [owncloud] 242/394: backport of fixing default email sender address

David Prévot taffit at alioth.debian.org
Fri Nov 8 23:12:15 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.

commit 1265bfa9b031c5da82e4c4df9fd33e8573a47546
Author: Randolph Carter <RandolphCarter at fantasymail.de>
Date:   Wed Dec 19 01:09:14 2012 +0100

    backport of fixing default email sender address
---
 core/ajax/share.php         |    8 +-------
 core/lostpassword/index.php |    2 +-
 lib/public/util.php         |   36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/core/ajax/share.php b/core/ajax/share.php
index 58567a7..c98a329 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -91,13 +91,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 				$text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($user, $file, $link));
 			}
 
-			// handle localhost installations
-			$server_host = OCP\Util::getServerHost();
-			if ($server_host === 'localhost') {
-				$server_host = "example.com";
-			}
-
-			$default_from = 'sharing-noreply@' . $server_host;
+			$default_from = OCP\Util::getDefaultEmailAddress('sharing-noreply');
 			$from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from);
 
 			// send it out now
diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php
index 906208d..e2f520b 100644
--- a/core/lostpassword/index.php
+++ b/core/lostpassword/index.php
@@ -22,7 +22,7 @@ if (isset($_POST['user'])) {
 			$tmpl->assign('link', $link, false);
 			$msg = $tmpl->fetchPage();
 			$l = OC_L10N::get('core');
-			$from = 'lostpassword-noreply@' . OCP\Util::getServerHost();
+			$from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
 			OC_MAIL::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
 			echo('sent');
 		}
diff --git a/lib/public/util.php b/lib/public/util.php
index 38da7e8..51b6d12 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -173,6 +173,42 @@ class Util {
 	}
 
 	/**
+	 * @brief returns the server hostname
+	 * @returns the server hostname
+	 *
+	 * Returns the server host name without an eventual port number
+	 */
+	public static function getServerHostName() {
+		$host_name = self::getServerHost();
+		// strip away port number (if existing)
+		$colon_pos = strpos($host_name, ':');
+		if ($colon_pos != FALSE) {
+			$host_name = substr($host_name, 0, $colon_pos);
+		}
+		return $host_name;
+	}
+
+	/**
+	 * @brief Returns the default email address
+	 * @param $user_part the user part of the address
+	 * @returns the default email address 
+	 *
+	 * Assembles a default email address (using the server hostname
+	 * and the given user part, and returns it
+	 * Example: when given lostpassword-noreply as $user_part param,
+	 *     and is currently accessed via http(s)://example.com/,
+	 *     it would return 'lostpassword-noreply at example.com'
+	 */
+	public static function getDefaultEmailAddress($user_part) {
+		$host_name = self::getServerHostName();
+		// handle localhost installations
+		if ($server_host === 'localhost') {
+			$server_host = "example.com";
+		}
+		return $user_part.'@'.$host_name;
+	}
+
+	/**
 	 * @brief Returns the server protocol
 	 * @returns the server protocol
 	 *

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list