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/includes/functions.php | 1 + phpBB/includes/message/admin_form.php | 118 +++++++++ phpBB/includes/message/form.php | 119 +++++++++ phpBB/includes/message/message.php | 188 ++++++++++++++ phpBB/includes/message/topic_form.php | 150 ++++++++++++ phpBB/includes/message/user_form.php | 111 +++++++++ phpBB/install/schemas/schema_data.sql | 1 + phpBB/language/en/common.php | 3 +- phpBB/language/en/memberlist.php | 9 + phpBB/memberlist.php | 269 +++------------------ phpBB/phpbb/session.php | 2 +- .../prosilver/template/memberlist_email.html | 28 +++ phpBB/styles/prosilver/template/navbar_footer.html | 1 + phpBB/styles/subsilver2/template/index_body.html | 5 +- .../subsilver2/template/memberlist_email.html | 24 ++ 15 files changed, 787 insertions(+), 242 deletions(-) create mode 100644 phpBB/includes/message/admin_form.php create mode 100644 phpBB/includes/message/form.php create mode 100644 phpBB/includes/message/message.php create mode 100644 phpBB/includes/message/topic_form.php create mode 100644 phpBB/includes/message/user_form.php diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c423e29d9d..8ca966eb52 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4922,6 +4922,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), + 'U_CONTACT_US' => (!$config['contact_admin_form_enable']) /** TODO: && !$config['contact_admin_info']) */ ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), diff --git a/phpBB/includes/message/admin_form.php b/phpBB/includes/message/admin_form.php new file mode 100644 index 0000000000..a27b281535 --- /dev/null +++ b/phpBB/includes/message/admin_form.php @@ -0,0 +1,118 @@ +config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ + { + return 'NO_CONTACT_PAGE'; + } + + return false; + } + + public function bind($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($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/includes/message/form.php b/phpBB/includes/message/form.php new file mode 100644 index 0000000000..2da5406a63 --- /dev/null +++ b/phpBB/includes/message/form.php @@ -0,0 +1,119 @@ +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($config['board_contact'], $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_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']; + $result = $this->db->sql_query($sql); + + if ($this->cc_sender) + { + $this->message->cc_sender(); + } + + $this->message->send($messenger); + + 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($template) + { + add_form_key('memberlist_email'); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('
', $this->errors) : '', + )); + } +} diff --git a/phpBB/includes/message/message.php b/phpBB/includes/message/message.php new file mode 100644 index 0000000000..b0948f940a --- /dev/null +++ b/phpBB/includes/message/message.php @@ -0,0 +1,188 @@ +board_contact = $board_contact; + $this->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 + 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) + { + 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' => $this->board_contact, + '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/includes/message/topic_form.php b/phpBB/includes/message/topic_form.php new file mode 100644 index 0000000000..0dbfdb0ca2 --- /dev/null +++ b/phpBB/includes/message/topic_form.php @@ -0,0 +1,150 @@ +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($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); + } + + protected function get_return_message() + { + return sprintf($this->user->lang['RETURN_TOPIC'], '', ''); + } + + public function render($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/includes/message/user_form.php b/phpBB/includes/message/user_form.php new file mode 100644 index 0000000000..3898975a3f --- /dev/null +++ b/phpBB/includes/message/user_form.php @@ -0,0 +1,111 @@ +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($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($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, + )); + } +} diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 7afed448ad..53d1b13e9d 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -82,6 +82,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('confirm_refresh', INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 5e524a6164..f451ac5f25 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -171,6 +171,7 @@ $lang = array_merge($lang, array( 'CONNECTION_SUCCESS' => 'Connection was successful!', 'CONTACT' => 'Contact', 'CONTACT_USER' => 'Contact %s', + 'CONTACT_US' => 'Contact us', 'COOKIES_DELETED' => 'All board cookies successfully deleted.', 'CURRENT_TIME' => 'It is currently %s', @@ -730,7 +731,7 @@ $lang = array_merge($lang, array( 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_USERNAME' => 'The username you entered is too short.', 'TOO_SHORT_EMAIL' => 'The email address you entered is too short.', - + 'TOO_SHORT_EMAIL_CONFIRM' => 'The email address confirmation you entered is too short.', 'TOO_SMALL' => 'The value you entered is too small.', 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too small.', diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index 7b6838e6d9..b8f2adf42b 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -49,6 +49,8 @@ $lang = array_merge($lang, array( 'BEFORE' => 'Before', 'CC_EMAIL' => 'Send a copy of this email to yourself.', + 'CONTACT_USER' => 'Contact', + 'CONTACT_ADMIN' => 'Contact a Board Administrator', 'DEST_LANG' => 'Language', 'DEST_LANG_EXPLAIN' => 'Select an appropriate language (if available) for the recipient of this message.', @@ -61,6 +63,8 @@ $lang = array_merge($lang, array( 'EMPTY_MESSAGE_EMAIL' => 'You must enter a message to be emailed.', 'EMPTY_MESSAGE_IM' => 'You must enter a message to be send.', 'EMPTY_NAME_EMAIL' => 'You must enter the real name of the recipient.', + 'EMPTY_SENDER_EMAIL' => 'You must provide a valid email address.', + 'EMPTY_SENDER_NAME' => 'You must provide a name.', 'EMPTY_SUBJECT_EMAIL' => 'You must specify a subject for the email.', 'EQUAL_TO' => 'Equal to', @@ -98,6 +102,8 @@ $lang = array_merge($lang, array( 'MORE_THAN' => 'More than', + 'NO_CONTACT_FORM' => 'The board administrator contact form has been disabled.', + 'NO_CONTACT_PAGE' => 'The board administrator contact page has been disabled.', 'NO_EMAIL' => 'You are not permitted to send email to this user.', 'NO_VIEW_USERS' => 'You are not authorised to view the member list or profiles.', @@ -113,6 +119,9 @@ $lang = array_merge($lang, array( 'SELECT_MARKED' => 'Select marked', 'SELECT_SORT_METHOD' => 'Select sort method', + 'SENDER_EMAIL_ADDRESS' => 'Your email address', + 'SENDER_NAME' => 'Your name', + 'SEND_AIM_MESSAGE' => 'Send AIM message', 'SEND_ICQ_MESSAGE' => 'Send ICQ message', 'SEND_IM' => 'Instant messaging', 'SEND_JABBER_MESSAGE' => 'Send Jabber message', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 187b4b1cd9..c81ee97cd7 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -20,6 +20,13 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); +$mode = request_var('mode', ''); + +if ($mode === 'contactadmin') +{ + define('SKIP_CHECK_BAN', true); +} + // Start session management $user->session_begin(); $auth->acl($user->data); @@ -29,7 +36,6 @@ $user->setup(array('memberlist', 'groups')); $template->assign_var('S_IN_MEMBERLIST', true); // Grab data -$mode = request_var('mode', ''); $action = request_var('action', ''); $user_id = request_var('u', ANONYMOUS); $username = request_var('un', '', true); @@ -44,7 +50,7 @@ if ($mode == 'leaders') } // Check our mode... -if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'team', 'livesearch'))) +if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch'))) { trigger_error('NO_MODE'); } @@ -52,6 +58,7 @@ if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'sear switch ($mode) { case 'email': + case 'contactadmin': break; case 'livesearch': @@ -736,265 +743,49 @@ switch ($mode) break; + case 'contactadmin': case 'email': - - // Send an email - $page_title = $user->lang['SEND_EMAIL']; - $template_html = 'memberlist_email.html'; - - add_form_key('memberlist_email'); - - if (!$config['email_enable']) - { - trigger_error('EMAIL_DISABLED'); - } - - if (!$auth->acl_get('u_sendemail')) - { - trigger_error('NO_EMAIL'); - } - - // Are we trying to abuse the facility? - if (time() - $user->data['user_emailtime'] < $config['flood_interval']) + if (!class_exists('messenger')) { - trigger_error('FLOOD_EMAIL_LIMIT'); + include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); } - // Determine action... - $user_id = request_var('u', 0); - $topic_id = request_var('t', 0); + $user_id = request_var('u', 0); + $topic_id = request_var('t', 0); - // Send email to user... if ($user_id) { - if ($user_id == ANONYMOUS || !$config['board_email_form']) - { - trigger_error('NO_EMAIL'); - } - - // Get the appropriate username, etc. - $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type - FROM ' . USERS_TABLE . " - WHERE user_id = $user_id - AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_USER'); - } - - // Can we send email to this user? - if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user')) - { - trigger_error('NO_EMAIL'); - } + $form = new phpbb_message_user_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); } else if ($topic_id) { - // Send topic heads-up to email address - $sql = 'SELECT forum_id, topic_title - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_TOPIC'); - } - - if ($row['forum_id']) - { - if (!$auth->acl_get('f_read', $row['forum_id'])) - { - trigger_error('SORRY_AUTH_READ'); - } - - if (!$auth->acl_get('f_email', $row['forum_id'])) - { - trigger_error('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 (!$auth->acl_getf_global('f_read')) - { - trigger_error('SORRY_AUTH_READ'); - } - - if (!$auth->acl_getf_global('f_email')) - { - trigger_error('NO_EMAIL'); - } - } + $form = new phpbb_message_topic_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + } + else if ($mode === 'contactadmin') + { + $form = new phpbb_message_admin_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); } else { trigger_error('NO_EMAIL'); } - $error = array(); - - $name = utf8_normalize_nfc(request_var('name', '', true)); - $email = request_var('email', ''); - $email_lang = request_var('lang', $config['default_lang']); - $subject = utf8_normalize_nfc(request_var('subject', '', true)); - $message = utf8_normalize_nfc(request_var('message', '', true)); - $cc = (isset($_POST['cc_email'])) ? true : false; - $submit = (isset($_POST['submit'])) ? true : false; - - if ($submit) + $form->bind($request); + $error = $form->check_allow(); + if ($error) { - if (!check_form_key('memberlist_email')) - { - $error[] = 'FORM_INVALID'; - } - if ($user_id) - { - if (!$subject) - { - $error[] = $user->lang['EMPTY_SUBJECT_EMAIL']; - } - - if (!$message) - { - $error[] = $user->lang['EMPTY_MESSAGE_EMAIL']; - } - - $name = $row['username']; - $email_lang = $row['user_lang']; - $email = $row['user_email']; - } - else - { - if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - $error[] = $user->lang['EMPTY_ADDRESS_EMAIL']; - } - - if (!$name) - { - $error[] = $user->lang['EMPTY_NAME_EMAIL']; - } - } - - if (!sizeof($error)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_emailtime = ' . time() . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(false); - $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify'; - - $mail_to_users = array(); - - $mail_to_users[] = array( - 'email_lang' => $email_lang, - 'email' => $email, - 'name' => $name, - 'username' => ($user_id) ? $row['username'] : '', - 'to_name' => $name, - 'user_jabber' => ($user_id) ? $row['user_jabber'] : '', - 'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL, - 'topic_title' => (!$user_id) ? $row['topic_title'] : '', - 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, - ); - - // Ok, now the same email if CC specified, but without exposing the users email address - if ($cc) - { - $mail_to_users[] = array( - 'email_lang' => $user->data['user_lang'], - 'email' => $user->data['user_email'], - 'name' => $user->data['username'], - 'username' => $user->data['username'], - 'to_name' => $name, - 'user_jabber' => $user->data['user_jabber'], - 'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL, - 'topic_title' => (!$user_id) ? $row['topic_title'] : '', - 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, - ); - } - - foreach ($mail_to_users as $row) - { - $messenger->template($email_tpl, $row['email_lang']); - $messenger->replyto($user->data['user_email']); - $messenger->to($row['email'], $row['name']); - - if ($user_id) - { - $messenger->subject(htmlspecialchars_decode($subject)); - $messenger->im($row['user_jabber'], $row['username']); - $notify_type = $row['user_notify_type']; - } - else - { - $notify_type = NOTIFY_EMAIL; - } - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'BOARD_CONTACT' => $config['board_contact'], - 'TO_USERNAME' => htmlspecialchars_decode($row['to_name']), - 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), - 'MESSAGE' => htmlspecialchars_decode($message)) - ); - - if ($topic_id) - { - $messenger->assign_vars(array( - 'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']), - 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id") - ); - } - - $messenger->send($notify_type); - } - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '', '') : sprintf($user->lang['RETURN_TOPIC'], '', ''); - trigger_error($user->lang['EMAIL_SENT'] . '

' . $message); - } + trigger_error($error); } - if ($user_id) + if (isset($_POST['submit'])) { - $template->assign_vars(array( - 'S_SEND_USER' => true, - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $row['username']), - - 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'], - 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id)) - ); - } - else - { - $template->assign_vars(array( - 'EMAIL' => $email, - 'NAME' => $name, - 'S_LANG_OPTIONS' => language_select($email_lang), - - 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'], - 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&t=' . $topic_id)) - ); + $messenger = new messenger(false); + $form->submit($messenger); } - $template->assign_vars(array( - 'ERROR_MESSAGE' => (sizeof($error)) ? implode('
', $error) : '', - 'SUBJECT' => $subject, - 'MESSAGE' => $message, - ) - ); + $page_title = $form->get_page_title(); + $template_html = $form->get_template_file(); + $form->render($template); break; 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; } diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index 78d0eba5a8..d66022887c 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -1,13 +1,22 @@ + +

{L_CONTACT_ADMIN}

+

{L_SEND_EMAIL_USER}

+
+ +
{CONTACT_INFO}
+
+
+

{ERROR_MESSAGE}

@@ -19,6 +28,25 @@
+ +
+
+
{L_ADMINISTRATOR}
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
diff --git a/phpBB/styles/prosilver/template/navbar_footer.html b/phpBB/styles/prosilver/template/navbar_footer.html index 13e50dae19..6912ee242e 100644 --- a/phpBB/styles/prosilver/template/navbar_footer.html +++ b/phpBB/styles/prosilver/template/navbar_footer.html @@ -16,6 +16,7 @@
  • {L_DELETE_COOKIES}
  • {L_THE_TEAM}
  • +
  • {L_CONTACT_US}
  • diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html index cb67768b15..52f04af35f 100644 --- a/phpBB/styles/subsilver2/template/index_body.html +++ b/phpBB/styles/subsilver2/template/index_body.html @@ -20,10 +20,13 @@ | {L_THE_TEAM} + + | + {L_CONTACT_US} +
    -
    diff --git a/phpBB/styles/subsilver2/template/memberlist_email.html b/phpBB/styles/subsilver2/template/memberlist_email.html index 7693a4167f..3b76525af9 100644 --- a/phpBB/styles/subsilver2/template/memberlist_email.html +++ b/phpBB/styles/subsilver2/template/memberlist_email.html @@ -6,13 +6,22 @@ + + + + + + + + + @@ -22,6 +31,21 @@ + + + + + + + + + + + + + + + -- 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/includes/acp/acp_email.php | 2 +- phpBB/includes/captcha/plugins/captcha_abstract.php | 2 +- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 4 ++-- phpBB/includes/functions.php | 6 +++--- phpBB/includes/message/form.php | 2 +- phpBB/includes/message/message.php | 6 ++---- phpBB/memberlist.php | 2 +- phpBB/phpbb/session.php | 6 ++---- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 63bfa3ac53..44489b90fe 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -201,7 +201,7 @@ class acp_email $messenger->set_mail_priority($priority); $messenger->assign_vars(array( - 'CONTACT_EMAIL' => $config['board_contact'], + 'CONTACT_EMAIL' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', 'MESSAGE' => htmlspecialchars_decode($message)) ); diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index dde3f9d4c9..cbf57cab9a 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -96,7 +96,7 @@ class phpbb_captcha_plugins_captcha_abstract else { $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( 'CONFIRM_IMAGE_LINK' => $link, diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 0568cb7c51..f7078b49c0 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -150,7 +150,7 @@ class phpbb_recaptcha extends phpbb_default_captcha function get_template() { - global $config, $user, $template; + global $config, $user, $template, $phpbb_root_path, $phpEx; if ($this->is_solved()) { @@ -158,7 +158,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8ca966eb52..220f1ae21d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2818,8 +2818,8 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $user->lang[$result['error_msg']], ($config['email_enable']) ? '' : '', ($config['email_enable']) ? '' : '', - ($config['board_contact']) ? '' : '', - ($config['board_contact']) ? '' : '' + '', + '' ); break; @@ -2830,7 +2830,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { - $err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '', ''); + $err = sprintf($user->lang[$result['error_msg']], '', ''); } break; diff --git a/phpBB/includes/message/form.php b/phpBB/includes/message/form.php index 2da5406a63..13909e1938 100644 --- a/phpBB/includes/message/form.php +++ b/phpBB/includes/message/form.php @@ -39,7 +39,7 @@ abstract class phpbb_message_form $this->errors = array(); - $this->message = new phpbb_message($config['board_contact'], $config['server_name']); + $this->message = new phpbb_message($config['server_name']); $this->message->set_sender_from_user($this->user); } diff --git a/phpBB/includes/message/message.php b/phpBB/includes/message/message.php index b0948f940a..1e4f0f65d8 100644 --- a/phpBB/includes/message/message.php +++ b/phpBB/includes/message/message.php @@ -17,7 +17,6 @@ if (!defined('IN_PHPBB')) class phpbb_message { - protected $board_contact; protected $server_name; protected $subject = ''; @@ -36,9 +35,8 @@ class phpbb_message protected $recipients; - public function __construct($board_contact, $server_name) + public function __construct($server_name) { - $this->board_contact = $board_contact; $this->server_name = $server_name; } @@ -171,7 +169,7 @@ class phpbb_message $messenger->subject(htmlspecialchars_decode($this->subject)); $messenger->assign_vars(array( - 'BOARD_CONTACT' => $this->board_contact, + '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)) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index c81ee97cd7..fab9747cce 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -393,7 +393,7 @@ switch ($mode) $messenger->set_addresses($row); $messenger->assign_vars(array( - 'BOARD_CONTACT' => $config['board_contact'], + 'BOARD_CONTACT' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 'TO_USERNAME' => htmlspecialchars_decode($row['username']), 'MESSAGE' => htmlspecialchars_decode($message)) 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 6c287e57fc3d93b98632d19933968ce1bed9dee2 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 3 Aug 2011 12:45:33 -0400 Subject: [ticket/10073] Add Admin contact email template PHPBB3-10073 --- phpBB/language/en/email/contact_admin.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 phpBB/language/en/email/contact_admin.txt diff --git a/phpBB/language/en/email/contact_admin.txt b/phpBB/language/en/email/contact_admin.txt new file mode 100644 index 0000000000..c895c4d687 --- /dev/null +++ b/phpBB/language/en/email/contact_admin.txt @@ -0,0 +1,23 @@ + +Hello {TO_USERNAME}, + +The following is an e-mail sent to you through the administration contact page on "{SITENAME}". + + +The message has been sent from an account on the site. +Username: {FROM_USERNAME} +E-mail address: {FROM_EMAIL_ADDRESS} +IP Address: {FROM_IP_ADDRESS} +Profile: {U_FROM_PROFILE} + +The message was sent from a guest who specified the following contact information: +Name: {FROM_USERNAME} +E-mail address: {FROM_EMAIL_ADDRESS} +IP Address: {FROM_IP_ADDRESS} + + + +Message sent to you follows +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +{MESSAGE} -- 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 --- phpBB/config/services.yml | 30 ++++ phpBB/includes/message/admin_form.php | 118 ------------- phpBB/includes/message/form.php | 119 ------------- phpBB/includes/message/message.php | 186 --------------------- phpBB/includes/message/topic_form.php | 150 ----------------- phpBB/includes/message/user_form.php | 111 ------------ phpBB/memberlist.php | 9 +- .../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 ++++++++++++ 13 files changed, 726 insertions(+), 688 deletions(-) delete mode 100644 phpBB/includes/message/admin_form.php delete mode 100644 phpBB/includes/message/form.php delete mode 100644 phpBB/includes/message/message.php delete mode 100644 phpBB/includes/message/topic_form.php delete mode 100644 phpBB/includes/message/user_form.php 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 diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4de47f750f..11a13c6b5f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -238,6 +238,36 @@ services: - %core.php_ext% - %tables.log% + message.form.admin: + class: phpbb\message\admin_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.topic: + class: phpbb\message\topic_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.user: + class: phpbb\message\user_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + notification_manager: class: phpbb\notification\manager arguments: diff --git a/phpBB/includes/message/admin_form.php b/phpBB/includes/message/admin_form.php deleted file mode 100644 index a27b281535..0000000000 --- a/phpBB/includes/message/admin_form.php +++ /dev/null @@ -1,118 +0,0 @@ -config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ - { - return 'NO_CONTACT_PAGE'; - } - - return false; - } - - public function bind($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($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/includes/message/form.php b/phpBB/includes/message/form.php deleted file mode 100644 index 13909e1938..0000000000 --- a/phpBB/includes/message/form.php +++ /dev/null @@ -1,119 +0,0 @@ -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($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_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']; - $result = $this->db->sql_query($sql); - - if ($this->cc_sender) - { - $this->message->cc_sender(); - } - - $this->message->send($messenger); - - 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($template) - { - add_form_key('memberlist_email'); - - $template->assign_vars(array( - 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('
    ', $this->errors) : '', - )); - } -} diff --git a/phpBB/includes/message/message.php b/phpBB/includes/message/message.php deleted file mode 100644 index 1e4f0f65d8..0000000000 --- a/phpBB/includes/message/message.php +++ /dev/null @@ -1,186 +0,0 @@ -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 - 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) - { - 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/includes/message/topic_form.php b/phpBB/includes/message/topic_form.php deleted file mode 100644 index 0dbfdb0ca2..0000000000 --- a/phpBB/includes/message/topic_form.php +++ /dev/null @@ -1,150 +0,0 @@ -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($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); - } - - protected function get_return_message() - { - return sprintf($this->user->lang['RETURN_TOPIC'], '', ''); - } - - public function render($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/includes/message/user_form.php b/phpBB/includes/message/user_form.php deleted file mode 100644 index 3898975a3f..0000000000 --- a/phpBB/includes/message/user_form.php +++ /dev/null @@ -1,111 +0,0 @@ -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($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($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, - )); - } -} diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index fab9747cce..2e480a472e 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -755,20 +755,21 @@ switch ($mode) if ($user_id) { - $form = new phpbb_message_user_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'user'; } else if ($topic_id) { - $form = new phpbb_message_topic_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'topic'; } else if ($mode === 'contactadmin') { - $form = new phpbb_message_admin_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'admin'; } else { trigger_error('NO_EMAIL'); } + $form = $phpbb_container->get('message.form.' . $form_name); $form->bind($request); $error = $form->check_allow(); @@ -777,7 +778,7 @@ switch ($mode) trigger_error($error); } - if (isset($_POST['submit'])) + if ($request->is_set_post('submit')) { $messenger = new messenger(false); $form->submit($messenger); 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(-) 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(-) 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(-) 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(-) 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/includes/functions.php | 2 +- phpBB/phpbb/message/admin_form.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 220f1ae21d..e66fd69f83 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4922,7 +4922,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), - 'U_CONTACT_US' => (!$config['contact_admin_form_enable']) /** TODO: && !$config['contact_admin_info']) */ ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'), + 'U_CONTACT_US' => ($config['contact_admin_form_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 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/config/services.yml | 1 + phpBB/phpbb/message/admin_form.php | 25 +++++++++++++++++++++- .../prosilver/template/memberlist_email.html | 6 +++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 11a13c6b5f..791981854c 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -253,6 +253,7 @@ services: arguments: - @auth - @config + - @config_text - @dbal.conn - @user - %core.root_path% 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, diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index d66022887c..b8366a073a 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -11,7 +11,11 @@
    -
    {CONTACT_INFO}
    +
    +
    + {CONTACT_INFO} +
    +

    -- 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/memberlist.php | 1 + phpBB/phpbb/message/user_form.php | 5 +++-- phpBB/styles/prosilver/template/memberlist_email.html | 2 +- phpBB/styles/subsilver2/template/index_body.html | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 2e480a472e..1621e98220 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -667,6 +667,7 @@ switch ($mode) 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), + 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 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, )); diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index b8366a073a..45e3fcc865 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -26,7 +26,7 @@
    -
    {USERNAME}
    +
    {USERNAME_FULL}
    diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html index 52f04af35f..2fdd0c77c1 100644 --- a/phpBB/styles/subsilver2/template/index_body.html +++ b/phpBB/styles/subsilver2/template/index_body.html @@ -26,6 +26,7 @@ +

    -- cgit v1.2.1 From 299fe086b474c1323902f91a067522b88f04308a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:02:46 +0200 Subject: [ticket/10073] Fix title for "Email topic" PHPBB3-10073 --- phpBB/styles/prosilver/template/memberlist_email.html | 18 ++++++++++++------ phpBB/styles/subsilver2/template/memberlist_email.html | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index 45e3fcc865..865f0b883c 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -2,23 +2,29 @@

    {L_CONTACT_ADMIN}

    - +

    {L_SEND_EMAIL_USER}

    + +

    {L_EMAIL_TOPIC}

    -
    -
    -
    -
    - {CONTACT_INFO} +
    +
    +
    +
    + {CONTACT_INFO} +
    +

    +
    +

    {ERROR_MESSAGE}

    diff --git a/phpBB/styles/subsilver2/template/memberlist_email.html b/phpBB/styles/subsilver2/template/memberlist_email.html index 3b76525af9..13ff4baace 100644 --- a/phpBB/styles/subsilver2/template/memberlist_email.html +++ b/phpBB/styles/subsilver2/template/memberlist_email.html @@ -8,8 +8,10 @@
    - + + + -- 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(+) 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(-) 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(+) 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(-) 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 deee3be9ef34e3760428291d165aee33b05a68c3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:13:12 +0200 Subject: [ticket/10073] Add new configs to the schema PHPBB3-10073 --- phpBB/install/schemas/schema_data.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 53d1b13e9d..5d879a4be6 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -83,6 +83,9 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_c INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_uid', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_flags', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); @@ -300,6 +303,9 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('sessio INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnings_last_gc', '0', 1); +# Config text +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); + # -- Forum related auth options INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1); -- 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 --- phpBB/adm/style/acp_contact.html | 136 +++++++++++++++++++++ phpBB/includes/acp/acp_contact.php | 118 ++++++++++++++++++ phpBB/includes/acp/info/acp_contact.php | 26 ++++ phpBB/includes/constants.php | 1 + phpBB/language/en/acp/board.php | 13 ++ phpBB/language/en/acp/common.php | 2 + .../data/v310/contact_admin_acp_module.php | 27 ++++ 7 files changed, 323 insertions(+) create mode 100644 phpBB/adm/style/acp_contact.html create mode 100644 phpBB/includes/acp/acp_contact.php create mode 100644 phpBB/includes/acp/info/acp_contact.php create mode 100644 phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html new file mode 100644 index 0000000000..b7a70e6f47 --- /dev/null +++ b/phpBB/adm/style/acp_contact.html @@ -0,0 +1,136 @@ + + + + + + + +

    {L_ACP_CONTACT_SETTINGS}

    + +

    {L_ACP_CONTACT_SETTINGS_EXPLAIN}

    + + +
    + {L_GENERAL_OPTIONS} +
    +

    {L_CONTACT_US_ENABLE_EXPLAIN}
    +
    + + +
    +
    +
    + + +
    + {L_CONTACT_US_INFO_PREVIEW} +

    {CONTACT_US_INFO_PREVIEW}

    +
    + + +
    + {L_CONTACT_US_INFO} +

    {L_CONTACT_US_INFO_EXPLAIN}

    + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    + +
    + +
    + +
    + + + + + + + + + +
    +
    {L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
    +
    +
    + +
    +   + + {S_FORM_TOKEN} +
    + + + diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php new file mode 100644 index 0000000000..21807082fc --- /dev/null +++ b/phpBB/includes/acp/acp_contact.php @@ -0,0 +1,118 @@ +add_lang(array('acp/board', 'posting')); + + $this->tpl_name = 'acp_contact'; + $this->page_title = 'ACP_CONTACT_SETTINGS'; + $form_name = 'acp_contact'; + add_form_key($form_name); + $error = ''; + + if (!function_exists('display_custom_bbcodes')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } + if (!class_exists('parse_message')) + { + include($phpbb_root_path . 'includes/message_parser.' . $phpEx); + } + + $config_text = new \phpbb\config\db_text($db, CONFIG_TEXT_TABLE); + + $contact_admin_info = $request->variable('contact_admin_info', $config_text->get('contact_admin_info'), true); + $contact_admin_info_uid = $config['contact_admin_info_uid']; + $contact_admin_info_bitfield= $config['contact_admin_info_bitfield']; + $contact_admin_info_flags = $config['contact_admin_info_flags']; + + if ($request->is_set_post('submit') || $request->is_set_post('preview')) + { + if (!check_form_key($form_name)) + { + $error = $user->lang('FORM_INVALID'); + } + + generate_text_for_storage( + $contact_admin_info, + $contact_admin_info_uid, + $contact_admin_info_bitfield, + $contact_admin_info_flags, + !$request->variable('disable_bbcode', false), + !$request->variable('disable_magic_url', false), + !$request->variable('disable_smilies', false) + ); + + if (empty($error) && $request->is_set_post('submit')) + { + $config->set('contact_admin_form_enable', $request->variable('contact_admin_form_enable', false)); + + $config_text->set('contact_admin_info', $contact_admin_info); + $config->set('contact_admin_info_uid', $contact_admin_info_uid); + $config->set('contact_admin_info_bitfield', $contact_admin_info_bitfield); + $config->set('contact_admin_info_flags', $contact_admin_info_flags); + + trigger_error($user->lang['CONTACT_US_INFO_UPDATED'] . adm_back_link($this->u_action)); + } + } + + $contact_admin_info_preview = ''; + if ($request->is_set_post('preview')) + { + $contact_admin_info_preview = generate_text_for_display($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_bitfield, $contact_admin_info_flags); + } + + $contact_admin_edit = generate_text_for_edit($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_flags); + + $template->assign_vars(array( + 'ERRORS' => $error, + 'CONTACT_ENABLED' => $config['contact_admin_form_enable'], + + 'CONTACT_US_INFO' => $contact_admin_edit['text'], + 'CONTACT_US_INFO_PREVIEW' => $contact_admin_info_preview, + + 'S_BBCODE_CHECKED' => (!$contact_admin_edit['allow_bbcode']) ? ' checked="checked"' : '', + 'S_SMILIES_CHECKED' => (!$contact_admin_edit['allow_smilies']) ? ' checked="checked"' : '', + 'S_MAGIC_URL_CHECKED' => (!$contact_admin_edit['allow_urls']) ? ' checked="checked"' : '', + + 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '', ''), + 'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'], + 'IMG_STATUS' => $user->lang['IMAGES_ARE_ON'], + 'FLASH_STATUS' => $user->lang['FLASH_IS_ON'], + 'URL_STATUS' => $user->lang['URL_IS_ON'], + + 'S_BBCODE_ALLOWED' => true, + 'S_SMILIES_ALLOWED' => true, + 'S_BBCODE_IMG' => true, + 'S_BBCODE_FLASH' => true, + 'S_LINKS_ALLOWED' => true, + )); + + // Assigning custom bbcodes + display_custom_bbcodes(); + } +} diff --git a/phpBB/includes/acp/info/acp_contact.php b/phpBB/includes/acp/info/acp_contact.php new file mode 100644 index 0000000000..b8326f34ea --- /dev/null +++ b/phpBB/includes/acp/info/acp_contact.php @@ -0,0 +1,26 @@ + 'acp_contact', + 'title' => 'ACP_CONTACT', + 'version' => '1.0.0', + 'modes' => array( + 'contact' => array('title' => 'ACP_CONTACT_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + ), + ); + } +} diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 602067a0e7..4259ae203c 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -233,6 +233,7 @@ define('BBCODES_TABLE', $table_prefix . 'bbcodes'); define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks'); define('BOTS_TABLE', $table_prefix . 'bots'); define('CONFIG_TABLE', $table_prefix . 'config'); +define('CONFIG_TEXT_TABLE', $table_prefix . 'config_text'); define('CONFIRM_TABLE', $table_prefix . 'confirm'); define('DISALLOW_TABLE', $table_prefix . 'disallow'); define('DRAFTS_TABLE', $table_prefix . 'drafts'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index e2f89839c5..8cb6a8f171 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -352,6 +352,19 @@ $lang = array_merge($lang, array( 'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.', )); +// Contact Settings +$lang = array_merge($lang, array( + 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the “Contact Us” page and also add a text that is displayed on the page.', + + 'CONTACT_US_ENABLE' => 'Enable “Contact Us” page', + 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators', + + 'CONTACT_US_INFO' => '“Contact Us” information', + 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the “Contact Us” page', + 'CONTACT_US_INFO_PREVIEW' => '“Contact Us” information - Preview', + 'CONTACT_US_INFO_UPDATED' => '“Contact Us” information has been updated.', +)); + // Load Settings $lang = array_merge($lang, array( 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index d340e467be..b81b9c2693 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -75,6 +75,8 @@ $lang = array_merge($lang, array( 'ACP_CAT_USERS' => 'Users', 'ACP_CLIENT_COMMUNICATION' => 'Client communication', 'ACP_COOKIE_SETTINGS' => 'Cookie settings', + 'ACP_CONTACT' => 'Contact page', + 'ACP_CONTACT_SETTINGS' => '“Contact Us” settings', 'ACP_CRITICAL_LOGS' => 'Error log', 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', 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 d1fb8d3c9e9e154d356d4764b592369d0e8ea30f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 16:01:32 +0200 Subject: [ticket/10073] Remove language string from rebase conflict PHPBB3-10073 --- phpBB/language/en/memberlist.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index b8f2adf42b..d900ababd1 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -121,7 +121,6 @@ $lang = array_merge($lang, array( 'SELECT_SORT_METHOD' => 'Select sort method', 'SENDER_EMAIL_ADDRESS' => 'Your email address', 'SENDER_NAME' => 'Your name', - 'SEND_AIM_MESSAGE' => 'Send AIM message', 'SEND_ICQ_MESSAGE' => 'Send ICQ message', 'SEND_IM' => 'Instant messaging', 'SEND_JABBER_MESSAGE' => 'Send Jabber message', -- 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/includes/acp/acp_email.php | 11 ++++++++++- phpBB/includes/captcha/plugins/captcha_abstract.php | 10 +++++++++- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 10 +++++++++- phpBB/includes/functions.php | 11 ++++++++++- phpBB/memberlist.php | 11 ++++++++++- phpBB/phpbb/message/form.php | 11 ++++++++++- phpBB/phpbb/message/message.php | 4 ++-- phpBB/phpbb/session.php | 10 +++++++++- 8 files changed, 69 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 44489b90fe..4402b6bcf0 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -200,8 +200,17 @@ class acp_email $messenger->subject(htmlspecialchars_decode($subject)); $messenger->set_mail_priority($priority); + if ($config['contact_admin_form_enable']) + { + $contact_link = generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; + } + else + { + $contact_link = $config['board_contact']; + } + $messenger->assign_vars(array( - 'CONTACT_EMAIL' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', + 'CONTACT_EMAIL' => $contact_link, 'MESSAGE' => htmlspecialchars_decode($message)) ); diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index cbf57cab9a..c75a4ffb83 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -96,7 +96,15 @@ class phpbb_captcha_plugins_captcha_abstract else { $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + 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']); + } + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( 'CONFIRM_IMAGE_LINK' => $link, diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index f7078b49c0..69864a75ab 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -158,7 +158,15 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + 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']); + } + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e66fd69f83..026dd949fb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2814,11 +2814,20 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa break; case LOGIN_ERROR_PASSWORD_CONVERT: + if ($config['contact_admin_form_enable']) + { + $contact_link = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword'); + } + else + { + $contact_link = 'mailto:' . htmlspecialchars($config['board_contact']); + } + $err = sprintf( $user->lang[$result['error_msg']], ($config['email_enable']) ? '' : '', ($config['email_enable']) ? '' : '', - '', + '', '' ); break; diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 1621e98220..a688f810a0 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -392,8 +392,17 @@ switch ($mode) $messenger->replyto($user->data['user_email']); $messenger->set_addresses($row); + if ($config['contact_admin_form_enable']) + { + $contact_link = generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; + } + else + { + $contact_link = $config['board_contact']; + } + $messenger->assign_vars(array( - 'BOARD_CONTACT' => generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin', + 'BOARD_CONTACT' => $contact_link, 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 'TO_USERNAME' => htmlspecialchars_decode($row['username']), 'MESSAGE' => htmlspecialchars_decode($message)) 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/includes/acp/acp_email.php | 11 +---- .../includes/captcha/plugins/captcha_abstract.php | 9 +--- .../captcha/plugins/phpbb_recaptcha_plugin.php | 9 +--- phpBB/includes/functions.php | 50 +++++++++++++++++----- phpBB/memberlist.php | 11 +---- phpBB/phpbb/message/form.php | 11 +---- phpBB/phpbb/session.php | 9 +--- 7 files changed, 46 insertions(+), 64 deletions(-) diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 4402b6bcf0..fe55b36e67 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -200,17 +200,8 @@ class acp_email $messenger->subject(htmlspecialchars_decode($subject)); $messenger->set_mail_priority($priority); - if ($config['contact_admin_form_enable']) - { - $contact_link = generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; - } - else - { - $contact_link = $config['board_contact']; - } - $messenger->assign_vars(array( - 'CONTACT_EMAIL' => $contact_link, + 'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx), 'MESSAGE' => htmlspecialchars_decode($message)) ); diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index c75a4ffb83..8e1e61bdb7 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -96,14 +96,7 @@ class phpbb_captcha_plugins_captcha_abstract else { $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - 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); $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 69864a75ab..12cc49ef9b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -158,14 +158,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { - 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); $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); $template->assign_vars(array( diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 026dd949fb..be032440b9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2814,20 +2814,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa break; case LOGIN_ERROR_PASSWORD_CONVERT: - if ($config['contact_admin_form_enable']) - { - $contact_link = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword'); - } - else - { - $contact_link = 'mailto:' . htmlspecialchars($config['board_contact']); - } - $err = sprintf( $user->lang[$result['error_msg']], ($config['email_enable']) ? '' : '', ($config['email_enable']) ? '' : '', - '', + '', '' ); break; @@ -5308,3 +5299,42 @@ function phpbb_convert_30_dbms_to_31($dbms) throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); } + +/** +* Get the board contact details (e.g. for emails) +* +* @param \phpbb\config\config $config +* @param string $phpEx +* @return string +*/ +function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx) +{ + if ($config['contact_admin_form_enable']) + { + return generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; + } + else + { + return $config['board_contact']; + } +} + +/** +* Get a clickable board contact details link +* +* @param \phpbb\config\config $config +* @param string $phpbb_root_path +* @param string $phpEx +* @return string +*/ +function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx) +{ + if ($config['contact_admin_form_enable']) + { + return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); + } + else + { + return 'mailto:' . htmlspecialchars($config['board_contact']); + } +} diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index a688f810a0..b3025dacce 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -392,17 +392,8 @@ switch ($mode) $messenger->replyto($user->data['user_email']); $messenger->set_addresses($row); - if ($config['contact_admin_form_enable']) - { - $contact_link = generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; - } - else - { - $contact_link = $config['board_contact']; - } - $messenger->assign_vars(array( - 'BOARD_CONTACT' => $contact_link, + 'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx), 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 'TO_USERNAME' => htmlspecialchars_decode($row['username']), 'MESSAGE' => htmlspecialchars_decode($message)) 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/includes/acp/acp_users.php | 2 +- phpBB/includes/functions_user.php | 45 ++++++++--- phpBB/includes/ucp/ucp_profile.php | 2 +- phpBB/includes/ucp/ucp_register.php | 2 +- phpBB/phpbb/avatar/driver/gravatar.php | 3 +- tests/functions/validate_email_test.php | 112 --------------------------- tests/functions/validate_user_email_test.php | 106 +++++++++++++++++++++++++ 7 files changed, 146 insertions(+), 126 deletions(-) delete mode 100644 tests/functions/validate_email_test.php create mode 100644 tests/functions/validate_user_email_test.php diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b653ddd13b..83ab88d48c 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -814,7 +814,7 @@ class acp_users $check_ary += array( 'email' => array( array('string', false, 6, 60), - array('email', $user_row['user_email']) + array('user_email', $user_row['user_email']), ), ); } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3dcb32350e..fafe29f957 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1746,25 +1746,21 @@ function validate_password($password) } /** -* Check to see if email address is banned or already present in the DB +* Check to see if email address is a valid address and contains a MX record * * @param string $email The email to check -* @param string $allowed_email An allowed email, default being $user->data['user_email'] * * @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) */ -function validate_email($email, $allowed_email = false) +function phpbb_validate_email($email, $config = null) { - global $config, $db, $user; - - $email = strtolower($email); - $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); - - if ($allowed_email == $email) + if ($config === null) { - return false; + global $config; } + $email = strtolower($email); + if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) { return 'EMAIL_INVALID'; @@ -1782,6 +1778,35 @@ function validate_email($email, $allowed_email = false) } } + return false; +} + +/** +* Check to see if email address is banned or already present in the DB +* +* @param string $email The email to check +* @param string $allowed_email An allowed email, default being $user->data['user_email'] +* +* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) +*/ +function validate_user_email($email, $allowed_email = false) +{ + global $config, $db, $user; + + $email = strtolower($email); + $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); + + if ($allowed_email == $email) + { + return false; + } + + $validate_email = phpbb_validate_email($email, $config); + if ($validate_email) + { + return $validate_email; + } + if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false) { return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c7ed12f4ee..5ba5f1e830 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -66,7 +66,7 @@ class ucp_profile 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array( array('string', false, 6, 60), - array('email')), + array('user_email')), ); if ($auth->acl_get('u_chgname') && $config['allow_namechange']) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index cdd5532429..97934fc32d 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -211,7 +211,7 @@ class ucp_register 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array( array('string', false, 6, 60), - array('email')), + array('user_email')), 'tz' => array('timezone'), 'lang' => array('language_iso_name'), )); 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'), + ), ) ); diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php deleted file mode 100644 index dbd4b05520..0000000000 --- a/tests/functions/validate_email_test.php +++ /dev/null @@ -1,112 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -require_once dirname(__FILE__) . '/../mock/user.php'; -require_once dirname(__FILE__) . '/validate_data_helper.php'; - -class phpbb_functions_validate_email_test extends phpbb_database_test_case -{ - protected $db; - protected $user; - protected $helper; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); - } - - protected function setUp() - { - parent::setUp(); - - $this->db = $this->new_dbal(); - $this->user = new phpbb_mock_user; - $this->helper = new phpbb_functions_validate_data_helper($this); - } - - /** - * Get validation prerequesites - * - * @param bool $check_mx Whether mx records should be checked - */ - protected function set_validation_prerequisites($check_mx) - { - global $config, $db, $user; - - $config['email_check_mx'] = $check_mx; - $db = $this->db; - $user = $this->user; - $user->optionset('banned_users', array('banned@example.com')); - } - - public function test_validate_email() - { - $this->set_validation_prerequisites(false); - - $this->helper->assert_valid_data(array( - 'empty' => array( - array(), - '', - array('email'), - ), - 'allowed' => array( - array(), - 'foobar@example.com', - array('email', 'foobar@example.com'), - ), - 'invalid' => array( - array('EMAIL_INVALID'), - 'fööbar@example.com', - array('email'), - ), - 'valid_complex' => array( - array(), - "'%$~test@example.com", - array('email'), - ), - 'taken' => array( - array('EMAIL_TAKEN'), - 'admin@example.com', - array('email'), - ), - 'banned' => array( - array('EMAIL_BANNED'), - 'banned@example.com', - array('email'), - ), - )); - } - - /** - * @group slow - */ - public function test_validate_email_mx() - { - $this->set_validation_prerequisites(true); - - $this->helper->assert_valid_data(array( - 'valid' => array( - array(), - 'foobar@phpbb.com', - array('email'), - ), - 'no_mx' => array( - array('DOMAIN_NO_MX_RECORD'), - 'test@does-not-exist.phpbb.com', - array('email'), - ), - )); - } -} diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php new file mode 100644 index 0000000000..951d5794e6 --- /dev/null +++ b/tests/functions/validate_user_email_test.php @@ -0,0 +1,106 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../mock/user.php'; +require_once dirname(__FILE__) . '/validate_data_helper.php'; + +class phpbb_functions_validate_user_email_test extends phpbb_database_test_case +{ + protected $db; + protected $user; + protected $helper; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->user = new phpbb_mock_user; + $this->helper = new phpbb_functions_validate_data_helper($this); + } + + /** + * Get validation prerequesites + * + * @param bool $check_mx Whether mx records should be checked + */ + protected function set_validation_prerequisites($check_mx) + { + global $config, $db, $user; + + $config['email_check_mx'] = $check_mx; + $db = $this->db; + $user = $this->user; + $user->optionset('banned_users', array('banned@example.com')); + } + + public static function validate_user_email_data() + { + return array( + array('empty', array(), ''), + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array('EMAIL_TAKEN'), 'admin@example.com'), + array('banned', array('EMAIL_BANNED'), 'banned@example.com'), + ); + } + + /** + * @dataProvider validate_user_email_data + */ + public function test_validate_user_email($case, $errors, $email) + { + $this->set_validation_prerequisites(false); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } + + public static function validate_user_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + + /** + * @dataProvider validate_user_email_mx_data + * @group slow + */ + public function test_validate_user_email_mx($case, $errors, $email) + { + $this->set_validation_prerequisites(true); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } +} -- cgit v1.2.1 From 0108e19d2119b312d48227bca9ae23d6dd8189f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 17:00:30 +0200 Subject: [ticket/10073] Add tests for new validate_email() PHPBB3-10073 --- tests/functions/validate_email_test.php | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/functions/validate_email_test.php diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php new file mode 100644 index 0000000000..b46509fda7 --- /dev/null +++ b/tests/functions/validate_email_test.php @@ -0,0 +1,102 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->user = new phpbb_mock_user; + $this->helper = new phpbb_functions_validate_data_helper($this); + } + + /** + * Get validation prerequesites + * + * @param bool $check_mx Whether mx records should be checked + */ + protected function set_validation_prerequisites($check_mx) + { + global $config, $db, $user; + + $config['email_check_mx'] = $check_mx; + $db = $this->db; + $user = $this->user; + $user->optionset('banned_users', array('banned@example.com')); + } + + public static function validate_email_data() + { + return array( + array('empty', array('EMAIL_INVALID'), ''), // email does not allow empty + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array(), 'admin@example.com'), // email does not check taken, should use user_email instead + array('banned', array(), 'banned@example.com'), // email does not check ban, should use user_email instead + ); + } + + /** + * @dataProvider validate_email_data + */ + public function test_validate_email($case, $errors, $email) + { + $this->set_validation_prerequisites(false); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('email'), + ), + )); + } + + public static function validate_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + + /** + * @dataProvider validate_email_mx_data + * @group slow + */ + public function test_validate_email_mx($case, $errors, $email) + { + $this->set_validation_prerequisites(true); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $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(-) 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 a2ca0bc6111492b10fbab05f092f7343f88b59ec Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:20:11 +0200 Subject: [ticket/10073] Deduplicate posting buttons code in ACP PHPBB3-10073 --- phpBB/adm/style/acp_contact.html | 66 ++---------------------------- phpBB/adm/style/acp_posting_buttons.html | 70 ++++++++++++++++++++++++++++++++ phpBB/adm/style/acp_users_signature.html | 64 +---------------------------- phpBB/docs/events.md | 28 ++++++------- 4 files changed, 88 insertions(+), 140 deletions(-) create mode 100644 phpBB/adm/style/acp_posting_buttons.html diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html index b7a70e6f47..9578b3df83 100644 --- a/phpBB/adm/style/acp_contact.html +++ b/phpBB/adm/style/acp_contact.html @@ -1,42 +1,16 @@ - @@ -67,41 +41,7 @@ {L_CONTACT_US_INFO}

    {L_CONTACT_US_INFO_EXPLAIN}

    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    +
    diff --git a/phpBB/adm/style/acp_posting_buttons.html b/phpBB/adm/style/acp_posting_buttons.html new file mode 100644 index 0000000000..70b6259689 --- /dev/null +++ b/phpBB/adm/style/acp_posting_buttons.html @@ -0,0 +1,70 @@ + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + diff --git a/phpBB/adm/style/acp_users_signature.html b/phpBB/adm/style/acp_users_signature.html index 5b5c3ecf7f..c7ec5cc0eb 100644 --- a/phpBB/adm/style/acp_users_signature.html +++ b/phpBB/adm/style/acp_users_signature.html @@ -5,36 +5,10 @@ var text_name = 'signature'; var load_draft = false; var upload = false; - - // Define the bbCode tags - var bbcode = new Array(); - var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', {custom_tags.BBCODE_NAME}); var imageTag = false; - // Helpline messages - var help_line = { - b: '{LA_BBCODE_B_HELP}', - i: '{LA_BBCODE_I_HELP}', - u: '{LA_BBCODE_U_HELP}', - q: '{LA_BBCODE_Q_HELP}', - c: '{LA_BBCODE_C_HELP}', - l: '{LA_BBCODE_L_HELP}', - o: '{LA_BBCODE_O_HELP}', - p: '{LA_BBCODE_P_HELP}', - w: '{LA_BBCODE_W_HELP}', - a: '{LA_BBCODE_A_HELP}', - s: '{LA_BBCODE_S_HELP}', - f: '{LA_BBCODE_F_HELP}', - y: '{LA_BBCODE_Y_HELP}', - d: '{LA_BBCODE_D_HELP}' - - ,cb_{custom_tags.BBCODE_ID}{L_COLON} '{custom_tags.A_BBCODE_HELPLINE}' - - } - // ]]> -
    @@ -49,43 +23,7 @@ {L_SIGNATURE}

    {L_SIGNATURE_EXPLAIN}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - +
    diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 4dc55540f3..44a7824901 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -64,6 +64,20 @@ acp_overall_header_head_append * Since: 3.1.0-a1 * Purpose: Add assets within the `` tags in the ACP +acp_posting_buttons_after +=== +* Locations: + + adm/style/acp_posting_buttons.html +* Since: 3.1.0-b4 +* Purpose: Add content after BBCode posting buttons in the ACP + +acp_posting_buttons_before +=== +* Locations: + + adm/style/acp_posting_buttons.html +* Since: 3.1.0-b4 +* Purpose: Add content before BBCode posting buttons in the ACP + acp_simple_footer_after === * Location: adm/style/simple_footer.html @@ -136,20 +150,6 @@ acp_users_prefs_view_prepend * Since: 3.1.0-b3 * Purpose: Add user options fieldset to the top of ACP users view prefs settings -acp_users_signature_editor_buttons_after -=== -* Locations: - + adm/style/acp_users_signature.html -* Since: 3.1.0-a3 -* Purpose: Add content after BBCode posting buttons in the ACP user signature - -acp_users_signature_editor_buttons_before -=== -* Locations: - + adm/style/acp_users_signature.html -* Since: 3.1.0-a3 -* Purpose: Add content before BBCode posting buttons in the ACP user signature - forumlist_body_category_header_after === * Locations: -- cgit v1.2.1 From c5a51efd2084f687eea17c93d95f1e13c7496d58 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:23:36 +0200 Subject: [ticket/10073] Change name of the ACP module PHPBB3-10073 --- phpBB/language/en/acp/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index b81b9c2693..ff52509cca 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -76,7 +76,7 @@ $lang = array_merge($lang, array( 'ACP_CLIENT_COMMUNICATION' => 'Client communication', 'ACP_COOKIE_SETTINGS' => 'Cookie settings', 'ACP_CONTACT' => 'Contact page', - 'ACP_CONTACT_SETTINGS' => '“Contact Us” settings', + 'ACP_CONTACT_SETTINGS' => 'Contact page settings', 'ACP_CRITICAL_LOGS' => 'Error log', 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', -- 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/memberlist.php | 1 + phpBB/phpbb/user.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index b3025dacce..4eb6d79272 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -25,6 +25,7 @@ $mode = request_var('mode', ''); if ($mode === 'contactadmin') { define('SKIP_CHECK_BAN', true); + define('SKIP_CHECK_DISABLED', true); } // Start session management 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 3e0f8d7f1ebb9cd655fd9826cac11f163c91d230 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:38:08 +0200 Subject: [ticket/10073] Move template code into the template PHPBB3-10073 --- phpBB/adm/style/acp_contact.html | 6 +++--- phpBB/includes/acp/acp_contact.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html index 9578b3df83..532617cc16 100644 --- a/phpBB/adm/style/acp_contact.html +++ b/phpBB/adm/style/acp_contact.html @@ -53,13 +53,13 @@
    - + - + - +
    {L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
    diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index 21807082fc..9abc901e54 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -95,9 +95,9 @@ class acp_contact 'CONTACT_US_INFO' => $contact_admin_edit['text'], 'CONTACT_US_INFO_PREVIEW' => $contact_admin_info_preview, - 'S_BBCODE_CHECKED' => (!$contact_admin_edit['allow_bbcode']) ? ' checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$contact_admin_edit['allow_smilies']) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$contact_admin_edit['allow_urls']) ? ' checked="checked"' : '', + 'S_BBCODE_ALLOWED' => $contact_admin_edit['allow_bbcode'], + 'S_SMILIES_ALLOWED' => $contact_admin_edit['allow_smilies'], + 'S_MAGIC_URL_ALLOWED' => $contact_admin_edit['allow_urls'], 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '', ''), 'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'], -- cgit v1.2.1 From 8e48840034aa0a00fc31f577d409663a529845f0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:41:22 +0200 Subject: [ticket/10073] Fix more "Contact Us" strings PHPBB3-10073 --- phpBB/language/en/acp/board.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 8cb6a8f171..d51b0999ff 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -354,15 +354,15 @@ $lang = array_merge($lang, array( // Contact Settings $lang = array_merge($lang, array( - 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the “Contact Us” page and also add a text that is displayed on the page.', + 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the contact page and also add a text that is displayed on the page.', - 'CONTACT_US_ENABLE' => 'Enable “Contact Us” page', + 'CONTACT_US_ENABLE' => 'Enable contact page', 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators', - 'CONTACT_US_INFO' => '“Contact Us” information', - 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the “Contact Us” page', - 'CONTACT_US_INFO_PREVIEW' => '“Contact Us” information - Preview', - 'CONTACT_US_INFO_UPDATED' => '“Contact Us” information has been updated.', + 'CONTACT_US_INFO' => 'Contact information', + 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the contact page', + 'CONTACT_US_INFO_PREVIEW' => 'Contact page information - Preview', + 'CONTACT_US_INFO_UPDATED' => 'Contact page information has been updated.', )); // Load Settings -- cgit v1.2.1 From 81f22a1c8e4e67d83a9308ad832db3c96a835798 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 17:41:43 +0200 Subject: [ticket/10073] Get service from container PHPBB3-10073 --- phpBB/includes/acp/acp_contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index 9abc901e54..c681018efd 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -24,7 +24,7 @@ class acp_contact public function main($id, $mode) { global $db, $user, $request, $template; - global $config, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx, $phpbb_container; $user->add_lang(array('acp/board', 'posting')); @@ -43,7 +43,7 @@ class acp_contact include($phpbb_root_path . 'includes/message_parser.' . $phpEx); } - $config_text = new \phpbb\config\db_text($db, CONFIG_TEXT_TABLE); + $config_text = $phpbb_container->get('config_text'); $contact_admin_info = $request->variable('contact_admin_info', $config_text->get('contact_admin_info'), true); $contact_admin_info_uid = $config['contact_admin_info_uid']; -- cgit v1.2.1 From 975afa90480f6d48f266e40870fb948a38e00f2a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 20:54:57 +0200 Subject: [ticket/10073] Deduplicate template variable names PHPBB3-10073 --- phpBB/adm/style/acp_contact.html | 6 +++--- phpBB/includes/acp/acp_contact.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html index 532617cc16..828fd4b659 100644 --- a/phpBB/adm/style/acp_contact.html +++ b/phpBB/adm/style/acp_contact.html @@ -53,13 +53,13 @@
    - + - + - +
    {L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
    diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index c681018efd..b53bfd022f 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -95,9 +95,9 @@ class acp_contact 'CONTACT_US_INFO' => $contact_admin_edit['text'], 'CONTACT_US_INFO_PREVIEW' => $contact_admin_info_preview, - 'S_BBCODE_ALLOWED' => $contact_admin_edit['allow_bbcode'], - 'S_SMILIES_ALLOWED' => $contact_admin_edit['allow_smilies'], - 'S_MAGIC_URL_ALLOWED' => $contact_admin_edit['allow_urls'], + 'S_BBCODE_DISABLE_CHECKED' => !$contact_admin_edit['allow_bbcode'], + 'S_SMILIES_DISABLE_CHECKED' => !$contact_admin_edit['allow_smilies'], + 'S_MAGIC_URL_DISABLE_CHECKED' => !$contact_admin_edit['allow_urls'], 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '', ''), 'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'], -- cgit v1.2.1 From 1c0036f11889d9ad5c821e922e5d3ca87969db26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 21:11:41 +0200 Subject: [ticket/10073] Fix request usage PHPBB3-10073 --- phpBB/includes/acp/acp_contact.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index b53bfd022f..5bda082ca8 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -45,7 +45,7 @@ class acp_contact $config_text = $phpbb_container->get('config_text'); - $contact_admin_info = $request->variable('contact_admin_info', $config_text->get('contact_admin_info'), true); + $contact_admin_info = $config_text->get('contact_admin_info'); $contact_admin_info_uid = $config['contact_admin_info_uid']; $contact_admin_info_bitfield= $config['contact_admin_info_bitfield']; $contact_admin_info_flags = $config['contact_admin_info_flags']; @@ -57,6 +57,8 @@ class acp_contact $error = $user->lang('FORM_INVALID'); } + $contact_admin_info = $request->variable('contact_admin_info', '', true); + generate_text_for_storage( $contact_admin_info, $contact_admin_info_uid, -- 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/config/services.yml | 1 + phpBB/install/schemas/schema_data.sql | 6 +++--- phpBB/phpbb/message/admin_form.php | 15 +++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 791981854c..3c913f347c 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -243,6 +243,7 @@ services: arguments: - @auth - @config + - @config_text - @dbal.conn - @user - %core.root_path% diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 5d879a4be6..7f2cf13bbf 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -83,9 +83,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_c INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_uid', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_info_flags', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); @@ -305,6 +302,9 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnin # Config text INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_uid', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', ''); # -- Forum related auth options INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); 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 6a9fd06b7368b2f33f597bb9a3c2e1fb8cf97bdb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 21:32:59 +0200 Subject: [ticket/10073] Store values with config_text in the ACP PHPBB3-10073 --- phpBB/includes/acp/acp_contact.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index 5bda082ca8..cd62a42a93 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -45,10 +45,17 @@ class acp_contact $config_text = $phpbb_container->get('config_text'); - $contact_admin_info = $config_text->get('contact_admin_info'); - $contact_admin_info_uid = $config['contact_admin_info_uid']; - $contact_admin_info_bitfield= $config['contact_admin_info_bitfield']; - $contact_admin_info_flags = $config['contact_admin_info_flags']; + $contact_admin_data = $config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_bitfield', + 'contact_admin_info_flags', + )); + + $contact_admin_info = $contact_admin_data['contact_admin_info']; + $contact_admin_info_uid = $contact_admin_data['contact_admin_info_uid']; + $contact_admin_info_bitfield= $contact_admin_data['contact_admin_info_bitfield']; + $contact_admin_info_flags = $contact_admin_data['contact_admin_info_flags']; if ($request->is_set_post('submit') || $request->is_set_post('preview')) { @@ -73,10 +80,12 @@ class acp_contact { $config->set('contact_admin_form_enable', $request->variable('contact_admin_form_enable', false)); - $config_text->set('contact_admin_info', $contact_admin_info); - $config->set('contact_admin_info_uid', $contact_admin_info_uid); - $config->set('contact_admin_info_bitfield', $contact_admin_info_bitfield); - $config->set('contact_admin_info_flags', $contact_admin_info_flags); + $config_text->set_array(array( + 'contact_admin_info' => $contact_admin_info, + 'contact_admin_info_uid' => $contact_admin_info_uid, + 'contact_admin_info_bitfield' => $contact_admin_info_bitfield, + 'contact_admin_info_flags' => $contact_admin_info_flags, + )); trigger_error($user->lang['CONTACT_US_INFO_UPDATED'] . adm_back_link($this->u_action)); } -- 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/includes/acp/acp_contact.php | 2 +- phpBB/install/schemas/schema_data.sql | 2 +- phpBB/phpbb/db/migration/data/v310/contact_admin_form.php | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php index cd62a42a93..13d38d9f29 100644 --- a/phpBB/includes/acp/acp_contact.php +++ b/phpBB/includes/acp/acp_contact.php @@ -23,7 +23,7 @@ class acp_contact public function main($id, $mode) { - global $db, $user, $request, $template; + global $user, $request, $template; global $config, $phpbb_root_path, $phpEx, $phpbb_container; $user->add_lang(array('acp/board', 'posting')); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 7f2cf13bbf..b7f2271aed 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -304,7 +304,7 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnin INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_uid', ''); INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); -INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', '7'); # -- Forum related auth options INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); 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 From 92f43c5371f1f37bd6d77ade2fc5e2804b5cc49f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Jun 2014 01:40:17 +0200 Subject: [ticket/10073] Fix button descriptions PHPBB3-10073 --- phpBB/language/en/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index f451ac5f25..b7250f1089 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -667,8 +667,8 @@ $lang = array_merge($lang, array( 'SELECT_ALL_CODE' => 'Select all', 'SELECT_DESTINATION_FORUM' => 'Please select a destination forum', 'SELECT_FORUM' => 'Select a forum', - 'SEND_EMAIL' => 'Email', // Used for submit buttons - 'SEND_EMAIL_USER' => 'Email %s', + 'SEND_EMAIL' => 'Send email', // Used for submit buttons + 'SEND_EMAIL_USER' => 'Send email to %s', 'SEND_PRIVATE_MESSAGE' => 'Send private message', 'SETTINGS' => 'Settings', 'SIGNATURE' => 'Signature', -- cgit v1.2.1
    {L_CONTACT_ADMIN} {L_SEND_EMAIL_USER}
    {ERROR_MESSAGE}
    {CONTACT_INFO}
    {L_RECIPIENT}{L_SUBJECT}
    {L_RECIPIENT}{L_ADMINISTRATOR}
    {L_SENDER_EMAIL_ADDRESS}
    {L_SENDER_NAME}
    {L_EMAIL_ADDRESS}
    {L_CONTACT_ADMIN} {L_SEND_EMAIL_USER}{L_EMAIL_TOPIC}