<!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][4634] trunk: Introduces bp_xprofile_fullname_field_name() to avoid referencing BP_XPROFILE_FULLNAME_FIELD_NAME throughout BuddyPress.</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>4634</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-07-09 22:13:15 +0000 (Sat, 09 Jul 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduces bp_xprofile_fullname_field_name() to avoid referencing BP_XPROFILE_FULLNAME_FIELD_NAME throughout BuddyPress. See #3314</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreclassesphp">trunk/bp-core/bp-core-classes.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsclassesphp">trunk/bp-friends/bp-friends-classes.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileclassesphp">trunk/bp-xprofile/bp-xprofile-classes.php</a></li>
<li><a href="#trunkbpxprofilebpxprofilefunctionsphp">trunk/bp-xprofile/bp-xprofile-functions.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 (4633 => 4634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-classes.php        2011-07-09 22:01:46 UTC (rev 4633)
+++ trunk/bp-core/bp-core-classes.php        2011-07-09 22:13:15 UTC (rev 4634)
</span><span class="lines">@@ -143,12 +143,14 @@
</span><span class="cx">         function populate() {
</span><span class="cx">                 global $bp;
</span><span class="cx"> 
</span><ins>+                $full_name_field_name = bp_xprofile_fullname_field_name();
+
</ins><span class="cx">                 if ( bp_is_active( 'xprofile' ) )
</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><span class="cx">                         $this-&gt;user_url  = bp_core_get_user_domain( $this-&gt;id, $this-&gt;profile_data['user_nicename'], $this-&gt;profile_data['user_login'] );
</span><del>-                        $this-&gt;fullname  = esc_attr( $this-&gt;profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
</del><ins>+                        $this-&gt;fullname  = esc_attr( $this-&gt;profile_data[$full_name_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><span class="cx">                         $this-&gt;email     = esc_attr( $this-&gt;profile_data['user_email'] );
</span><span class="cx">                 } else {
</span><span class="lines">@@ -379,8 +381,8 @@
</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="cx"> 
</span><del>-                $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb-&gt;prepare( &quot;SELECT COUNT(DISTINCT u.ID) FROM {$wpdb-&gt;users} u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%'  ORDER BY pd.value ASC&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
-                $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb-&gt;prepare( &quot;SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb-&gt;users} u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
</del><ins>+                $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb-&gt;prepare( &quot;SELECT COUNT(DISTINCT u.ID) FROM {$wpdb-&gt;users} u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%'  ORDER BY pd.value ASC&quot;, bp_xprofile_fullname_field_name() ), $letter );
+                $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb-&gt;prepare( &quot;SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb-&gt;users} u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}&quot;, bp_xprofile_fullname_field_name() ), $letter, $pag_sql );
</ins><span class="cx"> 
</span><span class="cx">                 $total_users = $wpdb-&gt;get_var( $total_users_sql );
</span><span class="cx">                 $paged_users = $wpdb-&gt;get_results( $paged_users_sql );
</span><span class="lines">@@ -506,7 +508,7 @@
</span><span class="cx"> 
</span><span class="cx">                 // Fetch the user's full name
</span><span class="cx">                 if ( bp_is_active( 'xprofile' ) &amp;&amp; 'alphabetical' != $type ) {
</span><del>-                        $names = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT pd.user_id as id, pd.value as fullname FROM {$bp-&gt;profile-&gt;table_name_fields} pf, {$bp-&gt;profile-&gt;table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ) );
</del><ins>+                        $names = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT pd.user_id as id, pd.value as fullname FROM {$bp-&gt;profile-&gt;table_name_fields} pf, {$bp-&gt;profile-&gt;table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )&quot;, bp_xprofile_fullname_field_name() ) );
</ins><span class="cx">                         for ( $i = 0; $i &lt; count( $paged_users ); $i++ ) {
</span><span class="cx">                                 foreach ( (array)$names as $name ) {
</span><span class="cx">                                         if ( $name-&gt;id == $paged_users[$i]-&gt;id )
</span></span></pre></div>
<a id="trunkbpfriendsbpfriendsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-classes.php (4633 => 4634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-classes.php        2011-07-09 22:01:46 UTC (rev 4633)
+++ trunk/bp-friends/bp-friends-classes.php        2011-07-09 22:13:15 UTC (rev 4634)
</span><span class="lines">@@ -271,7 +271,7 @@
</span><span class="cx">                 if ( !bp_is_active( 'xprofile' ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><del>-                return $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT user_id FROM {$bp-&gt;profile-&gt;table_name_data} pd, {$bp-&gt;profile-&gt;table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ) );
</del><ins>+                return $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT user_id FROM {$bp-&gt;profile-&gt;table_name_data} pd, {$bp-&gt;profile-&gt;table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC&quot;, bp_xprofile_fullname_field_name() ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function get_random_friends( $user_id, $total_friends = 5 ) {
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (4633 => 4634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2011-07-09 22:01:46 UTC (rev 4633)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2011-07-09 22:13:15 UTC (rev 4634)
</span><span class="lines">@@ -983,9 +983,11 @@
</span><span class="cx">                 if ( !$user_id )
</span><span class="cx">                         $user_id = $bp-&gt;displayed_user-&gt;id;
</span><span class="cx"> 
</span><del>-                $data = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
</del><ins>+                $field_name = bp_xprofile_fullname_field_name();
</ins><span class="cx"> 
</span><del>-                return $data[BP_XPROFILE_FULLNAME_FIELD_NAME];
</del><ins>+                $data = xprofile_get_field_data( $field_name, $user_id );
+
+                return $data[$field_name];
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-functions.php (4633 => 4634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-functions.php        2011-07-09 22:01:46 UTC (rev 4633)
+++ trunk/bp-xprofile/bp-xprofile-functions.php        2011-07-09 22:13:15 UTC (rev 4634)
</span><span class="lines">@@ -385,7 +385,7 @@
</span><span class="cx">         if ( empty( $user_id ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
</del><ins>+        $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_name(), $user_id );
</ins><span class="cx">         $space    = strpos( $fullname, ' ' );
</span><span class="cx"> 
</span><span class="cx">         if ( false === $space ) {
</span><span class="lines">@@ -418,7 +418,7 @@
</span><span class="cx">         if ( ( !empty( $bp-&gt;site_options['bp-disable-profile-sync'] ) &amp;&amp; (int)$bp-&gt;site_options['bp-disable-profile-sync'] ) || !$update || $errors-&gt;get_error_codes() )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><del>-        xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user-&gt;ID, $user-&gt;display_name );
</del><ins>+        xprofile_set_field_data( bp_xprofile_fullname_field_name(), $user-&gt;ID, $user-&gt;display_name );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 );
</span><span class="cx"> 
</span><span class="lines">@@ -578,4 +578,17 @@
</span><span class="cx"> function bp_xprofile_update_fielddata_meta( $field_data_id, $meta_key, $meta_value ) {
</span><span class="cx">         return bp_xprofile_update_meta( $field_data_id, 'data', $meta_key, $meta_value );
</span><span class="cx"> }
</span><ins>+
+/**
+ * Return the field name for the Full Name xprofile field
+ *
+ * @package BuddyPress
+ * @since 1.3
+ *
+ * @return str The field name
+ */
+function bp_xprofile_fullname_field_name() {
+        return apply_filters( 'bp_xprofile_fullname_field_name', BP_XPROFILE_FULLNAME_FIELD_NAME );
+}
+
</ins><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>