User > Forum Moderators Version History: 1.0 : Initial Release Please note that the plugin will disable all priviledges for moderators and will need to be given specific priviledges to each forum from the admin menu. */ function forum_moderators_add_admin_page() { global $bb_submenu; $bb_submenu['users.php'][] = array(__('Forum Moderators'), 'use_keys', 'forum_moderators_admin_page'); } function forum_moderators_admin_page() { $bb_user_search = new BB_Forum_Moderators_Search($_REQUEST['usersearch'], $_REQUEST['userspage']); $bb_user_search->display(); } function forum_moderators_process_post() { if ($_POST['mod_user_id']) { foreach($_POST['mod_user_id'] as $mod) { $user_obj = new BB_User( $mod); $user_obj->set_role('moderator'); bb_update_usermeta( $mod, 'forum_moderator', $_POST['mod_forums'][$mod] ); //print_r($_POST['mod_forums'][$mod]); } } } add_action( 'bb_admin-header.php','forum_moderators_process_post'); add_action( 'bb_admin_menu_generator', 'forum_moderators_add_admin_page' ); add_filter('bb_user_has_cap','forum_moderators_process_capacities',10,2); function forum_moderators_process_capacities($allcaps, $caps){ global $bb_current_user, $forum,$topic_id; if (!$bb_current_user || in_array('keymaster',$bb_current_user->roles) || in_array('administrator',$bb_current_user->roles)) return $allcaps; if (empty($forum)) { $topic = get_topic($topic_id); $forum = get_forum($topic->forum_id); } $forum_moderator = ((!empty($bb_current_user->data->forum_moderator)) ? $bb_current_user->data->forum_moderator : array()); $filtering_caps = array( 'manage_topics' , 'edit_closed' , 'edit_deleted' , 'browse_deleted' , 'edit_others_tags' , 'edit_others_topics' , 'manage_posts' , 'ignore_edit_lock' , 'edit_others_posts' ); if (!empty($forum) && !array_key_exists($forum->forum_id,$forum_moderator ) && array_intersect($filtering_caps,$caps)) { foreach($filtering_caps as $filtering_cap) { unset($allcaps[$filtering_cap]); } } return $allcaps; } class BB_Forum_Moderators_Search { var $results; var $search_term; var $page; var $raw_page; var $users_per_page = 50; var $first_user; var $last_user; var $query_limit; var $query_from_where; var $total_users_for_query = 0; var $search_errors; function BB_Forum_Moderators_Search ($search_term = '', $page = '') { // constructor $this->search_term = $search_term; $this->raw_page = ( '' == $page ) ? false : (int) $page; $this->page = (int) ( '' == $page ) ? 1 : $page; $this->prepare_query(); $this->query(); $this->prepare_vars_for_template_usage(); $this->do_paging(); } function prepare_query() { global $bbdb; $this->first_user = ($this->page - 1) * $this->users_per_page; $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page; if ( $this->search_term ) { $searches = array(); $search_sql = 'AND ('; foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) $searches[] = $col . " LIKE '%$this->search_term%'"; $search_sql .= implode(' OR ', $searches); $search_sql .= ')'; } $this->query_from_where = "FROM $bbdb->users WHERE 1=1 $search_sql"; } function query() { global $bbdb; $this->results = $bbdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_limit); $keymasters = get_ids_by_role( 'keymaster'); $administrators = get_ids_by_role( 'administrator'); $this->results = array_diff($this->results, $keymasters , $administrators ); if ( $this->results ) $this->total_users_for_query = $bbdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit else $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); } function prepare_vars_for_template_usage() { $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone } function do_paging() { global $bb_current_submenu; if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results $pagenow = bb_get_admin_tab_link($bb_current_submenu); $this->paging_text = paginate_links( array( 'total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'prev_text' => '« Previous Page', 'next_text' => 'Next Page »', 'base' => $pagenow . ( false === strpos($pagenow, '?') ? '?%_%' : '&%_%' ), 'format' => 'userspage=%#%', 'add_args' => array( 'usersearch' => urlencode($this->search_term) ) ) ); } } function get_results() { return (array) $this->results; } function page_links() { echo $this->paging_text; } function results_are_paged() { if ( $this->paging_text ) return true; return false; } function is_search() { if ( $this->search_term ) return true; return false; } function display( $show_search = true, $show_email = false ) { global $bb_roles; $r = ''; // Make the user objects foreach ( $this->get_results() as $user_id ) { $tmp_user = new BB_User($user_id); $roles = $tmp_user->roles; $role = array_shift($roles); $roleclasses[$role][$tmp_user->data->user_login] = $tmp_user; } if ( isset($this->title) ) $title = $this->title; elseif ( $this->is_search() ) $title = sprintf(__('Users Matching "%s" by Role'), wp_specialchars( $this->search_term )); else $title = __('User List by Role'); $r .= "

$title

\n"; if ( $show_search ) { $r .= "\n\n"; } if ( is_wp_error( $this->search_errors ) ) { $r .= "
\n"; $r .= "\t\n
\n\n"; } $forums = get_forums(); if ( $this->get_results() ) { $colspan = 3; $r .= '

' . sprintf(__('%1$s – %2$s of %3$s shown below'), $this->first_user + 1, min($this->first_user + $this->users_per_page, $this->total_users_for_query), $this->total_users_for_query) . "

\n"; if ( $this->results_are_paged() ) $r .= "
\n" . $this->paging_text . "
\n\n"; $r .= "
\n"; foreach($roleclasses as $role => $roleclass) { ksort($roleclass); $r .= "\t\n"; if ( !empty($role) ) $r .= "\t\t\n"; else $r .= "\t\t\n"; $r .= "\t\n"; $r .= "\t\n"; $r .= "\t\t\n"; $r .= "\t\t\n"; $r .= "\t\t\n"; $r .= "\t\n\n"; $r .= "\n"; foreach ( (array) $roleclass as $user_object ) { $forum_moderator = ((!empty($user_object->data->forum_moderator)) ? $user_object->data->forum_moderator : array()); $r .= "\t\n"; $r .= "\t\t\n"; $r .= "\t\t\t\n"; $r .= "\t\t\t\n"; $r .= "\t\t\t\n"; $r .= "\t\t\n"; $r .= "\t\n"; } $r .= "\n"; } $r .= "

{$bb_roles->role_names[$role]}

" . __('Users with no role in these forums') . "

" . __('Add/Update') . "" . __('Username') . "" . __('Actions') . "
"; $r .= ""; $r .= "" . get_user_name( $user_object->ID ) . "\n"; foreach($forums as $forum) { $r .= "\t\t\t\t

forum_id, $forum_moderator)) ? 'checked' : '' ) . " /> $forum->forum_name

