<!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-&gt;profile_data = $this-&gt;get_profile_data();
</span><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;profile_data ) {
</span><del>-                        $this-&gt;user_url = bp_core_get_user_domain( $this-&gt;id, $this-&gt;profile_data['user_nicename'], $this-&gt;profile_data['user_login'] );
-                        $this-&gt;fullname = esc_attr( $this-&gt;profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
</del><ins>+                        $this-&gt;user_url  = bp_core_get_user_domain( $this-&gt;id, $this-&gt;profile_data['user_nicename'], $this-&gt;profile_data['user_login'] );
+                        $this-&gt;fullname  = esc_attr( $this-&gt;profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
</ins><span class="cx">                         $this-&gt;user_link = &quot;&lt;a href='{$this-&gt;user_url}' title='{$this-&gt;fullname}'&gt;{$this-&gt;fullname}&lt;/a&gt;&quot;;
</span><del>-                        $this-&gt;email = esc_attr( $this-&gt;profile_data['user_email'] );
</del><ins>+                        $this-&gt;email     = esc_attr( $this-&gt;profile_data['user_email'] );
</ins><span class="cx">                 } else {
</span><del>-                        $this-&gt;user_url = bp_core_get_user_domain( $this-&gt;id );
</del><ins>+                        $this-&gt;user_url  = bp_core_get_user_domain( $this-&gt;id );
</ins><span class="cx">                         $this-&gt;user_link = bp_core_get_userlink( $this-&gt;id );
</span><del>-                        $this-&gt;fullname = esc_attr( bp_core_get_user_displayname( $this-&gt;id ) );
-                        $this-&gt;email = esc_attr( bp_core_get_user_email( $this-&gt;id ) );
</del><ins>+                        $this-&gt;fullname  = esc_attr( bp_core_get_user_displayname( $this-&gt;id ) );
+                        $this-&gt;email     = esc_attr( bp_core_get_user_email( $this-&gt;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-&gt;id, $this-&gt;fullname, 'bp' );
</span><span class="cx">                 wp_cache_set( 'bp_user_email_' . $this-&gt;id, $this-&gt;email, 'bp' );
</span><span class="cx">                 wp_cache_set( 'bp_user_url_' . $this-&gt;id, $this-&gt;user_url, 'bp' );
</span><span class="cx"> 
</span><del>-                $this-&gt;avatar = bp_core_fetch_avatar( array( 'item_id' =&gt; $this-&gt;id, 'type' =&gt; 'full' ) );
</del><ins>+                $this-&gt;avatar       = bp_core_fetch_avatar( array( 'item_id' =&gt; $this-&gt;id, 'type' =&gt; 'full'  ) );
</ins><span class="cx">                 $this-&gt;avatar_thumb = bp_core_fetch_avatar( array( 'item_id' =&gt; $this-&gt;id, 'type' =&gt; 'thumb' ) );
</span><del>-                $this-&gt;avatar_mini = bp_core_fetch_avatar( array( 'item_id' =&gt; $this-&gt;id, 'type' =&gt; 'thumb', 'width' =&gt; 30, 'height' =&gt; 30 ) );
-
-                $this-&gt;last_active = bp_core_get_last_activity( get_user_meta( $this-&gt;id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
</del><ins>+                $this-&gt;avatar_mini  = bp_core_fetch_avatar( array( 'item_id' =&gt; $this-&gt;id, 'type' =&gt; 'thumb', 'width' =&gt; 30, 'height' =&gt; 30 ) );
+                $this-&gt;last_active  = bp_core_get_last_activity( get_user_meta( $this-&gt;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-&gt;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'] = &quot;AND u.ID IN ({$friend_ids})&quot;;
</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 &amp;&amp; bp_is_active( 'profile' ) ) {
</span><del>-                        $search_terms = like_escape( $wpdb-&gt;escape( $search_terms ) );
</del><ins>+                        $search_terms             = like_escape( $wpdb-&gt;escape( $search_terms ) );
</ins><span class="cx">                         $sql['where_searchterms'] = &quot;AND pd.value LIKE '%%$search_terms%%'&quot;;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -192,11 +192,11 @@
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="cx">                         $sql['pagination'] = $wpdb-&gt;prepare( &quot;LIMIT %d, %d&quot;, 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-&gt;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, &quot;SELECT COUNT(DISTINCT u.ID)&quot; );
</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-&gt;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-&gt;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( &amp;$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-&gt;escape( $letter ) );
</del><ins>+                $letter     = like_escape( $wpdb-&gt;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 ) ) ? &quot; AND u.ID NOT IN ({$exclude})&quot; : &quot;&quot;;
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx"> 
</span><del>-                $user_sql = &quot; AND user_id IN ( &quot; . $wpdb-&gt;escape( $user_ids ) . &quot; ) &quot;;
</del><ins>+                $user_sql   = &quot; AND user_id IN ( &quot; . $wpdb-&gt;escape( $user_ids ) . &quot; ) &quot;;
</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-&gt;prepare( &quot;SELECT COUNT(DISTINCT ID) FROM &quot; . CUSTOM_USER_TABLE . &quot; WHERE {$status_sql} AND ID IN ( &quot; . $wpdb-&gt;escape( $user_ids ) . &quot; ) &quot; ), $wpdb-&gt;escape( $user_ids ) );
</span><span class="lines">@@ -318,7 +318,7 @@
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx"> 
</span><span class="cx">                 $search_terms = like_escape( $wpdb-&gt;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', &quot;SELECT COUNT(DISTINCT u.ID) as id FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC&quot;, $search_terms );
</span><span class="cx">                 $paged_users_sql = apply_filters( 'bp_core_search_users_sql', &quot;SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;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}&quot;, $search_terms, $pag_sql );
</span><span class="lines">@@ -335,7 +335,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $user_ids = $wpdb-&gt;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( &amp;$paged_users, &amp;$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' ) &amp;&amp; '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-&gt;get_results( &quot;SELECT user_id as id, meta_value as total_friend_count FROM &quot; . CUSTOM_USER_META_TABLE . &quot; WHERE meta_key = 'total_friend_count' AND user_id IN ( {$user_ids} )&quot; );
</span><span class="cx">                         for ( $i = 0; $i &lt; 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-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp-&gt;friends-&gt;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 )&quot;, $bp-&gt;loggedin_user-&gt;id, $bp-&gt;loggedin_user-&gt;id ) );
</span><span class="cx">                         for ( $i = 0; $i &lt; 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-&gt;get_results( &quot;SELECT user_id as id, meta_value as last_activity FROM &quot; . CUSTOM_USER_META_TABLE . &quot; WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )&quot; );
</span><span class="cx">                         for ( $i = 0; $i &lt; 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-&gt;get_results( &quot;SELECT user_id as id, meta_value as latest_update FROM &quot; . CUSTOM_USER_META_TABLE . &quot; WHERE meta_key = 'bp_latest_update' AND user_id IN ( {$user_ids} )&quot; );
</span><span class="cx">                 for ( $i = 0; $i &lt; 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-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE id = %d&quot;, $this-&gt;id ) ) ) {
</span><span class="cx">                         $this-&gt;item_id = $notification-&gt;item_id;
</span><span class="cx">                         $this-&gt;secondary_item_id = $notification-&gt;secondary_item_id;
</span><del>-                        $this-&gt;user_id = $notification-&gt;user_id;
-                        $this-&gt;component_name = $notification-&gt;component_name;
-                        $this-&gt;component_action = $notification-&gt;component_action;
-                        $this-&gt;date_notified = $notification-&gt;date_notified;
-                        $this-&gt;is_new = $notification-&gt;is_new;
</del><ins>+                        $this-&gt;user_id           = $notification-&gt;user_id;
+                        $this-&gt;component_name    = $notification-&gt;component_name;
+                        $this-&gt;component_action  = $notification-&gt;component_action;
+                        $this-&gt;date_notified     = $notification-&gt;date_notified;
+                        $this-&gt;is_new            = $notification-&gt;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-&gt;id ) {
-                        // Update
</del><ins>+                // Update
+                if ( $this-&gt;id )
</ins><span class="cx">                         $sql = $wpdb-&gt;prepare( &quot;UPDATE {$bp-&gt;core-&gt;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&quot;, $this-&gt;item_id, $this-&gt;secondary_item_id, $this-&gt;user_id, $this-&gt;component_name, $this-&gt;component_action, $this-&gt;date_notified, $this-&gt;is_new, $this-&gt;id );
</span><del>-                } else {
-                        // Save
</del><ins>+
+                // Save
+                else
</ins><span class="cx">                         $sql = $wpdb-&gt;prepare( &quot;INSERT INTO {$bp-&gt;core-&gt;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 )&quot;, $this-&gt;item_id, $this-&gt;secondary_item_id, $this-&gt;user_id, $this-&gt;component_name, $this-&gt;component_action, $this-&gt;date_notified, $this-&gt;is_new );
</span><del>-                }
</del><span class="cx"> 
</span><span class="cx">                 if ( !$result = $wpdb-&gt;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>