Ticket #921: 921.04.diff
File 921.04.diff, 16.3 KB (added by , 11 years ago) |
---|
-
bp-groups/bp-groups-classes.php
diff --git bp-groups/bp-groups-classes.php bp-groups/bp-groups-classes.php index 2ed7441..bed0eb7 100644
class BP_Group_Member_Query extends BP_User_Query { 1460 1460 'group_id' => 0, 1461 1461 'group_role' => array( 'member' ), 1462 1462 'is_confirmed' => true, 1463 'type' => 'last_modified', 1463 1464 ) ); 1464 1465 1465 1466 $group_member_ids = $this->get_group_member_ids(); … … class BP_Group_Member_Query extends BP_User_Query { 1562 1563 1563 1564 /** ORDER BY clause ***************************************************/ 1564 1565 1565 // @todo For now, mimicking legacy behavior of 1566 // bp_group_has_members(), which has us order by date_modified 1567 // only. Should abstract it in the future 1566 /** 1567 * The order for alphabetical type will be set in 1568 * BP_Group_Member_Query->set_orderby() In the group members 1569 * table, date_modified is the 'sortable' field available. 1570 * The two remaining types, last_modified and first_modified, 1571 * are managed here. 1572 */ 1573 1574 if ( isset( $this->query_vars['type'] ) ) { 1575 $type = $this->query_vars['type']; 1576 } else { 1577 $type = 'last_modified'; 1578 } 1579 1568 1580 $sql['orderby'] = "ORDER BY date_modified"; 1569 1581 $sql['order'] = "DESC"; 1570 1582 1583 if ( 'first_modified' == $type ) { 1584 $sql['order'] = "ASC"; 1585 } 1586 1571 1587 /** LIMIT clause ******************************************************/ 1572 1588 $this->group_member_ids = $wpdb->get_col( "{$sql['select']} {$sql['where']} {$sql['orderby']} {$sql['order']} {$sql['limit']}" ); 1573 1589 1574 return $this->group_member_ids; 1590 /** 1591 * You can filter the group member ids from here to build your custom query 1592 * if you defined a custom type using the action 'bp_groups_members_order_options' 1593 * for instance 1594 */ 1595 return apply_filters( 'bp_group_member_query_group_member_ids', $this->group_member_ids, $type, $this->query_vars['group_id'] ); 1575 1596 } 1576 1597 1577 1598 /** … … class BP_Group_Member_Query extends BP_User_Query { 1583 1604 * @param BP_User_Query $query BP_User_Query object. 1584 1605 */ 1585 1606 public function set_orderby( $query ) { 1586 $gm_ids = $this->get_group_member_ids(); 1607 1608 $gm_ids = $this->get_group_member_ids( $query->query_vars['type'] ); 1609 1587 1610 if ( empty( $gm_ids ) ) { 1588 1611 $gm_ids = array( 0 ); 1589 1612 } 1590 1613 1591 // The first param in the FIELD() clause is the sort column id 1592 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 1593 $gm_ids_sql = implode( ',', $gm_ids ); 1614 // No need to change the order of BP_User_Query in case type is alphabetical 1615 if ( 'alphabetical' != $query->query_vars['type'] ) { 1616 // The first param in the FIELD() clause is the sort column id 1617 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 1618 $gm_ids_sql = implode( ',', $gm_ids ); 1594 1619 1595 $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")"; 1620 $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")"; 1621 } 1596 1622 1597 1623 // Prevent this filter from running on future BP_User_Query 1598 1624 // instances on the same page -
bp-groups/bp-groups-functions.php
diff --git bp-groups/bp-groups-functions.php bp-groups/bp-groups-functions.php index a27a499..9642849 100644
function groups_get_group_members( $args = array() ) { 422 422 'exclude' => false, 423 423 'group_role' => array(), 424 424 'search_terms' => false, 425 'type' => 'last_modified' 425 426 ) ); 426 427 427 428 // For legacy users. Use of BP_Groups_Member::get_all_for_group() … … function groups_get_group_members( $args = array() ) { 455 456 'group_role' => $r['group_role'], 456 457 'exclude' => $r['exclude'], 457 458 'search_terms' => $r['search_terms'], 458 'type' => 'last_modified',459 'type' => $r['type'], 459 460 ) ); 460 461 461 462 // Structure the return value as expected by the template functions -
bp-groups/bp-groups-template.php
diff --git bp-groups/bp-groups-template.php bp-groups/bp-groups-template.php index 675409e..44fe89b 100644
class BP_Groups_Group_Members_Template { 1982 1982 'exclude_banned' => 1, 1983 1983 'group_role' => false, 1984 1984 'search_terms' => false, 1985 'type' => 'last_modified', 1985 1986 ) ); 1986 1987 1987 1988 // @todo No … … class BP_Groups_Group_Members_Template { 1990 1991 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : $r['page']; 1991 1992 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1992 1993 1994 /** 1995 * In themes, If 'groups/single/home' template has been updated 1996 * but not 'groups/single/members', it prevents the pagination 1997 * url to be messed up with admin-ajax. 1998 */ 1999 $base_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) . bp_current_action() ); 2000 2001 if ( bp_action_variable() ) { 2002 $base_url = trailingslashit( $base_url . bp_action_variable() ); 2003 } 2004 1993 2005 $members_args = $r; 1994 2006 1995 2007 $members_args['page'] = $this->pag_page; … … class BP_Groups_Group_Members_Template { 2014 2026 } 2015 2027 2016 2028 $this->pag_links = paginate_links( array( 2017 'base' => add_query_arg( 'mlpage', '%#%'),2029 'base' => add_query_arg( array( 'mlpage' => '%#%' ), $base_url ), 2018 2030 'format' => '', 2019 2031 'total' => !empty( $this->pag_num ) ? ceil( $this->total_member_count / $this->pag_num ) : $this->total_member_count, 2020 2032 'current' => $this->pag_page, … … class BP_Groups_Group_Members_Template { 2091 2103 function bp_group_has_members( $args = '' ) { 2092 2104 global $members_template; 2093 2105 2106 $exclude_admins_mods = 1; 2107 2108 if ( bp_is_group_members() ) { 2109 $exclude_admins_mods = 0; 2110 } 2111 2094 2112 $r = wp_parse_args( $args, array( 2095 2113 'group_id' => bp_get_current_group_id(), 2096 2114 'page' => 1, 2097 2115 'per_page' => 20, 2098 2116 'max' => false, 2099 2117 'exclude' => false, 2100 'exclude_admins_mods' => 1,2118 'exclude_admins_mods' => $exclude_admins_mods, 2101 2119 'exclude_banned' => 1, 2102 2120 'group_role' => false, 2103 2121 'search_terms' => false, 2122 'type' => 'last_modified', 2104 2123 ) ); 2105 2124 2106 2125 if ( empty( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) … … function bp_group_member_admin_pagination() { 2282 2301 return $members_template->pag_links; 2283 2302 } 2284 2303 2304 /** 2305 * Output the Group members template 2306 * 2307 * @since BuddyPress (?) 2308 * 2309 * @return string html output 2310 */ 2311 function bp_groups_members_template_part() { 2312 ?> 2313 <div class="item-list-tabs" id="subnav" role="navigation"> 2314 <ul> 2315 <li class="groups-members-search" role="search"> 2316 <?php bp_directory_members_search_form(); ?> 2317 </li> 2318 2319 <?php bp_groups_members_filter(); ?> 2320 <?php do_action( 'bp_members_directory_member_sub_types' ); ?> 2321 2322 </ul> 2323 </div> 2324 2325 <div id="members-group-list" class="group_members dir-list"> 2326 2327 <?php bp_get_template_part( 'groups/single/members' ); ?> 2328 2329 </div> 2330 <?php 2331 } 2332 2333 /** 2334 * Output the Group members filters 2335 * 2336 * @since BuddyPress (?) 2337 * 2338 * @return string html output 2339 */ 2340 function bp_groups_members_filter() { 2341 ?> 2342 <li id="group_members-order-select" class="last filter"> 2343 <label for="group_members-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label> 2344 <select id="group_members-order-by"> 2345 <option value="last_modified"><?php _e( 'Newest', 'buddypress' ); ?></option> 2346 <option value="first_modified"><?php _e( 'Oldest', 'buddypress' ); ?></option> 2347 <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> 2348 2349 <?php do_action( 'bp_groups_members_order_options' ); ?> 2350 2351 </select> 2352 </li> 2353 <?php 2354 } 2285 2355 2286 2356 /*************************************************************************** 2287 2357 * Group Creation Process Template Tags -
bp-templates/bp-legacy/buddypress-functions.php
diff --git bp-templates/bp-legacy/buddypress-functions.php bp-templates/bp-legacy/buddypress-functions.php index 0cb3153..658ab62 100644
function bp_legacy_theme_object_template_loader() { 541 541 if ( ! bp_current_action() ) 542 542 bp_update_is_directory( true, bp_current_component() ); 543 543 544 $template_part = $object . '/' . $object . '-loop'; 545 546 if ( ! empty( $_POST['template'] ) ) 547 $template_part = sanitize_option( 'upload_path', $_POST['template'] ); 548 544 549 // Locate the object template 545 bp_get_template_part( "$object/$object-loop");550 bp_get_template_part( $template_part ); 546 551 exit(); 547 552 } 548 553 -
bp-templates/bp-legacy/buddypress/groups/single/home.php
diff --git bp-templates/bp-legacy/buddypress/groups/single/home.php bp-templates/bp-legacy/buddypress/groups/single/home.php index 55dd5b0..8499866 100644
47 47 elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' ); 48 48 49 49 // Otherwise show members 50 elseif ( bp_is_active( 'members' ) ) : bp_g et_template_part( 'groups/single/members');50 elseif ( bp_is_active( 'members' ) ) : bp_groups_members_template_part(); 51 51 52 52 endif; 53 53 … … 61 61 elseif ( bp_is_group_activity() ) : bp_get_template_part( 'groups/single/activity' ); 62 62 63 63 // Group Members 64 elseif ( bp_is_group_members() ) : bp_g et_template_part( 'groups/single/members');64 elseif ( bp_is_group_members() ) : bp_groups_members_template_part(); 65 65 66 66 // Group Invitations 67 67 elseif ( bp_is_group_invites() ) : bp_get_template_part( 'groups/single/send-invites' ); -
bp-templates/bp-legacy/buddypress/groups/single/members.php
diff --git bp-templates/bp-legacy/buddypress/groups/single/members.php bp-templates/bp-legacy/buddypress/groups/single/members.php index fb7b4e2..f1714a5 100644
1 <?php if ( bp_group_has_members( 'exclude_admins_mods=0') ) : ?>1 <?php if ( bp_group_has_members( bp_ajax_querystring( 'group_members' ) ) ) : ?> 2 2 3 3 <?php do_action( 'bp_before_group_members_content' ); ?> 4 4 5 <div class="item-list-tabs" id="subnav" role="navigation"> 6 <ul> 7 8 <?php do_action( 'bp_members_directory_member_sub_types' ); ?> 9 10 </ul> 11 </div> 12 13 <div id="pag-top" class="pagination no-ajax"> 5 <div id="pag-top" class="pagination"> 14 6 15 7 <div class="pag-count" id="member-count-top"> 16 8 … … 63 55 64 56 <?php do_action( 'bp_after_group_members_list' ); ?> 65 57 66 <div id="pag-bottom" class="pagination no-ajax">58 <div id="pag-bottom" class="pagination"> 67 59 68 60 <div class="pag-count" id="member-count-bottom"> 69 61 -
bp-templates/bp-legacy/css/buddypress.css
diff --git bp-templates/bp-legacy/css/buddypress.css bp-templates/bp-legacy/css/buddypress.css index 81dd03f..995d650 100644
body.activity-permalink #buddypress div.activity-comments div.acomment-content { 486 486 float: right; 487 487 margin: -39px 0 0 0; 488 488 } 489 #buddypress div.dir-search input[type=text] { 489 #buddypress div.dir-search input[type=text], 490 #buddypress li.groups-members-search input[type=text] { 490 491 font-size: 90%; 491 492 padding: 1px 3px; 492 493 } … … body.activity-permalink #buddypress div.activity-comments div.acomment-content { 581 582 #buddypress .standard-form select, 582 583 #buddypress .standard-form input[type=password], 583 584 #buddypress .dir-search input[type=search], 584 #buddypress .dir-search input[type=text] { 585 #buddypress .dir-search input[type=text], 586 #buddypress .groups-members-search input[type=search], 587 #buddypress .groups-members-search input[type=text] { 585 588 border: 1px solid #ccc; 586 589 background: #fafafa; 587 590 border-radius: 0; -
bp-templates/bp-legacy/js/buddypress.js
diff --git bp-templates/bp-legacy/js/buddypress.js bp-templates/bp-legacy/js/buddypress.js index 350193e..562c734 100644
jq(document).ready( function() { 17 17 bp_init_activity(); 18 18 19 19 /* Object filter and scope set. */ 20 var objects = [ 'members', 'groups', 'blogs', 'forums' ];20 var objects = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ]; 21 21 bp_init_objects( objects ); 22 22 23 23 /* @mention Compose Scrolling */ … … jq(document).ready( function() { 663 663 /**** Directory Search ****************************************************/ 664 664 665 665 /* The search form on all directory pages */ 666 jq('.dir-search ').on( 'click', function(event) {666 jq('.dir-search, .groups-members-search').on( 'click', function(event) { 667 667 if ( jq(this).hasClass('no-ajax') ) 668 668 return; 669 669 … … jq(document).ready( function() { 673 673 var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' ); 674 674 var object = css_id[0]; 675 675 676 bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') ); 676 if ( 'members' == object && 'groups' == css_id[1] ) { 677 object = 'group_members'; 678 var template = 'groups/single/members'; 679 } else { 680 var template = null; 681 } 682 683 bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras'), null, template ); 677 684 678 685 return false; 679 686 } … … jq(document).ready( function() { 721 728 if ( jq('.dir-search input').length ) 722 729 search_terms = jq('.dir-search input').val(); 723 730 731 if ( jq( '.groups-members-search input' ).length ) 732 search_terms = jq( '.groups-members-search input' ).val(); 733 734 if ( 'members' == object && 'groups' == scope ) { 735 object = 'group_members'; 736 var template = 'groups/single/members'; 737 } else { 738 var template = null; 739 } 740 724 741 if ( 'friends' == object ) 725 742 object = 'members'; 726 743 727 bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );744 bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras'), null, template ); 728 745 729 746 return false; 730 747 }); … … jq(document).ready( function() { 754 771 if ( jq('div.dir-search input').length ) 755 772 search_terms = jq('.dir-search input').val(); 756 773 774 if ( jq( '.groups-members-search input' ).length ) 775 search_terms = jq( '.groups-members-search input' ).val(); 776 777 if ( 'members' == object && 'groups' == css_id[1] ) { 778 var object = 'group_members'; 779 var template = 'groups/single/members'; 780 } else { 781 var template = null; 782 } 783 757 784 if ( jq(target).hasClass('next') ) 758 785 var page_number = Number( jq('.pagination span.current').html() ) + 1; 759 786 else if ( jq(target).hasClass('prev') ) … … jq(document).ready( function() { 767 794 var caller = null; 768 795 } 769 796 770 bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras'), caller );797 bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras'), caller, template ); 771 798 772 799 return false; 773 800 } … … jq(document).ready( function() { 966 993 }); 967 994 968 995 /* Add / Remove friendship buttons */ 969 jq( '#members-dir-list').on('click', '.friendship-button a', function() {996 jq( '#members-dir-list, #members-group-list' ).on('click', '.friendship-button a', function() { 970 997 jq(this).parent().addClass('loading'); 971 998 var fid = jq(this).attr('id'); 972 999 fid = fid.split('-'); … … function bp_init_objects(objects) { 1383 1410 } 1384 1411 1385 1412 /* Filter the current content list (groups/members/blogs/topics) */ 1386 function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller ) {1413 function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller, template ) { 1387 1414 if ( 'activity' == object ) 1388 1415 return false; 1389 1416 … … function bp_filter_request( object, filter, scope, target, search_terms, page, e 1412 1439 jq('.item-list-tabs li.selected').addClass('loading'); 1413 1440 jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true ); 1414 1441 1415 if ( 'friends' == object )1442 if ( 'friends' == object || 'group_members' == object ) { 1416 1443 object = 'members'; 1444 } 1417 1445 1418 1446 if ( bp_ajax_request ) 1419 1447 bp_ajax_request.abort(); … … function bp_filter_request( object, filter, scope, target, search_terms, page, e 1426 1454 'search_terms': search_terms, 1427 1455 'scope': scope, 1428 1456 'page': page, 1429 'extras': extras 1457 'extras': extras, 1458 'template':template 1430 1459 }, 1431 1460 function(response) 1432 1461 {