\n"; } $r .= "\t\t\t\t\n"; $r .= "\t\t\t
\n\n"; if ( $this->results_are_paged() ) $r .= "
\n" . $this->paging_text . "
\n\n"; } echo $r; } } function bb_forum_moderator_user_row( $user_id) { $user = bb_get_user( $user_id ); $r = "\t\n"; $r .= "\t\t$user_id\n"; $r .= "\t\t" . get_user_name( $user_id ) . "\n"; if ( $email ) $r .= "\t\t$user->user_email\n"; $r .= "\t\t$user->user_registered\n"; $r .= "\t\tEdit\n\t"; return $r; } ?> FOCUS Forums
  • Search
  • Register
  • Log in
  • FOCUS Forums
  • FOCUS East
  • FOCUS West
  • FOCUS North
  • FOCUS Northwest
  • FOCUS Central
  • FOCUS Uganda Website
  • FOCUS Forums is an exciting new way to stay connected. FOCUS Forums is a place where FOCUS Associates and staff can stay informed of news, events, prayer requests and more. Registered users can post topics for discussion, network with other associates and keep connected within this online community. Sign up now!

  • Latest Discussions   Add New »
  •  

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
     

    Last post by Hiicollictt22

    1 post(s)
    5 months ago
  • Forums
  •  
    FOCUS East
    FOCUS East Forum
    1 discussion(s)
     
    Prayer
    FOCUS East Prayer
    0 discussion(s)
     
    News
    FOCUS East News
    0 discussion(s)
     
    Events
    FOCUS East Events
    0 discussion(s)
     
    FOCUS North
    FOCUS North Forum
    1 discussion(s)
     
    Prayer
    FOCUS North Prayer
    0 discussion(s)
     
    News
    FOCUS North News
    0 discussion(s)
     
    Events
    FOCUS North Events
    1 discussion(s)
     
    FOCUS West
    FOCUS West Forum
    1 discussion(s)
     
    Prayer
    FOCUS West Prayer
    0 discussion(s)
     
    News
    FOCUS West News
    0 discussion(s)
     
    Events
    FOCUS West Events
    0 discussion(s)
     
    FOCUS Northwest
    FOCUS Northwest Forum
    1 discussion(s)
     
    Prayer
    FOCUS Northwest Prayer
    0 discussion(s)
     
    News
    FOCUS Northwest News
    0 discussion(s)
     
    Events
    FOCUS Northwest Events
    0 discussion(s)
     
    FOCUS Central
    FOCUS Central Forum
    1 discussion(s)
     
    Prayer
    FOCUS Central Prayer
    0 discussion(s)
     
    News
    FOCUS Central News
    0 discussion(s)
     
    Events
    FOCUS Central Events
    700 discussion(s)
    Stats   
  • Topics with no replies
  •   
  • Topics with no tags
  •   
  • Highest Rated
  •     
    Hot Tags
     

     
    [ Time : 0.091s | 8 Queries ]