mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/14754] Clean up code as per review
PHPBB3-14754
This commit is contained in:
parent
9f4a240f91
commit
ec6335bdfd
2 changed files with 18 additions and 18 deletions
|
@ -83,7 +83,7 @@ class email extends \phpbb\notification\method\messenger_base
|
|||
*/
|
||||
public function get_notified_users($notification_type_id, array $options)
|
||||
{
|
||||
$notified_users = array();
|
||||
$notified_users = [];
|
||||
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . $this->notification_emails_table . '
|
||||
|
@ -111,7 +111,7 @@ class email extends \phpbb\notification\method\messenger_base
|
|||
/** @var \phpbb\notification\type\type_interface $notification */
|
||||
foreach ($this->queue as $notification)
|
||||
{
|
||||
$data = $this->clean_data($notification->get_insert_array());
|
||||
$data = self::clean_data($notification->get_insert_array());
|
||||
$insert_buffer->insert($data);
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ class email extends \phpbb\notification\method\messenger_base
|
|||
public function mark_notifications($notification_type_id, $item_id, $user_id, $time = false, $mark_read = true)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
|
||||
WHERE ' . (($notification_type_id !== false) ? (is_array($notification_type_id) ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : 'notification_type_id = ' . $notification_type_id) : '1=1') .
|
||||
(($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') .
|
||||
(($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
|
||||
WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : '1=1') .
|
||||
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
|
||||
($item_id !== false ? ' AND ' . $this->db->sql_in_set('item_id', $item_id) : '');
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
|
@ -138,9 +138,9 @@ class email extends \phpbb\notification\method\messenger_base
|
|||
public function mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time = false, $mark_read = true)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
|
||||
WHERE ' . (($notification_type_id !== false) ? (is_array($notification_type_id) ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : 'notification_type_id = ' . $notification_type_id) : '1=1') .
|
||||
(($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') .
|
||||
(($item_parent_id !== false) ? ' AND ' . (is_array($item_parent_id) ? $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : 'item_parent_id = ' . (int) $item_parent_id) : '');
|
||||
WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : '1=1') .
|
||||
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
|
||||
($item_parent_id !== false ? ' AND ' . $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : '');
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
|
@ -150,15 +150,15 @@ class email extends \phpbb\notification\method\messenger_base
|
|||
* @param array $data Notification data
|
||||
* @return array Cleaned notification data
|
||||
*/
|
||||
protected function clean_data(array $data)
|
||||
static public function clean_data(array $data)
|
||||
{
|
||||
$model = array(
|
||||
$row = [
|
||||
'notification_type_id' => null,
|
||||
'item_id' => null,
|
||||
'item_parent_id' => null,
|
||||
'user_id' => null,
|
||||
);
|
||||
];
|
||||
|
||||
return array_intersect_key($data, $model);
|
||||
return array_intersect_key($data, $row);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
|||
|
||||
protected function get_notification_methods()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'notification.method.email',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function setUp() : void
|
||||
|
@ -45,13 +45,13 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
|||
global $db, $config, $user, $auth, $cache, $phpbb_container;
|
||||
|
||||
$db = $this->db = $this->new_dbal();
|
||||
$config = $this->config = new \phpbb\config\config(array(
|
||||
$config = $this->config = new \phpbb\config\config([
|
||||
'allow_privmsg' => true,
|
||||
'allow_bookmarks' => true,
|
||||
'allow_topic_notify' => true,
|
||||
'allow_forum_notify' => true,
|
||||
'allow_board_notifications' => true,
|
||||
));
|
||||
]);
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
|
@ -184,7 +184,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
|||
6 => ['user_id' => '6'],
|
||||
7 => ['user_id' => '7'],
|
||||
8 => ['user_id' => '8'],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -193,7 +193,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
|||
'topic_id' => '3',
|
||||
],
|
||||
[
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue