Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:13:42 PM (11 years ago)
Author:
tw2113
Message:

More documentation cleanup for part of BP-Core component.

See #6398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-core-user.php

    r10108 r10355  
    1919 *    $user = new BP_Core_User( $user_id );
    2020 *    $user_avatar = $user->avatar;
    21  *        $user_email = $user->email;
     21 *    $user_email = $user->email;
    2222 *    $user_status = $user->status;
    2323 *    etc.
    … …  
    178178                }
    179179
    180                 // Cache a few things that are fetched often
     180                // Cache a few things that are fetched often.
    181181                wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
    182182                wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
    … …  
    282282                $sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
    283283
    284                 // We search against xprofile fields, so we must join the table
     284                // We search against xprofile fields, so we must join the table.
    285285                if ( $search_terms && bp_is_active( 'xprofile' ) ) {
    286286                        $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
    287287                }
    288288
    289                 // Alphabetical sorting is done by the xprofile Full Name field
     289                // Alphabetical sorting is done by the xprofile Full Name field.
    290290                if ( 'alphabetical' == $type ) {
    291291                        $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
    … …  
    349349                        $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
    350350
    351                         // If a meta value is provided, match it
     351                        // If a meta value is provided, match it.
    352352                        if ( $meta_value ) {
    353353                                $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
    … …  
    388388                $paged_users     = $wpdb->get_results( $paged_users_sql );
    389389
    390                 // Re-jig the SQL so we can get the total user count
     390                // Re-jig the SQL so we can get the total user count.
    391391                unset( $sql['select_main'] );
    392392
    … …  
    420420                $total_users     = $wpdb->get_var( $total_users_sql );
    421421
    422                 /***
     422                /**
    423423                 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
    424                  * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
     424                 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join).
    425425                 */
    426426                if ( !empty( $populate_extras ) ) {
    … …  
    431431                        }
    432432
    433                         // Add additional data to the returned results
     433                        // Add additional data to the returned results.
    434434                        $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
    435435                }
    … …  
    448448         * @param int    $page            The page number we are currently on, used in conjunction
    449449         *                                with $limit to get the start position for the limit.
    450          * @param bool   $populate_extras Populate extra user fields?
     450         * @param bool   $populate_extras If we should populate extra user fields.
    451451         * @param string $exclude         Comma-separated IDs of users whose results
    452452         *                                aren't to be fetched.
    453          *
    454453         * @return mixed False on error, otherwise associative array of results.
    455454         */
    … …  
    462461                }
    463462
    464                 // Multibyte compliance
     463                // Multibyte compliance.
    465464                if ( function_exists( 'mb_strlen' ) ) {
    466465                        if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
    … …  
    506505                $paged_users = $wpdb->get_results( $paged_users_sql );
    507506
    508                 /***
     507                /**
    509508                 * Lets fetch some other useful data in a separate queries, this will be
    510509                 * faster than querying the data for every user in a list. We can't add
    … …  
    517516                        $user_ids[] = (int) $user->id;
    518517
    519                 // Add additional data to the returned results
     518                // Add additional data to the returned results.
    520519                if ( $populate_extras ) {
    521520                        $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
    … …  
    536535         * @param int   $limit           The limit of results we want.
    537536         * @param int   $page            The page we are on for pagination.
    538          * @param bool  $populate_extras Populate extra user fields?
    539          *
     537         * @param bool  $populate_extras If we should populate extra user fields.
    540538         * @return array Associative array.
    541539         */
    … …  
    607605                $paged_users = $wpdb->get_results( $paged_users_sql );
    608606
    609                 /***
     607                /**
    610608                 * Lets fetch some other useful data in a separate queries, this will be
    611609                 * faster than querying the data for every user in a list. We can't add
    … …  
    615613                 */
    616614
    617                 // Add additional data to the returned results
     615                // Add additional data to the returned results.
    618616                if ( !empty( $populate_extras ) ) {
    619617                        $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
    … …  
    632630         * @param int     $limit           The limit of results we want.
    633631         * @param int     $page            The page we are on for pagination.
    634          * @param boolean $populate_extras Populate extra user fields?
    635          *
     632         * @param boolean $populate_extras If we should populate extra user fields.
    636633         * @return array Associative array.
    637634         */
    … …  
    668665                $paged_users = $wpdb->get_results( $paged_users_sql );
    669666
    670                 /***
     667                /**
    671668                 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
    672669                 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
    … …  
    675672                        $user_ids[] = $user->id;
    676673
    677                 // Add additional data to the returned results
     674                // Add additional data to the returned results.
    678675                if ( $populate_extras )
    679676                        $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
    … …  
    692689         * @param string      $user_ids    The user ids to select information about.
    693690         * @param string|bool $type        The type of fields we wish to get.
    694          *
    695691         * @return mixed False on error, otherwise associative array of results.
    696692         */
    … …  
    703699                        return $paged_users;
    704700
    705                 // Sanitize user IDs
     701                // Sanitize user IDs.
    706702                $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
    707703
    708                 // Fetch the user's full name
     704                // Fetch the user's full name.
    709705                if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
    710706                        $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
    … …  
    717713                }
    718714
    719                 // Fetch the user's total friend count
     715                // Fetch the user's total friend count.
    720716                if ( 'popular' != $type ) {
    721717                        $friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
    … …  
    728724                }
    729725
    730                 // Fetch whether or not the user is a friend
     726                // Fetch whether or not the user is a friend.
    731727                if ( bp_is_active( 'friends' ) ) {
    732728                        $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
    … …  
    749745                }
    750746
    751                 // Fetch the user's last_activity
     747                // Fetch the user's last_activity.
    752748                if ( 'active' != $type ) {
    753749                        $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
    … …  
    760756                }
    761757
    762                 // Fetch the user's latest update
     758                // Fetch the user's latest update.
    763759                $user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
    764760                for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
    … …  
    778774         *
    779775         * @param int $user_id User ID.
    780          *
    781776         * @return array Associative array.
    782777         */
    … …  
    793788         * Get last activity data for a user or set of users.
    794789         *
    795          * @param int|array User IDs or multiple user IDs.
    796          *
     790         * @param int|array $user_id User IDs or multiple user IDs.
    797791         * @return array
    798792         */
    … …  
    800794                global $wpdb;
    801795
    802                 // Sanitize and remove empty values
     796                // Sanitize and remove empty values.
    803797                $user_ids = array_filter( wp_parse_id_list( $user_id ) );
    804798
    … …  
    825819                }
    826820
    827                 // Fetch all user data from the cache
     821                // Fetch all user data from the cache.
    828822                $retval = array();
    829823                foreach ( $user_ids as $user_id ) {
    … …  
    844838         * @param int    $user_id ID of the user whose last_activity you are updating.
    845839         * @param string $time    MySQL-formatted time string.
    846          *
    847840         * @return bool True on success, false on failure.
    848841         */
    … …  
    858851                                $table_name,
    859852
    860                                 // Data to update
     853                                // Data to update.
    861854                                array(
    862855                                        'date_recorded' => $time,
    863856                                ),
    864857
    865                                 // WHERE
     858                                // WHERE.
    866859                                array(
    867860                                        'id' => $activity[ $user_id ]['activity_id'],
    868861                                ),
    869862
    870                                 // Data sanitization format
     863                                // Data sanitization format.
    871864                                array(
    872865                                        '%s',
    873866                                ),
    874867
    875                                 // WHERE sanitization format
     868                                // WHERE sanitization format.
    876869                                array(
    877870                                        '%d',
    … …  
    879872                        );
    880873
    881                         // add new date to existing activity entry for caching
     874                        // Add new date to existing activity entry for caching.
    882875                        $activity[ $user_id ]['date_recorded'] = $time;
    883876
    … …  
    886879                                $table_name,
    887880
    888                                 // Data
     881                                // Data.
    889882                                array(
    890883                                        'user_id'       => $user_id,
    … …  
    898891                                ),
    899892
    900                                 // Data sanitization format
     893                                // Data sanitization format.
    901894                                array(
    902895                                        '%d',
    … …  
    911904                        );
    912905
    913                         // set up activity array for caching
    914                         // view the foreach loop in the get_last_activity() method for format
     906                        // Set up activity array for caching.
     907                        // View the foreach loop in the get_last_activity() method for format.
    915908                        $activity = array();
    916909                        $activity[ $user_id ] = array(
    … …  
    921914                }
    922915
    923                 // set cache
     916                // Set cache.
    924917                wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
    925918
    … …  
    932925         * @since 2.0.0
    933926         *
    934          * @param int $user_id
    935          *
     927         * @param int $user_id ID of the user whose activity should be deleted.
    936928         * @return bool True on success, false on failure or if no last_activity
    937929         *              is found for the user.
    … …  
    949941                        buddypress()->members->table_name_last_activity,
    950942
    951                         // WHERE
     943                        // WHERE.
    952944                        array(
    953945                                'id' => $existing[ $user_id ]['activity_id'],
    954946                        ),
    955947
    956                         // WHERE sanitization format
     948                        // WHERE sanitization format.
    957949                        array(
    958950                                '%s',
Note: See TracChangeset for help on using the changeset viewer.