mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/17135] Move notify method constants to interface class
PHPBB-17135
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
class notification_options_reconvert extends \phpbb\db\migration\migration
|
||||
{
|
||||
public static function depends_on()
|
||||
@@ -67,12 +69,12 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
|
||||
// In-board notification
|
||||
$notification_methods[] = '';
|
||||
|
||||
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
|
||||
if ($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
|
||||
{
|
||||
$notification_methods[] = 'email';
|
||||
}
|
||||
|
||||
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
|
||||
if ($row['user_notify_type'] == messenger_interface::NOTIFY_IM || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
|
||||
{
|
||||
$notification_methods[] = 'jabber';
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
/**
|
||||
* Class admin_form
|
||||
* Displays a message to the user and allows him to send an email
|
||||
@@ -155,7 +157,7 @@ class admin_form extends form
|
||||
}
|
||||
|
||||
$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_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
$this->message->set_template('contact_admin');
|
||||
@@ -165,7 +167,7 @@ class admin_form extends form
|
||||
$this->user->lang['ADMINISTRATOR'],
|
||||
$this->config['board_contact'],
|
||||
$this->config['default_lang'],
|
||||
NOTIFY_EMAIL
|
||||
messenger_interface::NOTIFY_EMAIL
|
||||
);
|
||||
|
||||
$this->message->set_template_vars(array(
|
||||
|
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
/**
|
||||
* Class message
|
||||
* Holds all information for an email and sends it in the end
|
||||
@@ -46,7 +48,7 @@ class message
|
||||
/** @var string */
|
||||
protected $sender_jabber = '';
|
||||
/** @var int */
|
||||
protected $sender_notify_type = NOTIFY_EMAIL;
|
||||
protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL;
|
||||
|
||||
/** @var array */
|
||||
protected $recipients;
|
||||
@@ -134,7 +136,7 @@ class message
|
||||
* @param string $recipient_jabber
|
||||
* @return void
|
||||
*/
|
||||
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
|
||||
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
|
||||
{
|
||||
$this->recipients[] = array(
|
||||
'name' => $recipient_name,
|
||||
@@ -250,7 +252,7 @@ class message
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
$messenger_method->set_use_queue(false);
|
||||
if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == NOTIFY_BOTH)
|
||||
if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == $messenger_method::NOTIFY_BOTH)
|
||||
{
|
||||
$messenger_method->template($this->template, $recipient['lang']);
|
||||
$messenger_method->set_addresses($recipient);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\message;
|
||||
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
/**
|
||||
* Class topic_form
|
||||
* Form used to send topics as notification emails
|
||||
@@ -130,9 +132,9 @@ class topic_form extends form
|
||||
$this->recipient_name,
|
||||
$this->recipient_address,
|
||||
$this->recipient_lang,
|
||||
NOTIFY_EMAIL
|
||||
messenger_interface::NOTIFY_EMAIL
|
||||
);
|
||||
$this->message->set_sender_notify_type(NOTIFY_EMAIL);
|
||||
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
|
||||
|
||||
parent::submit($messenger);
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class email extends base
|
||||
*/
|
||||
public function get_id(): int
|
||||
{
|
||||
return NOTIFY_EMAIL;
|
||||
return self::NOTIFY_EMAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -115,7 +115,7 @@ class jabber extends base
|
||||
*/
|
||||
public function get_id(): int
|
||||
{
|
||||
return NOTIFY_IM;
|
||||
return self::NOTIFY_IM;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,15 @@ namespace phpbb\messenger\method;
|
||||
*/
|
||||
interface messenger_interface
|
||||
{
|
||||
/** @var int Email notify method used */
|
||||
public const NOTIFY_EMAIL = 0;
|
||||
|
||||
/** @var int Instant messaging (Jabber) notify method used */
|
||||
public const NOTIFY_IM = 1;
|
||||
|
||||
/** @var int Both notify methods used */
|
||||
public const NOTIFY_BOTH = 2;
|
||||
|
||||
/**
|
||||
* Get messenger method id
|
||||
*
|
||||
|
@@ -19,6 +19,7 @@ use phpbb\user_loader;
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\di\service_collection;
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
/**
|
||||
* Email notification method class
|
||||
@@ -135,7 +136,7 @@ class email extends \phpbb\notification\method\messenger_base
|
||||
|
||||
$insert_buffer->flush();
|
||||
|
||||
$this->notify_using_messenger(NOTIFY_EMAIL);
|
||||
$this->notify_using_messenger(messenger_interface::NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ use phpbb\user;
|
||||
use phpbb\user_loader;
|
||||
use phpbb\config\config;
|
||||
use phpbb\di\service_collection;
|
||||
use phpbb\messenger\method\messenger_interface;
|
||||
|
||||
/**
|
||||
* Jabber notification method class
|
||||
@@ -98,6 +99,6 @@ class jabber extends \phpbb\notification\method\messenger_base
|
||||
return;
|
||||
}
|
||||
|
||||
$this->notify_using_messenger(NOTIFY_IM, 'short/');
|
||||
$this->notify_using_messenger(messenger_interface::NOTIFY_IM, 'short/');
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||
/**
|
||||
* Notify using phpBB messenger
|
||||
*
|
||||
* @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
|
||||
* @param int $notify_method Notify method for messenger (e.g. \phpbb\messenger\method\messenger_interface::NOTIFY_IM)
|
||||
* @param string $template_dir_prefix Base directory to prepend to the email template name
|
||||
*
|
||||
* @return void
|
||||
@@ -115,7 +115,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||
$messenger_collection_iterator = $this->messenger->getIterator();
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
if ($messenger_method->get_id() == $notify_method || $notify_method == NOTIFY_BOTH)
|
||||
if ($messenger_method->get_id() == $notify_method || $notify_method == $messenger_method::NOTIFY_BOTH)
|
||||
{
|
||||
$messenger_method->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
|
||||
$messenger_method->set_addresses($user);
|
||||
|
Reference in New Issue
Block a user