mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +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)
|
public function get_notified_users($notification_type_id, array $options)
|
||||||
{
|
{
|
||||||
$notified_users = array();
|
$notified_users = [];
|
||||||
|
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . $this->notification_emails_table . '
|
FROM ' . $this->notification_emails_table . '
|
||||||
|
@ -111,7 +111,7 @@ class email extends \phpbb\notification\method\messenger_base
|
||||||
/** @var \phpbb\notification\type\type_interface $notification */
|
/** @var \phpbb\notification\type\type_interface $notification */
|
||||||
foreach ($this->queue as $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);
|
$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)
|
public function mark_notifications($notification_type_id, $item_id, $user_id, $time = false, $mark_read = true)
|
||||||
{
|
{
|
||||||
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
|
$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') .
|
WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('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) : '') .
|
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
|
||||||
(($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
|
($item_id !== false ? ' AND ' . $this->db->sql_in_set('item_id', $item_id) : '');
|
||||||
$this->db->sql_query($sql);
|
$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)
|
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 . '
|
$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') .
|
WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('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) : '') .
|
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $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) : '');
|
($item_parent_id !== false ? ' AND ' . $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : '');
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,15 +150,15 @@ class email extends \phpbb\notification\method\messenger_base
|
||||||
* @param array $data Notification data
|
* @param array $data Notification data
|
||||||
* @return array Cleaned 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,
|
'notification_type_id' => null,
|
||||||
'item_id' => null,
|
'item_id' => null,
|
||||||
'item_parent_id' => null,
|
'item_parent_id' => null,
|
||||||
'user_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()
|
protected function get_notification_methods()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'notification.method.email',
|
'notification.method.email',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp() : void
|
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;
|
global $db, $config, $user, $auth, $cache, $phpbb_container;
|
||||||
|
|
||||||
$db = $this->db = $this->new_dbal();
|
$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_privmsg' => true,
|
||||||
'allow_bookmarks' => true,
|
'allow_bookmarks' => true,
|
||||||
'allow_topic_notify' => true,
|
'allow_topic_notify' => true,
|
||||||
'allow_forum_notify' => true,
|
'allow_forum_notify' => true,
|
||||||
'allow_board_notifications' => true,
|
'allow_board_notifications' => true,
|
||||||
));
|
]);
|
||||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||||
$lang = new \phpbb\language\language($lang_loader);
|
$lang = new \phpbb\language\language($lang_loader);
|
||||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
$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'],
|
6 => ['user_id' => '6'],
|
||||||
7 => ['user_id' => '7'],
|
7 => ['user_id' => '7'],
|
||||||
8 => ['user_id' => '8'],
|
8 => ['user_id' => '8'],
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
@ -193,7 +193,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
||||||
'topic_id' => '3',
|
'topic_id' => '3',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue