Changeset 9982 for trunk/src/bp-groups/classes/class-bp-groups-group.php
- Timestamp:
- 06/30/2015 06:22:31 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-groups-group.php
r9906 r9982 1 1 <?php 2 2 /** 3 * BuddyPress Groups Classes 3 * BuddyPress Groups Classes. 4 4 * 5 5 * @package BuddyPress … … 160 160 * @param array $args { 161 161 * Array of optional arguments. 162 * @type bool $populate_extras Whether to fetch "extra" data about 163 * the group(group admins/mods, access for the current user).164 * Default: false.162 * @type bool $populate_extras Whether to fetch "extra" data about the group 163 * (group admins/mods, access for the current user). 164 * Default: false. 165 165 * } 166 166 */ … … 444 444 * 445 445 * @param string $slug See {@link BP_Groups_Group::group_exists()}. 446 * 446 447 * @return string|null See {@link BP_Groups_Group::group_exists()}. 447 448 */ … … 455 456 * @param int $user_id ID of the inviting user. 456 457 * @param int $group_id ID of the group. 458 * 457 459 * @return array IDs of users who have been invited to the group by the 458 * user but have not yet accepted.460 * user but have not yet accepted. 459 461 */ 460 462 public static function get_invites( $user_id, $group_id ) { … … 469 471 * Get a list of a user's groups, filtered by a search string. 470 472 * 471 * @param string $filterSearch term. Matches against 'name' and472 * 'description' fields.473 * @param int $user_id ID of the user whose groups are being searched.474 * Default: the displayed user.475 * @param mixed $orderNot used.476 * @param int|null $limit Optional. The max number of results to return.477 * Default: null (no limit).478 * @param int|null $page Optional. The page offset of results to return.479 * Default: null (no limit).473 * @param string $filter Search term. Matches against 'name' and 474 * 'description' fields. 475 * @param int $user_id ID of the user whose groups are being searched. 476 * Default: the displayed user. 477 * @param mixed $order Not used. 478 * @param int|null $limit Optional. The max number of results to return. 479 * Default: null (no limit). 480 * @param int|null $page Optional. The page offset of results to return. 481 * Default: null (no limit). 480 482 * @return false|array { 481 483 * @type array $groups Array of matched and paginated group objects. 482 * @type int $totalTotal count of groups matching the query.484 * @type int $total Total count of groups matching the query. 483 485 * } 484 486 */ … … 515 517 * Get a list of groups, filtered by a search string. 516 518 * 517 * @param string $filterSearch term. Matches against 'name' and518 * 'description' fields.519 * @param int|null $limitOptional. The max number of results to return.520 * Default: null (no limit).521 * @param int|null $pageOptional. The page offset of results to return.522 * Default: null (no limit).519 * @param string $filter Search term. Matches against 'name' and 520 * 'description' fields. 521 * @param int|null $limit Optional. The max number of results to return. 522 * Default: null (no limit). 523 * @param int|null $page Optional. The page offset of results to return. 524 * Default: null (no limit). 523 525 * @param string|bool $sort_by Column to sort by. Default: false (default 524 526 * sort). 525 * @param string|bool $order ASC or DESC. Default: false (default sort). 527 * @param string|bool $order ASC or DESC. Default: false (default sort). 528 * 526 529 * @return array { 527 530 * @type array $groups Array of matched and paginated group objects. 528 * @type int $totalTotal count of groups matching the query.531 * @type int $total Total count of groups matching the query. 529 532 * } 530 533 */ … … 560 563 * 561 564 * @param string $slug Slug to check. 565 * 562 566 * @return string|null The slug, if found. Otherwise null. 563 567 */ … … 574 578 * 575 579 * @param int $group_id ID of the group. 580 * 576 581 * @return string|null The slug, if found. Otherwise null. 577 582 */ … … 588 593 * 589 594 * @param int $group_id ID of the group. 595 * 590 596 * @return bool True if the group has members, otherwise false. 591 597 */ … … 607 613 * 608 614 * @param int $group_id ID of the group. 615 * 609 616 * @return int|null The number of outstanding requests, or null if 610 * none are found.617 * none are found. 611 618 */ 612 619 public static function has_membership_requests( $group_id ) { … … 621 628 * Get outstanding membership requests for a group. 622 629 * 623 * @param int $group_id ID of the group.624 * @param int|null $limit Optional. Max number of results to return.625 * Default: null (no limit).626 * @param int|null $page Optional. Page offset of results returned. Default:627 * null (no limit).630 * @param int $group_id ID of the group. 631 * @param int|null $limit Optional. Max number of results to return. 632 * Default: null (no limit). 633 * @param int|null $page Optional. Page offset of results returned. Default: 634 * null (no limit). 628 635 * @return array { 629 636 * @type array $requests The requested page of located requests. 630 * @type int $totalTotal number of requests outstanding for the631 * group.637 * @type int $total Total number of requests outstanding for the 638 * group. 632 639 * } 633 640 */ … … 655 662 * @param array { 656 663 * Array of parameters. All items are optional. 657 * @type string $type Optional. Shorthand for certain orderby/ 658 * order combinations. 'newest', 'active', 'popular', 659 * 'alphabetical', 'random'. When present, will override 660 * orderby and order params. Default: null. 661 * @type string $orderby Optional. Property to sort by. 662 * 'date_created', 'last_activity', 'total_member_count', 663 * 'name', 'random'. Default: 'date_created'. 664 * @type string $order Optional. Sort order. 'ASC' or 'DESC'. 665 * Default: 'DESC'. 666 * @type int $per_page Optional. Number of items to return per page 667 * of results. Default: null (no limit). 668 * @type int $page Optional. Page offset of results to return. 669 * Default: null (no limit). 670 * @type int $user_id Optional. If provided, results will be limited 671 * to groups of which the specified user is a member. Default: 672 * null. 673 * @type string $search_terms Optional. If provided, only groups 674 * whose names or descriptions match the search terms will be 675 * returned. Default: false. 676 * @type array $meta_query Optional. An array of meta_query 677 * conditions. See {@link WP_Meta_Query::queries} for 678 * description. 679 * @type array|string Optional. Array or comma-separated list of 680 * group IDs. Results will be limited to groups within the 681 * list. Default: false. 682 * @type bool $populate_extras Whether to fetch additional 683 * information (such as member count) about groups. Default: 684 * true. 685 * @type array|string $exclude Optional. Array or comma-separated 686 * list of group IDs. Results will exclude the listed groups. 687 * Default: false. 688 * @type bool $update_meta_cache Whether to pre-fetch groupmeta for 689 * the returned groups. Default: true. 690 * @type bool $show_hidden Whether to include hidden groups in 691 * results. Default: false. 664 * @type string $type Optional. Shorthand for certain orderby/ 665 * order combinations. 'newest', 'active', 'popular', 666 * 'alphabetical', 'random'. When present, will override 667 * orderby and order params. Default: null. 668 * @type string $orderby Optional. Property to sort by. 669 * 'date_created', 'last_activity', 'total_member_count', 670 * 'name', 'random'. Default: 'date_created'. 671 * @type string $order Optional. Sort order. 'ASC' or 'DESC'. 672 * Default: 'DESC'. 673 * @type int $per_page Optional. Number of items to return per page 674 * of results. Default: null (no limit). 675 * @type int $page Optional. Page offset of results to return. 676 * Default: null (no limit). 677 * @type int $user_id Optional. If provided, results will be limited to groups 678 * of which the specified user is a member. Default: null. 679 * @type string $search_terms Optional. If provided, only groups whose names 680 * or descriptions match the search terms will be 681 * returned. Default: false. 682 * @type array $meta_query Optional. An array of meta_query conditions. 683 * See {@link WP_Meta_Query::queries} for description. 684 * @type array|string $value Optional. Array or comma-separated list of group IDs. 685 * Results will be limited to groups within the 686 * list. Default: false. 687 * @type bool $populate_extras Whether to fetch additional information 688 * (such as member count) about groups. Default: true. 689 * @type array|string $exclude Optional. Array or comma-separated list of group IDs. 690 * Results will exclude the listed groups. Default: false. 691 * @type bool $update_meta_cache Whether to pre-fetch groupmeta for 692 * the returned groups. Default: true. 693 * @type bool $show_hidden Whether to include hidden groups in results. Default: false. 692 694 * } 693 695 * @return array { 694 696 * @type array $groups Array of group objects returned by the 695 * paginated query.696 * @type int $totalTotal count of all groups matching non-697 * paginated query params.697 * paginated query. 698 * @type int $total Total count of all groups matching non- 699 * paginated query params. 698 700 * } 699 701 */ … … 953 955 * 954 956 * @param array $meta_query An array of meta_query filters. See the 955 * documentation for {@link WP_Meta_Query} for details. 957 * documentation for {@link WP_Meta_Query} for details. 958 * 956 959 * @return array $sql_array 'join' and 'where' clauses. 957 960 */ … … 1000 1003 * 1001 1004 * @param string $type The 'type' shorthand param. 1005 * 1002 1006 * @return array { 1003 * @type string $order SQL-friendly order string.1007 * @type string $order SQL-friendly order string. 1004 1008 * @type string $orderby SQL-friendly orderby column name. 1005 1009 * } … … 1039 1043 1040 1044 /** 1041 * Convert the 'orderby' param into a proper SQL term/column.1042 *1043 * @since BuddyPress (1.8.0)1044 * @access protected1045 *1046 * @param string $orderby Orderby term as passed to get().1047 * @return string $order_by_term SQL-friendly orderby term.1048 */1049 protected static function convert_orderby_to_order_by_term( $orderby ) {1050 $order_by_term = '';1051 1052 switch ( $orderby ) {1053 case 'date_created' :1054 default :1055 $order_by_term = 'g.date_created';1056 break;1057 1058 case 'last_activity' :1059 $order_by_term = 'last_activity';1060 break;1061 1062 case 'total_member_count' :1063 $order_by_term = 'CONVERT(gm1.meta_value, SIGNED)';1064 break;1065 1066 case 'name' :1067 $order_by_term = 'g.name';1068 break;1069 1070 case 'random' :1071 $order_by_term = 'rand()';1072 break;1073 }1074 1075 return $order_by_term;1076 }1077 1078 /**1079 1045 * Get a list of groups, sorted by those that have the most legacy forum topics. 1080 1046 * 1081 * @param int|null $limit Optional. The max number of results to return. 1082 * Default: null (no limit). 1083 * @param int|null $page Optional. The page offset of results to return. 1084 * Default: null (no limit). 1085 * @param int $user_id Optional. If present, groups will be limited to 1086 * those of which the specified user is a member. 1087 * @param string|bool $search_terms Optional. Limit groups to those whose 1088 * name or description field contain the search string. 1089 * @param bool $populate_extras Optional. Whether to fetch extra 1090 * information about the groups. Default: true. 1091 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1092 * IDs to exclude from results. 1047 * @param int|null $limit Optional. The max number of results to return. 1048 * Default: null (no limit). 1049 * @param int|null $page Optional. The page offset of results to return. 1050 * Default: null (no limit). 1051 * @param int $user_id Optional. If present, groups will be limited to 1052 * those of which the specified user is a member. 1053 * @param string|bool $search_terms Optional. Limit groups to those whose name 1054 * or description field contain the search string. 1055 * @param bool $populate_extras Optional. Whether to fetch extra 1056 * information about the groups. Default: true. 1057 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1058 * IDs to exclude from results. 1059 * 1093 1060 * @return array { 1094 1061 * @type array $groups Array of group objects returned by the 1095 * paginated query.1096 * @type int $totalTotal count of all groups matching non-1097 * paginated query params.1062 * paginated query. 1063 * @type int $total Total count of all groups matching non- 1064 * paginated query params. 1098 1065 * } 1099 1066 */ … … 1146 1113 1147 1114 /** 1115 * Convert the 'orderby' param into a proper SQL term/column. 1116 * 1117 * @since BuddyPress (1.8.0) 1118 * @access protected 1119 * 1120 * @param string $orderby Orderby term as passed to get(). 1121 * 1122 * @return string $order_by_term SQL-friendly orderby term. 1123 */ 1124 protected static function convert_orderby_to_order_by_term( $orderby ) { 1125 $order_by_term = ''; 1126 1127 switch ( $orderby ) { 1128 case 'date_created' : 1129 default : 1130 $order_by_term = 'g.date_created'; 1131 break; 1132 1133 case 'last_activity' : 1134 $order_by_term = 'last_activity'; 1135 break; 1136 1137 case 'total_member_count' : 1138 $order_by_term = 'CONVERT(gm1.meta_value, SIGNED)'; 1139 break; 1140 1141 case 'name' : 1142 $order_by_term = 'g.name'; 1143 break; 1144 1145 case 'random' : 1146 $order_by_term = 'rand()'; 1147 break; 1148 } 1149 1150 return $order_by_term; 1151 } 1152 1153 /** 1148 1154 * Get a list of groups, sorted by those that have the most legacy forum posts. 1149 1155 * 1150 * @param int|null $limit Optional. The max number of results to return. 1151 * Default: null (no limit). 1152 * @param int|null $page Optional. The page offset of results to return. 1153 * Default: null (no limit). 1154 * @param string|bool $search_terms Optional. Limit groups to those whose 1155 * name or description field contain the search string. 1156 * @param bool $populate_extras Optional. Whether to fetch extra 1157 * information about the groups. Default: true. 1158 * @param string|array|bool Optional. Array or comma-separated list of group 1159 * IDs to exclude from results. 1156 * @param int|null $limit Optional. The max number of results to return. 1157 * Default: null (no limit). 1158 * @param int|null $page Optional. The page offset of results to return. 1159 * Default: null (no limit). 1160 * @param string|bool $search_terms Optional. Limit groups to those whose name 1161 * or description field contain the search string. 1162 * @param bool $populate_extras Optional. Whether to fetch extra 1163 * information about the groups. Default: true. 1164 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1165 * IDs to exclude from results. 1166 * 1160 1167 * @return array { 1161 1168 * @type array $groups Array of group objects returned by the 1162 * paginated query.1163 * @type int $totalTotal count of all groups matching non-1164 * paginated query params.1169 * paginated query. 1170 * @type int $total Total count of all groups matching non- 1171 * paginated query params. 1165 1172 * } 1166 1173 */ … … 1215 1222 * Get a list of groups whose names start with a given letter. 1216 1223 * 1217 * @param string $letterThe letter.1218 * @param int|null $limitOptional. The max number of results to return.1219 * Default: null (no limit).1220 * @param int|null $pageOptional. The page offset of results to return.1221 * Default: null (no limit).1222 * @param bool $populate_extras Optional. Whether to fetch extra1223 * information about the groups. Default: true.1224 * @param string|array|bool $exclude Optional. Array or comma-separated list of group1225 * IDs to exclude from results.1224 * @param string $letter The letter. 1225 * @param int|null $limit Optional. The max number of results to return. 1226 * Default: null (no limit). 1227 * @param int|null $page Optional. The page offset of results to return. 1228 * Default: null (no limit). 1229 * @param bool $populate_extras Optional. Whether to fetch extra 1230 * information about the groups. Default: true. 1231 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1232 * IDs to exclude from results. 1226 1233 * @return false|array { 1227 1234 * @type array $groups Array of group objects returned by the 1228 * paginated query.1229 * @type int $totalTotal count of all groups matching non-1230 * paginated query params.1235 * paginated query. 1236 * @type int $total Total count of all groups matching non- 1237 * paginated query params. 1231 1238 * } 1232 1239 */ … … 1282 1289 * Use BP_Groups_Group::get() with 'type' = 'random' instead. 1283 1290 * 1284 * @param int|null $limit Optional. The max number of results to return. 1285 * Default: null (no limit). 1286 * @param int|null $page Optional. The page offset of results to return. 1287 * Default: null (no limit). 1288 * @param int $user_id Optional. If present, groups will be limited to 1289 * those of which the specified user is a member. 1290 * @param string|bool $search_terms Optional. Limit groups to those whose 1291 * name or description field contain the search string. 1292 * @param bool $populate_extras Optional. Whether to fetch extra 1293 * information about the groups. Default: true. 1294 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1295 * IDs to exclude from results. 1291 * @param int|null $limit Optional. The max number of results to return. 1292 * Default: null (no limit). 1293 * @param int|null $page Optional. The page offset of results to return. 1294 * Default: null (no limit). 1295 * @param int $user_id Optional. If present, groups will be limited to 1296 * those of which the specified user is a member. 1297 * @param string|bool $search_terms Optional. Limit groups to those whose name 1298 * or description field contain the search string. 1299 * @param bool $populate_extras Optional. Whether to fetch extra 1300 * information about the groups. Default: true. 1301 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1302 * IDs to exclude from results. 1303 * 1296 1304 * @return array { 1297 1305 * @type array $groups Array of group objects returned by the 1298 * paginated query.1299 * @type int $totalTotal count of all groups matching non-1300 * paginated query params.1306 * paginated query. 1307 * @type int $total Total count of all groups matching non- 1308 * paginated query params. 1301 1309 * } 1302 1310 */ … … 1355 1363 * is_confirmed, is_pending, is_banned) 1356 1364 * 1357 * @param array $paged_groups Array of groups. 1358 * @param string|array Array or comma-separated list of IDs matching 1359 * $paged_groups. 1360 * @param string|bool $type Not used. 1365 * @param array $paged_groups Array of groups. 1366 * @param string|array $group_ids Array or comma-separated list of IDs matching 1367 * $paged_groups. 1368 * @param string|bool $type Not used. 1369 * 1361 1370 * @return array $paged_groups 1362 1371 */ … … 1432 1441 * Delete all invitations to a given group. 1433 1442 * 1434 * @param int $group_id ID of the group whose invitations are being 1435 * deleted.1443 * @param int $group_id ID of the group whose invitations are being deleted. 1444 * 1436 1445 * @return int|null Number of rows records deleted on success, null on 1437 * failure.1446 * failure. 1438 1447 */ 1439 1448 public static function delete_all_invites( $group_id ) { … … 1469 1478 * 1470 1479 * @param string $type Optional. If 'unreplied', count will be limited to 1471 * those topics that have received no replies. 1480 * those topics that have received no replies. 1481 * 1472 1482 * @return int Forum topic count. 1473 1483 */ … … 1503 1513 * 1504 1514 * @param int $group_id Group ID. 1515 * 1505 1516 * @return int Count of confirmed members for the group. 1506 1517 */ … … 1514 1525 1515 1526 /** 1516 * Get a total count of all topics of a given status, across groups/forums 1527 * Get a total count of all topics of a given status, across groups/forums. 1517 1528 * 1518 1529 * @since BuddyPress (1.5.0) 1519 1530 * 1520 * @param string $statusWhich group type to count. 'public', 'private',1521 * 'hidden', or 'all'. Default: 'public'.1531 * @param string $status Which group type to count. 'public', 'private', 1532 * 'hidden', or 'all'. Default: 'public'. 1522 1533 * @param string|bool $search_terms Provided search terms. 1523 1534 *
Note: See TracChangeset
for help on using the changeset viewer.