Changeset 7145
- Timestamp:
- 06/04/2013 03:04:29 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r7144 r7145 988 988 // these defaults). 989 989 $this->query_vars = wp_parse_args( $this->query_vars, array( 990 'group_id' => 0, 991 'group_role' => array( 'member' ), 992 'exclude_banned' => true, 990 'group_id' => 0, 991 'group_role' => array( 'member' ), 993 992 ) ); 994 993 … … 1051 1050 // which there is no dedicated is_ column), figure out a list 1052 1051 // of columns *not* to match 1052 $roles_sql = ''; 1053 1053 if ( in_array( 'member', $roles ) ) { 1054 1054 $role_columns = array(); … … 1056 1056 $role_columns[] = 'is_' . $excluded_role . ' = 0'; 1057 1057 } 1058 $roles_sql = '(' . implode( ' AND ', $role_columns ) . ')'; 1058 1059 if ( ! empty( $role_columns ) ) { 1060 $roles_sql = '(' . implode( ' AND ', $role_columns ) . ')'; 1061 } 1059 1062 1060 1063 // When querying for a set of roles *not* containing 'member', … … 1065 1068 $role_columns[] = 'is_' . $role . ' = 1'; 1066 1069 } 1067 $roles_sql = '(' . implode( ' OR ', $role_columns ) . ')'; 1070 1071 if ( ! empty( $role_columns ) ) { 1072 $roles_sql = '(' . implode( ' OR ', $role_columns ) . ')'; 1073 } 1068 1074 } 1069 1075 1070 1076 if ( ! empty( $roles_sql ) ) { 1071 1077 $sql['where'][] = $roles_sql; 1072 }1073 1074 if ( ! empty( $this->query_vars['exclude_banned'] ) ) {1075 $sql['where'][] = "is_banned = 0";1076 1078 } 1077 1079 -
trunk/bp-groups/bp-groups-functions.php
r7141 r7145 405 405 } else { 406 406 407 // exclude_admins_mods is a legacy argument. Convert to group_role 407 // exclude_admins_mods and exclude_banned are legacy arguments. 408 // Convert to group_role 408 409 if ( empty( $group_role ) ) { 409 $group_role = $exclude_admins_mods ? array( 'member' ) : array( 'member', 'mod', 'admin' ); 410 $group_role = array( 'member' ); 411 412 if ( ! $exclude_admins_mods ) { 413 $group_role[] = 'mod'; 414 $group_role[] = 'admin'; 415 } 416 417 if ( ! $exclude_banned ) { 418 $group_role[] = 'banned'; 419 } 410 420 } 411 421 … … 416 426 'page' => $page, 417 427 'group_role' => $group_role, 418 'exclude_banned' => $exclude_banned,419 428 'exclude' => $exclude, 420 429 'type' => 'last_modified', -
trunk/tests/testcases/groups/class-bp-group-member-query.php
r7143 r7145 223 223 } 224 224 225 public function test_with_group_role_member_mod_admin_banned() { 226 $g = $this->factory->group->create(); 227 $u1 = $this->create_user(); 228 $u2 = $this->create_user(); 229 $u3 = $this->create_user(); 230 $u4 = $this->create_user(); 231 232 $this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) ); 233 $this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) ); 234 $this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) ); 235 $this->add_user_to_group( $u4, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) ); 236 237 $m1 = new BP_Groups_Member( $u1, $g ); 238 $m1->promote( 'admin' ); 239 $m2 = new BP_Groups_Member( $u2, $g ); 240 $m2->promote( 'mod' ); 241 $m3 = new BP_Groups_Member( $u3, $g ); 242 $m3->ban(); 243 244 $query_members = new BP_Group_Member_Query( array( 245 'group_id' => $g, 246 'group_role' => array( 'member', 'mod', 'admin', 'banned' ), 247 ) ); 248 249 $ids = wp_parse_id_list( array_keys( $query_members->results ) ); 250 $this->assertEquals( array( $u1, $u2, $u3, $u4, ), $ids ); 251 } 252 253 public function test_with_group_role_banned() { 254 $g = $this->factory->group->create(); 255 $u1 = $this->create_user(); 256 $u2 = $this->create_user(); 257 258 $this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) ); 259 $this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) ); 260 261 $m1 = new BP_Groups_Member( $u1, $g ); 262 $m1->ban(); 263 264 $query_members = new BP_Group_Member_Query( array( 265 'group_id' => $g, 266 'group_role' => array( 'banned' ), 267 ) ); 268 269 $ids = wp_parse_id_list( array_keys( $query_members->results ) ); 270 $this->assertEquals( array( $u1, ), $ids ); 271 } 272 225 273 public function test_group_has_no_members() { 226 274 $g = $this->factory->group->create(); -
trunk/tests/testcases/groups/template.php
r7141 r7145 2 2 /** 3 3 * @group groups 4 * @group template 4 5 */ 5 6 class BP_Tests_Groups_Template extends BP_UnitTestCase {
Note: See TracChangeset
for help on using the changeset viewer.