aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-10-05 13:15:55 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-10-05 13:15:55 +0200
commit42bb97a95cf57074edf2a30f1b4f417cfce81d13 (patch)
tree378cb6bcd0c96795443cb798b9c215d1effe85aa /phpBB/includes
parentbfa6a50a4ff2caf1589a1039c1037d4153223d63 (diff)
downloadforums-42bb97a95cf57074edf2a30f1b4f417cfce81d13.tar
forums-42bb97a95cf57074edf2a30f1b4f417cfce81d13.tar.gz
forums-42bb97a95cf57074edf2a30f1b4f417cfce81d13.tar.bz2
forums-42bb97a95cf57074edf2a30f1b4f417cfce81d13.tar.xz
forums-42bb97a95cf57074edf2a30f1b4f417cfce81d13.zip
[feature/soft-delete] Make use of set_post_visibility() limits when applicable
PHPBB3-9567
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/content_visibility.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php
index be08a5f536..7bcabbdfd6 100644
--- a/phpBB/includes/content_visibility.php
+++ b/phpBB/includes/content_visibility.php
@@ -143,6 +143,24 @@ class phpbb_content_visibility
{
global $db;
+ if (in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED)))
+ {
+ return;
+ }
+
+ $sql = 'SELECT topic_visibility, topic_delete_time
+ FROM ' . TOPICS_TABLE . '
+ WHERE topic_id = ' . (int) $topic_id;
+ $result = $db->sql_query($sql);
+ $original_topic_data = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (!$original_topic_data)
+ {
+ // The topic does not exist...
+ return;
+ }
+
$data = array(
'topic_visibility' => (int) $visibility,
'topic_delete_user' => (int) $user_id,
@@ -155,10 +173,16 @@ class phpbb_content_visibility
WHERE topic_id = ' . (int) $topic_id;
$db->sql_query($sql);
- // If we're approving, disapproving, or deleteing a topic
- // we also update all posts in that topic that need to be changed.
- // However, we do not set the same reason for every post.
- self::set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true);
+ // If we're restoring a topic we only restore posts, that were soft deleted through the topic soft deletion.
+ if ($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.
+ 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
+ {
+ self::set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true);
+ }
}
/**