mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10073] Use namespaces and fix all class names
PHPBB3-10073
This commit is contained in:
parent
6c287e57fc
commit
fffb07fd91
8 changed files with 116 additions and 78 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
25
phpBB/phpbb/db/migration/data/v310/contact_admin_form.php
Normal file
25
phpBB/phpbb/db/migration/data/v310/contact_admin_form.php
Normal file
|
@ -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)),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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,
|
|
@ -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');
|
||||
|
|
@ -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))
|
||||
{
|
|
@ -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);
|
||||
|
|
@ -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);
|
||||
|
Loading…
Add table
Reference in a new issue