diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2003-11-13 12:39:11 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2003-11-13 12:39:11 +0000 |
commit | 5f91c611d7adee79729dcd04d0b47e4505265fa5 (patch) | |
tree | b5002a0d7d90a08a63f84295e33f676ddf13833e /phpBB/includes/functions_admin.php | |
parent | 6a701d1cf5315e104fd08c2637a5c569835b7c94 (diff) | |
download | forums-5f91c611d7adee79729dcd04d0b47e4505265fa5.tar forums-5f91c611d7adee79729dcd04d0b47e4505265fa5.tar.gz forums-5f91c611d7adee79729dcd04d0b47e4505265fa5.tar.bz2 forums-5f91c611d7adee79729dcd04d0b47e4505265fa5.tar.xz forums-5f91c611d7adee79729dcd04d0b47e4505265fa5.zip |
grmbl... another way to get your forum out of sync. ;)
git-svn-id: file:///svn/phpbb/trunk@4663 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r-- | phpBB/includes/functions_admin.php | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 0a3b994dbb..40377c1bfe 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -591,69 +591,75 @@ function delete_attachments($mode, $ids, $resync = TRUE) $topic_ids = array_unique($topic_ids); // Update post indicators - if ($mode == 'post' || $mode == 'topic') + if (sizeof($post_ids)) { - $db->sql_query('UPDATE ' . POSTS_TABLE . ' + if ($mode == 'post' || $mode == 'topic') + { + $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET post_attachment = 0 WHERE post_id IN (' . implode(', ', $post_ids) . ')'); - } + } - if ($mode == 'user' || $mode == 'attach') - { - $remaining = array(); + if ($mode == 'user' || $mode == 'attach') + { + $remaining = array(); - $sql = 'SELECT post_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE post_id IN (' . implode(', ', $post_ids) . ')'; - $result = $db->sql_query($sql); + $sql = 'SELECT post_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE post_id IN (' . implode(', ', $post_ids) . ')'; + $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $remaining[] = $row['post_id']; - } - $db->sql_fetchrow($result); + while ($row = $db->sql_fetchrow($result)) + { + $remaining[] = $row['post_id']; + } + $db->sql_fetchrow($result); - $unset_ids = array_diff($post_ids, $remaining); - if (sizeof($delete_ids)) - { - $db->sql_query('UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE post_id IN (' . implode(', ', $unset_ids) . ')'); + $unset_ids = array_diff($post_ids, $remaining); + if (sizeof($unset_ids)) + { + $db->sql_query('UPDATE ' . POSTS_TABLE . ' + SET post_attachment = 0 + WHERE post_id IN (' . implode(', ', $unset_ids) . ')'); + } } } - // Update topic indicator - if ($mode == 'topic') - { - $db->sql_query('UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 0 - WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'); - } - - if ($mode == 'post' || $mode == 'user' || $mode == 'attach') + if (sizeof($topic_ids)) { - $remaining = array(); - - $sql = 'SELECT topic_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) + // Update topic indicator + if ($mode == 'topic') { - $remaining[] = $row['topic_id']; + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' + SET topic_attachment = 0 + WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'); } - $db->sql_fetchrow($result); - $unset_ids = array_diff($topic_ids, $remaining); - if (sizeof($unset_ids)) + if ($mode == 'post' || $mode == 'user' || $mode == 'attach') { - $db->sql_query('UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 0 - WHERE topic_id IN (' . implode(', ', $unset_ids) . ')'); + $remaining = array(); + + $sql = 'SELECT topic_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE topic_id IN (' . implode(', ', $topic_ids) . ')'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $remaining[] = $row['topic_id']; + } + $db->sql_fetchrow($result); + + $unset_ids = array_diff($topic_ids, $remaining); + if (sizeof($unset_ids)) + { + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' + SET topic_attachment = 0 + WHERE topic_id IN (' . implode(', ', $unset_ids) . ')'); + } } } - + return $num_deleted; } |