Ticket #921: 921.diff
File 921.diff, 20.0 KB (added by , 11 years ago) |
---|
-
bp-templates/bp-legacy/buddypress-functions.php
134 134 'forums_filter' => 'bp_legacy_theme_object_template_loader', 135 135 'groups_filter' => 'bp_legacy_theme_object_template_loader', 136 136 'members_filter' => 'bp_legacy_theme_object_template_loader', 137 'groupmembers_filter' => 'bp_legacy_theme_object_template_loader', 137 138 'messages_filter' => 'bp_legacy_theme_messages_template_loader', 138 139 139 140 // Friends … … 444 445 445 446 $qs = array(); 446 447 448 if( 'groupmembers' == $object ) { 449 if( bp_is_group_admin_screen( 'manage-members' ) ) { 450 $qs[] = 'per_page=15'; 451 $qs[] = 'exclude_banned=false'; 452 } else { 453 $qs[] = 'exclude_admins_mods=0'; 454 } 455 } 456 447 457 /** 448 458 * Check if any cookie values are set. If there are then override the 449 459 * default params passed to the template loop. … … 524 534 // Sanitize the object 525 535 $object = sanitize_title( $_POST['object'] ); 526 536 537 $template_folder = $component = $object; 538 539 if( 'groupmembers' == $object ) { 540 $component = 'groups'; 541 $template_folder = 'groups/single'; 542 543 //pagination 544 if( !empty( $_POST['page'] ) ) { 545 $_REQUEST['mlpage'] = $_REQUEST['page']; 546 unset( $_REQUEST['page'] ); 547 } 548 } 549 527 550 // Bail if object is not an active component to prevent arbitrary file inclusion 528 if ( ! bp_is_active( $ object ) )551 if ( ! bp_is_active( $component ) ) 529 552 return; 530 553 531 554 /** … … 538 561 bp_update_is_directory( true, bp_current_component() ); 539 562 540 563 // Locate the object template 541 bp_get_template_part( "$ object/$object-loop" );564 bp_get_template_part( "$template_folder/$object-loop" ); 542 565 exit(); 543 566 } 544 567 -
bp-templates/bp-legacy/buddypress/groups/single/members.php
1 <?php if ( bp_group_has_members( 'exclude_admins_mods=0' ) ) : ?> 1 <div class="item-list-tabs" id="subnav" role="navigation"> 2 <ul> 2 3 3 <?php do_action( 'bp_before_group_members_content' ); ?>4 <?php do_action( 'bp_members_directory_member_sub_types' ); ?> 4 5 5 <div class="item-list-tabs" id="subnav" role="navigation"> 6 <ul> 6 <?php bp_group_members_filter(); ?> 7 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">14 15 <div class="pag-count" id="member-count-top">16 17 <?php bp_members_pagination_count(); ?>18 19 </div>20 21 <div class="pagination-links" id="member-pag-top">22 23 <?php bp_members_pagination_links(); ?>24 25 </div>26 27 </div>28 29 <?php do_action( 'bp_before_group_members_list' ); ?>30 31 <ul id="member-list" class="item-list" role="main">32 33 <?php while ( bp_group_members() ) : bp_group_the_member(); ?>34 35 <li>36 <a href="<?php bp_group_member_domain(); ?>">37 38 <?php bp_group_member_avatar_thumb(); ?>39 40 </a>41 42 <h5><?php bp_group_member_link(); ?></h5>43 <span class="activity"><?php bp_group_member_joined_since(); ?></span>44 45 <?php do_action( 'bp_group_members_list_item' ); ?>46 47 <?php if ( bp_is_active( 'friends' ) ) : ?>48 49 <div class="action">50 51 <?php bp_add_friend_button( bp_get_group_member_id(), bp_get_group_member_is_friend() ); ?>52 53 <?php do_action( 'bp_group_members_list_item_action' ); ?>54 55 </div>56 57 <?php endif; ?>58 </li>59 60 <?php endwhile; ?>61 62 8 </ul> 9 </div> 63 10 64 <?php do_action( 'bp_after_group_members_list' ); ?>65 11 66 <div id="pag-bottom" class="pagination no-ajax">67 12 68 <div class="pag-count" id="member-count-bottom">13 <?php do_action( 'bp_before_group_members_list' ); ?> 69 14 70 <?php bp_members_pagination_count(); ?>15 <div class="groupmembers" role="main"> 71 16 72 </div>17 <?php bp_get_template_part( 'groups/single/groupmembers-loop' ); ?> 73 18 74 <div class="pagination-links" id="member-pag-bottom"> 75 76 <?php bp_members_pagination_links(); ?> 77 78 </div> 79 80 </div> 81 82 <?php do_action( 'bp_after_group_members_content' ); ?> 83 84 <?php else: ?> 85 86 <div id="message" class="info"> 87 <p><?php _e( 'This group has no members.', 'buddypress' ); ?></p> 88 </div> 89 90 <?php endif; ?> 19 </div> -
bp-templates/bp-legacy/buddypress/groups/single/admin.php
230 230 <div class="bp-widget"> 231 231 <h4><?php _e("Members", "buddypress"); ?></h4> 232 232 233 < ?php if ( bp_group_has_members( 'per_page=15&exclude_banned=false' ) ) : ?>233 <div class="groupmembers" role="main"> 234 234 235 <?php if ( bp_group_member_needs_pagination() ) :?>235 <?php bp_get_template_part( 'groups/single/groupmembers-loop' ); ?> 236 236 237 <div class="pagination no-ajax">237 </div> 238 238 239 <div id="member-count" class="pag-count">240 <?php bp_group_member_pagination_count(); ?>241 </div>242 243 <div id="member-admin-pagination" class="pagination-links">244 <?php bp_group_member_admin_pagination(); ?>245 </div>246 247 </div>248 249 <?php endif; ?>250 251 <ul id="members-list" class="item-list single-line">252 <?php while ( bp_group_members() ) : bp_group_the_member(); ?>253 254 <li class="<?php bp_group_member_css_class(); ?>">255 <?php bp_group_member_avatar_mini(); ?>256 257 <h5>258 <?php bp_group_member_link(); ?>259 260 <?php if ( bp_get_group_member_is_banned() ) _e( '(banned)', 'buddypress' ); ?>261 262 <span class="small">263 264 <?php if ( bp_get_group_member_is_banned() ) : ?>265 266 <a href="<?php bp_group_member_unban_link(); ?>" class="button confirm member-unban" title="<?php _e( 'Unban this member', 'buddypress' ); ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a>267 268 <?php else : ?>269 270 <a href="<?php bp_group_member_ban_link(); ?>" class="button confirm member-ban" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick & Ban', 'buddypress' ); ?></a>271 <a href="<?php bp_group_member_promote_mod_link(); ?>" class="button confirm member-promote-to-mod" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a>272 <a href="<?php bp_group_member_promote_admin_link(); ?>" class="button confirm member-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a>273 274 <?php endif; ?>275 276 <a href="<?php bp_group_member_remove_link(); ?>" class="button confirm" title="<?php _e( 'Remove this member', 'buddypress' ); ?>"><?php _e( 'Remove from group', 'buddypress' ); ?></a>277 278 <?php do_action( 'bp_group_manage_members_admin_item' ); ?>279 280 </span>281 </h5>282 </li>283 284 <?php endwhile; ?>285 </ul>286 287 <?php else: ?>288 289 <div id="message" class="info">290 <p><?php _e( 'This group has no members.', 'buddypress' ); ?></p>291 </div>292 293 <?php endif; ?>294 295 239 </div> 296 240 297 241 <?php do_action( 'bp_after_group_manage_members_admin' ); ?> -
bp-templates/bp-legacy/js/buddypress.js
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', 'groupmembers' ]; 21 21 bp_init_objects( objects ); 22 22 23 23 /* @mention Compose Scrolling */ … … 703 703 704 704 return false; 705 705 } 706 706 707 }); 707 708 708 709 /* When the filter select box is changed re-query */ … … 724 725 if ( 'friends' == object ) 725 726 object = 'members'; 726 727 728 if( jq(this).attr('id').indexOf( 'groupmembers' ) != -1 ) 729 object = 'groupmembers'; 730 727 731 bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); 728 732 729 733 return false; … … 760 764 else 761 765 var page_number = Number( jq(target).html() ); 762 766 767 if( target.parent().attr('id').indexOf( 'groupmembers' ) != -1 ) 768 object = 'groupmembers'; 769 763 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') ); 764 771 765 772 return false; -
bp-groups/bp-groups-classes.php
1046 1046 1047 1047 $bp = buddypress(); 1048 1048 $sql = array( 1049 'select' => "SELECT user_id FROM {$bp->groups->table_name_members}",1049 'select' => "SELECT gm.user_id FROM {$bp->groups->table_name_members} gm", 1050 1050 'where' => array(), 1051 1051 'orderby' => '', 1052 1052 'order' => '', … … 1056 1056 /** WHERE clauses *****************************************************/ 1057 1057 1058 1058 // Group id 1059 $sql['where'][] = $wpdb->prepare( "g roup_id = %d", $this->query_vars['group_id'] );1059 $sql['where'][] = $wpdb->prepare( "gm.group_id = %d", $this->query_vars['group_id'] ); 1060 1060 1061 1061 // is_confirmed 1062 1062 $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0; 1063 $sql['where'][] = $wpdb->prepare( " is_confirmed = %d", $is_confirmed );1063 $sql['where'][] = $wpdb->prepare( "gm.is_confirmed = %d", $is_confirmed ); 1064 1064 1065 1065 // Role information is stored as follows: admins have 1066 1066 // is_admin = 1, mods have is_mod = 1, banned have is_banned = … … 1087 1087 if ( in_array( 'member', $roles ) ) { 1088 1088 $role_columns = array(); 1089 1089 foreach ( array_diff( $allowed_roles, $roles ) as $excluded_role ) { 1090 $role_columns[] = ' is_' . $excluded_role . ' = 0';1090 $role_columns[] = 'gm.is_' . $excluded_role . ' = 0'; 1091 1091 } 1092 1092 1093 1093 if ( ! empty( $role_columns ) ) { … … 1099 1099 } else { 1100 1100 $role_columns = array(); 1101 1101 foreach ( $roles as $role ) { 1102 $role_columns[] = ' is_' . $role . ' = 1';1102 $role_columns[] = 'gm.is_' . $role . ' = 1'; 1103 1103 } 1104 1104 1105 1105 if ( ! empty( $role_columns ) ) { … … 1111 1111 $sql['where'][] = $roles_sql; 1112 1112 } 1113 1113 1114 $type = $this->query_vars_raw['type']; 1115 $orderby = 'gm.date_modified'; 1116 $order = 'DESC'; 1117 1118 switch( $type ) { 1119 1120 case 'first_modified' : 1121 $order = 'ASC'; 1122 break; 1123 1124 case 'alphabetical' : 1125 1126 if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) { 1127 $sql['select'] .= " LEFT JOIN {$wpdb->users} u ON( gm.user_id = u.ID )"; 1128 $orderby = "u.display_name"; 1129 $order = "ASC"; 1130 1131 // When profile sync is disabled, alphabetical sorts must happen against 1132 // the xprofile table 1133 } else { 1134 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 1135 1136 $sql['select'] = " LEFT JOIN {$bp->profile->table_name_data} u ON( gm.user_id = u.user_id )"; 1137 $sql['where'][] = "u.field_id = {$fullname_field_id}"; 1138 $orderby = "u.value"; 1139 $order = "ASC"; 1140 } 1141 break; 1142 1143 case 'last_active' : 1144 1145 if( bp_is_active( 'activity') ) { 1146 $group_member_last_activity = $wpdb->get_results( 1147 $wpdb->prepare( "SELECT user_id, MAX(date_recorded) last_active FROM {$bp->activity->table_name} WHERE component = %s AND item_id = %d GROUP BY user_id ORDER BY last_active DESC", 'groups', $this->query_vars['group_id'] ) 1148 ); 1149 1150 foreach( $group_member_last_activity as $member_last ) 1151 $gm_ids[] = $member_last->user_id; 1152 1153 $gm_ids = array_merge( array( 'gm.user_id' ), $gm_ids ); 1154 1155 $orderby = "FIELD(" . implode( ',', $gm_ids ) . ")"; 1156 $order = ""; 1157 } 1158 break; 1159 1160 case 'user_friends' : 1161 1162 if ( bp_is_active( 'friends' ) ) { 1163 $friends = friends_get_friend_user_ids( bp_loggedin_user_id() ); 1164 if ( !empty( $friends ) ) 1165 $sql['where'][] = "gm.user_id IN(". implode(',', $friends ) .")"; 1166 else 1167 $sql['where'][] = "gm.user_id IN(0)"; 1168 } 1169 1170 break; 1171 } 1172 1114 1173 $sql['where'] = ! empty( $sql['where'] ) ? 'WHERE ' . implode( ' AND ', $sql['where'] ) : ''; 1115 1174 1116 1175 /** ORDER BY clause ***************************************************/ … … 1118 1177 // @todo For now, mimicking legacy behavior of 1119 1178 // bp_group_has_members(), which has us order by date_modified 1120 1179 // only. Should abstract it in the future 1121 $sql['orderby'] = "ORDER BY date_modified";1122 $sql['order'] = "DESC";1123 1180 1181 $sql['orderby'] = "ORDER BY {$orderby}"; 1182 $sql['order'] = $order; 1183 1124 1184 /** LIMIT clause ******************************************************/ 1125 1185 $this->group_member_ids = $wpdb->get_col( "{$sql['select']} {$sql['where']} {$sql['orderby']} {$sql['order']} {$sql['limit']}" ); 1126 1186 -
bp-groups/bp-groups-functions.php
391 391 * @param array|string $exclude Array or comma-sep list of users to exclude 392 392 * @return array Multi-d array of 'members' list and 'count' 393 393 */ 394 function groups_get_group_members( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false, $group_role = false ) {394 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 ) { 395 395 396 396 // For legacy users. Use of BP_Groups_Member::get_all_for_group() 397 397 // is deprecated. func_get_args() can't be passed to a function in PHP … … 416 416 } 417 417 } 418 418 419 if( empty( $type ) ) 420 $type = 'last_modified'; 421 419 422 // Perform the group member query (extends BP_User_Query) 420 423 $members = new BP_Group_Member_Query( array( 421 424 'group_id' => $group_id, … … 423 426 'page' => $page, 424 427 'group_role' => $group_role, 425 428 'exclude' => $exclude, 426 'type' => 'last_modified',429 'type' => $type, 427 430 ) ); 428 431 429 432 // Structure the return value as expected by the template functions -
bp-groups/bp-groups-template.php
1345 1345 function bp_get_group_member_promote_mod_link( $args = '' ) { 1346 1346 global $members_template, $groups_template; 1347 1347 1348 if ( !empty( $groups_template ) ) 1349 $group =& $groups_template->group; 1350 1351 else 1352 $group = groups_get_current_group(); 1353 1348 1354 $defaults = array( 1349 1355 'user_id' => $members_template->member->user_id, 1350 'group' => &$groups_template->group1356 'group' => $group 1351 1357 ); 1352 1358 1353 1359 $r = wp_parse_args( $args, $defaults ); … … 1362 1368 function bp_get_group_member_promote_admin_link( $args = '' ) { 1363 1369 global $members_template, $groups_template; 1364 1370 1371 if ( !empty( $groups_template ) ) 1372 $group =& $groups_template->group; 1373 1374 else 1375 $group = groups_get_current_group(); 1376 1365 1377 $defaults = array( 1366 1378 'user_id' => !empty( $members_template->member->user_id ) ? $members_template->member->user_id : false, 1367 'group' => &$groups_template->group1379 'group' => $group 1368 1380 ); 1369 1381 1370 1382 $r = wp_parse_args( $args, $defaults ); … … 1384 1396 function bp_get_group_member_demote_link( $user_id = 0, $group = false ) { 1385 1397 global $members_template, $groups_template; 1386 1398 1387 if ( empty( $group ) )1399 if ( empty( $group ) && !empty( $groups_template ) ) 1388 1400 $group =& $groups_template->group; 1389 1401 1402 else 1403 $group = groups_get_current_group(); 1404 1390 1405 if ( !$user_id ) 1391 1406 $user_id = $members_template->member->user_id; 1392 1407 … … 1404 1419 function bp_get_group_member_ban_link( $user_id = 0, $group = false ) { 1405 1420 global $groups_template; 1406 1421 1407 if ( empty( $group ) )1422 if ( empty( $group ) && !empty( $groups_template ) ) 1408 1423 $group =& $groups_template->group; 1409 1424 1425 else 1426 $group = groups_get_current_group(); 1427 1410 1428 return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id, 'groups_ban_member' ) ); 1411 1429 } 1412 1430 … … 1424 1442 if ( !$user_id ) 1425 1443 $user_id = $members_template->member->user_id; 1426 1444 1427 if ( empty( $group ) )1445 if ( empty( $group ) && !empty( $groups_template ) ) 1428 1446 $group =& $groups_template->group; 1429 1447 1448 else 1449 $group = groups_get_current_group(); 1450 1430 1451 return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) ); 1431 1452 } 1432 1453 … … 1442 1463 function bp_get_group_member_remove_link( $user_id = 0, $group = false ) { 1443 1464 global $groups_template; 1444 1465 1445 if ( empty( $group ) )1466 if ( empty( $group ) && !empty( $groups_template ) ) 1446 1467 $group =& $groups_template->group; 1447 1468 1469 else 1470 $group = groups_get_current_group(); 1471 1448 1472 return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id, 'groups_remove_member' ) ); 1449 1473 } 1450 1474 … … 1897 1921 var $pag_links; 1898 1922 var $total_group_count; 1899 1923 1900 function __construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude, $group_role = false ) {1924 function __construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude, $group_role = false, $type = false ) { 1901 1925 1902 1926 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 1903 1927 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1904 $this->members = groups_get_group_members( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude, $group_role );1928 $this->members = groups_get_group_members( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude, $group_role, $type ); 1905 1929 1906 1930 if ( !$max || $max >= (int) $this->members['count'] ) 1907 1931 $this->total_member_count = (int) $this->members['count']; … … 1985 2009 'exclude_admins_mods' => 1, 1986 2010 'exclude_banned' => 1, 1987 2011 'group_role' => false, 2012 'type' => false, 1988 2013 ) ); 1989 2014 1990 $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'] );2015 $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'], $r['type'] ); 1991 2016 return apply_filters( 'bp_group_has_members', $members_template->has_members(), $members_template ); 1992 2017 } 1993 2018 … … 2163 2188 return $members_template->pag_links; 2164 2189 } 2165 2190 2191 /** group members filters **/ 2166 2192 2193 function bp_group_members_filter() { 2194 ?> 2195 <li id="groupmembers-order-select" class="last filter"> 2196 <label for="groupmembers-order-by"><?php _e( 'Filter By:', 'buddypress' ); ?></label> 2197 <select id="groupmembers-order-by"> 2198 <option value="last_modified"><?php _e( 'Newest', 'buddypress' ); ?></option> 2199 <option value="first_modified"><?php _e( 'Oldest', 'buddypress' ); ?></option> 2200 <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> 2201 2202 <?php if ( bp_is_active( 'activity' ) ) : ?> 2203 <option value="last_active"><?php _e( 'Active', 'buddypress' ); ?></option> 2204 <?php endif; ?> 2205 2206 <?php if ( bp_is_active( 'friends' ) ) : ?> 2207 <option value="user_friends"><?php _e( 'Friends', 'buddypress' ); ?></option> 2208 <?php endif; ?> 2209 2210 <?php do_action( 'bp_group_members_order_options' ); ?> 2211 </select> 2212 </li> 2213 <?php 2214 } 2215 2216 function bp_group_members_admin_filter( $current_tab = '', $group_slug = '' ) { 2217 if ( bp_is_group_admin_screen( 'manage-members' ) ) 2218 bp_group_members_filter(); 2219 } 2220 2221 add_action( 'groups_admin_tabs', 'bp_group_members_admin_filter', 10, 2 ); 2222 2223 2167 2224 /*************************************************************************** 2168 2225 * Group Creation Process Template Tags 2169 2226 **/