[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
This commit is contained in:
Nils Adermann 2011-06-05 09:40:43 +02:00 committed by Joas Schilling
parent 624c0e4ef6
commit d52f34f5ec
15 changed files with 787 additions and 242 deletions

View file

@ -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_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_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_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_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_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),

View file

@ -0,0 +1,118 @@
<?php
/**
*
* @package email
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_message_admin_form extends phpbb_message_form
{
protected $subject;
protected $sender_name;
protected $sender_address;
public function check_allow()
{
$error = parent::check_allow();
if ($error)
{
return $error;
}
if (!$this->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);
}
}

View file

@ -0,0 +1,119 @@
<?php
/**
*
* @package message
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
abstract class phpbb_message_form
{
protected $phpbb_root_path;
protected $phpEx;
protected $user;
protected $auth;
protected $config;
protected $db;
protected $errors;
protected $message;
protected $cc_sender;
protected $body;
public function __construct($phpbb_root_path, $phpEx, $user, $auth, $config, $db)
{
$this->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'], '<a href="' . append_sid($this->phpbb_root_path . 'index.' . $this->phpEx) . '">', '</a>');
}
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'] . '<br /><br />' . $this->get_return_message());
}
}
public function render($template)
{
add_form_key('memberlist_email');
$template->assign_vars(array(
'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('<br />', $this->errors) : '',
));
}
}

View file

@ -0,0 +1,188 @@
<?php
/**
*
* @package message
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_message
{
protected $board_contact;
protected $server_name;
protected $subject = '';
protected $body = '';
protected $template = '';
protected $template_vars = array();
protected $sender_ip = '';
protected $sender_name = '';
protected $sender_address = '';
protected $sender_lang = '';
protected $sender_id = '';
protected $sender_username = '';
protected $sender_jabber = '';
protected $sender_notify_type = NOTIFY_EMAIL;
protected $recipients;
public function __construct($board_contact, $server_name)
{
$this->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']);
}
}
}

View file

@ -0,0 +1,150 @@
<?php
/**
*
* @package message
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_message_topic_form extends phpbb_message_form
{
protected $topic_id;
protected $topic_row;
protected $recipient_address;
protected $recipient_name;
protected $recipient_lang;
protected function get_topic_row($topic_id)
{
$sql = 'SELECT forum_id, topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . (int) $topic_id;
$result = $this->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'], '<a href="' . append_sid($this->phpbb_root_path . 'viewtopic.' . $this->phpEx, 'f=' . $this->topic_row['forum_id'] . '&amp;t=' . $this->topic_id) . '">', '</a>');
}
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&amp;t=' . $this->topic_id))
);
}
}

View file

@ -0,0 +1,111 @@
<?php
/**
*
* @package message
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_message_user_form extends phpbb_message_form
{
protected $recipient_id;
protected $subject;
public function check_allow()
{
$error = parent::check_allow();
if ($error)
{
return $error;
}
if (!$this->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&amp;u=' . $this->recipient_id),
'USERNAME' => $this->recipient_row['username'],
'SUBJECT' => $this->subject,
'MESSAGE' => $this->body,
));
}
}

View file

@ -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_attachment_content', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); 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 ('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_domain', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/');

View file

@ -171,6 +171,7 @@ $lang = array_merge($lang, array(
'CONNECTION_SUCCESS' => 'Connection was successful!', 'CONNECTION_SUCCESS' => 'Connection was successful!',
'CONTACT' => 'Contact', 'CONTACT' => 'Contact',
'CONTACT_USER' => 'Contact %s', 'CONTACT_USER' => 'Contact %s',
'CONTACT_US' => 'Contact us',
'COOKIES_DELETED' => 'All board cookies successfully deleted.', 'COOKIES_DELETED' => 'All board cookies successfully deleted.',
'CURRENT_TIME' => 'It is currently %s', '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_USER_PASSWORD' => 'The password you entered is too short.',
'TOO_SHORT_USERNAME' => 'The username 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' => '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' => 'The value you entered is too small.',
'TOO_SMALL_MAX_RECIPIENTS' => 'The value of <strong>Maximum number of allowed recipients per private message</strong> setting you entered is too small.', 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of <strong>Maximum number of allowed recipients per private message</strong> setting you entered is too small.',

View file

@ -49,6 +49,8 @@ $lang = array_merge($lang, array(
'BEFORE' => 'Before', 'BEFORE' => 'Before',
'CC_EMAIL' => 'Send a copy of this email to yourself.', 'CC_EMAIL' => 'Send a copy of this email to yourself.',
'CONTACT_USER' => 'Contact',
'CONTACT_ADMIN' => 'Contact a Board Administrator',
'DEST_LANG' => 'Language', 'DEST_LANG' => 'Language',
'DEST_LANG_EXPLAIN' => 'Select an appropriate language (if available) for the recipient of this message.', '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_EMAIL' => 'You must enter a message to be emailed.',
'EMPTY_MESSAGE_IM' => 'You must enter a message to be send.', 'EMPTY_MESSAGE_IM' => 'You must enter a message to be send.',
'EMPTY_NAME_EMAIL' => 'You must enter the real name of the recipient.', '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.', 'EMPTY_SUBJECT_EMAIL' => 'You must specify a subject for the email.',
'EQUAL_TO' => 'Equal to', 'EQUAL_TO' => 'Equal to',
@ -98,6 +102,8 @@ $lang = array_merge($lang, array(
'MORE_THAN' => 'More than', '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_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.', '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_MARKED' => 'Select marked',
'SELECT_SORT_METHOD' => 'Select sort method', '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_ICQ_MESSAGE' => 'Send ICQ message',
'SEND_IM' => 'Instant messaging', 'SEND_IM' => 'Instant messaging',
'SEND_JABBER_MESSAGE' => 'Send Jabber message', 'SEND_JABBER_MESSAGE' => 'Send Jabber message',

View file

@ -20,6 +20,13 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
$mode = request_var('mode', '');
if ($mode === 'contactadmin')
{
define('SKIP_CHECK_BAN', true);
}
// Start session management // Start session management
$user->session_begin(); $user->session_begin();
$auth->acl($user->data); $auth->acl($user->data);
@ -29,7 +36,6 @@ $user->setup(array('memberlist', 'groups'));
$template->assign_var('S_IN_MEMBERLIST', true); $template->assign_var('S_IN_MEMBERLIST', true);
// Grab data // Grab data
$mode = request_var('mode', '');
$action = request_var('action', ''); $action = request_var('action', '');
$user_id = request_var('u', ANONYMOUS); $user_id = request_var('u', ANONYMOUS);
$username = request_var('un', '', true); $username = request_var('un', '', true);
@ -44,7 +50,7 @@ if ($mode == 'leaders')
} }
// Check our mode... // 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'); trigger_error('NO_MODE');
} }
@ -52,6 +58,7 @@ if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'sear
switch ($mode) switch ($mode)
{ {
case 'email': case 'email':
case 'contactadmin':
break; break;
case 'livesearch': case 'livesearch':
@ -736,265 +743,49 @@ switch ($mode)
break; break;
case 'contactadmin':
case 'email': case 'email':
if (!class_exists('messenger'))
// 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'); include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
} }
if (!$auth->acl_get('u_sendemail')) $user_id = request_var('u', 0);
{ $topic_id = request_var('t', 0);
trigger_error('NO_EMAIL');
}
// Are we trying to abuse the facility?
if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
{
trigger_error('FLOOD_EMAIL_LIMIT');
}
// Determine action...
$user_id = request_var('u', 0);
$topic_id = request_var('t', 0);
// Send email to user...
if ($user_id) if ($user_id)
{ {
if ($user_id == ANONYMOUS || !$config['board_email_form']) $form = new phpbb_message_user_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db);
{
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');
}
} }
else if ($topic_id) else if ($topic_id)
{ {
// Send topic heads-up to email address $form = new phpbb_message_topic_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db);
$sql = 'SELECT forum_id, topic_title }
FROM ' . TOPICS_TABLE . " else if ($mode === 'contactadmin')
WHERE topic_id = $topic_id"; {
$result = $db->sql_query($sql); $form = new phpbb_message_admin_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db);
$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');
}
}
} }
else else
{ {
trigger_error('NO_EMAIL'); trigger_error('NO_EMAIL');
} }
$error = array(); $form->bind($request);
$error = $form->check_allow();
$name = utf8_normalize_nfc(request_var('name', '', true)); if ($error)
$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)
{ {
if (!check_form_key('memberlist_email')) trigger_error($error);
{
$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'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&amp;t=$topic_id") . '">', '</a>');
trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
}
} }
if ($user_id) if (isset($_POST['submit']))
{ {
$template->assign_vars(array( $messenger = new messenger(false);
'S_SEND_USER' => true, $form->submit($messenger);
'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&amp;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&amp;t=' . $topic_id))
);
} }
$template->assign_vars(array( $page_title = $form->get_page_title();
'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '', $template_html = $form->get_template_file();
'SUBJECT' => $subject, $form->render($template);
'MESSAGE' => $message,
)
);
break; break;

View file

@ -1075,7 +1075,7 @@ class session
{ {
global $config, $db; global $config, $db;
if (defined('IN_CHECK_BAN')) if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))
{ {
return; return;
} }

View file

@ -1,13 +1,22 @@
<!-- INCLUDE overall_header.html --> <!-- INCLUDE overall_header.html -->
<!-- IF S_CONTACT_ADMIN-->
<h2 class="titlespace">{L_CONTACT_ADMIN}</h2>
<!-- ELSE -->
<h2 class="titlespace">{L_SEND_EMAIL_USER}</h2> <h2 class="titlespace">{L_SEND_EMAIL_USER}</h2>
<!-- ENDIF -->
<form method="post" action="{S_POST_ACTION}" id="post"> <form method="post" action="{S_POST_ACTION}" id="post">
<div class="panel"> <div class="panel">
<div class="inner"> <div class="inner">
<!-- IF CONTACT_INFO -->
<div class="postbody"><div class="content">{CONTACT_INFO}</div></div>
<br class="clear" />
<!-- ENDIF -->
<div class="content"> <div class="content">
<!-- IF ERROR_MESSAGE --><p class="error">{ERROR_MESSAGE}</p><!-- ENDIF --> <!-- IF ERROR_MESSAGE --><p class="error">{ERROR_MESSAGE}</p><!-- ENDIF -->
<fieldset class="fields2"> <fieldset class="fields2">
<!-- IF S_SEND_USER --> <!-- IF S_SEND_USER -->
@ -19,6 +28,25 @@
<dt><label for="subject">{L_SUBJECT}{L_COLON}</label></dt> <dt><label for="subject">{L_SUBJECT}{L_COLON}</label></dt>
<dd><input class="inputbox autowidth" type="text" name="subject" id="subject" size="50" tabindex="1" value="{SUBJECT}" /></dd> <dd><input class="inputbox autowidth" type="text" name="subject" id="subject" size="50" tabindex="1" value="{SUBJECT}" /></dd>
</dl> </dl>
<!-- ELSEIF S_CONTACT_ADMIN-->
<dl>
<dt><label>{L_RECIPIENT}:</label></dt>
<dd><strong>{L_ADMINISTRATOR}</strong></dd>
</dl>
<!-- IF not S_IS_REGISTERED -->
<dl>
<dt><label for="email">{L_SENDER_EMAIL_ADDRESS}:</label></dt>
<dd><input class="inputbox autowidth" type="text" name="email" id="email" size="50" maxlength="100" tabindex="1" value="{EMAIL}" /></dd>
</dl>
<dl>
<dt><label for="name">{L_SENDER_NAME}:</label></dt>
<dd><input class="inputbox autowidth" type="text" name="name" id="name" size="50" tabindex="2" value="{NAME}" /></dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="subject">{L_SUBJECT}:</label></dt>
<dd><input class="inputbox autowidth" type="text" name="subject" id="subject" size="50" tabindex="3" value="{SUBJECT}" /></dd>
</dl>
<!-- ELSE --> <!-- ELSE -->
<dl> <dl>
<dt><label for="email">{L_EMAIL_ADDRESS}{L_COLON}</label></dt> <dt><label for="email">{L_EMAIL_ADDRESS}{L_COLON}</label></dt>

View file

@ -16,6 +16,7 @@
<!-- IF not S_IS_BOT --><li class="rightside"><a href="{U_DELETE_COOKIES}" data-ajax="true" data-refresh="true">{L_DELETE_COOKIES}</a></li><!-- ENDIF --> <!-- IF not S_IS_BOT --><li class="rightside"><a href="{U_DELETE_COOKIES}" data-ajax="true" data-refresh="true">{L_DELETE_COOKIES}</a></li><!-- ENDIF -->
<!-- EVENT overall_footer_teamlink_before --> <!-- EVENT overall_footer_teamlink_before -->
<!-- IF U_TEAM --><li class="rightside"><a href="{U_TEAM}">{L_THE_TEAM}</a></li><!-- ENDIF --> <!-- IF U_TEAM --><li class="rightside"><a href="{U_TEAM}">{L_THE_TEAM}</a></li><!-- ENDIF -->
<!-- IF U_CONTACT_US --><li class="rightside"><a href="{U_CONTACT_US}">{L_CONTACT_US}</a></li><!-- ENDIF -->
<!-- EVENT overall_footer_teamlink_after --> <!-- EVENT overall_footer_teamlink_after -->
</ul> </ul>

View file

@ -20,10 +20,13 @@
<!-- IF not S_IS_BOT and U_TEAM --> | <!-- ENDIF --> <!-- IF not S_IS_BOT and U_TEAM --> | <!-- ENDIF -->
<!-- EVENT overall_footer_teamlink_before --> <!-- EVENT overall_footer_teamlink_before -->
<!-- IF U_TEAM --><a href="{U_TEAM}">{L_THE_TEAM}</a><!-- ENDIF --> <!-- IF U_TEAM --><a href="{U_TEAM}">{L_THE_TEAM}</a><!-- ENDIF -->
<!-- IF U_CONTACT_US -->
<!-- IF U_TEAM --> | <!-- ENDIF -->
<a href="{U_CONTACT_US}">{L_CONTACT_US}</a>
<!-- ENDIF -->
<!-- EVENT overall_footer_teamlink_after --> <!-- EVENT overall_footer_teamlink_after -->
</span> </span>
<br /> <br />
<!-- ENDIF -->
<br clear="all" /> <br clear="all" />

View file

@ -6,13 +6,22 @@
<table class="tablebg" width="100%" cellspacing="1"> <table class="tablebg" width="100%" cellspacing="1">
<tr> <tr>
<!-- IF S_CONTACT_ADMIN-->
<th colspan="2">{L_CONTACT_ADMIN}</th>
<!-- ELSE -->
<th colspan="2">{L_SEND_EMAIL_USER}</th> <th colspan="2">{L_SEND_EMAIL_USER}</th>
<!-- ENDIF -->
</tr> </tr>
<!-- IF ERROR_MESSAGE --> <!-- IF ERROR_MESSAGE -->
<tr> <tr>
<td class="row3" colspan="2" align="center"><span class="error">{ERROR_MESSAGE}</span></td> <td class="row3" colspan="2" align="center"><span class="error">{ERROR_MESSAGE}</span></td>
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF CONTACT_INFO -->
<tr>
<td class="row1" colspan="2">{CONTACT_INFO}</td>
</tr>
<!-- ENDIF -->
<!-- IF S_SEND_USER --> <!-- IF S_SEND_USER -->
<tr> <tr>
<td class="row1" width="35%"><b class="genmed">{L_RECIPIENT}</b></td> <td class="row1" width="35%"><b class="genmed">{L_RECIPIENT}</b></td>
@ -22,6 +31,21 @@
<td class="row1" width="35%"><b class="genmed">{L_SUBJECT}</b></td> <td class="row1" width="35%"><b class="genmed">{L_SUBJECT}</b></td>
<td class="row2"><input class="post" type="text" name="subject" size="50" tabindex="2" value="{SUBJECT}" /></td> <td class="row2"><input class="post" type="text" name="subject" size="50" tabindex="2" value="{SUBJECT}" /></td>
</tr> </tr>
<!-- ELSEIF S_CONTACT_ADMIN-->
<tr>
<td class="row1" width="35%"><b class="genmed">{L_RECIPIENT}</b></td>
<td class="row2" width="65%"><b class="genmed">{L_ADMINISTRATOR}</b></td>
</tr>
<!-- IF not S_IS_REGISTERED -->
<tr>
<td class="row1" width="35%"><b class="genmed">{L_SENDER_EMAIL_ADDRESS}</b></td>
<td class="row2"><input class="post" type="text" name="email" size="50" maxlength="100" value="{EMAIL}" /></td>
</tr>
<tr>
<td class="row1" width="35%"><b class="genmed">{L_SENDER_NAME}</b></td>
<td class="row2"><input class="post" type="text" name="name" size="50" value="{NAME}" /></td>
</tr>
<!-- ENDIF -->
<!-- ELSE --> <!-- ELSE -->
<tr> <tr>
<td class="row1" width="35%"><b class="genmed">{L_EMAIL_ADDRESS}</b></td> <td class="row1" width="35%"><b class="genmed">{L_EMAIL_ADDRESS}</b></td>