diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-06-01 13:44:12 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-06-01 13:44:12 +0000 |
commit | ad4cfc051ca94b8f326072bd877ede82195188d6 (patch) | |
tree | 9b02226d8579168a08d2456816506d49d08a7ffd /phpBB/index.php | |
parent | f3d9aa24f069ccc9f50e05e51e1cd4a30304fd1d (diff) | |
download | forums-ad4cfc051ca94b8f326072bd877ede82195188d6.tar forums-ad4cfc051ca94b8f326072bd877ede82195188d6.tar.gz forums-ad4cfc051ca94b8f326072bd877ede82195188d6.tar.bz2 forums-ad4cfc051ca94b8f326072bd877ede82195188d6.tar.xz forums-ad4cfc051ca94b8f326072bd877ede82195188d6.zip |
Allow restricted view forums
git-svn-id: file:///svn/phpbb/trunk@402 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/index.php')
-rw-r--r-- | phpBB/index.php | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/phpBB/index.php b/phpBB/index.php index ee66b632e1..d1de5625b4 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -127,11 +127,12 @@ if($total_categories) default: // This works on: MySQL, MSSQL and ODBC (Access) $limit_forums = ($viewcat != -1) ? "WHERE f.cat_id = $viewcat " : ""; - $sql = "SELECT f.*, t.topic_id, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, p.post_time - FROM (( ".FORUMS_TABLE." f + $sql = "SELECT f.*, t.topic_id, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, p.post_time, af.auth_view, af.auth_read, af.auth_post, af.auth_reply, af.auth_edit, af.auth_delete, af.auth_votecreate, af.auth_vote + FROM ((( ".FORUMS_TABLE." f LEFT JOIN ".POSTS_TABLE." p ON f.forum_last_post_id = p.post_id ) LEFT JOIN ".TOPICS_TABLE." t ON p.post_id = t.topic_last_post_id ) - LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id + LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id ) + LEFT JOIN ".AUTH_FORUMS_TABLE." af ON af.forum_id = f.forum_id $limit_forums ORDER BY f.cat_id, f.forum_order"; break; @@ -140,6 +141,8 @@ if($total_categories) { error_die(SQL_QUERY, "Could not query forums information.", __LINE__, __FILE__); } + $total_forums = $db->sql_numrows($q_forums); + $forum_rows = $db->sql_fetchrowset($q_forums); // // Note that this doesn't resolve conflicts where a user @@ -162,9 +165,6 @@ if($total_categories) { error_die(SQL_QUERY, "Could not query forum moderator information.", __LINE__, __FILE__); } - - $total_forums = $db->sql_numrows($q_forums); - $forum_rows = $db->sql_fetchrowset($q_forums); $forum_mods_list = $db->sql_fetchrowset($q_forum_mods); for($i = 0; $i < count($forum_mods_list); $i++) @@ -173,23 +173,25 @@ if($total_categories) $forum_mods['forum_'.$forum_mods_list[$i]['forum_id'].'_id'][] = $forum_mods_list[$i]['user_id']; } + // + // Find which forums are visible for + // this user + // + $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_rows); + + // + // Okay, let's build the index + // + $gen_cat = array(); + for($i = 0; $i < $total_categories; $i++) { - $template->assign_block_vars("catrow", - array( - "CAT_ID" => $category_rows[$i]['cat_id'], - "CAT_DESC" => stripslashes($category_rows[$i]['cat_title']), - "U_VIEWCAT" => append_sid("index." . $phpEx . "?viewcat=" . $category_rows[$i]['cat_id']) - ) - ); - for($j = 0; $j < $total_forums; $j++) { - - if( ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $viewcat == -1 ) || - ( $category_rows[$i]['cat_id'] == $viewcat) ) + if( ( ($forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $viewcat == -1) || + ($category_rows[$i]['cat_id'] == $viewcat) ) && + $is_auth_ary[$forum_rows[$j]['forum_id']]['auth_view']) { - $folder_image = "<img src=\"".$images['folder']."\">"; $posts = $forum_rows[$j]['forum_posts']; $topics = $forum_rows[$j]['forum_topics']; @@ -231,6 +233,17 @@ if($total_categories) $moderators_links .= "<a href=\"".append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_mods['forum_'.$forum_rows[$j]['forum_id'].'_id'][$mods])."\">".$forum_mods['forum_'.$forum_rows[$j]['forum_id'].'_name'][$mods]."</a>"; } + if(!$gen_cat[$category_rows[$i]['cat_id']]) + { + $category_rows[$i]['cat_id']. " : " . $gen_cat[$category_rows[$i]['cat_id']]."<br>"; + $template->assign_block_vars("catrow", array( + "CAT_ID" => $category_rows[$i]['cat_id'], + "CAT_DESC" => stripslashes($category_rows[$i]['cat_title']), + "U_VIEWCAT" => append_sid("index." . $phpEx . "?viewcat=" . $category_rows[$i]['cat_id'])) + ); + $gen_cat[$category_rows[$i]['cat_id']] = 1; + } + $template->assign_block_vars("catrow.forumrow", array( "FOLDER" => $folder_image, @@ -243,13 +256,21 @@ if($total_categories) "MODERATORS" => $moderators_links, "U_VIEWFORUM" => append_sid("viewforum." . $phpEx . "?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id'] . "&" . $forum_rows[$j]['forum_posts'])) + ); + } + else if($viewcat != -1) + { + if(!$gen_cat[$category_rows[$i]['cat_id']]) + { + $template->assign_block_vars("catrow", array( + "CAT_ID" => $category_rows[$i]['cat_id'], + "CAT_DESC" => stripslashes($category_rows[$i]['cat_title']), + "U_VIEWCAT" => append_sid("index." . $phpEx . "?viewcat=" . $category_rows[$i]['cat_id'])) ); -// "LAST_POST_USER" => "$forum_rows[$j]['username']", -// "U_LAST_POST_USER_PROFILE" => "profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_rows[$j]['user_id']", -// "U_LAST_POST" => "viewtopic.".$phpEx."?t=".$forum_rows[$j]['topic_id'], + $gen_cat[$category_rows[$i]['cat_id']] = 1; + } } } - } // for ... categories }// if ... total_categories |