diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/config/services.yml | 30 | ||||
-rw-r--r-- | phpBB/memberlist.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v310/contact_admin_form.php | 25 | ||||
-rw-r--r-- | phpBB/phpbb/message/admin_form.php (renamed from phpBB/includes/message/admin_form.php) | 22 | ||||
-rw-r--r-- | phpBB/phpbb/message/form.php (renamed from phpBB/includes/message/form.php) | 42 | ||||
-rw-r--r-- | phpBB/phpbb/message/message.php (renamed from phpBB/includes/message/message.php) | 23 | ||||
-rw-r--r-- | phpBB/phpbb/message/topic_form.php (renamed from phpBB/includes/message/topic_form.php) | 22 | ||||
-rw-r--r-- | phpBB/phpbb/message/user_form.php (renamed from phpBB/includes/message/user_form.php) | 21 |
8 files changed, 116 insertions, 78 deletions
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4de47f750f..11a13c6b5f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -238,6 +238,36 @@ services: - %core.php_ext% - %tables.log% + message.form.admin: + class: phpbb\message\admin_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.topic: + class: phpbb\message\topic_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.user: + class: phpbb\message\user_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + notification_manager: class: phpbb\notification\manager arguments: diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index fab9747cce..2e480a472e 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -755,20 +755,21 @@ switch ($mode) if ($user_id) { - $form = new phpbb_message_user_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'user'; } else if ($topic_id) { - $form = new phpbb_message_topic_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'topic'; } else if ($mode === 'contactadmin') { - $form = new phpbb_message_admin_form($phpbb_root_path, $phpEx, $user, $auth, $config, $db); + $form_name = 'admin'; } else { trigger_error('NO_EMAIL'); } + $form = $phpbb_container->get('message.form.' . $form_name); $form->bind($request); $error = $form->check_allow(); @@ -777,7 +778,7 @@ switch ($mode) trigger_error($error); } - if (isset($_POST['submit'])) + if ($request->is_set_post('submit')) { $messenger = new messenger(false); $form->submit($messenger); diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php new file mode 100644 index 0000000000..c4149a0976 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -0,0 +1,25 @@ +<?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)), + ); + } +} diff --git a/phpBB/includes/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index a27b281535..dc995062a0 100644 --- a/phpBB/includes/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -1,21 +1,15 @@ <?php /** * -* @package email -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} +namespace phpbb\message; -class phpbb_message_admin_form extends phpbb_message_form +class admin_form extends form { protected $subject; protected $sender_name; @@ -37,7 +31,7 @@ class phpbb_message_admin_form extends phpbb_message_form return false; } - public function bind($request) + public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -46,7 +40,7 @@ class phpbb_message_admin_form extends phpbb_message_form $this->sender_name = $request->variable('name', '', true); } - public function submit(messenger $messenger) + public function submit(\messenger $messenger) { if (!$this->subject) { @@ -99,7 +93,7 @@ class phpbb_message_admin_form extends phpbb_message_form parent::submit($messenger); } - public function render($template) + public function render(\phpbb\template\template $template) { $template->assign_vars(array( 'S_CONTACT_ADMIN' => true, diff --git a/phpBB/includes/message/form.php b/phpBB/phpbb/message/form.php index 13909e1938..91da2d69b5 100644 --- a/phpBB/includes/message/form.php +++ b/phpBB/phpbb/message/form.php @@ -2,33 +2,35 @@ /** * * @package message -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} +namespace phpbb\message; -abstract class phpbb_message_form +abstract class form { - protected $phpbb_root_path; - protected $phpEx; - protected $user; + /** @var \phpbb\auth\auth */ protected $auth; + /** @var \phpbb\config\config */ protected $config; + /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** @var \phpbb\user */ + protected $user; + + /** @var string */ + protected $phpbb_root_path; + /** @var string */ + protected $phpEx; + protected $errors; protected $message; protected $cc_sender; protected $body; - public function __construct($phpbb_root_path, $phpEx, $user, $auth, $config, $db) + 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; @@ -39,7 +41,7 @@ abstract class phpbb_message_form $this->errors = array(); - $this->message = new phpbb_message($config['server_name']); + $this->message = new \phpbb\message\message($config['server_name']); $this->message->set_sender_from_user($this->user); } @@ -76,13 +78,13 @@ abstract class phpbb_message_form 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) + public function bind(\phpbb\request\request_interface $request) { $this->cc_sender = $request->is_set_post('cc_sender'); $this->body = $request->variable('message', '', true); } - public function submit(messenger $messenger) + public function submit(\messenger $messenger) { if (!check_form_key('memberlist_email')) { @@ -94,21 +96,21 @@ abstract class phpbb_message_form $sql = 'UPDATE ' . USERS_TABLE . ' SET user_emailtime = ' . time() . ' WHERE user_id = ' . $this->user->data['user_id']; - $result = $this->db->sql_query($sql); + $this->db->sql_query($sql); if ($this->cc_sender) { $this->message->cc_sender(); } - $this->message->send($messenger); + $this->message->send($messenger, $this->phpEx); meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); trigger_error($this->user->lang['EMAIL_SENT'] . '<br /><br />' . $this->get_return_message()); } } - public function render($template) + public function render(\phpbb\template\template $template) { add_form_key('memberlist_email'); diff --git a/phpBB/includes/message/message.php b/phpBB/phpbb/message/message.php index 1e4f0f65d8..9e94d4bbcd 100644 --- a/phpBB/includes/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -2,20 +2,14 @@ /** * * @package message -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} +namespace phpbb\message; -class phpbb_message +class message { protected $server_name; @@ -116,8 +110,11 @@ class phpbb_message $this->sender_notify_type = $sender_notify_type; } - -// Ok, now the same email if CC specified, but without exposing the users email address + /** + * Ok, now the same email if CC specified, but without exposing the users email address + * + * @return null + */ public function cc_sender() { if (!sizeof($this->recipients)) @@ -140,7 +137,7 @@ class phpbb_message ); } - public function send(messenger $messenger) + public function send(\messenger $messenger, $phpEx) { if (!sizeof($this->recipients)) { diff --git a/phpBB/includes/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index 0dbfdb0ca2..2b6d50aa26 100644 --- a/phpBB/includes/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -2,20 +2,14 @@ /** * * @package message -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} +namespace phpbb\message; -class phpbb_message_topic_form extends phpbb_message_form +class topic_form extends form { protected $topic_id; @@ -86,7 +80,7 @@ class phpbb_message_topic_form extends phpbb_message_form return false; } - public function bind($request) + public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -98,7 +92,7 @@ class phpbb_message_topic_form extends phpbb_message_form $this->topic_row = $this->get_topic_row($this->topic_id); } - public function submit(messenger $messenger) + public function submit(\messenger $messenger) { if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address)) { @@ -128,12 +122,12 @@ class phpbb_message_topic_form extends phpbb_message_form parent::submit($messenger); } - protected function get_return_message() + 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>'); } - public function render($template) + public function render(\phpbb\template\template $template) { parent::render($template); diff --git a/phpBB/includes/message/user_form.php b/phpBB/phpbb/message/user_form.php index 3898975a3f..a76d553b7c 100644 --- a/phpBB/includes/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -2,23 +2,18 @@ /** * * @package message -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} +namespace phpbb\message; -class phpbb_message_user_form extends phpbb_message_form +class user_form extends form { protected $recipient_id; protected $subject; + protected $recipient_row; public function check_allow() { @@ -65,7 +60,7 @@ class phpbb_message_user_form extends phpbb_message_form return $row; } - public function bind($request) + public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -75,7 +70,7 @@ class phpbb_message_user_form extends phpbb_message_form $this->recipient_row = $this->get_user_row($this->recipient_id); } - public function submit(messenger $messenger) + public function submit(\messenger $messenger) { if (!$this->subject) { @@ -95,7 +90,7 @@ class phpbb_message_user_form extends phpbb_message_form parent::submit($messenger); } - public function render($template) + public function render(\phpbb\template\template $template) { parent::render($template); |