PDF rausgenommen
This commit is contained in:
192
msd2/phpBB3/phpbb/message/admin_form.php
Normal file
192
msd2/phpBB3/phpbb/message/admin_form.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Class admin_form
|
||||
* Displays a message to the user and allows him to send an email
|
||||
*/
|
||||
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'],
|
||||
'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'),
|
||||
|
||||
'CONTACT_INFO' => $l_admin_info,
|
||||
'MESSAGE' => $this->body,
|
||||
'SUBJECT' => $this->subject,
|
||||
'NAME' => $this->sender_name,
|
||||
'EMAIL' => $this->sender_address,
|
||||
));
|
||||
|
||||
parent::render($template);
|
||||
}
|
||||
}
|
175
msd2/phpBB3/phpbb/message/form.php
Normal file
175
msd2/phpBB3/phpbb/message/form.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Abstract class form
|
||||
*/
|
||||
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 (!count($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->user->data['is_registered'])
|
||||
{
|
||||
$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' => (count($this->errors)) ? implode('<br />', $this->errors) : '',
|
||||
));
|
||||
}
|
||||
}
|
282
msd2/phpBB3/phpbb/message/message.php
Normal file
282
msd2/phpBB3/phpbb/message/message.php
Normal file
@ -0,0 +1,282 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Class message
|
||||
* Holds all information for an email and sends it in the end
|
||||
*/
|
||||
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 array $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 (!count($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 $contact
|
||||
* @return null
|
||||
*/
|
||||
public function send(\messenger $messenger, $contact)
|
||||
{
|
||||
if (!count($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 (count($this->template_vars))
|
||||
{
|
||||
$messenger->assign_vars($this->template_vars);
|
||||
}
|
||||
|
||||
$messenger->send($recipient['notify_type']);
|
||||
}
|
||||
}
|
||||
}
|
166
msd2/phpBB3/phpbb/message/topic_form.php
Normal file
166
msd2/phpBB3/phpbb/message/topic_form.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Class topic_form
|
||||
* Form used to send topics as notification emails
|
||||
*/
|
||||
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']))
|
||||
{
|
||||
if ($this->user->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
send_status_line(401, 'Unauthorized');
|
||||
}
|
||||
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->set_body($this->body);
|
||||
$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))
|
||||
);
|
||||
}
|
||||
}
|
136
msd2/phpBB3/phpbb/message/user_form.php
Normal file
136
msd2/phpBB3/phpbb/message/user_form.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
/**
|
||||
* Class user_form
|
||||
* Allows users to send emails to other users
|
||||
*/
|
||||
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,
|
||||
));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user