1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 09:16:55 +02:00

[ticket/17135] Move notify method constants to interface class

PHPBB-17135
This commit is contained in:
rxu
2025-01-06 20:01:52 +07:00
parent 28d5534d06
commit 0d8c0c4228
21 changed files with 77 additions and 50 deletions

View File

@@ -11,6 +11,8 @@
*
*/
use phpbb\messenger\method\messenger_interface;
/**
* @ignore
*/
@@ -156,9 +158,9 @@ class acp_email
foreach ($rows as $row)
{
if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) ||
($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) ||
($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
if (($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL && $row['user_email']) ||
($row['user_notify_type'] == messenger_interface::NOTIFY_IM && $row['user_jabber']) ||
($row['user_notify_type'] == messenger_interface::NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
{
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
{
@@ -228,14 +230,14 @@ class acp_email
foreach ($messenger_collection_iterator as $messenger_method)
{
$notify_method = $messenger_method->get_id();
if ($notify_method == $used_method || $used_method == NOTIFY_BOTH)
if ($notify_method == $used_method || $used_method == messenger_interface::NOTIFY_BOTH)
{
$messenger_method->set_use_queue($use_queue);
$messenger_method->template($email_template, $used_lang);
$messenger_method->subject(html_entity_decode($subject, ENT_COMPAT));
$messenger_method->assign_vars($template_data);
if ($notify_method == NOTIFY_EMAIL)
if ($notify_method == messenger_interface::NOTIFY_EMAIL)
{
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
{
@@ -243,7 +245,6 @@ class acp_email
if (count($email_list[$i]) == 1)
{
$messenger_method->to($email_row['email'], $email_row['name']);
}
else
{
@@ -254,7 +255,7 @@ class acp_email
$messenger_method->anti_abuse_headers($config, $user);
$messenger_method->set_mail_priority($priority);
}
else if ($notify_method == NOTIFY_IM)
else if ($notify_method == messenger_interface::NOTIFY_IM)
{
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
{

View File

@@ -207,7 +207,7 @@ class acp_inactive
{
foreach ($messenger_collection_iterator as $messenger_method)
{
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == NOTIFY_BOTH)
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
{
$messenger_method->template('user_remind_inactive', $row['user_lang']);
$messenger_method->set_addresses($row);

View File

@@ -30,15 +30,10 @@ class acp_jabber
function main($id, $mode)
{
global $db, $user, $template, $phpbb_log, $request;
global $config, $phpbb_root_path, $phpEx;
global $config, $phpbb_container, $phpbb_root_path, $phpEx;
$user->add_lang('acp/board');
if (!class_exists('jabber'))
{
include($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
}
$submit = (isset($_POST['submit'])) ? true : false;
if ($mode != 'settings')
@@ -73,11 +68,11 @@ class acp_jabber
$message = $user->lang['JAB_SETTINGS_CHANGED'];
$log = 'JAB_SETTINGS_CHANGED';
// Is this feature enabled? Then try to establish a connection
if ($jab_enable)
{
$jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl, $jab_verify_peer, $jab_verify_peer_name, $jab_allow_self_signed);
$jabber = $phpbb_container->get('messenger.method.jabber');
// Is this feature enabled? Then try to establish a connection
if ($jabber->is_enabled())
{
if (!$jabber->connect())
{
trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
@@ -97,12 +92,12 @@ class acp_jabber
// We update the user table to be sure all users that have IM as notify type are set to both as notify type
// We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled.
$sql_ary = array(
'user_notify_type' => NOTIFY_BOTH,
'user_notify_type' => $jabber::NOTIFY_BOTH,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_notify_type = ' . NOTIFY_IM;
WHERE user_notify_type = ' . $jabber::NOTIFY_IM;
$db->sql_query($sql);
}
@@ -137,7 +132,7 @@ class acp_jabber
'JAB_VERIFY_PEER' => $jab_verify_peer,
'JAB_VERIFY_PEER_NAME' => $jab_verify_peer_name,
'JAB_ALLOW_SELF_SIGNED' => $jab_allow_self_signed,
'S_CAN_USE_SSL' => jabber::can_use_ssl(),
'S_CAN_USE_SSL' => $jabber::can_use_ssl(),
'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false,
));
}

View File

@@ -16,6 +16,7 @@
*/
use phpbb\controller\helper;
use phpbb\messenger\method\messenger_interface;
if (!defined('IN_PHPBB'))
{
@@ -1792,9 +1793,9 @@ class acp_users
'MASS_EMAIL' => $data['massemail'],
'ALLOW_PM' => $data['allowpm'],
'HIDE_ONLINE' => $data['hideonline'],
'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
'NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false,
'NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false,
'NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false,
'NOTIFY_PM' => $data['notifypm'],
'BBCODE' => $data['bbcode'],
'SMILIES' => $data['smilies'],

View File

@@ -120,8 +120,11 @@ define('POST_ANNOUNCE', 2);
define('POST_GLOBAL', 3);
// Notify methods
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_EMAIL, to be removed in 5.0.0-a1 */
define('NOTIFY_EMAIL', 0);
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_IM, to be removed in 5.0.0-a1 */
define('NOTIFY_IM', 1);
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_BOTH, to be removed in 5.0.0-a1 */
define('NOTIFY_BOTH', 2);
// Notify status

View File

@@ -11,6 +11,8 @@
*
*/
use phpbb\messenger\method\messenger_interface;
/**
* @ignore
*/
@@ -244,7 +246,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
'user_notify' => 0,
'user_notify_pm' => 1,
'user_notify_type' => NOTIFY_EMAIL,
'user_notify_type' => messenger_interface::NOTIFY_EMAIL,
'user_allow_pm' => 1,
'user_allow_viewonline' => 1,
'user_allow_viewemail' => 1,

View File

@@ -135,7 +135,7 @@ class ucp_activate
$messenger_collection_iterator = $messenger->getIterator();
foreach ($messenger_collection_iterator as $messenger_method)
{
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == NOTIFY_BOTH)
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
{
$messenger_method->set_use_queue(false);
$messenger_method->template('admin_welcome_activated', $user_row['user_lang']);

View File

@@ -11,6 +11,8 @@
*
*/
use phpbb\messenger\method\messenger_interface;
/**
* @ignore
*/
@@ -52,10 +54,10 @@ class ucp_prefs
'allowpm' => $request->variable('allowpm', (bool) $user->data['user_allow_pm']),
);
if ($data['notifymethod'] == NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml')))
if ($data['notifymethod'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml')))
{
// Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct.
$data['notifymethod'] = NOTIFY_BOTH;
$data['notifymethod'] = messenger_interface::NOTIFY_BOTH;
}
/**
@@ -182,9 +184,9 @@ class ucp_prefs
$template->assign_vars([
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
'S_NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
'S_NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false,
'S_NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false,
'S_NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false,
'S_VIEW_EMAIL' => $data['viewemail'],
'S_MASS_EMAIL' => $data['massemail'],
'S_ALLOW_PM' => $data['allowpm'],

View File

@@ -11,6 +11,8 @@
*
*/
use phpbb\messenger\method\messenger_interface;
/**
* @ignore
*/
@@ -363,11 +365,11 @@ class ucp_profile
{
$data['notify'] = $user->data['user_notify_type'];
if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
if ($data['notify'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
{
// User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
// Disable notify by Jabber now for this user.
$data['notify'] = NOTIFY_EMAIL;
$data['notify'] = messenger_interface::NOTIFY_EMAIL;
}
$sql_ary = array(

View File

@@ -139,7 +139,7 @@ class ucp_resend
foreach ($messenger_collection_iterator as $messenger_method)
{
$messenger_method->set_use_queue(false);
if ($messenger_method->get_id() == $row['user_notify_type'] || $row['user_notify_type'] == NOTIFY_BOTH)
if ($messenger_method->get_id() == $row['user_notify_type'] || $row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
{
$messenger_method->template('admin_activate', $row['user_lang']);
$messenger_method->set_addresses($row);