Ticket #921: 921.02.diff
File 921.02.diff, 18.4 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 de81785..a64d52d 100644
class BP_Group_Member_Query extends BP_User_Query { 1446 1446 'group_id' => 0, 1447 1447 'group_role' => array( 'member' ), 1448 1448 'is_confirmed' => true, 1449 'type' => 'last_modified' 1449 1450 ) ); 1450 1451 1451 $group_member_ids = $this->get_group_member_ids( );1452 $group_member_ids = $this->get_group_member_ids( $this->query_vars['type'] ); 1452 1453 1453 1454 // If the group member query returned no users, bail with an 1454 1455 // array that will guarantee no matches for BP_User_Query … … class BP_Group_Member_Query extends BP_User_Query { 1470 1471 * 1471 1472 * @return array $ids User IDs of relevant group member ids. 1472 1473 */ 1473 protected function get_group_member_ids( ) {1474 protected function get_group_member_ids( $type = '' ) { 1474 1475 global $wpdb; 1475 1476 1477 if ( empty( $type ) ) 1478 $type = 'last_modified'; 1479 1476 1480 if ( is_array( $this->group_member_ids ) ) { 1477 1481 return $this->group_member_ids; 1478 1482 } … … class BP_Group_Member_Query extends BP_User_Query { 1547 1551 $sql['where'] = ! empty( $sql['where'] ) ? 'WHERE ' . implode( ' AND ', $sql['where'] ) : ''; 1548 1552 1549 1553 /** ORDER BY clause ***************************************************/ 1550 1551 // @todo For now, mimicking legacy behavior of 1552 // bp_group_has_members(), which has us order by date_modified 1553 // only. Should abstract it in the future 1554 /** 1555 * The order for alphabetical type will be set in BP_Group_Member_Query->set_order_by() 1556 * In group members tables, date_modified is the 'sortable' field available 1557 * The 2 types left: last_modified and first_modified are managed here 1558 */ 1554 1559 $sql['orderby'] = "ORDER BY date_modified"; 1555 1560 $sql['order'] = "DESC"; 1556 1561 1562 if ( 'first_modified' == $type ) { 1563 $sql['order'] = "ASC"; 1564 } 1565 1557 1566 /** LIMIT clause ******************************************************/ 1558 1567 $this->group_member_ids = $wpdb->get_col( "{$sql['select']} {$sql['where']} {$sql['orderby']} {$sql['order']} {$sql['limit']}" ); 1559 1568 1560 return $this->group_member_ids; 1569 /** 1570 * You can filter the group member ids from here to build your custom query 1571 * if you defined a custom type using the action 'bp_groups_members_order_options' 1572 * for instance 1573 */ 1574 return apply_filters( 'bp_group_member_query_group_member_ids', $this->group_member_ids, $type, $this->query_vars['group_id'] ); 1561 1575 } 1562 1576 1563 1577 /** … … class BP_Group_Member_Query extends BP_User_Query { 1569 1583 * @param BP_User_Query $query BP_User_Query object. 1570 1584 */ 1571 1585 public function set_orderby( $query ) { 1572 $gm_ids = $this->get_group_member_ids(); 1586 1587 $gm_ids = $this->get_group_member_ids( $query->query_vars['type'] ); 1588 1573 1589 if ( empty( $gm_ids ) ) { 1574 1590 $gm_ids = array( 0 ); 1575 1591 } 1576 1592 1577 // The first param in the FIELD() clause is the sort column id 1578 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 1579 $gm_ids_sql = implode( ',', $gm_ids ); 1593 // No need to change the order of BP_User_Query in case type is alphabetical 1594 if ( 'alphabetical' != $query->query_vars['type'] ) { 1595 // The first param in the FIELD() clause is the sort column id 1596 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 1597 $gm_ids_sql = implode( ',', $gm_ids ); 1580 1598 1581 $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")"; 1599 $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")"; 1600 } 1582 1601 1583 1602 // Prevent this filter from running on future BP_User_Query 1584 1603 // 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 a356e1d..0f78bd2 100644
function groups_get_group_mods( $group_id ) { 373 373 * @param array|string $exclude Array or comma-sep list of users to exclude 374 374 * @return array Multi-d array of 'members' list and 'count' 375 375 */ 376 function groups_get_group_members( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false, $group_role = false ) {376 function groups_get_group_members( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false, $group_role = false, $type = false, $search_terms = false ) { 377 377 378 378 // For legacy users. Use of BP_Groups_Member::get_all_for_group() 379 379 // is deprecated. func_get_args() can't be passed to a function in PHP … … function groups_get_group_members( $group_id, $limit = false, $page = false, $ex 398 398 } 399 399 } 400 400 401 if ( empty( $type ) ) 402 $type = 'last_modified'; 403 401 404 // Perform the group member query (extends BP_User_Query) 402 405 $members = new BP_Group_Member_Query( array( 403 406 'group_id' => $group_id, … … function groups_get_group_members( $group_id, $limit = false, $page = false, $ex 405 408 'page' => $page, 406 409 'group_role' => $group_role, 407 410 'exclude' => $exclude, 408 'type' => 'last_modified', 411 'type' => $type, 412 'search_terms' => $search_terms, 409 413 ) ); 410 414 411 415 // 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 512724f..1dfa0dd 100644
class BP_Groups_Group_Members_Template { 1914 1914 var $pag_links; 1915 1915 var $total_group_count; 1916 1916 1917 function __construct( $group_id, $p er_page, $max, $exclude_admins_mods, $exclude_banned, $exclude, $group_role = false) {1917 function __construct( $group_id, $page_number, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude, $group_role = false, $type, $search_terms ) { 1918 1918 1919 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;1919 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : (int) $page_number; 1920 1920 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1921 $this->members = groups_get_group_members( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude, $group_role );1921 $this->members = groups_get_group_members( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude, $group_role, $type, $search_terms ); 1922 1922 1923 1923 if ( !$max || $max >= (int) $this->members['count'] ) 1924 1924 $this->total_member_count = (int) $this->members['count']; … … function bp_group_has_members( $args = '' ) { 1995 1995 global $members_template; 1996 1996 1997 1997 $r = wp_parse_args( $args, array( 1998 'group_id' => bp_get_current_group_id(), 1999 'per_page' => 20, 2000 'max' => false, 2001 'exclude' => false, 1998 'group_id' => bp_get_current_group_id(), 1999 'page' => 1, 2000 'per_page' => 20, 2001 'max' => false, 2002 'exclude' => false, 2002 2003 'exclude_admins_mods' => 1, 2003 'exclude_banned' => 1, 2004 'group_role' => false, 2004 'exclude_banned' => 1, 2005 'group_role' => false, 2006 'type' => 'last_modified', 2007 'search_terms' => false 2005 2008 ) ); 2006 2009 2007 $members_template = new BP_Groups_Group_Members_Template( $r['group_id'], $r['per_page'], $r['max'], (int) $r['exclude_admins_mods'], (int) $r['exclude_banned'], $r['exclude'], $r['group_role'] ); 2010 if ( empty( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) 2011 $r['search_terms'] = $_REQUEST['s']; 2012 2013 $members_template = new BP_Groups_Group_Members_Template( $r['group_id'], $r['page'], $r['per_page'], $r['max'], (int) $r['exclude_admins_mods'], (int) $r['exclude_banned'], $r['exclude'], $r['group_role'], $r['type'], $r['search_terms'] ); 2008 2014 return apply_filters( 'bp_group_has_members', $members_template->has_members(), $members_template ); 2009 2015 } 2010 2016 … … function bp_group_member_admin_pagination() { 2180 2186 return $members_template->pag_links; 2181 2187 } 2182 2188 2189 /** 2190 * Output the Group members template 2191 * 2192 * @since BuddyPress (?) 2193 * 2194 * @return string html output 2195 */ 2196 function bp_groups_members_template_part() { 2197 ?> 2198 <div class="item-list-tabs" id="subnav" role="navigation"> 2199 <ul> 2200 <li class="groups-members-search" role="search"> 2201 <?php bp_directory_members_search_form(); ?> 2202 </li> 2203 2204 <?php bp_groups_members_filter(); ?> 2205 <?php do_action( 'bp_members_directory_member_sub_types' ); ?> 2206 2207 </ul> 2208 </div> 2209 2210 <div id="members-group-list" class="group_members dir-list"> 2211 2212 <?php bp_get_template_part( 'groups/single/members' ); ?> 2213 2214 </div> 2215 <?php 2216 } 2217 2218 /** 2219 * Output the Group members filters 2220 * 2221 * @since BuddyPress (?) 2222 * 2223 * @return string html output 2224 */ 2225 function bp_groups_members_filter() { 2226 ?> 2227 <li id="group_members-order-select" class="last filter"> 2228 <label for="group_members-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label> 2229 <select id="group_members-order-by"> 2230 <option value="last_modified"><?php _e( 'Newest', 'buddypress' ); ?></option> 2231 <option value="first_modified"><?php _e( 'Oldest', 'buddypress' ); ?></option> 2232 <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> 2233 2234 <?php do_action( 'bp_groups_members_order_options' ); ?> 2235 2236 </select> 2237 </li> 2238 <?php 2239 } 2183 2240 2184 2241 /*************************************************************************** 2185 2242 * 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..eeddc24 100644
function bp_legacy_theme_ajax_querystring( $query_string, $object ) { 448 448 449 449 $qs = array(); 450 450 451 /* Single Group Members specific case */ 452 if ( bp_is_group_members() ) { 453 $object = 'group_members'; 454 $qs[] = 'exclude_admins_mods=0'; 455 } 456 451 457 /** 452 458 * Check if any cookie values are set. If there are then override the 453 459 * default params passed to the template loop. … … function bp_legacy_theme_object_template_loader() { 541 547 if ( ! bp_current_action() ) 542 548 bp_update_is_directory( true, bp_current_component() ); 543 549 550 $template_part = $object . '/' . $object . '-loop'; 551 552 if ( ! empty( $_POST['template'] ) ) 553 $template_part = sanitize_option( 'upload_path', $_POST['template'] ); 554 544 555 // Locate the object template 545 bp_get_template_part( "$object/$object-loop");556 bp_get_template_part( $template_part ); 546 557 exit(); 547 558 } 548 559 -
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 {