Private Forums

forum_id,$private_forums) ? ' checked ' : '') ; ?> >

Privacy Options

/>

/>

Error Options

When a user tries to access a private forum without having access he will be redirected to a error page with the following text.

Usage:

path . 'bb-login.php'; if ($_SERVER['PHP_SELF'] != $login_page) { $private_forums = private_forums_custom_get_options('private_forums'); if ( !private_forums_check_user_access() && !empty($private_forums)) { add_action( 'bb_forum.php_pre_db', 'private_forums_check_private_forum' ); add_action( 'bb_topic.php_pre_db', 'private_forums_check_private_topic' ); add_action( 'bb_tag-single.php', 'private_forums_check_private_tag' ); if (private_forums_custom_get_options('hide_show_flag') == 'SHOW_PRIVATE') { add_filter( 'get_forum_name', 'private_forums_add_private_name_to_forums', 10,2); add_filter( 'get_topic_title', 'private_forums_add_private_name_to_topics', 10,2); } else { add_action( 'bb_head', 'private_forums_filter_topics_in_head' ); add_filter( 'get_forums','private_forums_filter_forums'); } } } } function private_forums_format_error($err_msg){ global $bb; if(empty($err_msg)) $err_msg = "This %s requires access to private forum. \r\nPlease login to access it."; $err_msg = trim($err_msg); $err_msg = strip_tags ( $err_msg ); $order = array("\r\n", "\n", "\r"); $replace = '
'; $err_msg = str_replace($order, $replace, $err_msg); $replace = 'login'; $err_msg = str_replace('login', $replace, $err_msg); return $err_msg; } function private_forums_filter_topics_in_head() { global $forums, $topics, $super_stickies, $stickies, $topic, $topic_id; $topics = private_forums_filter_topics($topics); $stickies = private_forums_filter_topics($stickies); $super_stickies = private_forums_filter_topics($super_stickies); } function private_forums_check_private_forum($forum_id) { $private_forums = private_forums_custom_get_options('private_forums'); if(array_key_exists($forum_id,$private_forums)) { bb_die(__(sprintf(private_forums_format_error(private_forums_custom_get_options('failure_msg')), 'forum'))); } } function private_forums_check_private_topic($topic_id) { global $topic; $private_forums = private_forums_custom_get_options('private_forums'); if(array_key_exists($topic->forum_id,$private_forums)) { bb_die(__(sprintf(private_forums_format_error(private_forums_custom_get_options('failure_msg')), 'topic'))); } } function private_forums_check_private_tag($tag_id) { global $topics; $topics = private_forums_filter_topics($topics); if (empty($topics)) { bb_die(__(sprintf(private_forums_format_error(private_forums_custom_get_options('failure_msg')), 'tag'))); } } function private_forums_filter_forums($forums) { $new_forums = array(); if ($forums) { $private_forums = private_forums_custom_get_options('private_forums'); foreach($forums as $forum) { if(!array_key_exists($forum->forum_id,$private_forums)) { $new_forums[] = $forum; } else { //$new_forums[] = $forum; } } return $new_forums ; } return $forums; } function private_forums_filter_topics($topics) { $new_topics = array(); if ($topics) { $private_forums = private_forums_custom_get_options('private_forums'); foreach($topics as $topic) { if(!array_key_exists($topic->forum_id,$private_forums)) { $new_topics[] = $topic; } } return $new_topics ; } return $topics; } function private_forums_add_private_name_to_forums($text, $id) { $private_forums = private_forums_custom_get_options('private_forums'); if(array_key_exists($id,$private_forums)) { return '[' . private_forums_custom_get_options('private_text') . '] ' . $text; } else { return $text; } } function private_forums_add_private_name_to_topics($text, $id) { $topic = get_topic( $id ); $id = $topic->forum_id; $private_forums = private_forums_custom_get_options('private_forums'); if(array_key_exists($id,$private_forums)) { return '[' . private_forums_custom_get_options('private_text') . '] ' . $text; } else { return $text; } } function private_forums_check_user_access() { if(bb_current_user()) { switch(private_forums_custom_get_options('user_role')) { case 'MODERATOR': return bb_current_user_can('moderate'); break; case 'ADMINSTRATOR': return bb_current_user_can('administrate'); break; default: return bb_current_user_can('participate'); break; } } else { return false; } } ?>