diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-10-05 13:30:59 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-10-05 13:30:59 +0200 |
commit | 01a78907bd05fc51f62ebd169065277365c5d1f4 (patch) | |
tree | 5bbe3403c0c4bbbe17b5842b308e2a8f4366142e /phpBB | |
parent | 92c5039af971722198ce634d719db6290d58c678 (diff) | |
download | forums-01a78907bd05fc51f62ebd169065277365c5d1f4.tar forums-01a78907bd05fc51f62ebd169065277365c5d1f4.tar.gz forums-01a78907bd05fc51f62ebd169065277365c5d1f4.tar.bz2 forums-01a78907bd05fc51f62ebd169065277365c5d1f4.tar.xz forums-01a78907bd05fc51f62ebd169065277365c5d1f4.zip |
[feature/soft-delete] Update set_topic_visibility() with some more logic
By default, when a soft deleted topic is restored. Only posts that were
approved at the time of soft deleting, are being restored. Same applies to
soft deleting. Only approved posts will be marked as soft deleted.
If you want to update all posts, use the force option.
PHPBB3-9567
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/content_visibility.php | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index 4f5da25919..238e131f1d 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -132,11 +132,24 @@ class phpbb_content_visibility } /** - * Description: Allows approving (which is akin to undeleting), unapproving (!) or soft deleting an entire topic. + * Set topic visibility + * + * Allows approving (which is akin to undeleting/restore) or soft deleting an entire topic. * Calls set_post_visibility as needed. - * @param $visibility - int - element of {ITEM_UNAPPROVED, ITEM_APPROVED, ITEM_DELETED} - * @param $topic_id - int - topic ID to act on - * @param $forum_id - int - forum ID where $topic_id resides + * + * Note: By default, when a soft deleted topic is restored. Only posts that + * were approved at the time of soft deleting, are being restored. + * Same applies to soft deleting. Only approved posts will be marked + * as soft deleted. + * If you want to update all posts, use the force option. + * + * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED} + * @param $topic_id mixed Topic ID to act on + * @param $forum_id int Forum where $topic_id is found + * @param $user_id int User performing the action + * @param $time int Timestamp when the action is performed + * @param $reason string Reason why the visibilty was changed. + * @param $force_update_all bool Force to update all posts within the topic * @return void */ static public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) @@ -164,6 +177,7 @@ class phpbb_content_visibility } } + // Note, we do not set a reason for the posts, just for the topic $data = array( 'topic_visibility' => (int) $visibility, 'topic_delete_user' => (int) $user_id, @@ -176,12 +190,16 @@ class phpbb_content_visibility WHERE topic_id = ' . (int) $topic_id; $db->sql_query($sql); - // If we're restoring a topic we only restore posts, that were soft deleted through the topic soft deletion. if (!$force_update_all && $original_topic_data['topic_delete_time'] && $original_topic_data['topic_visibility'] == ITEM_DELETED && $visibility == ITEM_APPROVED) { - // Note, we do not set the same reason for every post. + // If we're restoring a topic we only restore posts, that were soft deleted through the topic soft deletion. self::set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility'], $original_topic_data['topic_delete_time']); } + else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED) + { + // If we're soft deleting a topic we only approved posts are soft deleted. + self::set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']); + } else { self::set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true); |