<!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][8210] trunk: Profile Visibility Settings:</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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/8210">8210</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2014-03-30 18:35:15 +0000 (Sun, 30 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Profile Visibility Settings:

* Rename template functions to match existing functions (profile VS xprofile)
* Allow passing of `field_id` so they can be used outside of the profile field loop.
* Allow before/after in radio buttons output.
* See <a href="http://buddypress.trac.wordpress.org/ticket/5352">#5352</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbptemplatesbplegacybuddypressmemberssinglesettingsprofilephp">trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php</a></li>
<li><a href="#trunkbpthemesbpdefaultmemberssinglesettingsprofilephp">trunk/bp-themes/bp-default/members/single/settings/profile.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="trunkbptemplatesbplegacybuddypressmemberssinglesettingsprofilephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php (8209 => 8210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php      2014-03-30 18:30:35 UTC (rev 8209)
+++ trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php 2014-03-30 18:35:15 UTC (rev 8210)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> 
</span><span class="cx">                                          <tr <?php bp_field_css_class(); ?>>
</span><span class="cx">                                                  <td class="field-name"><?php bp_the_profile_field_name(); ?></td>
</span><del>-                                                       <td class="field-visibility"><?php bp_xprofile_settings_visibility_select(); ?></td>
</del><ins>+                                                        <td class="field-visibility"><?php bp_profile_settings_visibility_select(); ?></td>
</ins><span class="cx">                                           </tr>
</span><span class="cx"> 
</span><span class="cx">                                  <?php endwhile; ?>
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultmemberssinglesettingsprofilephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/members/single/settings/profile.php (8209 => 8210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/members/single/settings/profile.php   2014-03-30 18:30:35 UTC (rev 8209)
+++ trunk/bp-themes/bp-default/members/single/settings/profile.php      2014-03-30 18:35:15 UTC (rev 8210)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx"> 
</span><span class="cx">                                                                          <tr <?php bp_field_css_class(); ?>>
</span><span class="cx">                                                                                  <td class="field-name"><?php bp_the_profile_field_name(); ?></td>
</span><del>-                                                                                       <td class="field-visibility"><?php bp_xprofile_settings_visibility_select(); ?></td>
</del><ins>+                                                                                        <td class="field-visibility"><?php bp_profile_settings_visibility_select(); ?></td>
</ins><span class="cx">                                                                           </tr>
</span><span class="cx"> 
</span><span class="cx">                                                                  <?php endwhile; ?>
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofiletemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-template.php (8209 => 8210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-template.php       2014-03-30 18:30:35 UTC (rev 8209)
+++ trunk/bp-xprofile/bp-xprofile-template.php  2014-03-30 18:35:15 UTC (rev 8210)
</span><span class="lines">@@ -691,28 +691,61 @@
</span><span class="cx"> /**
</span><span class="cx">  * Echo the field visibility radio buttons
</span><span class="cx">  */
</span><del>-function bp_profile_visibility_radio_buttons() {
-       echo bp_profile_get_visibility_radio_buttons();
</del><ins>+function bp_profile_visibility_radio_buttons( $args = '' ) {
+       echo bp_profile_get_visibility_radio_buttons( $args );
</ins><span class="cx"> }
</span><span class="cx">  /**
</span><span class="cx">   * Return the field visibility radio buttons
</span><span class="cx">   */
</span><del>-       function bp_profile_get_visibility_radio_buttons() {
-               $html = '<ul class="radio">';
</del><ins>+        function bp_profile_get_visibility_radio_buttons( $args = '' ) {
</ins><span class="cx"> 
</span><del>-               foreach( bp_xprofile_get_visibility_levels() as $level ) {
-                       $checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
</del><ins>+                // Parse optional arguments
+               $r = bp_parse_args( $args, array(
+                       'field_id'     => bp_get_the_profile_field_id(),
+                       'before'       => '<ul class="radio">',
+                       'after'        => '</ul>',
+                       'before_radio' => '<li>',
+                       'after_radio'  => '</li>',
+                       'class'        => 'bp-xprofile-visibility'
+               ), 'xprofile_visibility_radio_buttons' );
</ins><span class="cx"> 
</span><del>-                       // Only sanitize once
-                       $field_id = bp_get_the_profile_field_id();
-                       $level_id = esc_attr( $level['id'] );
</del><ins>+                // Empty return value, filled in below if a valid field ID is found
+               $retval = '';
</ins><span class="cx"> 
</span><del>-                       $html .= '<li><label for="see-field_' . $field_id . '_' . $level_id . '"><input type="radio" id="see-field_' . $field_id . '_' . $level_id . '" name="field_' . $field_id . '_visibility" value="' . $level_id . '"' . $checked . ' /> ' . esc_html( $level['label'] ) . '</label></li>';
-               }
</del><ins>+                // Only do-the-do if there's a valid field ID
+               if ( ! empty( $r['field_id'] ) ) :
</ins><span class="cx"> 
</span><del>-               $html .= '</ul>';
</del><ins>+                        // Start the output buffer
+                       ob_start();
</ins><span class="cx"> 
</span><del>-               return apply_filters( 'bp_profile_get_visibility_radio_buttons', $html );
</del><ins>+                        // Output anything before
+                       echo $r['before']; ?>
+
+                       <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
+
+                               <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
+
+                                       <?php echo $r['before_radio']; ?>
+
+                                       <label for="<?php esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>">
+                                               <input type="radio" id="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] . '_visibility' ); ?>" value="<?php echo esc_attr( $level['id'] ); ?>" <?php checked( $level['id'], bp_get_the_profile_field_visibility_level() ); ?> />
+                                               <span class="field-visibility-text"><?php echo esc_html( $level['label'] ); ?></span>
+                                       </label>
+
+                                       <?php echo $r['after_radio']; ?>
+
+                               <?php endforeach; ?>
+
+                       <?php endif;
+
+                       // Output anything after
+                       echo $r['after'];
+
+                       // Get the output buffer and empty it
+                       $retval = ob_get_clean();
+               endif;
+
+               return apply_filters( 'bp_profile_get_visibility_radio_buttons', $retval, $r, $args );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -720,50 +753,61 @@
</span><span class="cx">  *
</span><span class="cx">  * @since BuddyPress (2.0.0)
</span><span class="cx">  */
</span><del>-function bp_xprofile_settings_visibility_select( $args = '' ) {
-       echo bp_xprofile_get_settings_visibility_select( $args );
</del><ins>+function bp_profile_settings_visibility_select( $args = '' ) {
+       echo bp_profile_get_settings_visibility_select( $args );
</ins><span class="cx"> }
</span><span class="cx">  /**
</span><span class="cx">   * Return the XProfile field visibility select list for settings
</span><span class="cx">   *
</span><span class="cx">   * @since BuddyPress (2.0.0)
</span><span class="cx">   */
</span><del>-       function bp_xprofile_get_settings_visibility_select( $args = '' ) {
</del><ins>+        function bp_profile_get_settings_visibility_select( $args = '' ) {
</ins><span class="cx"> 
</span><span class="cx">          // Parse optional arguments
</span><span class="cx">          $r = bp_parse_args( $args, array(
</span><del>-                       'before' => '',
-                       'after'  => '',
-                       'class'  => 'bp-xprofile-visibility'
</del><ins>+                        'field_id' => bp_get_the_profile_field_id(),
+                       'before'   => '',
+                       'after'    => '',
+                       'class'    => 'bp-xprofile-visibility'
</ins><span class="cx">           ), 'xprofile_settings_visibility_select' );
</span><span class="cx"> 
</span><del>-               // Start the output buffer
-               ob_start();
</del><ins>+                // Empty return value, filled in below if a valid field ID is found
+               $retval = '';
</ins><span class="cx"> 
</span><del>-               // Anything before
-               echo $r['before']; ?>
</del><ins>+                // Only do-the-do if there's a valid field ID
+               if ( ! empty( $r['field_id'] ) ) :
</ins><span class="cx"> 
</span><del>-               <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
</del><ins>+                        // Start the output buffer
+                       ob_start();
</ins><span class="cx"> 
</span><del>-                       <select class="<?php echo esc_attr( $r['class'] ); ?>" name="field_<?php bp_the_profile_field_id(); ?>_visibility">
</del><ins>+                        // Output anything before
+                       echo $r['before']; ?>
</ins><span class="cx"> 
</span><del>-                               <?php foreach ( bp_xprofile_get_visibility_levels() as $level ) : ?>
</del><ins>+                        <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
</ins><span class="cx"> 
</span><del>-                                       <option value="<?php echo esc_attr( $level['id'] ); ?>" <?php selected( $level['id'], bp_get_the_profile_field_visibility_level() ); ?>><?php echo esc_html( $level['label'] ); ?></option>
</del><ins>+                                <select class="<?php echo esc_attr( $r['class'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility">
</ins><span class="cx"> 
</span><del>-                               <?php endforeach; ?>
</del><ins>+                                        <?php foreach ( bp_xprofile_get_visibility_levels() as $level ) : ?>
</ins><span class="cx"> 
</span><del>-                       </select>
</del><ins>+                                                <option value="<?php echo esc_attr( $level['id'] ); ?>" <?php selected( $level['id'], bp_get_the_profile_field_visibility_level() ); ?>><?php echo esc_html( $level['label'] ); ?></option>
</ins><span class="cx"> 
</span><del>-               <?php else : ?>
</del><ins>+                                        <?php endforeach; ?>
</ins><span class="cx"> 
</span><del>-                       <span class="field-visibility-settings-notoggle" title="<?php esc_attr_e( "This field's visibility cannot be changed.", 'buddypress' ); ?>"><?php bp_the_profile_field_visibility_level_label(); ?></span>
</del><ins>+                                </select>
</ins><span class="cx"> 
</span><del>-               <?php endif;
</del><ins>+                        <?php else : ?>
</ins><span class="cx"> 
</span><del>-               // Anything after
-               echo $r['after'];
</del><ins>+                                <span class="field-visibility-settings-notoggle" title="<?php esc_attr_e( "This field's visibility cannot be changed.", 'buddypress' ); ?>"><?php bp_the_profile_field_visibility_level_label(); ?></span>
</ins><span class="cx"> 
</span><ins>+                       <?php endif;
+
+                       // Output anything after
+                       echo $r['after'];
+
+                       // Get the output buffer and empty it
+                       $retval = ob_get_clean();
+               endif;
+
</ins><span class="cx">           // Output the dropdown list
</span><del>-               return apply_filters( 'bp_xprofile_settings_visibility_select', ob_get_clean() );
</del><ins>+                return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args );
</ins><span class="cx">   }
</span></span></pre>
</div>
</div>

</body>
</html>