mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[feature/soft-delete] Extend functionality for updating a hole topic
Limit the posts to a certain visibility and deletion time This allows us to only restore posts, that were approved when the topic got soft deleted. So previous soft deleted and unapproved posts are still soft deleted/unapproved PHPBB3-9567
This commit is contained in:
parent
63d11c976b
commit
bfa6a50a4f
2 changed files with 30 additions and 19 deletions
|
@ -162,18 +162,28 @@ class phpbb_content_visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $visibility - int - element of {ITEM_UNAPPROVED, ITEM_APPROVED, ITEM_DELETED}
|
* Change visibility status of one post or a hole topic
|
||||||
* @param $post_id - int - the post ID to act on
|
*
|
||||||
* @param $topic_id - int - forum where $post_id is found
|
* @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED}
|
||||||
* @param $forum_id - int - forum ID where $topic_id resides
|
* @param $post_id mixed Post ID to act on, if it is empty,
|
||||||
* @param $is_starter - bool - is this the first post of the topic
|
* all posts of topic_id will be modified
|
||||||
* @param $is_latest - bool - is this the last post of the topic
|
* @param $topic_id int Topic where $post_id is found
|
||||||
|
* @param $forum_id int Forum where $topic_id is found
|
||||||
|
* @param $is_starter bool Is this the first post of the topic changed?
|
||||||
|
* @param $is_latest bool Is this the last post of the topic changed?
|
||||||
|
* @param $limit_visibility mixed Limit updating per topic_id to a certain visibility
|
||||||
|
* @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest)
|
static public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($post_id)
|
if ($post_id)
|
||||||
{
|
{
|
||||||
$where_sql = 'post_id = ' . (int) $post_id;
|
$where_sql = 'post_id = ' . (int) $post_id;
|
||||||
|
@ -181,6 +191,19 @@ class phpbb_content_visibility
|
||||||
else if ($topic_id)
|
else if ($topic_id)
|
||||||
{
|
{
|
||||||
$where_sql = 'topic_id = ' . (int) $topic_id;
|
$where_sql = 'topic_id = ' . (int) $topic_id;
|
||||||
|
|
||||||
|
// Limit the posts to a certain visibility and deletion time
|
||||||
|
// This allows us to only restore posts, that were approved
|
||||||
|
// when the topic got soft deleted. So previous soft deleted
|
||||||
|
// and unapproved posts are still soft deleted/unapproved
|
||||||
|
if ($limit_visibility !== false)
|
||||||
|
{
|
||||||
|
$where_sql .= ' AND post_visibility = ' . (int) $limit_visibility;
|
||||||
|
}
|
||||||
|
if ($limit_delete_time !== false)
|
||||||
|
{
|
||||||
|
$where_sql .= ' AND post_delete_time = ' . (int) $limit_delete_time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,18 +107,6 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
|
||||||
array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
|
||||||
ITEM_UNAPPROVED,
|
|
||||||
8, 3, 1,
|
|
||||||
2, time(), 'unapproved',
|
|
||||||
true, true,
|
|
||||||
array(
|
|
||||||
array('post_id' => 8, 'post_visibility' => 0, 'post_delete_reason' => 'unapproved'),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array('topic_visibility' => 0, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue