Skip to:
Content

BuddyPress.org

Changeset 5713


Ignore:
Timestamp:
02/11/2012 04:57:20 AM (15 years ago)
Author:
johnjamesjacoby
Message:

PHP5'ize bp-groups-classes.php - Set methods as public, private, static, and kill off PHP4 constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r5697 r5713  
    1717        var $total_member_count;
    1818
    19         function bp_groups_group( $id = null ) {
    20                 $this->__construct($id);
    21         }
    22 
    23         function __construct( $id = null ) {
    24                 if ( $id ) {
     19        public function __construct( $id = null ) {
     20                if ( !empty( $id ) ) {
    2521                        $this->id = $id;
    2622                        $this->populate();
    … …  
    2824        }
    2925
    30         function populate() {
     26        private function populate() {
    3127                global $wpdb, $bp;
    3228
    … …  
    6763        }
    6864
    69         function save() {
     65        public function save() {
    7066                global $wpdb, $bp;
    7167
    … …  
    138134        }
    139135
    140         function delete() {
     136        public function delete() {
    141137                global $wpdb, $bp;
    142138
    … …  
    165161        }
    166162
    167         /* Static Functions */
    168 
    169         function group_exists( $slug, $table_name = false ) {
    170                 global $wpdb, $bp;
    171 
    172                 if ( !$table_name )
     163        /** Static Methods ********************************************************/
     164
     165        public static function group_exists( $slug, $table_name = false ) {
     166                global $wpdb, $bp;
     167
     168                if ( empty( $table_name ) )
    173169                        $table_name = $bp->groups->table_name;
    174170
    175                 if ( !$slug )
     171                if ( empty( $slug ) )
    176172                        return false;
    177173
    … …  
    179175        }
    180176
    181         function get_id_from_slug( $slug ) {
     177        public static function get_id_from_slug( $slug ) {
    182178                return BP_Groups_Group::group_exists( $slug );
    183179        }
    … …  
    188184        }
    189185
    190         function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
     186        public static function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
    191187                global $wpdb, $bp;
    192188
    … …  
    196192                $filter = like_escape( $wpdb->escape( $filter ) );
    197193
    198                 if ( $limit && $page )
     194                if ( !empty( $limit ) && !empty( $page ) )
    199195                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    200196
    … …  
    202198                $gids = BP_Groups_Member::get_group_ids( $user_id );
    203199
    204                 if ( !$gids['groups'] )
     200                if ( empty( $gids['groups'] ) )
    205201                        return false;
    206202
    … …  
    213209        }
    214210
    215         function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
     211        public static function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
    216212                global $wpdb, $bp;
    217213
    218214                $filter = like_escape( $wpdb->escape( $filter ) );
    219215
    220                 if ( $limit && $page )
     216                if ( !empty( $limit ) && !empty( $page ) )
    221217                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    222218
    223                 if ( $sort_by && $order ) {
    224                         $sort_by = $wpdb->escape( $sort_by );
    225                         $order = $wpdb->escape( $order );
     219                if ( !empty( $sort_by ) && !empty( $order ) ) {
     220                        $sort_by   = $wpdb->escape( $sort_by );
     221                        $order     = $wpdb->escape( $order );
    226222                        $order_sql = "ORDER BY $sort_by $order";
    227223                }
    … …  
    236232        }
    237233
    238         function check_slug( $slug ) {
     234        public static function check_slug( $slug ) {
    239235                global $wpdb, $bp;
    240236
    … …  
    242238        }
    243239
    244         function get_slug( $group_id ) {
     240        public static function get_slug( $group_id ) {
    245241                global $wpdb, $bp;
    246242
    … …  
    248244        }
    249245
    250         function has_members( $group_id ) {
     246        public static function has_members( $group_id ) {
    251247                global $wpdb, $bp;
    252248
    253249                $members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
    254250
    255                 if ( !$members )
     251                if ( empty( $members ) )
    256252                        return false;
    257253
    … …  
    259255        }
    260256
    261         function has_membership_requests( $group_id ) {
     257        public static function has_membership_requests( $group_id ) {
    262258                global $wpdb, $bp;
    263259
    … …  
    265261        }
    266262
    267         function get_membership_requests( $group_id, $limit = null, $page = null ) {
    268                 global $wpdb, $bp;
    269 
    270                 if ( $limit && $page ) {
     263        public static function get_membership_requests( $group_id, $limit = null, $page = null ) {
     264                global $wpdb, $bp;
     265
     266                if ( !empty( $limit ) && !empty( $page ) ) {
    271267                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    272268                }
    … …  
    278274        }
    279275
    280         function get( $type = 'newest', $per_page = null, $page = null, $user_id = 0, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) {
    281                 global $wpdb, $bp;
    282 
    283                 $sql = array();
     276        public static function get( $type = 'newest', $per_page = null, $page = null, $user_id = 0, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) {
     277                global $wpdb, $bp;
     278
     279                $sql       = array();
     280                $total_sql = array();
    284281
    285282                $sql['select'] = "SELECT g.*, gm1.meta_value AS total_member_count, gm2.meta_value AS last_activity";
    … …  
    341338                }
    342339
    343                 if ( $per_page && $page )
     340                if ( !empty( $per_page ) && !empty( $page ) )
    344341                        $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page), intval( $per_page ) );
    345342
    … …  
    379376                        $t_sql .= " WHERE " . join( ' AND ', (array)$total_sql['where'] );
    380377
    381                 /* Get total group results */
     378                // Get total group results
    382379                $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', join( ' ', (array)$t_sql ), $t_sql );
    383380                $total_groups     = $wpdb->get_var( $total_groups_sql );
    … …  
    388385                }
    389386               
    390                 /* Populate some extra information instead of querying each time in the loop */
     387                // Populate some extra information instead of querying each time in the loop
    391388                if ( !empty( $populate_extras ) ) {
    392389                        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    … …  
    402399        }
    403400
    404         function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
     401        public static function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
    405402                global $wpdb, $bp, $bbdb;
    406403
    407                 if ( !$bbdb )
     404                if ( empty( $bbdb ) )
    408405                        do_action( 'bbpress_init' );
    409406
    410                 if ( $limit && $page ) {
     407                if ( !empty( $limit ) && !empty( $page ) ) {
    411408                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    412409                }
    … …  
    425422                }
    426423
    427                 if ( $user_id ) {
     424                if ( !empty( $user_id ) ) {
    428425                        $user_id = $wpdb->escape( $user_id );
    429426                        $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" );
    … …  
    443440        }
    444441
    445         function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) {
     442        public static function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) {
    446443                global $wpdb, $bp, $bbdb;
    447444
    448                 if ( !$bbdb )
     445                if ( empty( $bbdb ) )
    449446                        do_action( 'bbpress_init' );
    450447
    451                 if ( $limit && $page ) {
     448                if ( !empty( $limit ) && !empty( $page ) ) {
    452449                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    453450                }
    … …  
    456453                        $hidden_sql = " AND g.status != 'hidden'";
    457454
    458                 if ( $search_terms ) {
     455                if ( !empty( $search_terms ) ) {
    459456                        $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    460457                        $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
    … …  
    466463                }
    467464
    468                 if ( $user_id ) {
     465                if ( !empty( $user_id ) ) {
    469466                        $user_id = $wpdb->escape( $user_id );
    470467                        $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" );
    … …  
    484481        }
    485482
    486         function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
     483        public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
    487484                global $wpdb, $bp;
    488485
    … …  
    508505                $letter = like_escape( $wpdb->escape( $letter ) );
    509506
    510                 if ( $limit && $page ) {
     507                if ( !empty( $limit ) && !empty( $page ) ) {
    511508                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    512509                        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} {$exclude_sql}" ) );
    … …  
    524521        }
    525522
    526         function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
    527                 global $wpdb, $bp;
    528 
    529                 if ( $limit && $page )
     523        public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
     524                global $wpdb, $bp;
     525
     526                if ( !empty( $limit ) && !empty( $page ) )
    530527                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    531528
    … …  
    533530                        $hidden_sql = "AND g.status != 'hidden'";
    534531
    535                 if ( $search_terms ) {
     532                if ( !empty( $search_terms ) ) {
    536533                        $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    537534                        $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
    … …  
    543540                }
    544541
    545                 if ( $user_id ) {
     542                if ( !empty( $user_id ) ) {
    546543                        $user_id = $wpdb->escape( $user_id );
    547544                        $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY rand() {$pag_sql}" );
    … …  
    561558        }
    562559
    563         function get_group_extras( &$paged_groups, &$group_ids, $type = false ) {
     560        public static function get_group_extras( &$paged_groups, &$group_ids, $type = false ) {
    564561                global $bp, $wpdb;
    565562
    … …  
    567564                        return $paged_groups;
    568565
    569                 /* Fetch the logged in users status within each group */
     566                // Fetch the logged in users status within each group
    570567                $user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", bp_loggedin_user_id() ) );
    571568                for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
    … …  
    573570
    574571                        foreach ( (array)$user_status as $group_id ) {
    575                                 if ( $group_id == $paged_groups[$i]->id )
     572                                if ( $group_id == $paged_groups[$i]->id ) {
    576573                                        $paged_groups[$i]->is_member = true;
     574                                }
    577575                        }
    578576                }
    … …  
    583581
    584582                        foreach ( (array)$user_banned as $group_id ) {
    585                                 if ( $group_id == $paged_groups[$i]->id )
     583                                if ( $group_id == $paged_groups[$i]->id ) {
    586584                                        $paged_groups[$i]->is_banned = true;
     585                                }
    587586                        }
    588587                }
    … …  
    591590        }
    592591
    593         function delete_all_invites( $group_id ) {
     592        public static function delete_all_invites( $group_id ) {
    594593                global $wpdb, $bp;
    595594
    … …  
    597596        }
    598597
    599         function get_total_group_count() {
     598        public static function get_total_group_count() {
    600599                global $wpdb, $bp;
    601600
    … …  
    607606        }
    608607
    609         function get_global_forum_topic_count( $type ) {
     608        public static function get_global_forum_topic_count( $type ) {
    610609                global $bbdb, $wpdb, $bp;
    611610
    … …  
    618617        }
    619618
    620         function get_total_member_count( $group_id ) {
     619        public static function get_total_member_count( $group_id ) {
    621620                global $wpdb, $bp;
    622621
    623622                return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
    624623        }
    625 
    626624
    627625        /**
    … …  
    634632         * @return int The topic count
    635633         */
    636         function get_global_topic_count( $status = 'public', $search_terms = false ) {
     634        public static function get_global_topic_count( $status = 'public', $search_terms = false ) {
    637635                global $bbdb, $wpdb, $bp;
    638636
    … …  
    686684        var $comments;
    687685        var $invite_sent;
    688 
    689686        var $user;
    690687
    691         function bp_groups_member( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
    692                 $this->__construct($user_id,$group_id,$id,$populate);
    693         }
    694 
    695         function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
    696                 if ( $user_id && $group_id && !$id ) {
    697                         $this->user_id = $user_id;
     688        public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
     689               
     690                // User and group are not empty, and ID is
     691                if ( !empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {
     692                        $this->user_id  = $user_id;
    698693                        $this->group_id = $group_id;
    699694
    700                         if ( $populate )
     695                        if ( !empty( $populate ) ) {
    701696                                $this->populate();
    702                 }
    703 
    704                 if ( $id ) {
     697                        }
     698                }
     699
     700                // ID is not empty
     701                if ( !empty( $id ) ) {
    705702                        $this->id = $id;
    706703
    707                         if ( $populate )
     704                        if ( !empty( $populate ) ) {
    708705                                $this->populate();
    709                 }
    710         }
    711 
    712         function populate() {
     706                        }
     707                }
     708        }
     709
     710        private function populate() {
    713711                global $wpdb, $bp;
    714712
    … …  
    716714                        $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
    717715
    718                 if ( $this->id )
     716                if ( !empty( $this->id ) )
    719717                        $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id );
    720718
    721719                $member = $wpdb->get_row($sql);
    722720
    723                 if ( $member ) {
     721                if ( !empty( $member ) ) {
    724722                        $this->id            = $member->id;
    725723                        $this->group_id      = $member->group_id;
    … …  
    739737        }
    740738
    741         function save() {
     739        public function save() {
    742740                global $wpdb, $bp;
    743741
    … …  
    756754                do_action_ref_array( 'groups_member_before_save', array( &$this ) );
    757755
    758                 if ( $this->id )
     756                if ( !empty( $this->id ) )
    759757                        $sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = %s, is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id );
    760758                else
    761759                        $sql = $wpdb->prepare( "INSERT INTO {$bp->groups->table_name_members} ( user_id, group_id, inviter_id, is_admin, is_mod, is_banned, user_title, date_modified, is_confirmed, comments, invite_sent ) VALUES ( %d, %d, %d, %d, %d, %d, %s, %s, %d, %s, %d )", $this->user_id, $this->group_id, $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent );
    762760
    763                 if ( !$wpdb->query($sql) )
     761                if ( !$wpdb->query( $sql ) )
    764762                        return false;
    765763
    … …  
    771769        }
    772770
    773         function promote( $status = 'mod' ) {
     771        public function promote( $status = 'mod' ) {
    774772                if ( 'mod' == $status ) {
    775                         $this->is_admin = 0;
    776                         $this->is_mod = 1;
     773                        $this->is_admin   = 0;
     774                        $this->is_mod     = 1;
    777775                        $this->user_title = __( 'Group Mod', 'buddypress' );
    778776                }
    779777
    780778                if ( 'admin' == $status ) {
    781                         $this->is_admin = 1;
    782                         $this->is_mod = 0;
     779                        $this->is_admin   = 1;
     780                        $this->is_mod     = 0;
    783781                        $this->user_title = __( 'Group Admin', 'buddypress' );
    784782                }
    … …  
    787785        }
    788786
    789         function demote() {
    790                 $this->is_mod = 0;
    791                 $this->is_admin = 0;
     787        public function demote() {
     788                $this->is_mod     = 0;
     789                $this->is_admin   = 0;
    792790                $this->user_title = false;
    793791
    … …  
    795793        }
    796794
    797         function ban() {
    798 
    799                 if ( $this->is_admin )
     795        public function ban() {
     796
     797                if ( !empty( $this->is_admin ) )
    800798                        return false;
    801799
    … …  
    812810        }
    813811
    814         function unban() {
    815 
    816                 if ( $this->is_admin )
     812        public function unban() {
     813
     814                if ( !empty( $this->is_admin ) )
    817815                        return false;
    818816
    … …  
    825823        }
    826824
    827         function accept_invite() {
     825        public function accept_invite() {
    828826
    829827                $this->inviter_id    = 0;
    … …  
    834832        }
    835833
    836         function accept_request() {
     834        public function accept_request() {
    837835
    838836                $this->is_confirmed = 1;
    … …  
    842840        }
    843841
    844         function remove() {
     842        public function remove() {
    845843                global $wpdb, $bp;
    846844
    … …  
    859857        }
    860858
    861         /* Static Functions */
    862 
    863         function delete( $user_id, $group_id ) {
     859        /** Static Methods ********************************************************/
     860
     861        public static function delete( $user_id, $group_id ) {
    864862                global $wpdb, $bp;
    865863
    … …  
    867865        }
    868866
    869         function get_group_ids( $user_id, $limit = false, $page = false ) {
     867        public static function get_group_ids( $user_id, $limit = false, $page = false ) {
    870868                global $wpdb, $bp;
    871869
    872870                $pag_sql = '';
    873                 if ( $limit && $page )
     871                if ( !empty( $limit ) && !empty( $page ) )
    874872                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    875873
    … …  
    888886        }
    889887
    890         function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
     888        public static function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
    891889                global $wpdb, $bp;
    892890
    893891                $pag_sql = $hidden_sql = $filter_sql = '';
    894892
    895                 if ( $limit && $page )
     893                if ( !empty( $limit ) && !empty( $page ) )
    896894                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    897895
    898                 if ( $filter ) {
     896                if ( !empty( $filter ) ) {
    899897                        $filter = like_escape( $wpdb->escape( $filter ) );
    900898                        $filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
    … …  
    910908        }
    911909
    912         function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
     910        public static function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
    913911                global $wpdb, $bp;
    914912
    915913                $pag_sql = $hidden_sql = $filter_sql = '';
    916914
    917                 if ( $limit && $page )
     915                if ( !empty( $limit ) && !empty( $page ) )
    918916                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    919917
    920                 if ( $filter ) {
     918                if ( !empty( $filter ) ) {
    921919                        $filter = like_escape( $wpdb->escape( $filter ) );
    922920                        $filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
    … …  
    932930        }
    933931
    934         function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
     932        public static function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
    935933                global $wpdb, $bp;
    936934
    937935                $pag_sql = $hidden_sql = $filter_sql = '';
    938936
    939                 if ( $limit && $page )
     937                if ( !empty( $limit ) && !empty( $page ) )
    940938                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    941939
    942                 if ( $filter ) {
     940                if ( !empty( $filter ) ) {
    943941                        $filter = like_escape( $wpdb->escape( $filter ) );
    944942                        $filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
    … …  
    954952        }
    955953
    956         function total_group_count( $user_id = 0 ) {
     954        public static function total_group_count( $user_id = 0 ) {
    957955                global $bp, $wpdb;
    958956
    … …  
    967965        }
    968966
    969         function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {
     967        public static function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {
    970968                global $wpdb, $bp;
    971969
    … …  
    980978        }
    981979
    982         function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
     980        public static function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
    983981                global $wpdb, $bp;
    984982
    … …  
    994992        }
    995993
    996         function delete_invite( $user_id, $group_id ) {
     994        public static function delete_invite( $user_id, $group_id ) {
    997995                global $wpdb, $bp;
    998996
    … …  
    10031001        }
    10041002
    1005         function delete_request( $user_id, $group_id ) {
     1003        public static function delete_request( $user_id, $group_id ) {
    10061004                global $wpdb, $bp;
    10071005
    … …  
    10121010        }
    10131011
    1014         function check_is_admin( $user_id, $group_id ) {
     1012        public static function check_is_admin( $user_id, $group_id ) {
    10151013                global $wpdb, $bp;
    10161014
    … …  
    10211019        }
    10221020
    1023         function check_is_mod( $user_id, $group_id ) {
     1021        public static function check_is_mod( $user_id, $group_id ) {
    10241022                global $wpdb, $bp;
    10251023
    … …  
    10301028        }
    10311029
    1032         function check_is_member( $user_id, $group_id ) {
     1030        public static function check_is_member( $user_id, $group_id ) {
    10331031                global $wpdb, $bp;
    10341032
    … …  
    10391037        }
    10401038
    1041         function check_is_banned( $user_id, $group_id ) {
     1039        public static function check_is_banned( $user_id, $group_id ) {
    10421040                global $wpdb, $bp;
    10431041
    … …  
    10571055         * @since 1.2.6
    10581056         */
    1059         function check_is_creator( $user_id, $group_id ) {
     1057        public static function check_is_creator( $user_id, $group_id ) {
    10601058                global $bp, $wpdb;
    10611059
    … …  
    10661064        }
    10671065
    1068         function check_for_membership_request( $user_id, $group_id ) {
     1066        public static function check_for_membership_request( $user_id, $group_id ) {
    10691067                global $wpdb, $bp;
    10701068
    … …  
    10751073        }
    10761074
    1077         function get_random_groups( $user_id, $total_groups = 5 ) {
     1075        public static function get_random_groups( $user_id, $total_groups = 5 ) {
    10781076                global $wpdb, $bp;
    10791077
    … …  
    10861084        }
    10871085
    1088         function get_group_member_ids( $group_id ) {
     1086        public static function get_group_member_ids( $group_id ) {
    10891087                global $bp, $wpdb;
    10901088
    … …  
    10921090        }
    10931091
    1094         function get_group_administrator_ids( $group_id ) {
     1092        public static function get_group_administrator_ids( $group_id ) {
    10951093                global $bp, $wpdb;
    10961094
    … …  
    10981096        }
    10991097
    1100         function get_group_moderator_ids( $group_id ) {
     1098        public static function get_group_moderator_ids( $group_id ) {
    11011099                global $bp, $wpdb;
    11021100
    … …  
    11041102        }
    11051103
    1106         function get_all_membership_request_user_ids( $group_id ) {
     1104        public static function get_all_membership_request_user_ids( $group_id ) {
    11071105                global $bp, $wpdb;
    11081106
    … …  
    11101108        }
    11111109
    1112         function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) {
     1110        public static function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) {
    11131111                global $bp, $wpdb;
    11141112
    11151113                $pag_sql = '';
    1116                 if ( $limit && $page )
     1114                if ( !empty( $limit ) && !empty( $page ) )
    11171115                        $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    11181116
    11191117                $exclude_admins_sql = '';
    1120                 if ( $exclude_admins_mods )
     1118                if ( !empty( $exclude_admins_mods ) )
    11211119                        $exclude_admins_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
    11221120
    11231121                $banned_sql = '';
    1124                 if ( $exclude_banned )
     1122                if ( !empty( $exclude_banned ) )
    11251123                        $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
    11261124
    11271125                $exclude_sql = '';
    1128                 if ( $exclude )
     1126                if ( !empty( $exclude ) )
    11291127                        $exclude_sql = $wpdb->prepare( " AND m.user_id NOT IN ({$exclude})" );
    11301128
    … …  
    11341132                        $members = $wpdb->get_results( apply_filters( 'bp_group_members_user_join_filter', $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) ) );
    11351133
    1136                 if ( !$members )
     1134                if ( empty( $members ) )
    11371135                        return false;
    11381136
    … …  
    11421140                        $total_member_count = $wpdb->get_var( apply_filters( 'bp_group_members_count_user_join_filter', $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql}", $group_id ) ) );
    11431141
    1144                 /* Fetch whether or not the user is a friend */
    1145                 foreach ( (array)$members as $user ) $user_ids[] = $user->user_id;
    1146                 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
     1142                // Fetch whether or not the user is a friend
     1143                foreach ( (array)$members as $user )
     1144                        $user_ids[] = $user->user_id;
     1145
     1146                $user_ids = $wpdb->escape( join( ',', (array) $user_ids ) );
    11471147
    11481148                if ( bp_is_active( 'friends' ) ) {
    … …  
    11501150                        for ( $i = 0, $count = count( $members ); $i < $count; ++$i ) {
    11511151                                foreach ( (array)$friend_status as $status ) {
    1152                                         if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id )
     1152                                        if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id ) {
    11531153                                                $members[$i]->is_friend = $status->is_confirmed;
     1154                                        }
    11541155                                }
    11551156                        }
    … …  
    11591160        }
    11601161
    1161         function delete_all( $group_id ) {
     1162        public static function delete_all( $group_id ) {
    11621163                global $wpdb, $bp;
    11631164
    … …  
    11741175         * @uses BP_Groups_Member
    11751176         */
    1176         function delete_all_for_user( $user_id ) {
     1177        public static function delete_all_for_user( $user_id ) {
    11771178                global $bp, $wpdb;
    11781179
    … …  
    12091210        var $slug = false;
    12101211       
    1211         /* The name/slug of the Group Admin tab for this extension */
     1212        // The name/slug of the Group Admin tab for this extension
    12121213        var $admin_name = '';
    12131214        var $admin_slug = '';
    12141215
    1215         /* The name/slug of the Group Creation tab for this extension */
     1216        // The name/slug of the Group Creation tab for this extension
    12161217        var $create_name = '';
    12171218        var $create_slug = '';
    12181219
    1219         /* Will this extension be visible to non-members of a group? Options: public/private */
     1220        // Will this extension be visible to non-members of a group? Options: public/private
    12201221        var $visibility = 'public';
    12211222
Note: See TracChangeset for help on using the changeset viewer.