Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/30/2015 06:22:31 AM (9 years ago)
Author:
tw2113
Message:

Further docs cleanup for BP Groups component.

See #6401.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r9906 r9982  
    11<?php
    22/**
    3  * BuddyPress Groups Classes
     3 * BuddyPress Groups Classes.
    44 *
    55 * @package BuddyPress
     
    160160     * @param array    $args {
    161161     *     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.
    165165     * }
    166166     */
     
    444444     *
    445445     * @param string $slug See {@link BP_Groups_Group::group_exists()}.
     446     *
    446447     * @return string|null See {@link BP_Groups_Group::group_exists()}.
    447448     */
     
    455456     * @param int $user_id ID of the inviting user.
    456457     * @param int $group_id ID of the group.
     458     *
    457459     * @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.
    459461     */
    460462    public static function get_invites( $user_id, $group_id ) {
     
    469471     * Get a list of a user's groups, filtered by a search string.
    470472     *
    471      * @param string $filter Search term. Matches against 'name' and
    472      *        'description' fields.
    473      * @param int $user_id ID of the user whose groups are being searched.
    474      *        Default: the displayed user.
    475      * @param mixed $order Not 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).
    480482     * @return false|array {
    481483     *     @type array $groups Array of matched and paginated group objects.
    482      *     @type int $total Total count of groups matching the query.
     484     *     @type int   $total Total count of groups matching the query.
    483485     * }
    484486     */
     
    515517     * Get a list of groups, filtered by a search string.
    516518     *
    517      * @param string $filter Search term. Matches against 'name' and
    518      *        'description' fields.
    519      * @param int|null $limit Optional. The max number of results to return.
    520      *        Default: null (no limit).
    521      * @param int|null $page Optional. 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).
    523525     * @param string|bool $sort_by Column to sort by. Default: false (default
    524526     *        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     *
    526529     * @return array {
    527530     *     @type array $groups Array of matched and paginated group objects.
    528      *     @type int $total Total count of groups matching the query.
     531     *     @type int   $total Total count of groups matching the query.
    529532     * }
    530533     */
     
    560563     *
    561564     * @param string $slug Slug to check.
     565     *
    562566     * @return string|null The slug, if found. Otherwise null.
    563567     */
     
    574578     *
    575579     * @param int $group_id ID of the group.
     580     *
    576581     * @return string|null The slug, if found. Otherwise null.
    577582     */
     
    588593     *
    589594     * @param int $group_id ID of the group.
     595     *
    590596     * @return bool True if the group has members, otherwise false.
    591597     */
     
    607613     *
    608614     * @param int $group_id ID of the group.
     615     *
    609616     * @return int|null The number of outstanding requests, or null if
    610      *         none are found.
     617     *                  none are found.
    611618     */
    612619    public static function has_membership_requests( $group_id ) {
     
    621628     * Get outstanding membership requests for a group.
    622629     *
    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).
    628635     * @return array {
    629636     *     @type array $requests The requested page of located requests.
    630      *     @type int $total Total number of requests outstanding for the
    631      *           group.
     637     *     @type int   $total    Total number of requests outstanding for the
     638     *                           group.
    632639     * }
    633640     */
     
    655662     * @param array {
    656663     *     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.
    692694     * }
    693695     * @return array {
    694696     *     @type array $groups Array of group objects returned by the
    695      *           paginated query.
    696      *     @type int $total Total 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.
    698700     * }
    699701     */
     
    953955     *
    954956     * @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     *
    956959     * @return array $sql_array 'join' and 'where' clauses.
    957960     */
     
    10001003     *
    10011004     * @param string $type The 'type' shorthand param.
     1005     *
    10021006     * @return array {
    1003      *  @type string $order SQL-friendly order string.
     1007     *  @type string $order   SQL-friendly order string.
    10041008     *  @type string $orderby SQL-friendly orderby column name.
    10051009     * }
     
    10391043
    10401044    /**
    1041      * Convert the 'orderby' param into a proper SQL term/column.
    1042      *
    1043      * @since BuddyPress (1.8.0)
    1044      * @access protected
    1045      *
    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     /**
    10791045     * Get a list of groups, sorted by those that have the most legacy forum topics.
    10801046     *
    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     *
    10931060     * @return array {
    10941061     *     @type array $groups Array of group objects returned by the
    1095      *           paginated query.
    1096      *     @type int $total Total 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.
    10981065     * }
    10991066     */
     
    11461113
    11471114    /**
     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    /**
    11481154     * Get a list of groups, sorted by those that have the most legacy forum posts.
    11491155     *
    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     *
    11601167     * @return array {
    11611168     *     @type array $groups Array of group objects returned by the
    1162      *           paginated query.
    1163      *     @type int $total Total 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.
    11651172     * }
    11661173     */
     
    12151222     * Get a list of groups whose names start with a given letter.
    12161223     *
    1217      * @param string $letter The letter.
    1218      * @param int|null $limit Optional. The max number of results to return.
    1219      *        Default: null (no limit).
    1220      * @param int|null $page Optional. The page offset of results to return.
    1221      *        Default: null (no limit).
    1222      * @param bool $populate_extras Optional. Whether to fetch extra
    1223      *        information about the groups. Default: true.
    1224      * @param string|array|bool $exclude Optional. Array or comma-separated list of group
    1225      *        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.
    12261233     * @return false|array {
    12271234     *     @type array $groups Array of group objects returned by the
    1228      *           paginated query.
    1229      *     @type int $total Total 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.
    12311238     * }
    12321239     */
     
    12821289     * Use BP_Groups_Group::get() with 'type' = 'random' instead.
    12831290     *
    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     *
    12961304     * @return array {
    12971305     *     @type array $groups Array of group objects returned by the
    1298      *           paginated query.
    1299      *     @type int $total Total 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.
    13011309     * }
    13021310     */
     
    13551363     *       is_confirmed, is_pending, is_banned)
    13561364     *
    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     *
    13611370     * @return array $paged_groups
    13621371     */
     
    14321441     * Delete all invitations to a given group.
    14331442     *
    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     *
    14361445     * @return int|null Number of rows records deleted on success, null on
    1437      *         failure.
     1446     *                  failure.
    14381447     */
    14391448    public static function delete_all_invites( $group_id ) {
     
    14691478     *
    14701479     * @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     *
    14721482     * @return int Forum topic count.
    14731483     */
     
    15031513     *
    15041514     * @param int $group_id Group ID.
     1515     *
    15051516     * @return int Count of confirmed members for the group.
    15061517     */
     
    15141525
    15151526    /**
    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.
    15171528     *
    15181529     * @since BuddyPress (1.5.0)
    15191530     *
    1520      * @param string $status Which 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'.
    15221533     * @param string|bool $search_terms Provided search terms.
    15231534     *
Note: See TracChangeset for help on using the changeset viewer.