diff options
author | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-09-15 17:21:08 +0000 |
---|---|---|
committer | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-09-15 17:21:08 +0000 |
commit | eef332eea5d299784dc31891e84c11017548681d (patch) | |
tree | d62fe9feb2f2bbcc6b20672c3d406e506bf60d89 /phpBB/includes/functions.php | |
parent | 8d6c391d4810d7e56d917da79803983998fe442e (diff) | |
download | forums-eef332eea5d299784dc31891e84c11017548681d.tar forums-eef332eea5d299784dc31891e84c11017548681d.tar.gz forums-eef332eea5d299784dc31891e84c11017548681d.tar.bz2 forums-eef332eea5d299784dc31891e84c11017548681d.tar.xz forums-eef332eea5d299784dc31891e84c11017548681d.zip |
Cleanups
git-svn-id: file:///svn/phpbb/trunk@2889 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ffcb49dc1b..aa7feba656 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -81,6 +81,42 @@ function get_userdata($user) return ( $row = $db->sql_fetchrow($result) ) ? $row : false; } +function get_forum_branch($forum_id, $type='all', $order='descending', $include_forum=TRUE) +{ + global $db; + + switch ($type) + { + case 'parents': + $condition = 'f1.left_id BETWEEN f2.left_id AND f2.right_id'; + break; + + case 'children': + $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id'; + break; + + default: + $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id OR f1.left_id BETWEEN f2.left_id AND f2.right_id'; + } + $sql = 'SELECT f2.* + FROM ' . FORUMS_TABLE . ' f1 + LEFT JOIN ' . FORUMS_TABLE . " f2 ON $condition + WHERE f1.forum_id = $forum_id + ORDER BY f2.left_id " . (($order == 'descending') ? 'ASC' : 'DESC'); + + $rows = array(); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + if (!$include_forum && $row['forum_id'] == $forum_id) + { + continue; + } + $rows[] = $row; + } + return $rows; +} + // // Obtain list of moderators of each forum // First users, then groups ... broken into two queries |