diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 689b50389..a92525c54 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -843,6 +843,37 @@ class e107forum return $ret; } + /** + * Checks if post is the initial post which started the topic. + * Retrieves list of post_id's belonging to one post_thread. When lowest value is equal to input param, return true. + * Used to prevent deleting of the initial post (so topic shows empty does not get hidden accidently while posts remain in database) + * + * @param int id of the post + * @return boolean true if post is the initial post of the topic (false, if not) + * + */ + function threadDetermineInitialPost($postId) + { + $sql = e107::getDb(); + $postId = (int)$postId; + $threadId = $sql->retrieve('forum_post', 'post_thread', 'post_id = '.$postId); + + if($rows = $sql->retrieve('forum_post', 'post_id', 'post_thread = '.$threadId, TRUE)) + { + $postids = array(); + + foreach($rows as $row) + { + $postids[] = $row['post_id']; + } + + if($postId == min($postids)) + { + return true; + } + } + return false; + } function threadGetUserPostcount($threadId) { diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 79fb8b1f7..be7c5024d 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -506,8 +506,12 @@ class plugin_forum_view_shortcodes extends e_shortcode $text .= "