<!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][5837] trunk: Allows users to modify profile field visibility during registration.</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><a href="http://buddypress.trac.wordpress.org/changeset/5837">5837</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2012-02-24 22:34:38 +0000 (Fri, 24 Feb 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allows users to modify profile field visibility during registration. Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4044">#4044</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmembersbpmembersfunctionsphp">trunk/bp-members/bp-members-functions.php</a></li>
<li><a href="#trunkbpmembersbpmembersscreensphp">trunk/bp-members/bp-members-screens.php</a></li>
<li><a href="#trunkbpthemesbpdefault_inccssdefaultcss">trunk/bp-themes/bp-default/_inc/css/default.css</a></li>
<li><a href="#trunkbpthemesbpdefaultregistrationregisterphp">trunk/bp-themes/bp-default/registration/register.php</a></li>
<li><a href="#trunkbpxprofilebpxprofilecapsphp">trunk/bp-xprofile/bp-xprofile-caps.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileclassesphp">trunk/bp-xprofile/bp-xprofile-classes.php</a></li>
<li><a href="#trunkbpxprofilebpxprofiletemplatephp">trunk/bp-xprofile/bp-xprofile-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-functions.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-functions.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-members/bp-members-functions.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -1050,6 +1050,10 @@
</span><span class="cx"> 
</span><span class="cx">                                         $current_field = $usermeta[&quot;field_{$field_id}&quot;];
</span><span class="cx">                                         xprofile_set_field_data( $field_id, $user_id, $current_field );
</span><ins>+                                        
+                                        // Save the visibility level
+                                        $visibility_level = !empty( $usermeta['field_' . $field_id . '_visibility'] ) ? $usermeta['field_' . $field_id . '_visibility'] : 'public';
+                                        xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1108,6 +1112,10 @@
</span><span class="cx"> 
</span><span class="cx">                                         if ( !empty( $current_field ) )
</span><span class="cx">                                                 xprofile_set_field_data( $field_id, $user_id, $current_field );
</span><ins>+                                        
+                                        // Save the visibility level
+                                        $visibility_level = !empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
+                                        xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkbpmembersbpmembersscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-screens.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-screens.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-members/bp-members-screens.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -169,6 +169,9 @@
</span><span class="cx"> 
</span><span class="cx">                                         if ( !empty( $_POST['field_' . $field_id] ) )
</span><span class="cx">                                                 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
</span><ins>+                                        
+                                        if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
+                                                $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 // Store the profile field ID's in usermeta
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_inccssdefaultcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/css/default.css (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/css/default.css        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-themes/bp-default/_inc/css/default.css        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -2397,4 +2397,7 @@
</span><span class="cx"> .field-visibility-settings-toggle a,
</span><span class="cx"> .field-visibility-settings a {
</span><span class="cx">         font-size: .9em;
</span><ins>+}
+body.register div.page ul {
+        list-style: none;
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultregistrationregisterphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/registration/register.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/registration/register.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-themes/bp-default/registration/register.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -153,7 +153,26 @@
</span><span class="cx">                                                                         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                                                                 &lt;?php endif; ?&gt;
</span><ins>+                                                                
+                                                                &lt;?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?&gt;
+                                                                        &lt;div class=&quot;field-visibility-settings-toggle&quot; id=&quot;field-visibility-settings-toggle-&lt;?php bp_the_profile_field_id() ?&gt;&quot;&gt;
+                                                                                &lt;?php printf( __( 'This field can be seen by: &lt;span class=&quot;current-visibility-level&quot;&gt;%s&lt;/span&gt;', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?&gt; &lt;a href=&quot;#&quot; class=&quot;visibility-toggle-link&quot;&gt;Change&lt;/a&gt;
+                                                                        &lt;/div&gt;
+                                                                        
+                                                                        &lt;div class=&quot;field-visibility-settings&quot; id=&quot;field-visibility-settings-&lt;?php bp_the_profile_field_id() ?&gt;&quot;&gt;
+                                                                                &lt;label for=&quot;field-visibility&quot;&gt;&lt;?php _e( 'Who can see this field?', 'buddypress' ) ?&gt;&lt;/label&gt;
+                                                                                
+                                                                                &lt;?php bp_profile_visibility_radio_buttons() ?&gt;
+                                                                                
+                                                                                &lt;a class=&quot;field-visibility-settings-close&quot; href=&quot;#&quot;&gt;&lt;?php _e( 'Close', 'buddypress' ) ?&gt;&lt;/a&gt;
+                                                                        &lt;/div&gt;
+                                                                &lt;?php else : ?&gt;
+                                                                        &lt;div class=&quot;field-visibility-settings-notoggle&quot; id=&quot;field-visibility-settings-toggle-&lt;?php bp_the_profile_field_id() ?&gt;&quot;&gt;
+                                                                                &lt;?php printf( __( 'This field can be seen by: &lt;span class=&quot;current-visibility-level&quot;&gt;%s&lt;/span&gt;', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?&gt;
+                                                                        &lt;/div&gt;                        
+                                                                &lt;?php endif ?&gt;
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">                                                                 &lt;?php do_action( 'bp_custom_profile_edit_fields' ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                                                 &lt;p class=&quot;description&quot;&gt;&lt;?php bp_the_profile_field_description(); ?&gt;&lt;/p&gt;
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilecapsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-caps.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-caps.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-xprofile/bp-xprofile-caps.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> function bp_xprofile_map_meta_caps( $caps, $cap, $user_id, $args ) {
</span><span class="cx">         switch ( $cap ) {
</span><span class="cx">                 case 'bp_xprofile_change_field_visibility' :
</span><del>-                        $caps = array( 'read' );
</del><ins>+                        $caps = array( 'exist' ); // Must allow for logged-out users during registration
</ins><span class="cx"> 
</span><span class="cx">                         // You may pass args manually: $field_id, $profile_user_id
</span><span class="cx">                         $field_id        = isset( $args[0] ) ? (int)$args[0] : bp_get_the_profile_field_id();
</span><span class="lines">@@ -47,7 +47,6 @@
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         // Friends don't let friends edit each other's visibility
</span><del>-                        // @todo - This would be a proper map if we used CPTs?
</del><span class="cx">                         if ( $profile_user_id != bp_displayed_user_id() &amp;&amp; !bp_current_user_can( 'bp_moderate' ) ) {
</span><span class="cx">                                 $caps[] = 'do_not_allow'; 
</span><span class="cx">                                 break;
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -228,11 +228,11 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                                
-                                if ( $fetch_visibility_level ) {
-                                        $fields = self::fetch_visibility_level( $user_id, $fields );
-                                }
</del><span class="cx">                         }
</span><ins>+                                                                
+                        if ( $fetch_visibility_level ) {
+                                $fields = self::fetch_visibility_level( $user_id, $fields );
+                        }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // Merge the field array back in with the group array
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofiletemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-template.php (5836 => 5837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-template.php        2012-02-24 21:34:47 UTC (rev 5836)
+++ trunk/bp-xprofile/bp-xprofile-template.php        2012-02-24 22:34:38 UTC (rev 5837)
</span><span class="lines">@@ -159,7 +159,7 @@
</span><span class="cx">         $hide_empty_fields_default = ( !is_network_admin() &amp;&amp; !is_admin() &amp;&amp; !bp_is_user_profile_edit() &amp;&amp; !bp_is_register_page() );
</span><span class="cx">         
</span><span class="cx">         // We only need to fetch visibility levels when viewing your own profile
</span><del>-        if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) ) {
</del><ins>+        if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) {
</ins><span class="cx">                 $fetch_visibility_level_default = true;
</span><span class="cx">         } else {
</span><span class="cx">                 $fetch_visibility_level_default = false;
</span></span></pre>
</div>
</div>

</body>
</html>