Forum Restriction

ID).","; } foreach ($_POST['forum_restriction_for_forum'] as $forum_members) { if (!empty($forum_members)) { $members_allowed_in_forum = split(",",$forum_members); foreach ($members_allowed_in_forum as $forum_member) { $pos = strpos($users,$forum_member); if ($pos == FALSE) { $error_message = "$forum_member is not a valid user name."; } } } } bb_update_option('forum_restriction_db',$_POST['forum_restriction_for_forum']); bb_update_option('forum_restriction_notify',$_POST['forum_restriction_notify']); bb_update_option('forum_restriction_list_members',$_POST['forum_restriction_list_members']); bb_update_option('forum_restriction_highlight',$_POST['forum_restriction_highlight']); } if (isset($error_message)) { echo "ERROR: $error_message
"; } ?>

Current Settings

Enter the user names for each user to whom you would like to grant access to a restricted forum. Separate users in the list with commas and NO SPACES between names. You may need to use the "display name" for the users if you have the display-names plugin installed.

Forum
ID Forum Name Allowed Users "; foreach($forums as $forum) { echo "$forum->forum_id$forum->forum_nameforum_id]\" value=\"{$forum_restriction_allowed_in_forum[$forum->forum_id]}\" size=\"75\">"; } if (bb_get_option('forum_restriction_notify') == "on") { $forum_restriction_notify_or_not = "CHECKED"; } if (bb_get_option('forum_restriction_list_members') == "on") { $forum_restriction_list_members_or_not = "CHECKED"; } $forum_restriction_highlight = bb_get_option('forum_restriction_highlight'); echo ""; ?>

> Email members for new topics?

> List members in forum description?

Style for members in forum description ( eg. "background-color: yellow;" -- blank for none)?

get_results("SELECT ID FROM $bbdb->users WHERE user_status=0"); return $all_user_IDs; } // FILTER FORUMS ON FIRST PAGE function forum_restriction_alter_front_page_forum_list( $forums ) { global $bb_current_user,$forum,$forum_restriction_allowed_in_forum; $new_forums = array(); if($forums) { foreach($forums as $forum) { if ($bb_current_user){ $pos = strpos($forum_restriction_allowed_in_forum[$forum->forum_id],get_user_name($bb_current_user->ID)); } else { $pos = FALSE; } if ($pos === FALSE && !empty($forum_restriction_allowed_in_forum[$forum->forum_id])) { //$new_forums[] = $forum; } else { $new_forums[] = $forum; } } return $new_forums ; } return $forums; } add_filter('get_forums', 'forum_restriction_alter_front_page_forum_list'); // ADD LIST OF MEMBERS TO DESCRIPTIONS OF FORUMS SO YOU KNOW WHO CAN SEE WHAT YOU'RE WRITING function forum_restriction_alter_front_page_forum_description( $r ) { global $bb_current_user,$forum,$forum_restriction_allowed_in_forum; if (is_front()){ if (bb_get_option('forum_restriction_highlight') != '') { $forum_restriction_highlight_style = bb_get_option('forum_restriction_highlight'); } $forum_restriction_list_members = bb_get_option('forum_restriction_list_members'); if ($bb_current_user){ $pos = strpos($forum_restriction_allowed_in_forum[$forum->forum_id],get_user_name($bb_current_user->ID)); } else { $pos = FALSE; } if ($pos === FALSE && !empty($forum_restriction_allowed_in_forum[$forum->forum_id])) { return $r; } elseif (!empty($forum_restriction_allowed_in_forum[$forum->forum_id]) && $forum_restriction_list_members == 'on' ) { $r .= '

Users with access to this forum: '.$forum_restriction_allowed_in_forum[$forum->forum_id].'

'; return $r; } else { return $r; } } } add_filter('forum_description', 'forum_restriction_alter_front_page_forum_description'); // FILTER TOPICS ON FRONT PAGE function break_up_forum_array( $forums ) { global $forums; forum_restriction_alter_front_page_forum_list( $forums ); foreach ( $forums as $forum ) { $forum_ids .= $forum->forum_id.'\',\''; } $forum_ids = rtrim($forum_ids, ',\'\' '); return $forum_ids; } function forum_restriction_get_topics_where_plugin( $where ) { if ( is_front() ) { $list_of_allowed_forums = break_up_forum_array( $forums ) ; $where .= " AND forum_id IN ('$list_of_allowed_forums') "; return $where; } else { return $where; } } add_filter ( 'get_latest_topics_where', 'forum_restriction_get_topics_where_plugin' ); // HIJACK PAGE IF USER TRIES TO GO DIRECTLY TO FORUM.PHP function forum_restriction_hijack_forum_page() { global $bb_current_user,$forum,$forum_restriction_allowed_in_forum; if (is_forum()){ if ($bb_current_user){ $pos = strpos($forum_restriction_allowed_in_forum[$forum->forum_id],get_user_name($bb_current_user->ID)); } else { $pos = FALSE; } if ($pos === FALSE && !empty($forum_restriction_allowed_in_forum[$forum->forum_id])) { $wheretogo = bb_nonce_url( bb_get_option('uri')); header( 'Location:'.$wheretogo ); } else { } } } add_action('bb_forum.php_pre_db', 'forum_restriction_hijack_forum_page'); // HIJACK PAGE IF USER TRIES TO GO DIRECTLY TO TOPIC.PHP function forum_restriction_hijack_topic_page() { global $bb_current_user,$topic,$forum_restriction_allowed_in_forum; if (is_topic()){ if ($bb_current_user){ $pos = strpos($forum_restriction_allowed_in_forum[$topic->forum_id],get_user_name($bb_current_user->ID)); } else { $pos = FALSE; } if ($pos === FALSE && !empty($forum_restriction_allowed_in_forum[$topic->forum_id])) { $wheretogo = bb_nonce_url( bb_get_option('uri')); header( 'Location:'.$wheretogo ); } else { } } } add_action('bb_topic.php_pre_db', 'forum_restriction_hijack_topic_page'); // EMAIL FORUM MEMBERS WHEN NEW TOPIC IS STARTED IN FORUM function forum_restriction_send_email ($topic_id){ if (bb_get_option('forum_restriction_notify') == "on") { global $forum_restriction_allowed_in_forum, $bbdb, $bb_current_user; $topic = get_topic($topic_id); $forum = $topic->forum_id; $mailing_list = split(",",$forum_restriction_allowed_in_forum[$forum]); $message = __("There is a new topic called: %1\$s. The text is %4\$s. You can see it here %3\$s. You got this email because Bessler decided to turn on the option to notify all members of restricted forums when there are new TOPICS started in each FORUM. However, don't forget to click on \"Add this topic to your favorites\" so that you get an email when someone adds a POST to this TOPIC. This will keep you involved in that particular discussion. Kapish?"); foreach ($mailing_list as $member) { $userdata = $bbdb->get_var("SELECT ID FROM $bbdb->users WHERE `display_name` = '$member'"); $email_address .= $bbdb->get_var("SELECT user_email FROM $bbdb->users WHERE ID='$userdata'").","; } mail( $email_address, '['.bb_get_option('name') . '] ' . __('New Topic In Private Forum:').get_forum_name($forum), sprintf( $message, $topic->topic_title, get_user_name($bb_current_user->ID), get_topic_link($topic_id)), 'From: ' . bb_get_option('admin_email') ); } } add_action('bb_new_topic', 'forum_restriction_send_email'); /* */