Changeset 540 for trunk/bp-groups/bp-groups-templatetags.php
- Timestamp:
- 11/13/2008 11:20:15 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-templatetags.php
r536 r540 313 313 if ( !$admins = &$groups_template->group->admins ) 314 314 $admins = $groups_template->group->get_administrators(); 315 315 316 316 if ( $admins ) { 317 317 if ( $full_list ) { ?> … … 338 338 } 339 339 340 function bp_group_list_mods( $full_list = true ) { 341 global $groups_template, $group_mods; 342 343 if ( $group_mods ) { 344 if ( $full_list ) { ?> 345 <ul id="group-mods" class="mods-list"> 346 <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?> 347 <li> 348 <?php echo bp_core_get_avatar( $group_mods[$i]->user_id, 1, false, 36, 36 ) ?> 349 <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5> 350 <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span> 351 <div class="clear"></div> 352 </li> 353 <?php } ?> 354 </ul> 355 <?php } else { ?> 356 <?php for ( $i = 0; $i < count($admins); $i++ ) { ?> 357 <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?> 358 <?php } ?> 359 <?php } ?> 360 <?php } else { ?> 361 <span class="activity">No Admin</span> 362 <?php } ?> 363 364 <?php 365 } 366 340 367 function bp_group_all_members_permalink() { 341 368 global $groups_template, $bp; … … 457 484 } 458 485 486 function bp_group_admin_memberlist( $admin_list = false ) { 487 global $groups_template; 488 489 $admins = groups_get_group_admins( $groups_template->group->id ); 490 ?> 491 <?php if ( $admins ) { ?> 492 <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 493 <?php foreach ( $admins as $admin ) { ?> 494 <?php if ( $admin_list ) { ?> 495 <li> 496 <?php echo bp_core_get_avatar( $admin->user_id, 1, false, 30, 30 ) ?> 497 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 498 </li> 499 <?php } else { ?> 500 <li> 501 <?php echo bp_core_get_avatar( $admin->user_id, 1 ) ?> 502 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 503 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 504 505 <?php if ( function_exists( 'friends_install' ) ) : ?> 506 <div class="action"> 507 <?php bp_add_friend_button( $admin->user_id ) ?> 508 </div> 509 <?php endif; ?> 510 </li> 511 <?php } ?> 512 <?php } ?> 513 </ul> 514 <?php } else { ?> 515 <div id="message" class="info"> 516 <?php _e( 'This group has no administrators', 'buddypress' ); ?> 517 </div> 518 <?php } 519 } 520 521 function bp_group_mod_memberlist( $admin_list = false ) { 522 global $groups_template, $group_mods; 523 ?> 524 <?php if ( $group_mods ) { ?> 525 <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>"> 526 <?php foreach ( $group_mods as $mod ) { ?> 527 <?php if ( $admin_list ) { ?> 528 <li> 529 <?php echo bp_core_get_avatar( $mod->user_id, 1, false, 30, 30 ) ?> 530 <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> 531 </li> 532 <?php } else { ?> 533 <li> 534 <?php echo bp_core_get_avatar( $mod->user_id, 1 ) ?> 535 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 536 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 537 538 <?php if ( function_exists( 'friends_install' ) ) : ?> 539 <div class="action"> 540 <?php bp_add_friend_button( $mod->user_id ) ?> 541 </div> 542 <?php endif; ?> 543 </li> 544 <?php } ?> 545 <?php } ?> 546 </ul> 547 <?php } else { ?> 548 <div id="message" class="info"> 549 <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p> 550 </div> 551 <?php } 552 } 553 554 function bp_group_has_moderators() { 555 global $group_mods, $groups_template; 556 557 $group_mods = groups_get_group_mods( $groups_template->group->id ); 558 return $group_mods; 559 } 560 561 function bp_group_member_promote_link() { 562 global $members_template, $groups_template, $bp; 563 564 echo bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/promote/' . $members_template->member->user_id; 565 } 566 567 function bp_group_member_demote_link( $user_id = false) { 568 global $members_template, $groups_template, $bp; 569 570 if ( !$user_id ) 571 $user_id = $members_template->member->user_id; 572 573 echo bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/demote/' . $user_id; 574 } 575 576 function bp_group_member_ban_link() { 577 global $members_template, $groups_template, $bp; 578 579 echo bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/ban/' . $members_template->member->user_id; 580 } 581 582 function bp_group_member_unban_link() { 583 global $members_template, $groups_template, $bp; 584 585 echo bp_group_permalink( $groups_template->group, false ) . '/admin/manage-members/unban/' . $members_template->member->user_id; 586 } 587 459 588 function bp_group_admin_tabs() { 460 589 global $bp, $groups_template; … … 462 591 $current_tab = $bp['action_variables'][0]; 463 592 ?> 464 <li<?php if ( $current_tab == 'edit-details' || $current_tab == '' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 465 <li<?php if ( $current_tab == 'group-settings' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> 466 <li<?php if ( $current_tab == 'manage-members' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> 467 468 <?php if ( $groups_template->group->status == 'private' ) : ?> 593 <?php if ( $bp['is_item_admin'] || $bp['is_item_mod'] ) { ?> 594 <li<?php if ( $current_tab == 'edit-details' || $current_tab == '' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 595 <?php } ?> 596 597 <?php if ( $bp['is_item_admin'] ) { ?> 598 <li<?php if ( $current_tab == 'group-settings' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li> 599 <?php } ?> 600 601 <?php if ( $bp['is_item_admin'] ) { ?> 602 <li<?php if ( $current_tab == 'manage-members' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li> 603 <?php } ?> 604 605 <?php if ( $bp['is_item_admin'] && $groups_template->group->status == 'private' ) : ?> 469 606 <li<?php if ( $current_tab == 'membership-requests' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 470 607 <?php endif; ?> 471 472 <li<?php if ( $current_tab == 'delete-group' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 608 609 <?php if ( $bp['is_item_admin'] ) { ?> 610 <li<?php if ( $current_tab == 'delete-group' ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp['root_domain'] . '/' . $bp['groups']['slug'] ?>/<?php echo $groups_template->group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 611 <?php } ?> 473 612 474 613 <?php … … 680 819 } 681 820 682 function bp_group_list_members() {683 global $groups_template, $bp;684 685 for ( $i = 0; $i < count($groups_template->group->user_dataset); $i++ ) {686 $member = new BP_Groups_Member( $groups_template->group->user_dataset[$i]->user_id, $groups_template->group->id );687 688 ?><li id="uid-<?php echo $user->id ?>">689 <?php echo $member->user->avatar_thumb ?>690 <p><?php echo $member->user->user_link ?> <?php if ( $member->user_title ) { ?><?php echo '<span class="small">- ' . $member->user_title . '</span>' ?><?php } ?></p>691 <span class="activity"><?php echo sprintf( __( 'joined %s ago', 'buddypress' ), bp_core_time_since( strtotime( $member->date_modified ) ) ); ?></span>692 <?php if ( bp_exists('friends') && function_exists('bp_add_friend_button') ) { ?>693 <div class="action">694 <?php bp_add_friend_button( $member->user->id ) ?>695 </div>696 <?php } ?>697 </li>698 <?php699 }700 }701 702 821 function bp_group_accept_invite_link() { 703 822 global $groups_template, $bp; … … 775 894 global $bp, $groups_template; 776 895 777 if ( !is_user_logged_in() || BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $groups_template->group->id ) )896 if ( !is_user_logged_in() || BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $groups_template->group->id ) || groups_is_user_banned( $bp['loggedin_userid'], $groups_template->group->id ) ) 778 897 return false; 779 898 … … 852 971 var $total_member_count; 853 972 854 function bp_groups_group_members_template( $group_id ) {973 function bp_groups_group_members_template( $group_id, $num_per_page, $exclude_admins_mods, $exclude_banned ) { 855 974 global $bp; 856 975 857 976 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 858 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : 5;859 860 $members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page );977 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $num_per_page; 978 979 $members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); 861 980 862 981 $this->total_member_count = $members['count']; … … 922 1041 } 923 1042 924 function bp_group_has_members( $group_id = false ) {1043 function bp_group_has_members( $group_id = false, $num_per_page = 5, $exclude_admins_mods = true, $exclude_banned = true ) { 925 1044 global $members_template, $groups_template; 926 1045 927 if ( !$group_id ) 928 $group_id = $groups_template->group->id; 929 930 $members_template = new BP_Groups_Group_Members_Template( $group_id ); 1046 if ( !$groups_template ) 1047 $groups_template->group = new BP_Groups_Group( $group_id ); 1048 1049 1050 $members_template = new BP_Groups_Group_Members_Template( $groups_template->group->id, $num_per_page, $exclude_admins_mods, $exclude_banned ); 931 1051 932 1052 return $members_template->has_members(); … … 951 1071 } 952 1072 1073 function bp_group_member_avatar_mini( $width = 30, $height = 30 ) { 1074 global $members_template; 1075 1076 echo bp_core_get_avatar( $members_template->member->user_id, 1, false, $width, $height ); 1077 } 1078 953 1079 function bp_group_member_link() { 954 1080 global $members_template; 955 1081 956 1082 echo bp_core_get_userlink( $members_template->member->user_id ); 1083 } 1084 1085 function bp_group_member_is_banned() { 1086 global $members_template, $groups_template; 1087 1088 return groups_is_user_banned( $members_template->member->user_id, $groups_template->group->id ); 957 1089 } 958 1090 … … 990 1122 global $members_template; 991 1123 echo $members_template->pag_links; 992 wp_nonce_field( 'bp_groups_member_list' );1124 wp_nonce_field( 'bp_groups_member_list', '_member_pag_nonce' ); 993 1125 } 994 1126 … … 1000 1132 1001 1133 echo sprintf( __( 'Viewing members %d to %d (%d total members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ); 1134 } 1135 1136 function bp_group_member_admin_pagination() { 1137 global $members_template; 1138 echo $members_template->pag_links; 1139 wp_nonce_field( 'bp_groups_member_admin_list', '_member_admin_pag_nonce' ); 1002 1140 } 1003 1141 … … 1020 1158 var $total_request_count; 1021 1159 1022 function bp_groups_membership_requests_template( $group_id ) {1160 function bp_groups_membership_requests_template( $group_id, $num_per_page ) { 1023 1161 global $bp; 1024 1162 1025 1163 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1; 1026 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : 5;1164 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $num_per_page; 1027 1165 1028 1166 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); … … 1088 1226 } 1089 1227 1090 function bp_group_has_membership_requests( ) {1228 function bp_group_has_membership_requests( $num_per_page = 5 ) { 1091 1229 global $requests_template, $groups_template; 1092 1230 1093 $requests_template = new BP_Groups_Membership_Requests_Template( $groups_template->group->id );1231 $requests_template = new BP_Groups_Membership_Requests_Template( $groups_template->group->id, $num_per_page ); 1094 1232 1095 1233 return $requests_template->has_requests();
Note: See TracChangeset
for help on using the changeset viewer.