Ticket #5596: 5596.01.patch
| File 5596.01.patch, 3.0 KB (added by , 12 years ago) |
|---|
-
bp-groups/bp-groups-template.php
159 159 if ( 'invites' == $type ) { 160 160 $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude ); 161 161 } else if ( 'single-group' == $type ) { 162 $group = new stdClass; 163 $group->group_id = bp_get_current_group_id(); 164 $this->groups = array( $group ); 162 $this->single_group = true; 163 164 $group = new stdClass; 165 166 if ( bp_get_current_group_id() ) { 167 $group->group_id = bp_get_current_group_id(); 168 } else { 169 $group->group_id = BP_Groups_Group::get_id_from_slug( $slug ); 170 } 171 172 $this->groups = array( $group ); 165 173 } else { 166 174 $this->groups = groups_get_groups( array( 167 175 'type' => $type, … … 185 193 $this->group_count = (int) $this->groups['total']; 186 194 $this->groups = $this->groups['groups']; 187 195 } else if ( 'single-group' == $type ) { 188 $this->single_group = true; 189 $this->total_group_count = 1; 190 $this->group_count = 1; 196 if ( empty( $group->group_id ) ) { 197 $this->total_group_count = 0; 198 $this->group_count = 0; 199 } else { 200 $this->total_group_count = 1; 201 $this->group_count = 1; 202 } 191 203 } else { 192 204 if ( empty( $max ) || $max >= (int) $this->groups['total'] ) { 193 205 $this->total_group_count = (int) $this->groups['total']; … … 260 272 $this->in_the_loop = true; 261 273 $this->group = $this->next_group(); 262 274 263 if ( $this->single_group ) 264 $this->group = groups_get_current_group(); 275 if ( $this->single_group ) { 276 if ( groups_get_current_group() ) { 277 $this->group = groups_get_current_group(); 278 } else { 279 $this->group = groups_get_group( array( 'group_id' => $this->group->group_id ) ); 280 } 281 } 265 282 266 283 if ( 0 == $this->current_group ) // loop has just started 267 284 do_action('group_loop_start'); -
tests/testcases/groups/template.php
99 99 } 100 100 101 101 /** 102 * Test using the 'slug' parameter in bp_has_groups() 103 * 104 * Note: The 'slug' parameter currently also requires the 'type' to be set 105 * to 'single-group'. 106 * 107 * @group bp_has_groups 108 */ 109 public function test_bp_has_groups_single_group_with_slug() { 110 $g1 = $this->factory->group->create( array( 111 'name' => 'Test Group', 112 'slug' => 'test-group', 113 'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 100 ), 114 ) ); 115 116 global $groups_template; 117 bp_has_groups( array( 118 'type' => 'single-group', 119 'slug' => 'test-group', 120 ) ); 121 122 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'group_id' ) ); 123 $this->assertEquals( array( $g1 ), $ids ); 124 125 $this->assertEquals( 1, $groups_template->group_count ); 126 } 127 128 /** 102 129 * @group bp_group_has_members 103 130 */ 104 131 public function test_bp_group_has_members_vanilla() {