From d52f34f5ec5d006ec7e610e1c72266df21e70ac7 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 5 Jun 2011 09:40:43 +0200 Subject: [ticket/10073] Add a contact administrators page and refactor email forms. The message to be displayed on top of the email form cannot be configured yet. PHPBB3-10073 --- phpBB/phpbb/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index d286dc9cfc..cfcb8e10a2 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1075,7 +1075,7 @@ class session { global $config, $db; - if (defined('IN_CHECK_BAN')) + if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN')) { return; } -- cgit v1.2.1 From 389bc0b8dd5594a9f66c1026df408dfe73eb65b0 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 7 Jun 2011 03:46:38 +0200 Subject: [ticket/10073] Replace board_contact mail with links to contact page Error pages still contain the email address. PHPBB3-10073 --- phpBB/phpbb/session.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index cfcb8e10a2..c35caf5047 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1189,7 +1189,7 @@ class session if ($banned && !$return) { - global $template; + global $template, $phpbb_root_path, $phpEx; // If the session is empty we need to create a valid one... if (empty($this->session_id)) @@ -1210,8 +1210,6 @@ class session // We show a login box here to allow founders accessing the board if banned by IP if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) { - global $phpEx; - $this->setup('ucp'); $this->data['is_registered'] = $this->data['is_bot'] = false; @@ -1235,7 +1233,7 @@ class session $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - $message = sprintf($this->lang[$message], $till_date, '', ''); + $message = sprintf($this->lang[$message], $till_date, '', ''); $message .= ($ban_row['ban_give_reason']) ? '

' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; $message .= '

' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . ''; -- cgit v1.2.1 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 --- .../db/migration/data/v310/contact_admin_form.php | 25 +++ phpBB/phpbb/message/admin_form.php | 112 +++++++++++++ phpBB/phpbb/message/form.php | 121 ++++++++++++++ phpBB/phpbb/message/message.php | 183 +++++++++++++++++++++ phpBB/phpbb/message/topic_form.php | 144 ++++++++++++++++ phpBB/phpbb/message/user_form.php | 106 ++++++++++++ 6 files changed, 691 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/contact_admin_form.php create mode 100644 phpBB/phpbb/message/admin_form.php create mode 100644 phpBB/phpbb/message/form.php create mode 100644 phpBB/phpbb/message/message.php create mode 100644 phpBB/phpbb/message/topic_form.php create mode 100644 phpBB/phpbb/message/user_form.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php new file mode 100644 index 0000000000..c4149a0976 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -0,0 +1,25 @@ +config['contact_admin_form_enable']); + } + + public function update_data() + { + return array( + array('config.add', array('contact_admin_form_enable', 1)), + ); + } +} diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php new file mode 100644 index 0000000000..dc995062a0 --- /dev/null +++ b/phpBB/phpbb/message/admin_form.php @@ -0,0 +1,112 @@ +config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ + { + return 'NO_CONTACT_PAGE'; + } + + return false; + } + + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->subject = $request->variable('subject', '', true); + $this->sender_address = $request->variable('email', ''); + $this->sender_name = $request->variable('name', '', true); + } + + public function submit(\messenger $messenger) + { + if (!$this->subject) + { + $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; + } + if (!$this->body) + { + $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; + } + + if ($this->user->data['is_registered']) + { + $this->message->set_sender_from_user($this->user); + $this->sender_name = $this->user->data['username']; + $this->sender_address = $this->user->data['user_email']; + } + else + { + if (!$this->sender_name) + { + $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; + } + if (!$this->sender_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->sender_address)) + { + $this->errors[] = $this->user->lang['EMPTY_SENDER_EMAIL']; + } + + $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); + $this->message->set_sender_notify_type(NOTIFY_EMAIL); + } + + $this->message->set_template('contact_admin'); + $this->message->set_subject($this->subject); + $this->message->set_body($this->body); + $this->message->add_recipient( + $this->user->lang['ADMINISTRATOR'], + $this->config['board_contact'], + $this->config['default_lang'], + NOTIFY_EMAIL + ); + + $this->message->set_template_vars(array( + 'FROM_EMAIL_ADDRESS' => $this->sender_address, + 'FROM_IP_ADDRESS' => $this->user->ip, + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'U_FROM_PROFILE' => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'], + )); + + parent::submit($messenger); + } + + public function render(\phpbb\template\template $template) + { + $template->assign_vars(array( + 'S_CONTACT_ADMIN' => true, + 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'CONTACT_INFO' => '', /** TODO: $this->config['contact_admin_info'] */ + 'MESSAGE' => $this->body, + 'SUBJECT' => $this->subject, + 'NAME' => $this->sender_name, + 'EMAIL' => $this->sender_address, + )); + + parent::render($template); + } +} diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php new file mode 100644 index 0000000000..91da2d69b5 --- /dev/null +++ b/phpBB/phpbb/message/form.php @@ -0,0 +1,121 @@ +phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->db = $db; + + $this->errors = array(); + + $this->message = new \phpbb\message\message($config['server_name']); + $this->message->set_sender_from_user($this->user); + } + + /** + * Returns the title for the email form page + */ + public function get_page_title() + { + $this->user->lang['SEND_EMAIL']; + } + + public function get_template_file() + { + return 'memberlist_email.html'; + } + + public function check_allow() + { + if (!$this->config['email_enable']) + { + return 'EMAIL_DISABLED'; + } + + if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval']) + { + return 'FLOOD_EMAIL_LIMIT'; + } + + return false; + } + + public function get_return_message() + { + return sprintf($this->user->lang['RETURN_INDEX'], '', ''); + } + + public function bind(\phpbb\request\request_interface $request) + { + $this->cc_sender = $request->is_set_post('cc_sender'); + $this->body = $request->variable('message', '', true); + } + + public function submit(\messenger $messenger) + { + if (!check_form_key('memberlist_email')) + { + $this->errors[] = 'FORM_INVALID'; + } + + if (!sizeof($this->errors)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_emailtime = ' . time() . ' + WHERE user_id = ' . $this->user->data['user_id']; + $this->db->sql_query($sql); + + if ($this->cc_sender) + { + $this->message->cc_sender(); + } + + $this->message->send($messenger, $this->phpEx); + + meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); + trigger_error($this->user->lang['EMAIL_SENT'] . '

' . $this->get_return_message()); + } + } + + public function render(\phpbb\template\template $template) + { + add_form_key('memberlist_email'); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('
', $this->errors) : '', + )); + } +} 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']); + } + } +} diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php new file mode 100644 index 0000000000..2b6d50aa26 --- /dev/null +++ b/phpBB/phpbb/message/topic_form.php @@ -0,0 +1,144 @@ +db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + public function check_allow() + { + $error = parent::check_allow(); + if ($error) + { + return $error; + } + + if (!$this->auth->acl_get('u_sendemail')) + { + return 'NO_EMAIL'; + } + + if (!$this->topic_row) + { + return 'NO_TOPIC'; + } + + /** + * @todo remove else case when global topics have forum id + */ + if ($this->topic_row['forum_id']) + { + if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id'])) + { + return 'SORRY_AUTH_READ'; + } + + if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id'])) + { + return 'NO_EMAIL'; + } + } + else + { + // If global announcement, we need to check if the user is able to at least read and email in one forum... + if (!$this->auth->acl_getf_global('f_read')) + { + return 'SORRY_AUTH_READ'; + } + + if (!$this->auth->acl_getf_global('f_email')) + { + return 'NO_EMAIL'; + } + } + + return false; + } + + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->topic_id = $request->variable('t', 0); + $this->recipient_address = $request->variable('email', ''); + $this->recipient_name = $request->variable('name', '', true); + $this->recipient_lang = $request->variable('lang', $this->config['default_lang']); + + $this->topic_row = $this->get_topic_row($this->topic_id); + } + + public function submit(\messenger $messenger) + { + if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address)) + { + $this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL']; + } + + if (!$this->recipient_name) + { + $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL']; + } + + + $this->message->set_template('email_notify'); + $this->message->set_template_vars(array( + 'TOPIC_NAME' => htmlspecialchars_decode($this->topic_row['topic_title']), + 'U_TOPIC' => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id, + )); + + $this->message->add_recipient( + $this->recipient_name, + $this->recipient_address, + $this->recipient_lang, + NOTIFY_EMAIL + ); + $this->message->set_sender_notify_type(NOTIFY_EMAIL); + + parent::submit($messenger); + } + + public function get_return_message() + { + return sprintf($this->user->lang['RETURN_TOPIC'], '', ''); + } + + public function render(\phpbb\template\template $template) + { + parent::render($template); + + $template->assign_vars(array( + 'EMAIL' => $this->recipient_address, + 'NAME' => $this->recipient_name, + 'S_LANG_OPTIONS' => language_select($this->recipient_lang), + 'MESSAGE' => $this->body, + + 'L_EMAIL_BODY_EXPLAIN' => $this->user->lang['EMAIL_TOPIC_EXPLAIN'], + 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&t=' . $this->topic_id)) + ); + } +} diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php new file mode 100644 index 0000000000..a76d553b7c --- /dev/null +++ b/phpBB/phpbb/message/user_form.php @@ -0,0 +1,106 @@ +auth->acl_get('u_sendemail')) + { + return 'NO_EMAIL'; + } + + if ($this->recipient_id == ANONYMOUS || !$this->config['board_email_form']) + { + return 'NO_EMAIL'; + } + + if (!$this->recipient_row) + { + return 'NO_USER'; + } + + // Can we send email to this user? + if (!$this->recipient_row['user_allow_viewemail'] && !$this->auth->acl_get('a_user')) + { + return 'NO_EMAIL'; + } + + return false; + } + + protected function get_user_row($user_id) + { + $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . ((int) $user_id) . ' + AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->recipient_id = $request->variable('u', 0); + $this->subject = $request->variable('subject', '', true); + + $this->recipient_row = $this->get_user_row($this->recipient_id); + } + + public function submit(\messenger $messenger) + { + if (!$this->subject) + { + $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; + } + + if (!$this->body) + { + $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; + } + + $this->message->set_template('profile_send_email'); + $this->message->set_subject($this->subject); + $this->message->set_body($this->body); + $this->message->add_recipient_from_user_row($this->recipient_row); + + parent::submit($messenger); + } + + public function render(\phpbb\template\template $template) + { + parent::render($template); + + $template->assign_vars(array( + 'S_SEND_USER' => true, + 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&u=' . $this->recipient_id), + + 'USERNAME' => $this->recipient_row['username'], + 'SUBJECT' => $this->subject, + 'MESSAGE' => $this->body, + )); + } +} -- cgit v1.2.1 From ea9756917e7d7e437f0e8076b237c882dcd26a88 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 22:09:35 +0200 Subject: [ticket/10073] Fix code sniffer complain PHPBB3-10073 --- phpBB/phpbb/message/topic_form.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 2b6d50aa26..d691c1e45f 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -104,7 +104,6 @@ class topic_form extends form $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL']; } - $this->message->set_template('email_notify'); $this->message->set_template_vars(array( 'TOPIC_NAME' => htmlspecialchars_decode($this->topic_row['topic_title']), -- cgit v1.2.1 From af024ea3e503a07f4ca0635d186866fa7c5b795f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 22:37:49 +0200 Subject: [ticket/10073] Global announcements have a forum_id now PHPBB3-10073 --- phpBB/phpbb/message/topic_form.php | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index d691c1e45f..5a5d090017 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -48,33 +48,14 @@ class topic_form extends form return 'NO_TOPIC'; } - /** - * @todo remove else case when global topics have forum id - */ - if ($this->topic_row['forum_id']) + if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id'])) { - if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id'])) - { - return 'SORRY_AUTH_READ'; - } - - if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id'])) - { - return 'NO_EMAIL'; - } + return 'SORRY_AUTH_READ'; } - else + + if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id'])) { - // If global announcement, we need to check if the user is able to at least read and email in one forum... - if (!$this->auth->acl_getf_global('f_read')) - { - return 'SORRY_AUTH_READ'; - } - - if (!$this->auth->acl_getf_global('f_email')) - { - return 'NO_EMAIL'; - } + return 'NO_EMAIL'; } return false; -- 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') 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/admin_form.php | 21 ++++++++ phpBB/phpbb/message/form.php | 64 ++++++++++++++++++++--- phpBB/phpbb/message/message.php | 101 ++++++++++++++++++++++++++++++++++++- phpBB/phpbb/message/topic_form.php | 33 +++++++++++- phpBB/phpbb/message/user_form.php | 55 +++++++++++++++----- 5 files changed, 251 insertions(+), 23 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index dc995062a0..5201994c73 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -9,12 +9,24 @@ namespace phpbb\message; +/** +* Class admin_form +* Displays a message to the user and allows him to send an email +* +* @package phpbb\message +*/ class admin_form extends form { + /** @var string */ protected $subject; + /** @var string */ protected $sender_name; + /** @var string */ protected $sender_address; + /** + * {inheritDoc} + */ public function check_allow() { $error = parent::check_allow(); @@ -31,6 +43,9 @@ class admin_form extends form return false; } + /** + * {inheritDoc} + */ public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -40,6 +55,9 @@ class admin_form extends form $this->sender_name = $request->variable('name', '', true); } + /** + * {inheritDoc} + */ public function submit(\messenger $messenger) { if (!$this->subject) @@ -93,6 +111,9 @@ class admin_form extends form parent::submit($messenger); } + /** + * {inheritDoc} + */ public function render(\phpbb\template\template $template) { $template->assign_vars(array( diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php index 91da2d69b5..205999e5f2 100644 --- a/phpBB/phpbb/message/form.php +++ b/phpBB/phpbb/message/form.php @@ -9,6 +9,11 @@ namespace phpbb\message; +/** +* Abstract class form +* +* @package phpbb\message +*/ abstract class form { /** @var \phpbb\auth\auth */ @@ -17,6 +22,8 @@ abstract class form protected $config; /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** @var \phpbb\message\message */ + protected $message; /** @var \phpbb\user */ protected $user; @@ -25,11 +32,23 @@ abstract class form /** @var string */ protected $phpEx; - protected $errors; - protected $message; + /** @var array */ + protected $errors = array(); + /** @var bool */ protected $cc_sender; + /** @var string */ protected $body; + /** + * Construct + * + * @param \phpbb\auth\auth $auth + * @param \phpbb\config\config $config + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\user $user + * @param string $phpbb_root_path + * @param string $phpEx + */ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) { $this->phpbb_root_path = $phpbb_root_path; @@ -39,25 +58,35 @@ abstract class form $this->config = $config; $this->db = $db; - $this->errors = array(); - - $this->message = new \phpbb\message\message($config['server_name']); + $this->message = new message($config['server_name']); $this->message->set_sender_from_user($this->user); } /** * Returns the title for the email form page + * + * @return string */ public function get_page_title() { - $this->user->lang['SEND_EMAIL']; + return $this->user->lang['SEND_EMAIL']; } + /** + * Returns the file name of the form template + * + * @return string + */ public function get_template_file() { return 'memberlist_email.html'; } + /** + * Checks whether the user is allowed to use the form + * + * @return false|string Error string if not allowed, false otherwise + */ public function check_allow() { if (!$this->config['email_enable']) @@ -73,17 +102,34 @@ abstract class form return false; } + /** + * Get the return link after the message has been sent + * + * @return string + */ public function get_return_message() { return sprintf($this->user->lang['RETURN_INDEX'], '', ''); } + /** + * Bind the values of the request to the form + * + * @param \phpbb\request\request_interface $request + * @return null + */ public function bind(\phpbb\request\request_interface $request) { $this->cc_sender = $request->is_set_post('cc_sender'); $this->body = $request->variable('message', '', true); } + /** + * Submit form, generate the email and send it + * + * @param \messenger $messenger + * @return null + */ public function submit(\messenger $messenger) { if (!check_form_key('memberlist_email')) @@ -110,6 +156,12 @@ abstract class form } } + /** + * Render the template of the form + * + * @param \phpbb\template\template $template + * @return null + */ public function render(\phpbb\template\template $template) { add_form_key('memberlist_email'); 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)) diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 5a5d090017..988028c301 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -9,15 +9,31 @@ namespace phpbb\message; +/** +* Class topic_form +* Form used to send topics as notification emails +* +* @package phpbb\message +*/ class topic_form extends form { + /** @var int */ protected $topic_id; - + /** @var array */ protected $topic_row; + /** @var string */ protected $recipient_address; + /** @var string */ protected $recipient_name; + /** @var string */ protected $recipient_lang; + /** + * Get the data of the topic + * + * @param int $topic_id + * @return false|array false if the topic does not exist, array otherwise + */ protected function get_topic_row($topic_id) { $sql = 'SELECT forum_id, topic_title @@ -30,6 +46,9 @@ class topic_form extends form return $row; } + /** + * {inheritDoc} + */ public function check_allow() { $error = parent::check_allow(); @@ -61,6 +80,9 @@ class topic_form extends form return false; } + /** + * {inheritDoc} + */ public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -73,6 +95,9 @@ class topic_form extends form $this->topic_row = $this->get_topic_row($this->topic_id); } + /** + * {inheritDoc} + */ public function submit(\messenger $messenger) { if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address)) @@ -102,11 +127,17 @@ class topic_form extends form parent::submit($messenger); } + /** + * {inheritDoc} + */ public function get_return_message() { return sprintf($this->user->lang['RETURN_TOPIC'], '', ''); } + /** + * {inheritDoc} + */ public function render(\phpbb\template\template $template) { parent::render($template); diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php index a76d553b7c..5e98590c58 100644 --- a/phpBB/phpbb/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -9,12 +9,43 @@ namespace phpbb\message; +/** +* Class user_form +* Allows users to send emails to other users +* +* @package phpbb\message +*/ class user_form extends form { + /** @var int */ protected $recipient_id; - protected $subject; + /** @var array */ protected $recipient_row; + /** @var string */ + protected $subject; + /** + * Get the data of the recipient + * + * @param int $user_id + * @return false|array false if the user does not exist, array otherwise + */ + protected function get_user_row($user_id) + { + $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . (int) $user_id . ' + AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + /** + * {inheritDoc} + */ public function check_allow() { $error = parent::check_allow(); @@ -47,19 +78,9 @@ class user_form extends form return false; } - protected function get_user_row($user_id) - { - $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . ((int) $user_id) . ' - AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row; - } - + /** + * {inheritDoc} + */ public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -70,6 +91,9 @@ class user_form extends form $this->recipient_row = $this->get_user_row($this->recipient_id); } + /** + * {inheritDoc} + */ public function submit(\messenger $messenger) { if (!$this->subject) @@ -90,6 +114,9 @@ class user_form extends form parent::submit($messenger); } + /** + * {inheritDoc} + */ public function render(\phpbb\template\template $template) { parent::render($template); -- cgit v1.2.1 From 35b88624f5f85e3d7ea048e9f537dc477bf913c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:34:44 +0200 Subject: [ticket/10073] Remove unneccessary todos he config switch is enough PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 5201994c73..57564cff12 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -35,7 +35,7 @@ class admin_form extends form return $error; } - if (!$this->config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ + if (!$this->config['contact_admin_form_enable']) { return 'NO_CONTACT_PAGE'; } -- cgit v1.2.1 From ef8d7b995e854c64a5f529978ee4898030ae9fa4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:46:28 +0200 Subject: [ticket/10073] Add @config_text to admin_form PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 57564cff12..f7eddb59dc 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -17,6 +17,9 @@ namespace phpbb\message; */ class admin_form extends form { + /** @var \phpbb\config\db_text */ + protected $config_text; + /** @var string */ protected $subject; /** @var string */ @@ -24,6 +27,23 @@ class admin_form extends form /** @var string */ protected $sender_address; + /** + * Construct + * + * @param \phpbb\auth\auth $auth + * @param \phpbb\config\config $config + * @param \phpbb\config\db_text $config_text + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\user $user + * @param string $phpbb_root_path + * @param string $phpEx + */ + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) + { + parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx); + $this->config_text = $config_text; + } + /** * {inheritDoc} */ @@ -116,12 +136,15 @@ class admin_form extends form */ public function render(\phpbb\template\template $template) { + // @todo Add option to fill the db with it and add migration + $l_admin_info = '';//$this->config_text['contact_admin_info']; + $template->assign_vars(array( 'S_CONTACT_ADMIN' => true, 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], 'S_IS_REGISTERED' => $this->user->data['is_registered'], - 'CONTACT_INFO' => '', /** TODO: $this->config['contact_admin_info'] */ + 'CONTACT_INFO' => $l_admin_info, 'MESSAGE' => $this->body, 'SUBJECT' => $this->subject, 'NAME' => $this->sender_name, -- cgit v1.2.1 From 84a02f5cef6cd2cc4b8fb5e9e083e848df8d2a48 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 13:28:38 +0200 Subject: [ticket/10073] Use get_username_string and correctly sprintf for languages PHPBB3-10073 --- phpBB/phpbb/message/user_form.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php index 5e98590c58..7aa4b94def 100644 --- a/phpBB/phpbb/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -32,7 +32,7 @@ class user_form extends form */ protected function get_user_row($user_id) { - $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type + $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type FROM ' . USERS_TABLE . ' WHERE user_id = ' . (int) $user_id . ' AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; @@ -125,7 +125,8 @@ class user_form extends form 'S_SEND_USER' => true, 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&u=' . $this->recipient_id), - 'USERNAME' => $this->recipient_row['username'], + 'L_SEND_EMAIL_USER' => $this->user->lang('SEND_EMAIL_USER', $this->recipient_row['username']), + 'USERNAME_FULL' => get_username_string('full', $this->recipient_row['user_id'], $this->recipient_row['username'], $this->recipient_row['user_colour']), 'SUBJECT' => $this->subject, 'MESSAGE' => $this->body, )); -- cgit v1.2.1 From d6484a8177b2f8e38d7e4b65c02ac0db7463ce2c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:03:40 +0200 Subject: [ticket/10073] Fix missing language string PHPBB3-10073 --- phpBB/phpbb/message/topic_form.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 988028c301..3a35c35d21 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -142,6 +142,7 @@ class topic_form extends form { parent::render($template); + $this->user->add_lang('viewtopic'); $template->assign_vars(array( 'EMAIL' => $this->recipient_address, 'NAME' => $this->recipient_name, -- cgit v1.2.1 From 1ffcbdd3c5a0e199164f6f335ac8a2c460994bf5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:03:59 +0200 Subject: [ticket/10073] Fix invalid type hint PHPBB3-10073 --- phpBB/phpbb/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 8cbe1e1e2d..aaad333006 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -37,7 +37,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable /** * Retrieves an ArrayIterator over the configuration values. * - * @return ArrayIterator An iterator over all config data + * @return \ArrayIterator An iterator over all config data */ public function getIterator() { -- cgit v1.2.1 From 971b3f59bf04e9badd8f8f0397ca56c5884306f7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:04:20 +0200 Subject: [ticket/10073] Add configs for contact info text PHPBB3-10073 --- phpBB/phpbb/db/migration/data/v310/contact_admin_form.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php index c4149a0976..283840126e 100644 --- a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -20,6 +20,16 @@ class contact_admin_form extends \phpbb\db\migration\migration { return array( array('config.add', array('contact_admin_form_enable', 1)), + array('config.add', array('contact_admin_info_uid', '')), + array('config.add', array('contact_admin_info_bitfield', '')), + array('config.add', array('contact_admin_info_flags', '')), + array('custom', array(array($this, 'contact_admin_info'))), ); } + + public function contact_admin_info() + { + $text_config = new \phpbb\config\db_text($this->db, $this->table_prefix . 'config_text'); + $text_config->set('contact_admin_info', ''); + } } -- cgit v1.2.1 From 4f2f3d9757b40fc563300d81e23c3c3935375a5d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:04:55 +0200 Subject: [ticket/10073] Display contact info PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index f7eddb59dc..7bab96eec2 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -136,8 +136,16 @@ class admin_form extends form */ public function render(\phpbb\template\template $template) { - // @todo Add option to fill the db with it and add migration - $l_admin_info = '';//$this->config_text['contact_admin_info']; + $l_admin_info = $this->config_text->get('contact_admin_info'); + if ($l_admin_info) + { + $l_admin_info = generate_text_for_display( + $this->config_text->get('contact_admin_info'), + $this->config['contact_admin_info_uid'], + $this->config['contact_admin_info_bitfield'], + $this->config['contact_admin_info_flags'] + ); + } $template->assign_vars(array( 'S_CONTACT_ADMIN' => true, -- cgit v1.2.1 From d3f65cd66e4c3cbf2a8af45a7db99b40d0153214 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 15:59:06 +0200 Subject: [ticket/10073] Add ACP module to add bbcode text for contact admin info PHPBB3-10073 --- .../data/v310/contact_admin_acp_module.php | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php new file mode 100644 index 0000000000..bd682e2f7c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -0,0 +1,27 @@ + 'acp_contact', + 'modes' => array('contact'), + ), + )), + ); + } +} -- 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/form.php | 11 ++++++++++- phpBB/phpbb/message/message.php | 4 ++-- phpBB/phpbb/session.php | 10 +++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php index 205999e5f2..b57bf7423a 100644 --- a/phpBB/phpbb/message/form.php +++ b/phpBB/phpbb/message/form.php @@ -149,7 +149,16 @@ abstract class form $this->message->cc_sender(); } - $this->message->send($messenger, $this->phpEx); + + if ($this->config['contact_admin_form_enable']) + { + $board_contact = generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=contactadmin'; + } + else + { + $board_contact = $this->config['board_contact']; + } + $this->message->send($messenger, $board_contact); meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); trigger_error($this->user->lang['EMAIL_SENT'] . '

' . $this->get_return_message()); 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)) diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index c35caf5047..093c013e42 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1233,7 +1233,15 @@ class session $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - $message = sprintf($this->lang[$message], $till_date, '', ''); + if ($config['contact_admin_form_enable']) + { + $contact_link = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); + } + else + { + $contact_link = 'mailto:' . htmlspecialchars($config['board_contact']); + } + $message = sprintf($this->lang[$message], $till_date, '', ''); $message .= ($ban_row['ban_give_reason']) ? '

' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; $message .= '

' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . ''; -- cgit v1.2.1 From f01e0a2eef0604367620e8b9aa323f3feb86ea3c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 16:57:04 +0200 Subject: [ticket/10073] Deduplicate the if statement PHPBB3-10073 --- phpBB/phpbb/message/form.php | 11 +---------- phpBB/phpbb/session.php | 9 +-------- 2 files changed, 2 insertions(+), 18 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php index b57bf7423a..d7a42c4080 100644 --- a/phpBB/phpbb/message/form.php +++ b/phpBB/phpbb/message/form.php @@ -149,16 +149,7 @@ abstract class form $this->message->cc_sender(); } - - if ($this->config['contact_admin_form_enable']) - { - $board_contact = generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=contactadmin'; - } - else - { - $board_contact = $this->config['board_contact']; - } - $this->message->send($messenger, $board_contact); + $this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx)); meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); trigger_error($this->user->lang['EMAIL_SENT'] . '

' . $this->get_return_message()); diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 093c013e42..c2669ea6cc 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1233,14 +1233,7 @@ class session $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - if ($config['contact_admin_form_enable']) - { - $contact_link = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); - } - else - { - $contact_link = 'mailto:' . htmlspecialchars($config['board_contact']); - } + $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); $message = sprintf($this->lang[$message], $till_date, '', ''); $message .= ($ban_row['ban_give_reason']) ? '

' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; $message .= '

' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . ''; -- cgit v1.2.1 From 911725a5812cff5c1a0daa37b99767b5144e8a11 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 16:59:55 +0200 Subject: [ticket/10073] Split email validation from email ban and taken checks PHPBB3-10073 --- phpBB/phpbb/avatar/driver/gravatar.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index 34b894c2a7..c4344ee6e8 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -81,7 +81,8 @@ class gravatar extends \phpbb\avatar\driver\driver array( 'email' => array( array('string', false, 6, 60), - array('email')) + array('email'), + ), ) ); -- cgit v1.2.1 From 427d70d1387090befbff4b0d2f24efd84cfc0392 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 17:01:13 +0200 Subject: [ticket/10073] Use phpbb_validate_email to verify email address PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 7bab96eec2..aa185da740 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -101,9 +101,27 @@ class admin_form extends form { $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; } - if (!$this->sender_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->sender_address)) + + if (!function_exists('validate_data')) + { + require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + } + + $validate_array = validate_data( + array( + 'email' => $this->sender_address, + ), + array( + 'email' => array( + array('string', false, 6, 60), + array('email'), + ), + ) + ); + + foreach ($validate_array as $error) { - $this->errors[] = $this->user->lang['EMPTY_SENDER_EMAIL']; + $this->errors[] = $this->user->lang[$error]; } $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); -- cgit v1.2.1 From 67281199be8e796ed7bf50e6d6db0f36cff89428 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:31:53 +0200 Subject: [ticket/10073] Make contact page available when board is disabled PHPBB3-10073 --- phpBB/phpbb/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index f4cc26cc9a..4e90044395 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -317,7 +317,7 @@ class user extends \phpbb\session } // Is board disabled and user not an admin or moderator? - if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + if ($config['board_disable'] && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { if ($this->data['is_bot']) { -- cgit v1.2.1 From e2e7e2a55bffc709ac690c0130fed2bc33dd1b07 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 21:32:17 +0200 Subject: [ticket/10073] Move config values to config_text PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index aa185da740..b71b3fc535 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -157,11 +157,18 @@ class admin_form extends form $l_admin_info = $this->config_text->get('contact_admin_info'); if ($l_admin_info) { + $contact_admin_data = $this->config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_bitfield', + 'contact_admin_info_flags', + )); + $l_admin_info = generate_text_for_display( - $this->config_text->get('contact_admin_info'), - $this->config['contact_admin_info_uid'], - $this->config['contact_admin_info_bitfield'], - $this->config['contact_admin_info_flags'] + $contact_admin_data['contact_admin_info'], + $contact_admin_data['contact_admin_info_uid'], + $contact_admin_data['contact_admin_info_bitfield'], + $contact_admin_data['contact_admin_info_flags'] ); } -- cgit v1.2.1 From e3c3a5d2a788427ae4a1f4a9e8a05af9b443def7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Jun 2014 01:35:34 +0200 Subject: [ticket/10073] Do not check disable boxes by default PHPBB3-10073 --- phpBB/phpbb/db/migration/data/v310/contact_admin_form.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php index 283840126e..e255efb99d 100644 --- a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -20,9 +20,6 @@ class contact_admin_form extends \phpbb\db\migration\migration { return array( array('config.add', array('contact_admin_form_enable', 1)), - array('config.add', array('contact_admin_info_uid', '')), - array('config.add', array('contact_admin_info_bitfield', '')), - array('config.add', array('contact_admin_info_flags', '')), array('custom', array(array($this, 'contact_admin_info'))), ); } @@ -30,6 +27,11 @@ class contact_admin_form extends \phpbb\db\migration\migration public function contact_admin_info() { $text_config = new \phpbb\config\db_text($this->db, $this->table_prefix . 'config_text'); - $text_config->set('contact_admin_info', ''); + $text_config->set_array(array( + 'contact_admin_info' => '', + 'contact_admin_info_uid' => '', + 'contact_admin_info_bitfield' => '', + 'contact_admin_info_flags' => OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS, + )); } } -- cgit v1.2.1