From fffb07fd91b42d64e71e16a13bcdde87114fad19 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 18:09:25 +0200 Subject: [ticket/10073] Use namespaces and fix all class names PHPBB3-10073 --- phpBB/phpbb/message/message.php | 183 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 phpBB/phpbb/message/message.php (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php new file mode 100644 index 0000000000..9e94d4bbcd --- /dev/null +++ b/phpBB/phpbb/message/message.php @@ -0,0 +1,183 @@ +server_name = $server_name; + } + + public function set_subject($subject) + { + $this->subject = $subject; + } + + public function set_body($body) + { + $this->body = $body; + } + + public function set_template($template) + { + $this->template = $template; + } + + public function set_template_vars($template_vars) + { + $this->template_vars = $template_vars; + } + + public function add_recipient_from_user_row(array $user) + { + $this->add_recipient( + $user['username'], + $user['user_email'], + $user['user_lang'], + $user['username'], + $user['user_jabber'], + $user['user_notify_type'] + ); + } + + public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '') + { + $this->recipients[] = array( + 'name' => $recipient_name, + 'address' => $recipient_address, + 'lang' => $recipient_lang, + 'username' => $recipient_username, + 'jabber' => $recipient_jabber, + 'notify_type' => $recipient_notify_type, + 'to_name' => $recipient_name, + ); + } + + public function set_sender_from_user($user) + { + $this->set_sender( + $user->ip, + $user->data['username'], + $user->data['user_email'], + $user->lang_name, + $user->data['user_id'], + $user->data['username'], + $user->data['user_jabber'] + ); + + $this->set_sender_notify_type($user->data['user_notify_type']); + } + + public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '') + { + $this->sender_ip = $sender_ip; + $this->sender_name = $sender_name; + $this->sender_address = $sender_address; + $this->sender_lang = $sender_lang; + $this->sender_id = $sender_id; + $this->sender_username = $sender_username; + $this->sender_jabber = $sender_jabber; + } + + public function set_sender_notify_type($sender_notify_type) + { + $this->sender_notify_type = $sender_notify_type; + } + + /** + * Ok, now the same email if CC specified, but without exposing the users email address + * + * @return null + */ + public function cc_sender() + { + if (!sizeof($this->recipients)) + { + trigger_error('No email recipients specified'); + } + if (!$this->sender_address) + { + trigger_error('No email sender specified'); + } + + $this->recipients[] = array( + 'lang' => $this->sender_lang, + 'address' => $this->sender_address, + 'name' => $this->sender_name, + 'username' => $this->sender_username, + 'jabber' => $this->sender_jabber, + 'notify_type' => $this->sender_notify_type, + 'to_name' => $this->recipients[0]['to_name'], + ); + } + + public function send(\messenger $messenger, $phpEx) + { + if (!sizeof($this->recipients)) + { + return; + } + + foreach ($this->recipients as $recipient) + { + $messenger->template($this->template, $recipient['lang']); + $messenger->replyto($this->sender_address); + $messenger->to($recipient['address'], $recipient['name']); + $messenger->im($recipient['jabber'], $recipient['username']); + + $messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name); + $messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip); + + if ($this->sender_id) + { + $messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id); + } + if ($this->sender_username) + { + $messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username); + } + + $messenger->subject(htmlspecialchars_decode($this->subject)); + + $messenger->assign_vars(array( + 'BOARD_CONTACT' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', + 'TO_USERNAME' => htmlspecialchars_decode($recipient['to_name']), + 'FROM_USERNAME' => htmlspecialchars_decode($this->sender_name), + 'MESSAGE' => htmlspecialchars_decode($this->body)) + ); + + if (sizeof($this->template_vars)) + { + $messenger->assign_vars($this->template_vars); + } + + $messenger->send($recipient['notify_type']); + } + } +} -- cgit v1.2.1 From 5c13829111efffc8032db65cee83bcc80812bc1d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 22:38:08 +0200 Subject: [ticket/10073] Fix grammar in comment PHPBB3-10073 --- phpBB/phpbb/message/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 9e94d4bbcd..899d553a6d 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -111,7 +111,7 @@ class message } /** - * Ok, now the same email if CC specified, but without exposing the users email address + * Ok, now the same email if CC specified, but without exposing the user's email address * * @return null */ -- cgit v1.2.1 From 67cf0a912c8ed24c7466163fa409e8154082e1df Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:24:10 +0200 Subject: [ticket/10073] Add doc blocks to new classes PHPBB3-10073 --- phpBB/phpbb/message/message.php | 101 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 899d553a6d..332604cc8e 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -9,63 +9,129 @@ namespace phpbb\message; +/** +* Class message +* Holds all information for an email and sends it in the end +* +* @package phpbb\message +*/ class message { + /** @var string */ protected $server_name; + /** @var string */ protected $subject = ''; + /** @var string */ protected $body = ''; + /** @var string */ protected $template = ''; + /** @var array */ protected $template_vars = array(); + /** @var string */ protected $sender_ip = ''; + /** @var string */ protected $sender_name = ''; + /** @var string */ protected $sender_address = ''; + /** @var string */ protected $sender_lang = ''; + /** @var string */ protected $sender_id = ''; + /** @var string */ protected $sender_username = ''; + /** @var string */ protected $sender_jabber = ''; + /** @var int */ protected $sender_notify_type = NOTIFY_EMAIL; + /** @var array */ protected $recipients; + /** + * Construct + * + * @param string $server_name Used for AntiAbuse header + */ public function __construct($server_name) { $this->server_name = $server_name; } + /** + * Set the subject of the email + * + * @param string $subject + * @return null + */ public function set_subject($subject) { $this->subject = $subject; } + /** + * Set the body of the email text + * + * @param string $body + * @return null + */ public function set_body($body) { $this->body = $body; } + /** + * Set the name of the email template to use + * + * @param string $template + * @return null + */ public function set_template($template) { $this->template = $template; } + /** + * Set the array with the "template" data for the email + * + * @param array $template_vars + * @return null + */ public function set_template_vars($template_vars) { $this->template_vars = $template_vars; } + /** + * Add a recipient from \phpbb\user + * + * @param \phpbb\user $user + * @return null + */ public function add_recipient_from_user_row(array $user) { $this->add_recipient( $user['username'], $user['user_email'], $user['user_lang'], + $user['user_notify_type'], $user['username'], - $user['user_jabber'], - $user['user_notify_type'] + $user['user_jabber'] ); } + /** + * Add a recipient + * + * @param string $recipient_name Displayed sender name + * @param string $recipient_address Email address + * @param string $recipient_lang + * @param int $recipient_notify_type Used notification methods (Jabber, Email, ...) + * @param string $recipient_username User Name (used for AntiAbuse header) + * @param string $recipient_jabber + * @return null + */ public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '') { $this->recipients[] = array( @@ -79,6 +145,12 @@ class message ); } + /** + * Set the senders data from \phpbb\user object + * + * @param \phpbb\user $user + * @return null + */ public function set_sender_from_user($user) { $this->set_sender( @@ -94,6 +166,18 @@ class message $this->set_sender_notify_type($user->data['user_notify_type']); } + /** + * Set the senders data + * + * @param string $sender_ip + * @param string $sender_name Displayed sender name + * @param string $sender_address Email address + * @param string $sender_lang + * @param int $sender_id User ID + * @param string $sender_username User Name (used for AntiAbuse header) + * @param string $sender_jabber + * @return null + */ public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '') { $this->sender_ip = $sender_ip; @@ -105,6 +189,12 @@ class message $this->sender_jabber = $sender_jabber; } + /** + * Which notification type should be used? Jabber, Email, ...? + * + * @param int $sender_notify_type + * @return null + */ public function set_sender_notify_type($sender_notify_type) { $this->sender_notify_type = $sender_notify_type; @@ -137,6 +227,13 @@ class message ); } + /** + * Send the email + * + * @param \messenger $messenger + * @param string $phpEx + * @return null + */ public function send(\messenger $messenger, $phpEx) { if (!sizeof($this->recipients)) -- cgit v1.2.1 From ed8c16bf0ddb8fc8723aa870607f255d80aab55b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 16:34:25 +0200 Subject: [ticket/10073] Fallback to board_contact when contact page is disabled PHPBB3-10073 --- phpBB/phpbb/message/message.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 332604cc8e..182995ba21 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -234,7 +234,7 @@ class message * @param string $phpEx * @return null */ - public function send(\messenger $messenger, $phpEx) + public function send(\messenger $messenger, $contact) { if (!sizeof($this->recipients)) { @@ -263,7 +263,7 @@ class message $messenger->subject(htmlspecialchars_decode($this->subject)); $messenger->assign_vars(array( - 'BOARD_CONTACT' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', + 'BOARD_CONTACT' => $contact, 'TO_USERNAME' => htmlspecialchars_decode($recipient['to_name']), 'FROM_USERNAME' => htmlspecialchars_decode($this->sender_name), 'MESSAGE' => htmlspecialchars_decode($this->body)) -- cgit v1.2.1 From 0d0465bc08980b0ba946a4c001361e0e65a43d85 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 14:23:36 +0200 Subject: [ticket/12715] Cleanup comments in \phpbb\message\* PHPBB3-12715 --- phpBB/phpbb/message/message.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 182995ba21..7ba2b2f32d 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -106,7 +106,7 @@ class message /** * Add a recipient from \phpbb\user * - * @param \phpbb\user $user + * @param array $user * @return null */ public function add_recipient_from_user_row(array $user) @@ -231,7 +231,7 @@ class message * Send the email * * @param \messenger $messenger - * @param string $phpEx + * @param string $contact * @return null */ public function send(\messenger $messenger, $contact) -- cgit v1.2.1 From 32a2c95f903cbbfad909945887a1cbabd84d5039 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 20 Jun 2014 15:02:08 +0200 Subject: [ticket/12723] Add Sniff ensuring PHP files use the correct file header PHPBB3-12723 --- phpBB/phpbb/message/message.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/message/message.php') diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 7ba2b2f32d..5fd24b542e 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -12,8 +16,6 @@ namespace phpbb\message; /** * Class message * Holds all information for an email and sends it in the end -* -* @package phpbb\message */ class message { -- cgit v1.2.1