diff options
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ccff70652e..5154681472 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -80,6 +80,63 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl return $rows; } +// Create forum navigation links for given forum, create parent +// list if currently null, assign basic forum info to template +function generate_forum_nav(&$forum_data) +{ + global $db, $user, $template; + + // Get forum parents + $forum_parents = array(); + if ($forum_data['parent_id'] > 0) + { + if (empty($forum_data['forum_parents'])) + { + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE left_id < ' . $forum_data['left_id'] . ' + AND right_id > ' . $forum_data['right_id'] . ' + ORDER BY left_id ASC'; + + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $forum_parents[$row['forum_id']] = $row['forum_name']; + } + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = '" . sql_escape(serialize($forum_parents)) . "' + WHERE parent_id = " . $forum_data['parent_id']; + $db->sql_query($sql); + } + else + { + $forum_parents = unserialize($forum_data['forum_parents']); + } + } + + // Build navigation links + foreach ($forum_parents as $parent_forum_id => $parent_name) + { + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $parent_name, + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id + )); + } + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $forum_data['forum_name'], + 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id + )); + + $template->assign_vars(array( + 'FORUM_ID' => $forum_id, + 'FORUM_NAME' => $forum_data['forum_name'], + 'FORUM_DESC' => strip_tags($forum_data['forum_desc']) + )); + + return; +} + // Obtain list of moderators of each forum function get_moderators(&$forum_moderators, $forum_id = false) { |