mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/10073' into develop-ascraeus
* github-nickvergessen/ticket/10073: (36 commits) [ticket/10073] Fix button descriptions [ticket/10073] Do not check disable boxes by default [ticket/10073] Store values with config_text in the ACP [ticket/10073] Move config values to config_text [ticket/10073] Fix request usage [ticket/10073] Deduplicate template variable names [ticket/10073] Get service from container [ticket/10073] Fix more "Contact Us" strings [ticket/10073] Move template code into the template [ticket/10073] Make contact page available when board is disabled [ticket/10073] Change name of the ACP module [ticket/10073] Deduplicate posting buttons code in ACP [ticket/10073] Use phpbb_validate_email to verify email address [ticket/10073] Add tests for new validate_email() [ticket/10073] Split email validation from email ban and taken checks [ticket/10073] Deduplicate the if statement [ticket/10073] Fallback to board_contact when contact page is disabled [ticket/10073] Remove language string from rebase conflict [ticket/10073] Add ACP module to add bbcode text for contact admin info [ticket/10073] Add new configs to the schema ...
This commit is contained in:
@@ -81,7 +81,8 @@ class gravatar extends \phpbb\avatar\driver\driver
|
||||
array(
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('email'))
|
||||
array('email'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
@@ -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()
|
||||
{
|
||||
|
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class contact_admin_acp_module extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'ACP_BOARD_CONFIGURATION',
|
||||
array(
|
||||
'module_basename' => 'acp_contact',
|
||||
'modes' => array('contact'),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
37
phpBB/phpbb/db/migration/data/v310/contact_admin_form.php
Normal file
37
phpBB/phpbb/db/migration/data/v310/contact_admin_form.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class contact_admin_form extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return isset($this->config['contact_admin_form_enable']);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.add', array('contact_admin_form_enable', 1)),
|
||||
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_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,
|
||||
));
|
||||
}
|
||||
}
|
189
phpBB/phpbb/message/admin_form.php
Normal file
189
phpBB/phpbb/message/admin_form.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package message
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
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 \phpbb\config\db_text */
|
||||
protected $config_text;
|
||||
|
||||
/** @var string */
|
||||
protected $subject;
|
||||
/** @var string */
|
||||
protected $sender_name;
|
||||
/** @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}
|
||||
*/
|
||||
public function check_allow()
|
||||
{
|
||||
$error = parent::check_allow();
|
||||
if ($error)
|
||||
{
|
||||
return $error;
|
||||
}
|
||||
|
||||
if (!$this->config['contact_admin_form_enable'])
|
||||
{
|
||||
return 'NO_CONTACT_PAGE';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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 (!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[$error];
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
public function render(\phpbb\template\template $template)
|
||||
{
|
||||
$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(
|
||||
$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']
|
||||
);
|
||||
}
|
||||
|
||||
$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' => $l_admin_info,
|
||||
'MESSAGE' => $this->body,
|
||||
'SUBJECT' => $this->subject,
|
||||
'NAME' => $this->sender_name,
|
||||
'EMAIL' => $this->sender_address,
|
||||
));
|
||||
|
||||
parent::render($template);
|
||||
}
|
||||
}
|
173
phpBB/phpbb/message/form.php
Normal file
173
phpBB/phpbb/message/form.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package message
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Abstract class form
|
||||
*
|
||||
* @package phpbb\message
|
||||
*/
|
||||
abstract class form
|
||||
{
|
||||
/** @var \phpbb\auth\auth */
|
||||
protected $auth;
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
/** @var \phpbb\message\message */
|
||||
protected $message;
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path;
|
||||
/** @var string */
|
||||
protected $phpEx;
|
||||
|
||||
/** @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;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->user = $user;
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
|
||||
$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()
|
||||
{
|
||||
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'])
|
||||
{
|
||||
return 'EMAIL_DISABLED';
|
||||
}
|
||||
|
||||
if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval'])
|
||||
{
|
||||
return 'FLOOD_EMAIL_LIMIT';
|
||||
}
|
||||
|
||||
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'], '<a href="' . append_sid($this->phpbb_root_path . 'index.' . $this->phpEx) . '">', '</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'))
|
||||
{
|
||||
$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, 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'] . '<br /><br />' . $this->get_return_message());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('<br />', $this->errors) : '',
|
||||
));
|
||||
}
|
||||
}
|
280
phpBB/phpbb/message/message.php
Normal file
280
phpBB/phpbb/message/message.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package message
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
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']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'name' => $recipient_name,
|
||||
'address' => $recipient_address,
|
||||
'lang' => $recipient_lang,
|
||||
'username' => $recipient_username,
|
||||
'jabber' => $recipient_jabber,
|
||||
'notify_type' => $recipient_notify_type,
|
||||
'to_name' => $recipient_name,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the senders data from \phpbb\user object
|
||||
*
|
||||
* @param \phpbb\user $user
|
||||
* @return null
|
||||
*/
|
||||
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']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ok, now the same email if CC specified, but without exposing the user's 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'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the email
|
||||
*
|
||||
* @param \messenger $messenger
|
||||
* @param string $phpEx
|
||||
* @return null
|
||||
*/
|
||||
public function send(\messenger $messenger, $contact)
|
||||
{
|
||||
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' => $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']);
|
||||
}
|
||||
}
|
||||
}
|
156
phpBB/phpbb/message/topic_form.php
Normal file
156
phpBB/phpbb/message/topic_form.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package message
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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';
|
||||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
public 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'] . '&t=' . $this->topic_id) . '">', '</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
public function render(\phpbb\template\template $template)
|
||||
{
|
||||
parent::render($template);
|
||||
|
||||
$this->user->add_lang('viewtopic');
|
||||
$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))
|
||||
);
|
||||
}
|
||||
}
|
134
phpBB/phpbb/message/user_form.php
Normal file
134
phpBB/phpbb/message/user_form.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package message
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
/** @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 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 . ')';
|
||||
$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();
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {inheritDoc}
|
||||
*/
|
||||
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),
|
||||
|
||||
'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,
|
||||
));
|
||||
}
|
||||
}
|
@@ -1075,7 +1075,7 @@ class session
|
||||
{
|
||||
global $config, $db;
|
||||
|
||||
if (defined('IN_CHECK_BAN'))
|
||||
if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -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,8 @@ 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, '<a href="mailto:' . $config['board_contact'] . '">', '</a>');
|
||||
$contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
|
||||
$message = sprintf($this->lang[$message], $till_date, '<a href="' . $contact_link . '">', '</a>');
|
||||
$message .= ($ban_row['ban_give_reason']) ? '<br /><br />' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : '';
|
||||
$message .= '<br /><br /><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>';
|
||||
|
||||
|
@@ -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'])
|
||||
{
|
||||
|
Reference in New Issue
Block a user