mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/17493] Remove remnants of user_notify_type
PHPBB-17493
This commit is contained in:
@@ -69,7 +69,7 @@ class remove_jabber extends migration
|
||||
]],
|
||||
['permission.remove', ['a_jabber']],
|
||||
['permission.remove', ['u_sendim']],
|
||||
['custom', [[$this, 'remove_from_user_notifcations']]],
|
||||
['custom', [[$this, 'move_jabber_to_email_notifications']]],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -101,10 +101,15 @@ class remove_jabber extends migration
|
||||
];
|
||||
}
|
||||
|
||||
public function remove_from_user_notifcations()
|
||||
public function move_jabber_to_email_notifications(int $start = 0)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications
|
||||
WHERE notification_method = ' . $this->db->sql_escape('notification.method.jabber');
|
||||
$this->db->sql_query($sql);
|
||||
$limit = 1000;
|
||||
|
||||
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . "
|
||||
WHERE method = 'notification.method.jabber'";
|
||||
$this->db->sql_query_limit($sql, $limit, $start);
|
||||
|
||||
return $this->db->sql_affectedrows() < $limit ? true : $start + $limit;
|
||||
}
|
||||
}
|
||||
|
64
phpBB/phpbb/db/migration/data/v400/remove_notify_type.php
Normal file
64
phpBB/phpbb/db/migration/data/v400/remove_notify_type.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\db\migration\data\v400;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class remove_notify_type extends migration
|
||||
{
|
||||
public static function depends_on(): array
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v400\remove_jabber',
|
||||
'\phpbb\db\migration\data\v400\dev',
|
||||
'\phpbb\db\migration\data\v30x\release_3_0_0',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_schema(): array
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_notify_type',
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema(): array
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_notify_type' => ['TINT:4', 0],
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['custom', [[$this, 'remove_jabber_user_notifications']]],
|
||||
];
|
||||
}
|
||||
|
||||
protected function remove_jabber_user_notifications(): void
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $this->tables['user_notifications'] . "
|
||||
WHERE method = 'notification.method.jabber'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
@@ -157,7 +157,6 @@ 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(messenger_interface::NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
$this->message->set_template('contact_admin');
|
||||
|
@@ -54,9 +54,6 @@ class message
|
||||
/** @var string */
|
||||
protected $sender_username = '';
|
||||
|
||||
/** @var int */
|
||||
protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL;
|
||||
|
||||
/** @var array */
|
||||
protected $recipients;
|
||||
|
||||
@@ -126,7 +123,6 @@ class message
|
||||
$user['username'],
|
||||
$user['user_email'],
|
||||
$user['user_lang'],
|
||||
$user['user_notify_type'],
|
||||
$user['username']
|
||||
);
|
||||
}
|
||||
@@ -137,18 +133,16 @@ class message
|
||||
* @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)
|
||||
* @return void
|
||||
*/
|
||||
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '')
|
||||
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_username = '')
|
||||
{
|
||||
$this->recipients[] = array(
|
||||
'name' => $recipient_name,
|
||||
'user_email' => $recipient_address,
|
||||
'lang' => $recipient_lang,
|
||||
'username' => $recipient_username,
|
||||
'notify_type' => $recipient_notify_type,
|
||||
'to_name' => $recipient_name,
|
||||
);
|
||||
}
|
||||
@@ -169,8 +163,6 @@ class message
|
||||
$user->data['user_id'],
|
||||
$user->data['username']
|
||||
);
|
||||
|
||||
$this->set_sender_notify_type($user->data['user_notify_type']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,17 +186,6 @@ class message
|
||||
$this->sender_username = $sender_username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Which notification type should be used? Jabber, Email, ...?
|
||||
*
|
||||
* @param int $sender_notify_type
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
*
|
||||
@@ -226,7 +207,6 @@ class message
|
||||
'user_email' => $this->sender_address,
|
||||
'name' => $this->sender_name,
|
||||
'username' => $this->sender_username,
|
||||
'notify_type' => $this->sender_notify_type,
|
||||
'to_name' => $this->recipients[0]['to_name'],
|
||||
);
|
||||
}
|
||||
@@ -257,40 +237,37 @@ 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'] == $messenger_method::NOTIFY_BOTH)
|
||||
$messenger_method->template($this->template, $recipient['lang']);
|
||||
$messenger_method->set_addresses($recipient);
|
||||
$messenger_method->reply_to($this->sender_address);
|
||||
|
||||
$messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name);
|
||||
$messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
|
||||
if ($this->sender_id)
|
||||
{
|
||||
$messenger_method->template($this->template, $recipient['lang']);
|
||||
$messenger_method->set_addresses($recipient);
|
||||
$messenger_method->reply_to($this->sender_address);
|
||||
|
||||
$messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name);
|
||||
$messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
|
||||
if ($this->sender_id)
|
||||
{
|
||||
$messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id);
|
||||
}
|
||||
|
||||
if ($this->sender_username)
|
||||
{
|
||||
$messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username);
|
||||
}
|
||||
|
||||
$messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT));
|
||||
|
||||
$messenger_method->assign_vars([
|
||||
'BOARD_CONTACT' => $contact,
|
||||
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
|
||||
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
|
||||
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT),
|
||||
]);
|
||||
|
||||
if (count($this->template_vars))
|
||||
{
|
||||
$messenger_method->assign_vars($this->template_vars);
|
||||
}
|
||||
|
||||
$messenger_method->send();
|
||||
$messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id);
|
||||
}
|
||||
|
||||
if ($this->sender_username)
|
||||
{
|
||||
$messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username);
|
||||
}
|
||||
|
||||
$messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT));
|
||||
|
||||
$messenger_method->assign_vars([
|
||||
'BOARD_CONTACT' => $contact,
|
||||
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
|
||||
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
|
||||
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT),
|
||||
]);
|
||||
|
||||
if (count($this->template_vars))
|
||||
{
|
||||
$messenger_method->assign_vars($this->template_vars);
|
||||
}
|
||||
|
||||
$messenger_method->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -134,7 +134,6 @@ class topic_form extends form
|
||||
$this->recipient_lang,
|
||||
messenger_interface::NOTIFY_EMAIL
|
||||
);
|
||||
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
|
||||
|
||||
parent::submit($messenger);
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class user_form extends form
|
||||
*/
|
||||
protected function get_user_row($user_id)
|
||||
{
|
||||
$sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_notify_type
|
||||
$sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_id = ' . (int) $user_id . '
|
||||
AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
|
||||
|
@@ -176,7 +176,7 @@ class reset_password
|
||||
}
|
||||
|
||||
$sql_array = [
|
||||
'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,'
|
||||
'SELECT' => 'user_id, username, user_permissions, user_email, user_type,'
|
||||
. ' user_lang, user_inactive_reason, reset_token, reset_token_expiration',
|
||||
'FROM' => [$this->users_table => 'u'],
|
||||
'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" .
|
||||
@@ -308,7 +308,7 @@ class reset_password
|
||||
add_form_key('ucp_reset_password');
|
||||
|
||||
$sql_array = [
|
||||
'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,'
|
||||
'SELECT' => 'user_id, username, user_permissions, user_email, user_type,'
|
||||
. ' user_lang, user_inactive_reason, reset_token, reset_token_expiration',
|
||||
'FROM' => [$this->users_table => 'u'],
|
||||
'WHERE' => 'user_id = ' . $user_id,
|
||||
|
Reference in New Issue
Block a user