mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
[ticket/11449] Add separate method for deleting notifications by multiple types
PHPBB3-11449
This commit is contained in:
parent
ce0f7cb1fe
commit
d05ce65a98
3 changed files with 34 additions and 20 deletions
|
@ -894,11 +894,11 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
|
||||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||||
|
|
||||||
$phpbb_notifications->delete_notifications(array(
|
$phpbb_notifications->delete_notifications_by_types([
|
||||||
'notification.type.topic',
|
'notification.type.topic',
|
||||||
'notification.type.approve_topic',
|
'notification.type.approve_topic',
|
||||||
'notification.type.topic_in_queue',
|
'notification.type.topic_in_queue',
|
||||||
), $topic_ids);
|
], $topic_ids);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||||
|
|
||||||
$phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids);
|
$phpbb_notifications->delete_notifications_by_types($delete_notifications_types, $post_ids);
|
||||||
|
|
||||||
return count($post_ids);
|
return count($post_ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,25 +474,17 @@ class manager
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a notification
|
* Delete notifications of specified type
|
||||||
*
|
*
|
||||||
* @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types)
|
* @param string $notification_type_name Type identifier
|
||||||
* @param int|array $item_id Identifier within the type (or array of ids)
|
* @param int|array $item_id Identifier within the type (or array of ids)
|
||||||
* @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)
|
* @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)
|
||||||
* @param mixed $user_id User id (Default: false; not checked)
|
* @param mixed $user_id User id (Default: false; not checked)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete_notifications($notification_type_name, $item_id, $parent_id = false, $user_id = false)
|
public function delete_notifications(string $notification_type_name, $item_id, $parent_id = false, $user_id = false): void
|
||||||
{
|
{
|
||||||
if (is_array($notification_type_name))
|
|
||||||
{
|
|
||||||
foreach ($notification_type_name as $type)
|
|
||||||
{
|
|
||||||
$this->delete_notifications($type, $item_id, $parent_id, $user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$notification_type_id = $this->get_notification_type_id($notification_type_name);
|
$notification_type_id = $this->get_notification_type_id($notification_type_name);
|
||||||
|
|
||||||
/** @var method\method_interface $method */
|
/** @var method\method_interface $method */
|
||||||
|
@ -502,6 +494,24 @@ class manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete notifications specified by multiple types
|
||||||
|
*
|
||||||
|
* @param array $notification_type_names Array of item types (only acceptable if the $item_id is identical for the specified types)
|
||||||
|
* @param int|array $item_id Identifier within the type (or array of ids)
|
||||||
|
* @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)
|
||||||
|
* @param mixed $user_id User id (Default: false; not checked)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function delete_notifications_by_types(array $notification_type_names, $item_id, $parent_id = false, $user_id = false): void
|
||||||
|
{
|
||||||
|
foreach ($notification_type_names as $type)
|
||||||
|
{
|
||||||
|
$this->delete_notifications($type, $item_id, $parent_id, $user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all of the subscription types
|
* Get all of the subscription types
|
||||||
*
|
*
|
||||||
|
|
|
@ -61,6 +61,10 @@ class phpbb_mock_notification_manager
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete_notifications_by_types()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function get_subscription_types()
|
public function get_subscription_types()
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
|
Loading…
Add table
Reference in a new issue