<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][3825] trunk/bp-core/bp-core-classes.php: Clean up bp-core-classes code</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>3825</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-01-22 14:21:58 +0000 (Sat, 22 Jan 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Clean up bp-core-classes code</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreclassesphp">trunk/bp-core/bp-core-classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-classes.php (3824 => 3825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-classes.php        2011-01-22 14:17:33 UTC (rev 3824)
+++ trunk/bp-core/bp-core-classes.php        2011-01-22 14:21:58 UTC (rev 3825)
</span><span class="lines">@@ -59,27 +59,26 @@
</span><span class="cx">                         $this->profile_data = $this->get_profile_data();
</span><span class="cx">
</span><span class="cx">                 if ( $this->profile_data ) {
</span><del>-                        $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
-                        $this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
</del><ins>+                        $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
+                        $this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
</ins><span class="cx">                         $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
</span><del>-                        $this->email = esc_attr( $this->profile_data['user_email'] );
</del><ins>+                        $this->email = esc_attr( $this->profile_data['user_email'] );
</ins><span class="cx">                 } else {
</span><del>-                        $this->user_url = bp_core_get_user_domain( $this->id );
</del><ins>+                        $this->user_url = bp_core_get_user_domain( $this->id );
</ins><span class="cx">                         $this->user_link = bp_core_get_userlink( $this->id );
</span><del>-                        $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
-                        $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
</del><ins>+                        $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
+                        $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                /* Cache a few things that are fetched often */
</del><ins>+                // Cache a few things that are fetched often
</ins><span class="cx">                 wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
</span><span class="cx">                 wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
</span><span class="cx">                 wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
</span><span class="cx">
</span><del>-                $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
</del><ins>+                $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
</ins><span class="cx">                 $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
</span><del>-                $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
-
-                $this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
</del><ins>+                $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
+                $this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function populate_extras() {
</span><span class="lines">@@ -104,7 +103,7 @@
</span><span class="cx">                 return BP_XProfile_ProfileData::get_all_for_user( $this->id );
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* Static Functions */
</del><ins>+        /** Static Functions ******************************************************/
</ins><span class="cx">
</span><span class="cx">         function get_users( $type, $limit = null, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="lines">@@ -160,14 +159,15 @@
</span><span class="cx">
</span><span class="cx">                         if ( !empty( $friend_ids ) )
</span><span class="cx">                                 $sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
</span><del>-                        else {
-                                /* User has no friends, return false since there will be no users to fetch. */
</del><ins>+
+                        // User has no friends, return false since there will be no users to fetch.
+                        else
</ins><span class="cx">                                 return false;
</span><del>-                        }
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( $search_terms && bp_is_active( 'profile' ) ) {
</span><del>-                        $search_terms = like_escape( $wpdb->escape( $search_terms ) );
</del><ins>+                        $search_terms = like_escape( $wpdb->escape( $search_terms ) );
</ins><span class="cx">                         $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -192,11 +192,11 @@
</span><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><del>-                /* Get paginated results */
</del><ins>+                // Get paginated results
</ins><span class="cx">                 $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ), $sql );
</span><span class="cx">                 $paged_users = $wpdb->get_results( $paged_users_sql );
</span><span class="cx">
</span><del>-                /* Re-jig the SQL so we can get the total user count */
</del><ins>+                // Re-jig the SQL so we can get the total user count
</ins><span class="cx">                 unset( $sql['select_main'] );
</span><span class="cx">
</span><span class="cx">                 if ( !empty( $sql['select_active'] ) )
</span><span class="lines">@@ -213,7 +213,7 @@
</span><span class="cx">
</span><span class="cx">                 array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" );
</span><span class="cx">
</span><del>-                /* Get total user results */
</del><ins>+                // Get total user results
</ins><span class="cx">                 $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ), $sql );
</span><span class="cx">                 $total_users = $wpdb->get_var( $total_users_sql );
</span><span class="cx">
</span><span class="lines">@@ -229,7 +229,7 @@
</span><span class="cx">
</span><span class="cx">                         $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
</span><span class="cx">
</span><del>-                        /* Add additional data to the returned results */
</del><ins>+                        // Add additional data to the returned results
</ins><span class="cx">                         $paged_users = BP_Core_User::get_user_extras( &$paged_users, $user_ids, $type );
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -254,7 +254,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                $letter = like_escape( $wpdb->escape( $letter ) );
</del><ins>+                $letter = like_escape( $wpdb->escape( $letter ) );
</ins><span class="cx">                 $status_sql = bp_core_get_status_sql( 'u.' );
</span><span class="cx">
</span><span class="cx">                 $exclude_sql = ( !empty( $exclude ) ) ? " AND u.ID NOT IN ({$exclude})" : "";
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><del>-                $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) ";
</del><ins>+                $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) ";
</ins><span class="cx">                 $status_sql = bp_core_get_status_sql();
</span><span class="cx">
</span><span class="cx">                 $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT ID) FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) " ), $wpdb->escape( $user_ids ) );
</span><span class="lines">@@ -318,7 +318,7 @@
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><span class="cx">                 $search_terms = like_escape( $wpdb->escape( $search_terms ) );
</span><del>-                $status_sql = bp_core_get_status_sql( 'u.' );
</del><ins>+                $status_sql = bp_core_get_status_sql( 'u.' );
</ins><span class="cx">
</span><span class="cx">                 $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
</span><span class="cx">                 $paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
</span><span class="lines">@@ -335,7 +335,7 @@
</span><span class="cx">
</span><span class="cx">                 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
</span><span class="cx">
</span><del>-                /* Add additional data to the returned results */
</del><ins>+                // Add additional data to the returned results
</ins><span class="cx">                 if ( $populate_extras )
</span><span class="cx">                         $paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids );
</span><span class="cx">
</span><span class="lines">@@ -348,9 +348,9 @@
</span><span class="cx">                 if ( empty( $user_ids ) )
</span><span class="cx">                         return $paged_users;
</span><span class="cx">
</span><del>-                /* Fetch the user's full name */
</del><ins>+                // Fetch the user's full name
</ins><span class="cx">                 if ( bp_is_active( 'profile' ) && 'alphabetical' != $type ) {
</span><del>-                        /* Ensure xprofile globals are set */
</del><ins>+                        // Ensure xprofile globals are set
</ins><span class="cx">                         if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )
</span><span class="cx">                                 xprofile_setup_globals();
</span><span class="cx">
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /* Fetch the user's total friend count */
</del><ins>+                // Fetch the user's total friend count
</ins><span class="cx">                 if ( 'popular' != $type ) {
</span><span class="cx">                         $friend_count = $wpdb->get_results( "SELECT user_id as id, meta_value as total_friend_count FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'total_friend_count' AND user_id IN ( {$user_ids} )" );
</span><span class="cx">                         for ( $i = 0; $i < count( $paged_users ); $i++ ) {
</span><span class="lines">@@ -374,7 +374,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /* Fetch whether or not the user is a friend */
</del><ins>+                // Fetch whether or not the user is a friend
</ins><span class="cx">                 if ( bp_is_active( 'friends' ) ) {
</span><span class="cx">                         $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 ) );
</span><span class="cx">                         for ( $i = 0; $i < count( $paged_users ); $i++ ) {
</span><span class="lines">@@ -395,7 +395,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /* Fetch the user's last_activity */
</del><ins>+                // Fetch the user's last_activity
</ins><span class="cx">                 if ( 'active' != $type ) {
</span><span class="cx">                         $user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
</span><span class="cx">                         for ( $i = 0; $i < count( $paged_users ); $i++ ) {
</span><span class="lines">@@ -406,7 +406,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /* Fetch the user's latest update */
</del><ins>+                // Fetch the user's latest update
</ins><span class="cx">                 $user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bp_latest_update' AND user_id IN ( {$user_ids} )" );
</span><span class="cx">                 for ( $i = 0; $i < count( $paged_users ); $i++ ) {
</span><span class="cx">                         foreach ( (array)$user_update as $update ) {
</span><span class="lines">@@ -459,24 +459,24 @@
</span><span class="cx">                 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
</span><span class="cx">                         $this->item_id = $notification->item_id;
</span><span class="cx">                         $this->secondary_item_id = $notification->secondary_item_id;
</span><del>-                        $this->user_id = $notification->user_id;
-                        $this->component_name = $notification->component_name;
-                        $this->component_action = $notification->component_action;
-                        $this->date_notified = $notification->date_notified;
-                        $this->is_new = $notification->is_new;
</del><ins>+                        $this->user_id = $notification->user_id;
+                        $this->component_name = $notification->component_name;
+                        $this->component_action = $notification->component_action;
+                        $this->date_notified = $notification->date_notified;
+                        $this->is_new = $notification->is_new;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function save() {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx">
</span><del>-                if ( $this->id ) {
-                        // Update
</del><ins>+                // Update
+                if ( $this->id )
</ins><span class="cx">                         $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
</span><del>-                } else {
-                        // Save
</del><ins>+
+                // Save
+                else
</ins><span class="cx">                         $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
</span><del>-                }
</del><span class="cx">
</span><span class="cx">                 if ( !$result = $wpdb->query( $sql ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -485,7 +485,7 @@
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* Static functions */
</del><ins>+        /** Static functions ******************************************************/
</ins><span class="cx">
</span><span class="cx">         function check_access( $user_id, $notification_id ) {
</span><span class="cx">                 global $wpdb, $bp;
</span></span></pre>
</div>
</div>
</body>
</html>