Changeset 1250 for trunk/bp-groups/bp-groups-templatetags.php
- Timestamp:
- 03/25/2009 04:01:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-templatetags.php
r1238 r1250 1 1 <?php 2 2 3 class BP_Groups_Template { 4 var $current_group = -1; 5 var $group_count; 6 var $groups; 7 var $group; 8 9 var $in_the_loop; 10 11 var $pag_page; 12 var $pag_num; 13 var $pag_links; 14 var $total_group_count; 15 16 var $single_group = false; 17 18 var $sort_by; 19 var $order; 20 21 function bp_groups_template( $user_id = null, $group_slug = null, $groups_per_page = 10 ) { 22 global $bp, $current_user; 23 24 if ( !$user_id ) 25 $user_id = $current_user->id; 26 27 $this->pag_page = isset( $_REQUEST['fpage'] ) ? intval( $_REQUEST['fpage'] ) : 1; 28 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $groups_per_page; 29 30 if ( ( 'my-groups' == $bp->current_action && empty( $_REQUEST['group-filter-box'] ) ) || ( !$bp->current_action && !isset($_REQUEST['page']) && empty( $_REQUEST['group-filter-box'] ) ) ) { 31 32 $order = $bp->action_variables[0]; 33 34 if ( 'recently-joined' == $order ) { 35 $this->groups = groups_get_recently_joined_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 36 } else if ( 'most-popular' == $order ) { 37 $this->groups = groups_get_most_popular_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 38 } else if ( 'admin-of' == $order ) { 39 $this->groups = groups_get_user_is_admin_of( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 40 } else if ( 'mod-of' == $order ) { 41 $this->groups = groups_get_user_is_mod_of( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 42 } else if ( 'alphabetically' == $order ) { 43 $this->groups = groups_get_alphabetically_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 44 } else { 45 $this->groups = groups_get_recently_active_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 46 } 47 48 $this->total_group_count = (int)$this->groups['total']; 49 $this->groups = $this->groups['groups']; 50 $this->group_count = count($this->groups); 51 52 } else if ( ( 'my-groups' == $bp->current_action && $_REQUEST['group-filter-box'] != '' ) || ( !$bp->current_action && !isset($_REQUEST['page']) && $_REQUEST['group-filter-box'] != '' ) ) { 53 54 $this->groups = groups_filter_user_groups( $_REQUEST['group-filter-box'], $this->pag_num, $this->pag_page ); 55 $this->total_group_count = (int)$this->groups['total']; 56 $this->groups = $this->groups['groups']; 57 $this->group_count = count($this->groups); 58 59 } else if ( 'invites' == $bp->current_action ) { 60 61 $this->groups = groups_get_invites_for_user(); 62 $this->total_group_count = count($this->groups); 63 $this->group_count = count($this->groups); 64 65 } else if ( isset( $_REQUEST['page'] ) && 'groups_admin_settings' == $_REQUEST['page'] ) { 66 67 $this->sort_by = $_REQUEST['sortby']; 68 $this->order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'ASC'; 69 70 if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { 71 $this->groups = groups_search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page, $this->sort_by, $this->order ); 72 $this->total_group_count = (int)$this->groups['total']; 73 $this->groups = $this->groups['groups']; 74 $this->group_count = count($this->groups); 75 } else { 76 $this->groups = groups_get_all( $this->pag_num, $this->pag_page, false, $this->sort_by, $this->order ); 77 $this->total_group_count = count( groups_get_all() ); // TODO: not ideal 78 $this->group_count = count($this->groups); 79 } 80 81 } else if ( $group_slug ) { 82 83 $this->single_group = true; 84 85 $group = new stdClass; 86 $group->group_id = BP_Groups_Group::get_id_from_slug($group_slug); 87 88 $this->groups = array( $group ); 89 $this->total_group_count = 1; 90 $this->group_count = 1; 91 92 } else { 93 94 $this->groups = groups_get_user_groups( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 95 $this->total_group_count = (int)$this->groups['total']; 96 $this->groups = $this->groups['groups']; 97 $this->group_count = count($this->groups); 98 99 } 100 101 $this->pag_links = paginate_links( array( 102 'base' => add_query_arg( array( 'fpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order ) ), 103 'format' => '', 104 'total' => ceil($this->total_group_count / $this->pag_num), 105 'current' => $this->pag_page, 106 'prev_text' => '«', 107 'next_text' => '»', 108 'mid_size' => 1 109 )); 110 111 } 112 113 function has_groups() { 114 if ( $this->group_count ) 115 return true; 116 117 return false; 118 } 119 120 function next_group() { 121 $this->current_group++; 122 $this->group = $this->groups[$this->current_group]; 123 124 return $this->group; 125 } 126 127 function rewind_groups() { 128 $this->current_group = -1; 129 if ( $this->group_count > 0 ) { 130 $this->group = $this->groups[0]; 131 } 132 } 133 134 function user_groups() { 135 if ( $this->current_group + 1 < $this->group_count ) { 136 return true; 137 } elseif ( $this->current_group + 1 == $this->group_count ) { 138 do_action('loop_end'); 139 // Do some cleaning up after the loop 140 $this->rewind_groups(); 141 } 142 143 $this->in_the_loop = false; 144 return false; 145 } 146 147 function the_group() { 148 global $group; 149 150 $this->in_the_loop = true; 151 $this->group = $this->next_group(); 152 153 // If this is a single group then instantiate group meta when creating the object. 154 if ( $this->single_group ) { 155 if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) { 156 $group = new BP_Groups_Group( $this->group->group_id, true ); 157 wp_cache_set( 'groups_group_' . $this->group->group_id, $group, 'bp' ); 158 } 159 } else { 160 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 161 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 162 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 163 } 164 } 165 166 $this->group = $group; 167 168 if ( 0 == $this->current_group ) // loop has just started 169 do_action('loop_start'); 170 } 171 } 172 173 function bp_has_groups( $groups_per_page = 10 ) { 174 global $groups_template, $bp; 175 global $group_obj; 176 177 if ( !$bp->is_single_item ) { 178 $groups_template = new BP_Groups_Template( $bp->displayed_user->id, false, $groups_per_page ); 179 } else { 180 $groups_template = new BP_Groups_Template( $bp->displayed_user->id, $group_obj->slug, $groups_per_page ); 181 } 182 183 return $groups_template->has_groups(); 184 } 185 186 function bp_groups() { 187 global $groups_template; 188 return $groups_template->user_groups(); 189 } 190 191 function bp_the_group() { 192 global $groups_template; 193 return $groups_template->the_group(); 194 } 195 196 function bp_group_is_visible( $group = false ) { 197 global $bp, $groups_template; 198 199 if ( !$group ) 200 $group =& $groups_template->group; 201 202 if ( 'public' == $group->status ) { 203 return true; 204 } else { 205 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) { 206 return true; 207 } 208 } 209 210 return false; 211 } 212 213 function bp_group_has_news( $group = false ) { 214 global $groups_template; 215 216 if ( !$group ) 217 $group =& $groups_template->group; 218 219 if ( empty( $group->news ) ) 220 return false; 221 222 return true; 223 } 224 225 function bp_group_id( $echo = true, $group = false ) { 226 global $groups_template; 227 228 if ( !$group ) 229 $group =& $groups_template->group; 230 231 if ( $echo ) 232 echo apply_filters( 'bp_group_id', $group->id ); 233 else 234 return apply_filters( 'bp_group_id', $group->id ); 235 } 236 237 function bp_group_name( $echo = true, $group = false ) { 238 global $groups_template; 239 240 if ( !$group ) 241 $group =& $groups_template->group; 242 243 if ( $echo ) 244 echo apply_filters( 'bp_group_name', $group->name ); 245 else 246 return apply_filters( 'bp_group_name', $group->name ); 247 } 248 249 function bp_group_type( $group = false ) { 250 global $groups_template; 251 252 if ( !$group ) 253 $group =& $groups_template->group; 254 255 if ( 'public' == $group->status ) { 256 $type = __( "Public Group", "buddypress" ); 257 } else if ( 'hidden' == $group->status ) { 258 $type = __( "Hidden Group", "buddypress" ); 259 } else if ( 'private' == $group->status ) { 260 $type = __( "Private Group", "buddypress" ); 261 } else { 262 $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' ); 263 } 264 265 echo apply_filters( 'bp_group_type', $type ); 266 } 267 268 function bp_group_avatar( $group = false ) { 269 global $groups_template; 270 271 if ( !$group ) 272 $group =& $groups_template->group; 273 274 ?><img src="<?php echo $group->avatar_full ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 275 } 276 277 function bp_group_avatar_thumb( $group = false ) { 278 global $groups_template; 279 280 if ( !$group ) 281 $group =& $groups_template->group; 282 283 ?><img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 284 } 285 286 function bp_group_avatar_mini( $group = false) { 287 global $groups_template; 288 289 if ( !$group ) 290 $group =& $groups_template->group; 291 292 ?><img src="<?php echo $group->avatar_thumb ?>" width="30" height="30" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 293 } 294 295 function bp_group_last_active( $echo = true, $group = false ) { 296 global $groups_template; 297 298 if ( !$group ) 299 $group =& $groups_template->group; 300 301 $last_active = groups_get_groupmeta( $group->id, 'last_activity' ); 302 303 if ( empty( $last_active ) ) 304 _e( 'not yet active', 'buddypress' ); 305 else 306 echo apply_filters( 'bp_group_last_active', bp_core_time_since( $last_active ) ); 307 } 308 309 function bp_group_permalink( $group = false, $echo = true ) { 310 global $groups_template, $bp, $current_blog; 311 312 if ( !$group ) 313 $group =& $groups_template->group; 314 315 if ( $echo ) 316 echo apply_filters( 'bp_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug ); 317 else 318 return apply_filters( 'bp_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug ); 319 } 320 321 function bp_group_admin_permalink( $echo = true, $group = false ) { 322 global $groups_template, $bp, $current_blog; 323 324 if ( !$group ) 325 $group =& $groups_template->group; 326 327 if ( $echo ) 328 echo apply_filters( 'bp_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 329 else 330 return apply_filters( 'bp_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 331 } 332 333 function bp_group_slug( $group = false ) { 334 global $groups_template; 335 336 if ( !$group ) 337 $group =& $groups_template->group; 338 339 echo apply_filters( 'bp_group_slug', $group->slug ); 340 } 341 342 function bp_group_description( $group = false ) { 343 global $groups_template; 344 345 if ( !$group ) 346 $group =& $groups_template->group; 347 348 echo apply_filters( 'bp_group_description', stripslashes($group->description) ); 349 } 350 351 function bp_group_description_editable( $group = false ) { 352 global $groups_template; 353 354 if ( !$group ) 355 $group =& $groups_template->group; 356 357 echo apply_filters( 'bp_group_description_editable', $group->description ); 358 } 359 360 function bp_group_description_excerpt( $group = false ) { 361 global $groups_template; 362 363 if ( !$group ) 364 $group =& $groups_template->group; 365 366 echo apply_filters( 'bp_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 367 } 368 369 function bp_group_news( $group = false ) { 370 global $groups_template; 371 372 if ( !$group ) 373 $group =& $groups_template->group; 374 375 echo apply_filters( 'bp_group_news', stripslashes($groups_template->group->news) ); 376 } 377 378 function bp_group_news_editable( $group = false ) { 379 global $groups_template; 380 381 if ( !$group ) 382 $group =& $groups_template->group; 383 384 echo apply_filters( 'bp_group_news_editable', $group->news ); 385 } 386 387 function bp_group_public_status( $group = false ) { 388 global $groups_template; 389 390 if ( !$group ) 391 $group =& $groups_template->group; 392 393 if ( $group->is_public ) { 394 _e('Public', 'buddypress'); 395 } else { 396 _e('Private', 'buddypress'); 397 } 398 } 399 function bp_group_is_public( $group = false ) { 400 global $groups_template; 401 402 if ( !$group ) 403 $group =& $groups_template->group; 404 405 return apply_filters( 'bp_group_is_public', $group->is_public ); 406 } 407 408 409 function bp_group_date_created( $group = false ) { 410 global $groups_template; 411 412 if ( !$group ) 413 $group =& $groups_template->group; 414 415 echo apply_filters( 'bp_group_date_created', date( get_option( 'date_format' ), $group->date_created ) ); 416 } 417 418 function bp_group_list_admins( $full_list = true, $group = false ) { 419 global $groups_template; 420 421 if ( !$group ) 422 $group =& $groups_template->group; 423 424 if ( !$admins = &$group->admins ) 425 $admins = $group->get_administrators(); 426 427 if ( $admins ) { 428 if ( $full_list ) { ?> 429 <ul id="group-admins"> 430 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 431 <li> 432 <a href="<?php echo $admins[$i]->user->user_url ?>" title="<?php echo $admins[$i]->user->fullname ?>"><?php echo $admins[$i]->user->avatar_thumb ?></a> 433 <h5><?php echo $admins[$i]->user->user_link ?></h5> 434 <span class="activity"><?php echo $admins[$i]->user_title ?></span> 435 <hr /> 436 </li> 437 <?php } ?> 438 </ul> 439 <?php } else { ?> 440 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 441 <?php echo $admins[$i]->user->user_link ?> 442 <?php } ?> 443 <?php } ?> 444 <?php } else { ?> 445 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 446 <?php } ?> 447 3 function bp_groups_header_tabs() { 4 global $bp, $create_group_step, $completed_to_step; 5 ?> 6 <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li> 7 <li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li> 8 <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li> 9 <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li> 10 <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li> 11 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> 12 448 13 <?php 449 } 450 451 function bp_group_list_mods( $full_list = true, $group = false ) { 452 global $groups_template; 453 454 if ( !$group ) 455 $group =& $groups_template->group; 456 457 $group_mods = groups_get_group_mods( $group->id ); 458 459 if ( $group_mods ) { 460 if ( $full_list ) { ?> 461 <ul id="group-mods" class="mods-list"> 462 <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?> 463 <li> 464 <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_fetch_user_fullname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_get_avatar( $group_mods[$i]->user_id, 1, 50, 50 ) ?></a> 465 <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5> 466 <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span> 467 <div class="clear"></div> 468 </li> 469 <?php } ?> 470 </ul> 471 <?php } else { ?> 472 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 473 <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?> 474 <?php } ?> 475 <?php } ?> 476 <?php } else { ?> 477 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 478 <?php } ?> 479 480 <?php 481 } 482 483 function bp_group_all_members_permalink( $echo = true, $group = false ) { 484 global $groups_template, $bp; 485 486 if ( !$group ) 487 $group =& $groups_template->group; 488 489 if ( $echo ) 490 echo apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( $group, true ) . '/' . MEMBERS_SLUG ); 491 else 492 return apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( $group, false ) . '/' . MEMBERS_SLUG ); 493 } 494 495 function bp_group_random_members( $group = false ) { 496 global $groups_template; 497 498 if ( !$group ) 499 $group =& $groups_template->group; 500 501 $members = &$group->random_members; 502 ?> 503 <ul class="horiz-gallery"> 504 <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?> 505 <li> 506 <a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a> 507 <h5><?php echo $members[$i]->user->user_link ?></h5> 508 </li> 509 <?php } ?> 510 </ul> 511 <div class="clear"></div> 512 <?php 513 } 514 515 function bp_group_active_forum_topics( $total_topics = 3, $group = false ) { 516 global $groups_template, $forum_template; 517 518 if ( !$group ) 519 $group =& $groups_template->group; 520 521 $forum_id = groups_get_groupmeta( $group->id, 'forum_id' ); 522 523 if ( $forum_id && $forum_id != '' ) { 524 if ( function_exists( 'bp_forums_setup' ) ) { 525 $latest_topics = bp_forums_get_topics( $forum_id, $total_topics, 1 ); 526 527 if ( $latest_topics ) { ?> 528 <ul class="item-list" id="recent-forum-topics"><?php 529 530 $counter = 0; 531 532 foreach( $latest_topics as $topic ) { 533 $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : ''; 534 $forum_template->topic = (object)$topic; ?> 535 536 <li<?php echo $alt ?>> 537 <div class="avatar"> 538 <?php bp_the_topic_poster_avatar() ?> 539 </div> 540 541 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 542 <span class="small">- <?php bp_the_topic_total_post_count() ?> </span> 543 <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p> 544 545 <div class="latest-post"> 546 <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>: 547 <?php bp_the_topic_latest_post_excerpt() ?> 548 </div> 549 </li> 550 <?php $counter++ ?> 551 552 <?php } ?> 553 </ul> 554 <?php 555 } else { 556 ?> 557 <div id="message" class="info"> 558 <p><?php _e( 'There are no active forum topics for this group', 'buddypress' ) ?></p> 559 </div> 560 <?php 561 } 562 } 563 } 564 } 565 566 function bp_group_search_form() { 567 global $groups_template, $bp; 568 569 $action = $bp->loggedin_user->domain . $bp->groups->slug . '/my-groups/search/'; 570 $label = __('Filter Groups', 'buddypress'); 571 $name = 'group-filter-box'; 572 ?> 573 <form action="<?php echo $action ?>" id="group-search-form" method="post"> 574 <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" /></label> 575 <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> 576 577 <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?> 578 </form> 579 <?php 580 } 581 582 function bp_group_show_no_groups_message() { 583 global $bp; 584 585 if ( !groups_total_groups_for_user( $bp->displayed_user->id ) ) 586 return true; 587 588 return false; 589 } 590 591 function bp_group_pagination() { 592 global $groups_template; 593 echo apply_filters( 'bp_group_pagination', $groups_template->pag_links ); 594 } 595 596 function bp_total_group_count() { 597 global $groups_template; 598 599 echo apply_filters( 'bp_total_group_count', $groups_template->total_group_count ); 600 } 601 602 function bp_group_total_members( $echo = true, $group = false ) { 603 global $groups_template; 604 605 if ( !$group ) 606 $group =& $groups_template->group; 607 608 if ( $echo ) 609 echo apply_filters( 'groups_template', $group->total_member_count ); 610 else 611 return apply_filters( 'groups_template', $group->total_member_count ); 612 } 613 614 function bp_group_is_photos_enabled( $group = false ) { 615 global $groups_template; 616 617 if ( !$group ) 618 $group =& $groups_template->group; 619 620 if ( $group->enable_photos ) 621 return true; 622 623 return false; 624 } 625 626 function bp_group_show_wire_setting( $group = false ) { 627 global $groups_template; 628 629 if ( !$group ) 630 $group =& $groups_template->group; 631 632 if ( $group->enable_wire ) 633 echo ' checked="checked"'; 634 } 635 636 function bp_group_is_wire_enabled( $group = false ) { 637 global $groups_template; 638 639 if ( !$group ) 640 $group =& $groups_template->group; 641 642 if ( $group->enable_wire ) 643 return true; 644 645 return false; 646 } 647 648 function bp_group_forum_permalink( $group = false ) { 649 global $groups_template; 650 651 if ( !$group ) 652 $group =& $groups_template->group; 653 654 echo bp_group_permalink( $group, false ) . '/forum'; 655 } 656 657 function bp_group_is_forum_enabled( $group = false ) { 658 global $groups_template; 659 660 if ( !$group ) 661 $group =& $groups_template->group; 662 663 if ( function_exists( 'bp_forums_is_installed_correctly' ) ) { 664 if ( bp_forums_is_installed_correctly() ) { 665 if ( $group->enable_forum ) 666 return true; 667 668 return false; 669 } else { 670 return false; 671 } 672 } 673 674 return false; 675 } 676 677 function bp_group_show_forum_setting( $group = false ) { 678 global $groups_template; 679 680 if ( !$group ) 681 $group =& $groups_template->group; 682 683 if ( $group->enable_forum ) 684 echo ' checked="checked"'; 685 } 686 687 function bp_group_show_photos_setting( $group = false ) { 688 global $groups_template; 689 690 if ( !$group ) 691 $group =& $groups_template->group; 692 693 if ( $group->enable_photos ) 694 echo ' checked="checked"'; 695 } 696 697 function bp_group_show_photos_upload_setting( $permission, $group = false ) { 698 global $groups_template; 699 700 if ( !$group ) 701 $group =& $groups_template->group; 702 703 if ( 'admin' == $permission && $group->photos_admin_only ) 704 echo ' checked="checked"'; 705 706 if ( 'member' == $permission && !$group->photos_admin_only ) 707 echo ' checked="checked"'; 708 } 709 710 function bp_group_show_status_setting( $setting, $group = false ) { 711 global $groups_template; 712 713 if ( !$group ) 714 $group =& $groups_template->group; 715 716 if ( $setting == $group->status ) 717 echo ' checked="checked"'; 718 } 719 720 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 721 global $groups_template; 722 723 if ( !$group ) 724 $group =& $groups_template->group; 725 726 $admins = groups_get_group_admins( $group->id ); 727 ?> 728 <?php if ( $admins ) { ?> 729 <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 730 <?php foreach ( $admins as $admin ) { ?> 731 <?php if ( $admin_list ) { ?> 732 <li> 733 <?php echo bp_core_get_avatar( $admin->user_id, 1, 30, 30 ) ?> 734 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 735 </li> 736 <?php } else { ?> 737 <li> 738 <?php echo bp_core_get_avatar( $admin->user_id, 1 ) ?> 739 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 740 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 741 742 <?php if ( function_exists( 'friends_install' ) ) : ?> 743 <div class="action"> 744 <?php bp_add_friend_button( $admin->user_id ) ?> 745 </div> 746 <?php endif; ?> 747 </li> 748 <?php } ?> 749 <?php } ?> 750 </ul> 751 <?php } else { ?> 752 <div id="message" class="info"> 753 <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p> 754 </div> 755 <?php } 756 } 757 758 function bp_group_mod_memberlist( $admin_list = false, $group = false ) { 759 global $groups_template, $group_mods; 760 761 if ( !$group ) 762 $group =& $groups_template->group; 763 764 $group_mods = groups_get_group_mods( $group->id ); 765 ?> 766 <?php if ( $group_mods ) { ?> 767 <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 768 <?php foreach ( $group_mods as $mod ) { ?> 769 <?php if ( $admin_list ) { ?> 770 <li> 771 <?php echo bp_core_get_avatar( $mod->user_id, 1, 30, 30 ) ?> 772 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?> <span class="small"> — <a href="<?php bp_group_member_ban_link() ?>"><?php _e( 'Kick & Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5> 773 </li> 774 <?php } else { ?> 775 <li> 776 <?php echo bp_core_get_avatar( $mod->user_id, 1 ) ?> 777 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 778 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 779 780 <?php if ( function_exists( 'friends_install' ) ) : ?> 781 <div class="action"> 782 <?php bp_add_friend_button( $mod->user_id ) ?> 783 </div> 784 <?php endif; ?> 785 </li> 786 <?php } ?> 787 <?php } ?> 788 </ul> 789 <?php } else { ?> 790 <div id="message" class="info"> 791 <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p> 792 </div> 793 <?php } 794 } 795 796 function bp_group_has_moderators( $group = false ) { 797 global $group_mods, $groups_template; 798 799 if ( !$group ) 800 $group =& $groups_template->group; 801 802 return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ) ); 803 } 804 805 function bp_group_member_promote_link( $group = false ) { 806 global $members_template, $groups_template, $bp; 807 808 if ( !$group ) 809 $group =& $groups_template->group; 810 811 echo apply_filters( 'bp_group_member_promote_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/promote/' . $members_template->member->user_id, 'groups_promote_member' ) ); 812 } 813 814 function bp_group_member_demote_link( $user_id = false, $group = false ) { 815 global $members_template, $groups_template, $bp; 816 817 if ( !$group ) 818 $group =& $groups_template->group; 819 820 if ( !$user_id ) 821 $user_id = $members_template->member->user_id; 822 823 echo apply_filters( 'bp_group_member_demote_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) ); 824 } 825 826 function bp_group_member_ban_link( $group = false ) { 827 global $members_template, $groups_template, $bp; 828 829 if ( !$group ) 830 $group =& $groups_template->group; 831 832 echo apply_filters( 'bp_group_member_ban_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/ban/' . $members_template->member->user_id, 'groups_ban_member' ) ); 833 } 834 835 function bp_group_member_unban_link( $group = false ) { 836 global $members_template, $groups_template, $bp; 837 838 if ( !$group ) 839 $group =& $groups_template->group; 840 841 echo apply_filters( 'bp_group_member_unban_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/unban/' . $members_template->member->user_id, 'groups_unban_member' ) ); 842 } 843 844 function bp_group_admin_tabs( $group = false ) { 845 global $bp, $groups_template; 846 847 if ( !$group ) 848 $group =& $groups_template->group; 849 850 $current_tab = $bp->action_variables[0]; 851 ?> 852 <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?> 853 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 854 <?php } ?> 855 856 <?php if ( $bp->is_item_admin ) { ?> 857 <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> 858 <?php } ?> 859 860 <?php if ( $bp->is_item_admin ) { ?> 861 <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li> 862 <?php } ?> 863 864 <?php if ( $bp->is_item_admin ) { ?> 865 <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> 866 <?php } ?> 867 868 <?php if ( $bp->is_item_admin && $groups_template->group->status == 'private' ) : ?> 869 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 870 <?php endif; ?> 871 872 <?php if ( $bp->is_item_admin ) { ?> 873 <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 874 <?php } ?> 875 876 <?php 877 do_action( 'groups_admin_tabs' ); 878 } 879 880 function bp_group_form_action( $page, $group = false ) { 881 global $bp, $groups_template; 882 883 if ( !$group ) 884 $group =& $groups_template->group; 885 886 echo apply_filters( 'bp_group_form_action', bp_group_permalink( $group, false ) . '/' . $page ); 887 } 888 889 function bp_group_admin_form_action( $page, $group = false ) { 890 global $bp, $groups_template; 891 892 if ( !$group ) 893 $group =& $groups_template->group; 894 895 echo apply_filters( 'bp_group_admin_form_action', bp_group_permalink( $group, false ) . '/admin/' . $page ); 896 } 897 898 function bp_group_has_requested_membership( $group = false ) { 899 global $bp, $groups_template; 900 901 if ( !$group ) 902 $group =& $groups_template->group; 903 904 if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) ) 905 return true; 906 907 return false; 908 } 909 910 function bp_group_is_member( $group = false ) { 911 global $bp, $groups_template; 912 913 if ( !$group ) 914 $group =& $groups_template->group; 915 916 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 917 return true; 918 919 return false; 920 } 921 922 function bp_group_accept_invite_link( $group = false ) { 923 global $groups_template, $bp; 924 925 if ( !$group ) 926 $group =& $groups_template->group; 927 928 echo apply_filters( 'bp_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 929 } 930 931 function bp_group_reject_invite_link( $group = false ) { 932 global $groups_template, $bp; 933 934 if ( !$group ) 935 $group =& $groups_template->group; 936 937 echo apply_filters( 'bp_group_reject_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/reject/' . $group->id, 'groups_reject_invite' ) ); 938 } 939 940 function bp_has_friends_to_invite( $group = false ) { 941 global $groups_template, $bp; 942 943 if ( !function_exists('friends_install') ) 944 return false; 945 946 if ( !$group ) 947 $group =& $groups_template->group; 948 949 if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) ) 950 return false; 951 952 return true; 953 } 954 955 function bp_group_leave_confirm_link( $group = false ) { 956 global $groups_template, $bp; 957 958 if ( !$group ) 959 $group =& $groups_template->group; 960 961 echo apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_group_permalink( $group, true ) . '/leave-group/yes', 'groups_leave_group' ) ); 962 } 963 964 function bp_group_leave_reject_link( $group = false ) { 965 global $groups_template, $bp; 966 967 if ( !$group ) 968 $group =& $groups_template->group; 969 970 echo apply_filters( 'bp_group_leave_reject_link', bp_group_permalink( $group, true ) ); 971 } 972 973 function bp_group_send_invite_form( $group = false ) { 974 global $bp, $groups_template, $invites; 975 976 if ( !$group ) 977 $group =& $groups_template->group; 978 ?> 979 <div class="left-menu"> 980 <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4> 981 <?php bp_group_list_invite_friends() ?> 982 <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?> 983 <input type="hidden" name="group_id" id="group_id" value="<?php echo $group->id ?>" /> 984 </div> 985 986 <div class="main-column"> 987 988 <div id="message" class="info"> 989 <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> 990 </div> 991 992 <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id ) ?> 993 994 <ul id="friend-list" class="item-list"> 995 <?php for ( $i = 0; $i < count($invites); $i++ ) { 996 if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) { 997 $user = new BP_Core_User( $invites[$i] ); 998 wp_cache_set( 'bp_user_' . $invites[$i], $user, 'bp' ); 999 } 1000 ?> 1001 <li id="uid-<?php echo $user->id ?>"> 1002 <?php echo $user->avatar_thumb ?> 1003 <h4><?php echo $user->user_link ?></h4> 1004 <span class="activity"><?php echo $user->last_active ?></span> 1005 <div class="action"> 1006 <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 1007 </div> 1008 </li> 1009 <?php } // end for ?> 1010 </ul> 1011 1012 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?> 1013 </div> 1014 <?php 1015 } 1016 1017 function bp_group_send_invite_form_action( $group = false ) { 1018 global $groups_template, $bp; 1019 1020 if ( !$group ) 1021 $group =& $groups_template->group; 1022 1023 echo apply_filters( 'bp_group_send_invite_form_action', bp_group_permalink( $group, true ) . '/send-invites/send' ); 1024 } 1025 1026 function bp_group_join_button( $group = false ) { 1027 global $bp, $groups_template; 1028 1029 if ( !$group ) 1030 $group =& $groups_template->group; 1031 1032 // If they're not logged in or are banned from the group, no join button. 1033 if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) ) 1034 return false; 1035 1036 echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1037 1038 switch ( $group->status ) { 1039 case 'public': 1040 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) 1041 echo '<a class="leave-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1042 else 1043 echo '<a class="join-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1044 break; 1045 1046 case 'private': 1047 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) { 1048 echo '<a class="leave-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1049 } else { 1050 if ( !bp_group_has_requested_membership( $group ) ) 1051 echo '<a class="request-membership" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1052 else 1053 echo '<a class="membership-requested" href="' . bp_group_permalink( $group, false ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1054 } 1055 break; 1056 } 1057 1058 echo '</div>'; 1059 } 1060 1061 function bp_group_status_message( $group = false ) { 1062 global $groups_template; 1063 1064 if ( !$group ) 1065 $group =& $groups_template->group; 1066 1067 if ( 'private' == $group->status ) { 1068 if ( !bp_group_has_requested_membership() ) 1069 if ( is_user_logged_in() ) 1070 _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); 1071 else 1072 _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 1073 else 1074 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1075 } else { 1076 _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); 1077 } 14 do_action( 'groups_header_tabs' ); 1078 15 } 1079 16 … … 1306 243 } 1307 244 1308 function bp_groups_header_tabs() {1309 global $bp, $create_group_step, $completed_to_step;1310 ?>1311 <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>1312 <li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>1313 <li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>1314 <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>1315 <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>1316 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>1317 1318 <?php1319 do_action( 'groups_header_tabs' );1320 }1321 1322 245 function bp_groups_filter_title() { 1323 246 global $bp; … … 1396 319 <?php bp_group_join_button( $group ) ?> 1397 320 <div class="meta"> 1398 <?php $member_count = groups_get_groupmeta( $group->id, 'total_ member_count' ) ?>321 <?php $member_count = groups_get_groupmeta( $group->id, 'total_group_count' ) ?> 1399 322 <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> / 1400 323 <?php if ( 1 == $member_count ) : ?> … … 1469 392 } 1470 393 1471 /**** 394 395 /***************************************************************************** 396 * User Groups Template Class/Tags 397 **/ 398 399 class BP_Groups_User_Groups_Template { 400 var $current_group = -1; 401 var $group_count; 402 var $groups; 403 var $group; 404 405 var $in_the_loop; 406 407 var $pag_page; 408 var $pag_num; 409 var $pag_links; 410 var $total_group_count; 411 412 var $single_group = false; 413 414 var $sort_by; 415 var $order; 416 417 function bp_groups_user_groups_template( $user_id = null, $group_slug = null, $groups_per_page = 10 ) { 418 global $bp, $current_user; 419 420 if ( !$user_id ) 421 $user_id = $current_user->id; 422 423 $this->pag_page = isset( $_REQUEST['fpage'] ) ? intval( $_REQUEST['fpage'] ) : 1; 424 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $groups_per_page; 425 426 if ( ( 'my-groups' == $bp->current_action && empty( $_REQUEST['group-filter-box'] ) ) || ( !$bp->current_action && !isset($_REQUEST['page']) && empty( $_REQUEST['group-filter-box'] ) ) ) { 427 428 $order = $bp->action_variables[0]; 429 430 if ( 'recently-joined' == $order ) { 431 $this->groups = groups_get_recently_joined_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 432 } else if ( 'most-popular' == $order ) { 433 $this->groups = groups_get_most_popular_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 434 } else if ( 'admin-of' == $order ) { 435 $this->groups = groups_get_user_is_admin_of( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 436 } else if ( 'mod-of' == $order ) { 437 $this->groups = groups_get_user_is_mod_of( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 438 } else if ( 'alphabetically' == $order ) { 439 $this->groups = groups_get_alphabetically_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 440 } else { 441 $this->groups = groups_get_recently_active_for_user( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 442 } 443 444 $this->total_group_count = (int)$this->groups['total']; 445 $this->groups = $this->groups['groups']; 446 $this->group_count = count($this->groups); 447 448 } else if ( ( 'my-groups' == $bp->current_action && $_REQUEST['group-filter-box'] != '' ) || ( !$bp->current_action && !isset($_REQUEST['page']) && $_REQUEST['group-filter-box'] != '' ) ) { 449 450 $this->groups = groups_filter_user_groups( $_REQUEST['group-filter-box'], $this->pag_num, $this->pag_page ); 451 $this->total_group_count = (int)$this->groups['total']; 452 $this->groups = $this->groups['groups']; 453 $this->group_count = count($this->groups); 454 455 } else if ( 'invites' == $bp->current_action ) { 456 457 $this->groups = groups_get_invites_for_user(); 458 $this->total_group_count = count($this->groups); 459 $this->group_count = count($this->groups); 460 461 } else if ( isset( $_REQUEST['page'] ) && 'groups_admin_settings' == $_REQUEST['page'] ) { 462 463 $this->sort_by = $_REQUEST['sortby']; 464 $this->order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'ASC'; 465 466 if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { 467 $this->groups = groups_search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page, $this->sort_by, $this->order ); 468 $this->total_group_count = (int)$this->groups['total']; 469 $this->groups = $this->groups['groups']; 470 $this->group_count = count($this->groups); 471 } else { 472 $this->groups = groups_get_all( $this->pag_num, $this->pag_page, false, $this->sort_by, $this->order ); 473 $this->total_group_count = count( groups_get_all() ); // TODO: not ideal 474 $this->group_count = count($this->groups); 475 } 476 477 } else if ( $group_slug ) { 478 479 $this->single_group = true; 480 481 $group = new stdClass; 482 $group->group_id = BP_Groups_Group::get_id_from_slug($group_slug); 483 484 $this->groups = array( $group ); 485 $this->total_group_count = 1; 486 $this->group_count = 1; 487 488 } else { 489 490 $this->groups = groups_get_user_groups( $bp->displayed_user->id, $this->pag_num, $this->pag_page ); 491 $this->total_group_count = (int)$this->groups['total']; 492 $this->groups = $this->groups['groups']; 493 $this->group_count = count($this->groups); 494 495 } 496 497 $this->pag_links = paginate_links( array( 498 'base' => add_query_arg( array( 'fpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order ) ), 499 'format' => '', 500 'total' => ceil($this->total_group_count / $this->pag_num), 501 'current' => $this->pag_page, 502 'prev_text' => '«', 503 'next_text' => '»', 504 'mid_size' => 1 505 )); 506 507 } 508 509 function has_groups() { 510 if ( $this->group_count ) 511 return true; 512 513 return false; 514 } 515 516 function next_group() { 517 $this->current_group++; 518 $this->group = $this->groups[$this->current_group]; 519 520 return $this->group; 521 } 522 523 function rewind_groups() { 524 $this->current_group = -1; 525 if ( $this->group_count > 0 ) { 526 $this->group = $this->groups[0]; 527 } 528 } 529 530 function user_groups() { 531 if ( $this->current_group + 1 < $this->group_count ) { 532 return true; 533 } elseif ( $this->current_group + 1 == $this->group_count ) { 534 do_action('loop_end'); 535 // Do some cleaning up after the loop 536 $this->rewind_groups(); 537 } 538 539 $this->in_the_loop = false; 540 return false; 541 } 542 543 function the_group() { 544 global $group; 545 546 $this->in_the_loop = true; 547 $this->group = $this->next_group(); 548 549 // If this is a single group then instantiate group meta when creating the object. 550 if ( $this->single_group ) { 551 if ( !$group = wp_cache_get( 'groups_group_' . $this->group->group_id, 'bp' ) ) { 552 $group = new BP_Groups_Group( $this->group->group_id, true ); 553 wp_cache_set( 'groups_group_' . $this->group->group_id, $group, 'bp' ); 554 } 555 } else { 556 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 557 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 558 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 559 } 560 } 561 562 $this->group = $group; 563 564 if ( 0 == $this->current_group ) // loop has just started 565 do_action('loop_start'); 566 } 567 } 568 569 function bp_has_groups( $groups_per_page = 10 ) { 570 global $groups_template, $bp; 571 global $group_obj; 572 573 if ( !$bp->is_single_item ) { 574 $groups_template = new BP_Groups_User_Groups_Template( $bp->displayed_user->id, false, $groups_per_page ); 575 } else { 576 $groups_template = new BP_Groups_User_Groups_Template( $bp->displayed_user->id, $group_obj->slug, $groups_per_page ); 577 } 578 579 return $groups_template->has_groups(); 580 } 581 582 function bp_groups() { 583 global $groups_template; 584 return $groups_template->user_groups(); 585 } 586 587 function bp_the_group() { 588 global $groups_template; 589 return $groups_template->the_group(); 590 } 591 592 function bp_group_is_visible( $group = false ) { 593 global $bp, $groups_template; 594 595 if ( !$group ) 596 $group =& $groups_template->group; 597 598 if ( 'public' == $group->status ) { 599 return true; 600 } else { 601 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) { 602 return true; 603 } 604 } 605 606 return false; 607 } 608 609 function bp_group_has_news( $group = false ) { 610 global $groups_template; 611 612 if ( !$group ) 613 $group =& $groups_template->group; 614 615 if ( empty( $group->news ) ) 616 return false; 617 618 return true; 619 } 620 621 function bp_group_id( $echo = true, $group = false ) { 622 global $groups_template; 623 624 if ( !$group ) 625 $group =& $groups_template->group; 626 627 if ( $echo ) 628 echo apply_filters( 'bp_group_id', $group->id ); 629 else 630 return apply_filters( 'bp_group_id', $group->id ); 631 } 632 633 function bp_group_name( $echo = true, $group = false ) { 634 global $groups_template; 635 636 if ( !$group ) 637 $group =& $groups_template->group; 638 639 if ( $echo ) 640 echo apply_filters( 'bp_group_name', $group->name ); 641 else 642 return apply_filters( 'bp_group_name', $group->name ); 643 } 644 645 function bp_group_type( $group = false ) { 646 global $groups_template; 647 648 if ( !$group ) 649 $group =& $groups_template->group; 650 651 if ( 'public' == $group->status ) { 652 $type = __( "Public Group", "buddypress" ); 653 } else if ( 'hidden' == $group->status ) { 654 $type = __( "Hidden Group", "buddypress" ); 655 } else if ( 'private' == $group->status ) { 656 $type = __( "Private Group", "buddypress" ); 657 } else { 658 $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' ); 659 } 660 661 echo apply_filters( 'bp_group_type', $type ); 662 } 663 664 function bp_group_avatar( $group = false ) { 665 global $groups_template; 666 667 if ( !$group ) 668 $group =& $groups_template->group; 669 670 ?><img src="<?php echo $group->avatar_full ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 671 } 672 673 function bp_group_avatar_thumb( $group = false ) { 674 global $groups_template; 675 676 if ( !$group ) 677 $group =& $groups_template->group; 678 679 ?><img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 680 } 681 682 function bp_group_avatar_mini( $group = false) { 683 global $groups_template; 684 685 if ( !$group ) 686 $group =& $groups_template->group; 687 688 ?><img src="<?php echo $group->avatar_thumb ?>" width="30" height="30" class="avatar" alt="<?php echo $group->name ?> Avatar" /><?php 689 } 690 691 function bp_group_last_active( $echo = true, $group = false ) { 692 global $groups_template; 693 694 if ( !$group ) 695 $group =& $groups_template->group; 696 697 $last_active = groups_get_groupmeta( $group->id, 'last_activity' ); 698 699 if ( empty( $last_active ) ) { 700 if ( $echo ) 701 _e( 'not yet active', 'buddypress' ); 702 else 703 return __( 'not yet active', 'buddypress' ); 704 } else { 705 if ( $echo ) 706 echo apply_filters( 'bp_group_last_active', bp_core_time_since( $last_active ) ); 707 else 708 return apply_filters( 'bp_group_last_active', bp_core_time_since( $last_active ) ); 709 } 710 } 711 712 function bp_group_permalink( $group = false, $echo = true ) { 713 global $groups_template, $bp, $current_blog; 714 715 if ( !$group ) 716 $group =& $groups_template->group; 717 718 if ( $echo ) 719 echo apply_filters( 'bp_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug ); 720 else 721 return apply_filters( 'bp_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug ); 722 } 723 724 function bp_group_admin_permalink( $echo = true, $group = false ) { 725 global $groups_template, $bp, $current_blog; 726 727 if ( !$group ) 728 $group =& $groups_template->group; 729 730 if ( $echo ) 731 echo apply_filters( 'bp_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 732 else 733 return apply_filters( 'bp_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 734 } 735 736 function bp_group_slug( $group = false ) { 737 global $groups_template; 738 739 if ( !$group ) 740 $group =& $groups_template->group; 741 742 echo apply_filters( 'bp_group_slug', $group->slug ); 743 } 744 745 function bp_group_description( $group = false ) { 746 global $groups_template; 747 748 if ( !$group ) 749 $group =& $groups_template->group; 750 751 echo apply_filters( 'bp_group_description', stripslashes($group->description) ); 752 } 753 754 function bp_group_description_editable( $group = false ) { 755 global $groups_template; 756 757 if ( !$group ) 758 $group =& $groups_template->group; 759 760 echo apply_filters( 'bp_group_description_editable', $group->description ); 761 } 762 763 function bp_group_description_excerpt( $group = false ) { 764 global $groups_template; 765 766 if ( !$group ) 767 $group =& $groups_template->group; 768 769 echo apply_filters( 'bp_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 770 } 771 772 function bp_group_news( $group = false ) { 773 global $groups_template; 774 775 if ( !$group ) 776 $group =& $groups_template->group; 777 778 echo apply_filters( 'bp_group_news', stripslashes($groups_template->group->news) ); 779 } 780 781 function bp_group_news_editable( $group = false ) { 782 global $groups_template; 783 784 if ( !$group ) 785 $group =& $groups_template->group; 786 787 echo apply_filters( 'bp_group_news_editable', $group->news ); 788 } 789 790 function bp_group_public_status( $group = false ) { 791 global $groups_template; 792 793 if ( !$group ) 794 $group =& $groups_template->group; 795 796 if ( $group->is_public ) { 797 _e('Public', 'buddypress'); 798 } else { 799 _e('Private', 'buddypress'); 800 } 801 } 802 function bp_group_is_public( $group = false ) { 803 global $groups_template; 804 805 if ( !$group ) 806 $group =& $groups_template->group; 807 808 return apply_filters( 'bp_group_is_public', $group->is_public ); 809 } 810 811 812 function bp_group_date_created( $group = false ) { 813 global $groups_template; 814 815 if ( !$group ) 816 $group =& $groups_template->group; 817 818 echo apply_filters( 'bp_group_date_created', date( get_option( 'date_format' ), $group->date_created ) ); 819 } 820 821 function bp_group_list_admins( $full_list = true, $group = false ) { 822 global $groups_template; 823 824 if ( !$group ) 825 $group =& $groups_template->group; 826 827 if ( !$admins = &$group->admins ) 828 $admins = $group->get_administrators(); 829 830 if ( $admins ) { 831 if ( $full_list ) { ?> 832 <ul id="group-admins"> 833 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 834 <li> 835 <a href="<?php echo $admins[$i]->user->user_url ?>" title="<?php echo $admins[$i]->user->fullname ?>"><?php echo $admins[$i]->user->avatar_thumb ?></a> 836 <h5><?php echo $admins[$i]->user->user_link ?></h5> 837 <span class="activity"><?php echo $admins[$i]->user_title ?></span> 838 <hr /> 839 </li> 840 <?php } ?> 841 </ul> 842 <?php } else { ?> 843 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 844 <?php echo $admins[$i]->user->user_link ?> 845 <?php } ?> 846 <?php } ?> 847 <?php } else { ?> 848 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 849 <?php } ?> 850 851 <?php 852 } 853 854 function bp_group_list_mods( $full_list = true, $group = false ) { 855 global $groups_template; 856 857 if ( !$group ) 858 $group =& $groups_template->group; 859 860 $group_mods = groups_get_group_mods( $group->id ); 861 862 if ( $group_mods ) { 863 if ( $full_list ) { ?> 864 <ul id="group-mods" class="mods-list"> 865 <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?> 866 <li> 867 <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_fetch_user_fullname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_get_avatar( $group_mods[$i]->user_id, 1, 50, 50 ) ?></a> 868 <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5> 869 <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span> 870 <div class="clear"></div> 871 </li> 872 <?php } ?> 873 </ul> 874 <?php } else { ?> 875 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 876 <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?> 877 <?php } ?> 878 <?php } ?> 879 <?php } else { ?> 880 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 881 <?php } ?> 882 883 <?php 884 } 885 886 function bp_group_all_members_permalink( $echo = true, $group = false ) { 887 global $groups_template, $bp; 888 889 if ( !$group ) 890 $group =& $groups_template->group; 891 892 if ( $echo ) 893 echo apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( $group, true ) . '/' . MEMBERS_SLUG ); 894 else 895 return apply_filters( 'bp_group_all_members_permalink', bp_group_permalink( $group, false ) . '/' . MEMBERS_SLUG ); 896 } 897 898 function bp_group_random_members( $group = false ) { 899 global $groups_template; 900 901 if ( !$group ) 902 $group =& $groups_template->group; 903 904 $members = &$group->random_members; 905 ?> 906 <ul class="horiz-gallery"> 907 <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?> 908 <li> 909 <a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a> 910 <h5><?php echo $members[$i]->user->user_link ?></h5> 911 </li> 912 <?php } ?> 913 </ul> 914 <div class="clear"></div> 915 <?php 916 } 917 918 function bp_group_active_forum_topics( $total_topics = 3, $group = false ) { 919 global $groups_template, $forum_template; 920 921 if ( !$group ) 922 $group =& $groups_template->group; 923 924 $forum_id = groups_get_groupmeta( $group->id, 'forum_id' ); 925 926 if ( $forum_id && $forum_id != '' ) { 927 if ( function_exists( 'bp_forums_setup' ) ) { 928 $latest_topics = bp_forums_get_topics( $forum_id, $total_topics, 1 ); 929 930 if ( $latest_topics ) { ?> 931 <ul class="item-list" id="recent-forum-topics"><?php 932 933 $counter = 0; 934 935 foreach( $latest_topics as $topic ) { 936 $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : ''; 937 $forum_template->topic = (object)$topic; ?> 938 939 <li<?php echo $alt ?>> 940 <div class="avatar"> 941 <?php bp_the_topic_poster_avatar() ?> 942 </div> 943 944 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 945 <span class="small">- <?php bp_the_topic_total_post_count() ?> </span> 946 <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p> 947 948 <div class="latest-post"> 949 <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>: 950 <?php bp_the_topic_latest_post_excerpt() ?> 951 </div> 952 </li> 953 <?php $counter++ ?> 954 955 <?php } ?> 956 </ul> 957 <?php 958 } else { 959 ?> 960 <div id="message" class="info"> 961 <p><?php _e( 'There are no active forum topics for this group', 'buddypress' ) ?></p> 962 </div> 963 <?php 964 } 965 } 966 } 967 } 968 969 function bp_group_search_form() { 970 global $groups_template, $bp; 971 972 $action = $bp->loggedin_user->domain . $bp->groups->slug . '/my-groups/search/'; 973 $label = __('Filter Groups', 'buddypress'); 974 $name = 'group-filter-box'; 975 ?> 976 <form action="<?php echo $action ?>" id="group-search-form" method="post"> 977 <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( 'Loading', 'buddypress' ) ?>" style="display: none;" /></label> 978 <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> 979 980 <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?> 981 </form> 982 <?php 983 } 984 985 function bp_group_show_no_groups_message() { 986 global $bp; 987 988 if ( !groups_total_groups_for_user( $bp->displayed_user->id ) ) 989 return true; 990 991 return false; 992 } 993 994 function bp_group_pagination() { 995 global $groups_template; 996 echo apply_filters( 'bp_group_pagination', $groups_template->pag_links ); 997 } 998 999 function bp_total_group_count() { 1000 global $groups_template; 1001 1002 echo apply_filters( 'bp_total_group_count', $groups_template->total_group_count ); 1003 } 1004 1005 function bp_group_total_members( $echo = true, $group = false ) { 1006 global $groups_template; 1007 1008 if ( !$group ) 1009 $group =& $groups_template->group; 1010 1011 if ( $echo ) 1012 echo apply_filters( 'groups_template', $group->total_group_count ); 1013 else 1014 return apply_filters( 'groups_template', $group->total_group_count ); 1015 } 1016 1017 function bp_group_is_photos_enabled( $group = false ) { 1018 global $groups_template; 1019 1020 if ( !$group ) 1021 $group =& $groups_template->group; 1022 1023 if ( $group->enable_photos ) 1024 return true; 1025 1026 return false; 1027 } 1028 1029 function bp_group_show_wire_setting( $group = false ) { 1030 global $groups_template; 1031 1032 if ( !$group ) 1033 $group =& $groups_template->group; 1034 1035 if ( $group->enable_wire ) 1036 echo ' checked="checked"'; 1037 } 1038 1039 function bp_group_is_wire_enabled( $group = false ) { 1040 global $groups_template; 1041 1042 if ( !$group ) 1043 $group =& $groups_template->group; 1044 1045 if ( $group->enable_wire ) 1046 return true; 1047 1048 return false; 1049 } 1050 1051 function bp_group_forum_permalink( $group = false ) { 1052 global $groups_template; 1053 1054 if ( !$group ) 1055 $group =& $groups_template->group; 1056 1057 echo bp_group_permalink( $group, false ) . '/forum'; 1058 } 1059 1060 function bp_group_is_forum_enabled( $group = false ) { 1061 global $groups_template; 1062 1063 if ( !$group ) 1064 $group =& $groups_template->group; 1065 1066 if ( function_exists( 'bp_forums_is_installed_correctly' ) ) { 1067 if ( bp_forums_is_installed_correctly() ) { 1068 if ( $group->enable_forum ) 1069 return true; 1070 1071 return false; 1072 } else { 1073 return false; 1074 } 1075 } 1076 1077 return false; 1078 } 1079 1080 function bp_group_show_forum_setting( $group = false ) { 1081 global $groups_template; 1082 1083 if ( !$group ) 1084 $group =& $groups_template->group; 1085 1086 if ( $group->enable_forum ) 1087 echo ' checked="checked"'; 1088 } 1089 1090 function bp_group_show_photos_setting( $group = false ) { 1091 global $groups_template; 1092 1093 if ( !$group ) 1094 $group =& $groups_template->group; 1095 1096 if ( $group->enable_photos ) 1097 echo ' checked="checked"'; 1098 } 1099 1100 function bp_group_show_photos_upload_setting( $permission, $group = false ) { 1101 global $groups_template; 1102 1103 if ( !$group ) 1104 $group =& $groups_template->group; 1105 1106 if ( 'admin' == $permission && $group->photos_admin_only ) 1107 echo ' checked="checked"'; 1108 1109 if ( 'member' == $permission && !$group->photos_admin_only ) 1110 echo ' checked="checked"'; 1111 } 1112 1113 function bp_group_show_status_setting( $setting, $group = false ) { 1114 global $groups_template; 1115 1116 if ( !$group ) 1117 $group =& $groups_template->group; 1118 1119 if ( $setting == $group->status ) 1120 echo ' checked="checked"'; 1121 } 1122 1123 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 1124 global $groups_template; 1125 1126 if ( !$group ) 1127 $group =& $groups_template->group; 1128 1129 $admins = groups_get_group_admins( $group->id ); 1130 ?> 1131 <?php if ( $admins ) { ?> 1132 <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 1133 <?php foreach ( $admins as $admin ) { ?> 1134 <?php if ( $admin_list ) { ?> 1135 <li> 1136 <?php echo bp_core_get_avatar( $admin->user_id, 1, 30, 30 ) ?> 1137 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 1138 </li> 1139 <?php } else { ?> 1140 <li> 1141 <?php echo bp_core_get_avatar( $admin->user_id, 1 ) ?> 1142 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 1143 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 1144 1145 <?php if ( function_exists( 'friends_install' ) ) : ?> 1146 <div class="action"> 1147 <?php bp_add_friend_button( $admin->user_id ) ?> 1148 </div> 1149 <?php endif; ?> 1150 </li> 1151 <?php } ?> 1152 <?php } ?> 1153 </ul> 1154 <?php } else { ?> 1155 <div id="message" class="info"> 1156 <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p> 1157 </div> 1158 <?php } 1159 } 1160 1161 function bp_group_mod_memberlist( $admin_list = false, $group = false ) { 1162 global $groups_template, $group_mods; 1163 1164 if ( !$group ) 1165 $group =& $groups_template->group; 1166 1167 $group_mods = groups_get_group_mods( $group->id ); 1168 ?> 1169 <?php if ( $group_mods ) { ?> 1170 <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 1171 <?php foreach ( $group_mods as $mod ) { ?> 1172 <?php if ( $admin_list ) { ?> 1173 <li> 1174 <?php echo bp_core_get_avatar( $mod->user_id, 1, 30, 30 ) ?> 1175 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?> <span class="small"> — <a href="<?php bp_group_member_ban_link() ?>"><?php _e( 'Kick & Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5> 1176 </li> 1177 <?php } else { ?> 1178 <li> 1179 <?php echo bp_core_get_avatar( $mod->user_id, 1 ) ?> 1180 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 1181 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 1182 1183 <?php if ( function_exists( 'friends_install' ) ) : ?> 1184 <div class="action"> 1185 <?php bp_add_friend_button( $mod->user_id ) ?> 1186 </div> 1187 <?php endif; ?> 1188 </li> 1189 <?php } ?> 1190 <?php } ?> 1191 </ul> 1192 <?php } else { ?> 1193 <div id="message" class="info"> 1194 <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p> 1195 </div> 1196 <?php } 1197 } 1198 1199 function bp_group_has_moderators( $group = false ) { 1200 global $group_mods, $groups_template; 1201 1202 if ( !$group ) 1203 $group =& $groups_template->group; 1204 1205 return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ) ); 1206 } 1207 1208 function bp_group_member_promote_link( $group = false ) { 1209 global $members_template, $groups_template, $bp; 1210 1211 if ( !$group ) 1212 $group =& $groups_template->group; 1213 1214 echo apply_filters( 'bp_group_member_promote_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/promote/' . $members_template->member->user_id, 'groups_promote_member' ) ); 1215 } 1216 1217 function bp_group_member_demote_link( $user_id = false, $group = false ) { 1218 global $members_template, $groups_template, $bp; 1219 1220 if ( !$group ) 1221 $group =& $groups_template->group; 1222 1223 if ( !$user_id ) 1224 $user_id = $members_template->member->user_id; 1225 1226 echo apply_filters( 'bp_group_member_demote_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) ); 1227 } 1228 1229 function bp_group_member_ban_link( $group = false ) { 1230 global $members_template, $groups_template, $bp; 1231 1232 if ( !$group ) 1233 $group =& $groups_template->group; 1234 1235 echo apply_filters( 'bp_group_member_ban_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/ban/' . $members_template->member->user_id, 'groups_ban_member' ) ); 1236 } 1237 1238 function bp_group_member_unban_link( $group = false ) { 1239 global $members_template, $groups_template, $bp; 1240 1241 if ( !$group ) 1242 $group =& $groups_template->group; 1243 1244 echo apply_filters( 'bp_group_member_unban_link', wp_nonce_url( bp_group_permalink( $group, false ) . '/admin/manage-members/unban/' . $members_template->member->user_id, 'groups_unban_member' ) ); 1245 } 1246 1247 function bp_group_admin_tabs( $group = false ) { 1248 global $bp, $groups_template; 1249 1250 if ( !$group ) 1251 $group =& $groups_template->group; 1252 1253 $current_tab = $bp->action_variables[0]; 1254 ?> 1255 <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?> 1256 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 1257 <?php } ?> 1258 1259 <?php if ( $bp->is_item_admin ) { ?> 1260 <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> 1261 <?php } ?> 1262 1263 <?php if ( $bp->is_item_admin ) { ?> 1264 <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li> 1265 <?php } ?> 1266 1267 <?php if ( $bp->is_item_admin ) { ?> 1268 <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> 1269 <?php } ?> 1270 1271 <?php if ( $bp->is_item_admin && $groups_template->group->status == 'private' ) : ?> 1272 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 1273 <?php endif; ?> 1274 1275 <?php if ( $bp->is_item_admin ) { ?> 1276 <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 1277 <?php } ?> 1278 1279 <?php 1280 do_action( 'groups_admin_tabs' ); 1281 } 1282 1283 function bp_group_form_action( $page, $group = false ) { 1284 global $bp, $groups_template; 1285 1286 if ( !$group ) 1287 $group =& $groups_template->group; 1288 1289 echo apply_filters( 'bp_group_form_action', bp_group_permalink( $group, false ) . '/' . $page ); 1290 } 1291 1292 function bp_group_admin_form_action( $page, $group = false ) { 1293 global $bp, $groups_template; 1294 1295 if ( !$group ) 1296 $group =& $groups_template->group; 1297 1298 echo apply_filters( 'bp_group_admin_form_action', bp_group_permalink( $group, false ) . '/admin/' . $page ); 1299 } 1300 1301 function bp_group_has_requested_membership( $group = false ) { 1302 global $bp, $groups_template; 1303 1304 if ( !$group ) 1305 $group =& $groups_template->group; 1306 1307 if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) ) 1308 return true; 1309 1310 return false; 1311 } 1312 1313 function bp_group_is_member( $group = false ) { 1314 global $bp, $groups_template; 1315 1316 if ( !$group ) 1317 $group =& $groups_template->group; 1318 1319 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 1320 return true; 1321 1322 return false; 1323 } 1324 1325 function bp_group_accept_invite_link( $group = false ) { 1326 global $groups_template, $bp; 1327 1328 if ( !$group ) 1329 $group =& $groups_template->group; 1330 1331 echo apply_filters( 'bp_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 1332 } 1333 1334 function bp_group_reject_invite_link( $group = false ) { 1335 global $groups_template, $bp; 1336 1337 if ( !$group ) 1338 $group =& $groups_template->group; 1339 1340 echo apply_filters( 'bp_group_reject_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/reject/' . $group->id, 'groups_reject_invite' ) ); 1341 } 1342 1343 function bp_has_friends_to_invite( $group = false ) { 1344 global $groups_template, $bp; 1345 1346 if ( !function_exists('friends_install') ) 1347 return false; 1348 1349 if ( !$group ) 1350 $group =& $groups_template->group; 1351 1352 if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) ) 1353 return false; 1354 1355 return true; 1356 } 1357 1358 function bp_group_leave_confirm_link( $group = false ) { 1359 global $groups_template, $bp; 1360 1361 if ( !$group ) 1362 $group =& $groups_template->group; 1363 1364 echo apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_group_permalink( $group, true ) . '/leave-group/yes', 'groups_leave_group' ) ); 1365 } 1366 1367 function bp_group_leave_reject_link( $group = false ) { 1368 global $groups_template, $bp; 1369 1370 if ( !$group ) 1371 $group =& $groups_template->group; 1372 1373 echo apply_filters( 'bp_group_leave_reject_link', bp_group_permalink( $group, true ) ); 1374 } 1375 1376 function bp_group_send_invite_form( $group = false ) { 1377 global $bp, $groups_template, $invites; 1378 1379 if ( !$group ) 1380 $group =& $groups_template->group; 1381 ?> 1382 <div class="left-menu"> 1383 <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4> 1384 <?php bp_group_list_invite_friends() ?> 1385 <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?> 1386 <input type="hidden" name="group_id" id="group_id" value="<?php echo $group->id ?>" /> 1387 </div> 1388 1389 <div class="main-column"> 1390 1391 <div id="message" class="info"> 1392 <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> 1393 </div> 1394 1395 <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_obj->id ) ?> 1396 1397 <ul id="friend-list" class="item-list"> 1398 <?php for ( $i = 0; $i < count($invites); $i++ ) { 1399 if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) { 1400 $user = new BP_Core_User( $invites[$i] ); 1401 wp_cache_set( 'bp_user_' . $invites[$i], $user, 'bp' ); 1402 } 1403 ?> 1404 <li id="uid-<?php echo $user->id ?>"> 1405 <?php echo $user->avatar_thumb ?> 1406 <h4><?php echo $user->user_link ?></h4> 1407 <span class="activity"><?php echo $user->last_active ?></span> 1408 <div class="action"> 1409 <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 1410 </div> 1411 </li> 1412 <?php } // end for ?> 1413 </ul> 1414 1415 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?> 1416 </div> 1417 <?php 1418 } 1419 1420 function bp_group_send_invite_form_action( $group = false ) { 1421 global $groups_template, $bp; 1422 1423 if ( !$group ) 1424 $group =& $groups_template->group; 1425 1426 echo apply_filters( 'bp_group_send_invite_form_action', bp_group_permalink( $group, true ) . '/send-invites/send' ); 1427 } 1428 1429 function bp_group_join_button( $group = false ) { 1430 global $bp, $groups_template; 1431 1432 if ( !$group ) 1433 $group =& $groups_template->group; 1434 1435 // If they're not logged in or are banned from the group, no join button. 1436 if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) ) 1437 return false; 1438 1439 echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1440 1441 switch ( $group->status ) { 1442 case 'public': 1443 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) 1444 echo '<a class="leave-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1445 else 1446 echo '<a class="join-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1447 break; 1448 1449 case 'private': 1450 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) { 1451 echo '<a class="leave-group" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1452 } else { 1453 if ( !bp_group_has_requested_membership( $group ) ) 1454 echo '<a class="request-membership" href="' . wp_nonce_url( bp_group_permalink( $group, false ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1455 else 1456 echo '<a class="membership-requested" href="' . bp_group_permalink( $group, false ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1457 } 1458 break; 1459 } 1460 1461 echo '</div>'; 1462 } 1463 1464 function bp_group_status_message( $group = false ) { 1465 global $groups_template; 1466 1467 if ( !$group ) 1468 $group =& $groups_template->group; 1469 1470 if ( 'private' == $group->status ) { 1471 if ( !bp_group_has_requested_membership() ) 1472 if ( is_user_logged_in() ) 1473 _e( 'This is a private group and you must request group membership in order to join.', 'buddypress' ); 1474 else 1475 _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 1476 else 1477 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1478 } else { 1479 _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); 1480 } 1481 } 1482 1483 1484 /*************************************************************************** 1472 1485 * Group Members Template Tags 1473 1486 **/ … … 1484 1497 var $pag_num; 1485 1498 var $pag_links; 1486 var $total_ member_count;1499 var $total_group_count; 1487 1500 1488 1501 function bp_groups_group_members_template( $group_id, $num_per_page, $exclude_admins_mods, $exclude_banned ) { … … 1494 1507 $members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); 1495 1508 1496 $this->total_ member_count = $members['count'];1509 $this->total_group_count = $members['count']; 1497 1510 $this->members = $members['members']; 1498 1511 … … 1502 1515 'base' => add_query_arg( 'mlpage', '%#%' ), 1503 1516 'format' => '', 1504 'total' => ceil( $this->total_ member_count / $this->pag_num ),1517 'total' => ceil( $this->total_group_count / $this->pag_num ), 1505 1518 'current' => $this->pag_page, 1506 1519 'prev_text' => '«', … … 1632 1645 global $members_template; 1633 1646 1634 if ( $members_template->total_ member_count > $members_template->pag_num )1647 if ( $members_template->total_group_count > $members_template->pag_num ) 1635 1648 return true; 1636 1649 … … 1655 1668 1656 1669 $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 1657 $to_num = ( $from_num + 4 > $members_template->total_ member_count ) ? $members_template->total_member_count : $from_num + 4;1658 1659 echo apply_filters( 'bp_group_reject_invite_link', sprintf( __( 'Viewing members %d to %d (%d total members)', 'buddypress' ), $from_num, $to_num, $members_template->total_ member_count ) );1670 $to_num = ( $from_num + 4 > $members_template->total_group_count ) ? $members_template->total_group_count : $from_num + 4; 1671 1672 echo apply_filters( 'bp_group_reject_invite_link', sprintf( __( 'Viewing members %d to %d (%d total members)', 'buddypress' ), $from_num, $to_num, $members_template->total_group_count ) ); 1660 1673 } 1661 1674 … … 1666 1679 } 1667 1680 1668 1669 /**** 1681 /******************************************************************************** 1682 * Site Groups Template Tags 1683 **/ 1684 1685 class BP_Groups_Site_Groups_Template { 1686 var $current_group = -1; 1687 var $group_count; 1688 var $groups; 1689 var $group; 1690 1691 var $in_the_loop; 1692 1693 var $pag_page; 1694 var $pag_num; 1695 var $pag_links; 1696 var $total_group_count; 1697 1698 function bp_groups_site_groups_template( $type, $per_page, $max ) { 1699 global $bp; 1700 1701 $this->pag_page = isset( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1; 1702 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1703 1704 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 1705 $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page ); 1706 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 1707 $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 1708 } else { 1709 switch ( $type ) { 1710 case 'random': 1711 $this->groups = BP_Groups_Group::get_random( $this->pag_num, $this->pag_page ); 1712 break; 1713 1714 case 'newest': 1715 $this->groups = BP_Groups_Group::get_newest( $this->pag_num, $this->pag_page ); 1716 break; 1717 1718 case 'popular': 1719 $this->groups = BP_Groups_Group::get_popular( $this->pag_num, $this->pag_page ); 1720 break; 1721 1722 case 'active': default: 1723 $this->groups = BP_Groups_Group::get_active( $this->pag_num, $this->pag_page ); 1724 break; 1725 } 1726 } 1727 1728 if ( !$max ) 1729 $this->total_group_count = (int)$this->groups['total']; 1730 else 1731 $this->total_group_count = (int)$max; 1732 1733 $this->groups = $this->groups['groups']; 1734 $this->group_count = count($this->groups); 1735 1736 $this->pag_links = paginate_links( array( 1737 'base' => add_query_arg( 'page', '%#%' ), 1738 'format' => '', 1739 'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ), 1740 'current' => (int) $this->pag_page, 1741 'prev_text' => '«', 1742 'next_text' => '»', 1743 'mid_size' => 1 1744 )); 1745 } 1746 1747 function has_groups() { 1748 if ( $this->group_count ) 1749 return true; 1750 1751 return false; 1752 } 1753 1754 function next_group() { 1755 $this->current_group++; 1756 $this->group = $this->groups[$this->current_group]; 1757 1758 return $this->group; 1759 } 1760 1761 function rewind_groups() { 1762 $this->current_group = -1; 1763 if ( $this->group_count > 0 ) { 1764 $this->group = $this->groups[0]; 1765 } 1766 } 1767 1768 function groups() { 1769 if ( $this->current_group + 1 < $this->group_count ) { 1770 return true; 1771 } elseif ( $this->current_group + 1 == $this->group_count ) { 1772 do_action('loop_end'); 1773 // Do some cleaning up after the loop 1774 $this->rewind_groups(); 1775 } 1776 1777 $this->in_the_loop = false; 1778 return false; 1779 } 1780 1781 function the_group() { 1782 global $group; 1783 1784 $this->in_the_loop = true; 1785 $this->group = $this->next_group(); 1786 1787 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 1788 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 1789 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 1790 } 1791 1792 $this->group = $group; 1793 1794 if ( 0 == $this->current_group ) // loop has just started 1795 do_action('loop_start'); 1796 } 1797 } 1798 1799 function bp_rewind_site_groups() { 1800 global $site_groups_template; 1801 1802 $site_groups_template->rewind_groups(); 1803 } 1804 1805 function bp_has_site_groups( $args = '' ) { 1806 global $site_groups_template; 1807 1808 $defaults = array( 1809 'type' => 'active', 1810 'per_page' => 10, 1811 'max' => false 1812 ); 1813 1814 $r = wp_parse_args( $args, $defaults ); 1815 extract( $r, EXTR_SKIP ); 1816 1817 // type: active ( default ) | random | newest | popular 1818 1819 if ( $max ) { 1820 if ( $per_page > $max ) 1821 $per_page = $max; 1822 } 1823 1824 $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max ); 1825 1826 return $site_groups_template->has_groups(); 1827 } 1828 1829 function bp_site_groups() { 1830 global $site_groups_template; 1831 1832 return $site_groups_template->groups(); 1833 } 1834 1835 function bp_the_site_group() { 1836 global $site_groups_template; 1837 1838 return $site_groups_template->the_group(); 1839 } 1840 1841 function bp_site_groups_pagination_count() { 1842 global $bp, $site_groups_template; 1843 1844 $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1; 1845 $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ; 1846 1847 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> 1848 <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /><?php 1849 } 1850 1851 function bp_site_groups_pagination_links() { 1852 global $site_groups_template; 1853 echo $site_groups_template->pag_links; 1854 } 1855 1856 function bp_the_site_group_avatar() { 1857 global $site_groups_template; 1858 echo bp_group_avatar( $site_groups_template->group ); 1859 } 1860 1861 function bp_the_site_group_avatar_thumb() { 1862 global $site_groups_template; 1863 echo bp_group_avatar_thumb( $site_groups_template->group ); 1864 } 1865 1866 function bp_the_site_group_avatar_mini() { 1867 global $site_groups_template; 1868 echo bp_group_avatar_mini( $site_groups_template->group ); 1869 } 1870 1871 function bp_the_site_group_link() { 1872 global $site_groups_template; 1873 echo bp_group_permalink( $site_groups_template->group ); 1874 } 1875 1876 function bp_the_site_group_name() { 1877 global $site_groups_template; 1878 echo bp_group_name( true, $site_groups_template->group ); 1879 } 1880 1881 function bp_the_site_group_last_active() { 1882 global $site_groups_template; 1883 1884 printf( __( 'active %s ago', 'buddypress' ), bp_group_last_active( false, $site_groups_template->group ) ); 1885 } 1886 1887 function bp_the_site_group_join_button() { 1888 global $site_groups_template; 1889 1890 echo bp_group_join_button( $site_groups_template->group ); 1891 } 1892 1893 function bp_the_site_group_description() { 1894 global $site_groups_template; 1895 1896 echo bp_group_description( $site_groups_template->group ); 1897 } 1898 1899 function bp_the_site_group_member_count() { 1900 global $site_groups_template; 1901 1902 if ( 1 == (int) $site_groups_template->group->total_member_count ) 1903 printf( '%d member', (int) $site_groups_template->group->total_member_count ); 1904 else 1905 printf( '%d members', (int) $site_groups_template->group->total_member_count ); 1906 } 1907 1908 function bp_the_site_group_type() { 1909 global $site_groups_template; 1910 1911 echo bp_group_type( $site_groups_template->group ); 1912 } 1913 1914 1915 function bp_the_site_group_hidden_fields() { 1916 if ( isset( $_REQUEST['s'] ) ) { 1917 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />'; 1918 } 1919 1920 if ( isset( $_REQUEST['letter'] ) ) { 1921 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 1922 } 1923 1924 if ( isset( $_REQUEST['groups_search'] ) ) { 1925 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />'; 1926 } 1927 } 1928 1929 function bp_directory_groups_search_form() { 1930 global $bp; ?> 1931 <form action="<?php echo $bp->root_domain . '/' . groups_SLUG . '/search/' ?>" method="post" id="search-groups-form"> 1932 <label><input type="text" name="groups_search" id="groups_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 1933 <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 1934 </form> 1935 <?php 1936 } 1937 1938 /************************************************************************************ 1670 1939 * Membership Requests Template Tags 1671 1940 **/ … … 1809 2078 } 1810 2079 2080 2081 2082 1811 2083 ?>
Note: See TracChangeset
for help on using the changeset viewer.