<!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][7960] trunk: First pass at Profile Settings for improved profile field visibility UX:</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/7960">7960</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2014-02-21 23:08:04 +0000 (Fri, 21 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>First pass at Profile Settings for improved profile field visibility UX:

* Adds `/members/single/settings/profile.php` template to `bp-legacy` and `bp-default`.
* Introduces `bp-xprofile.settings.php` for Settings specific functionality going forward.
* Introduces actions & screens for handling output and saving of profile visibility data.
* Introduces `_is_` function for identifying the new component/action URL.
* See <a href="http://buddypress.trac.wordpress.org/ticket/5352">#5352</a>. (still more @todo...)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoretemplatephp">trunk/bp-core/bp-core-template.php</a></li>
<li><a href="#trunkbptemplatesbplegacybuddypressmemberssinglesettingsphp">trunk/bp-templates/bp-legacy/buddypress/members/single/settings.php</a></li>
<li><a href="#trunkbptemplatesbplegacycssbuddypresscss">trunk/bp-templates/bp-legacy/css/buddypress.css</a></li>
<li><a href="#trunkbpthemesbpdefault_inccssdefaultcss">trunk/bp-themes/bp-default/_inc/css/default.css</a></li>
<li><a href="#trunkbpthemesbpdefaultmemberssinglesettingsphp">trunk/bp-themes/bp-default/members/single/settings.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileactionsphp">trunk/bp-xprofile/bp-xprofile-actions.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileloaderphp">trunk/bp-xprofile/bp-xprofile-loader.php</a></li>
<li><a href="#trunkbpxprofilebpxprofilescreensphp">trunk/bp-xprofile/bp-xprofile-screens.php</a></li>
<li><a href="#trunkbpxprofilebpxprofiletemplatephp">trunk/bp-xprofile/bp-xprofile-template.php</a></li>
</ul>

<h3>Added 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="#trunkbpxprofilebpxprofilesettingsphp">trunk/bp-xprofile/bp-xprofile-settings.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoretemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-template.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-template.php       2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-core/bp-core-template.php  2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -1871,6 +1871,22 @@
</span><span class="cx">  return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Is this a user's profile settings?
+ *
+ * Eg http://example.com/members/joe/settings/profile/.
+ *
+ * @since BuddyPress (2.0.0)
+ *
+ * @return bool True if the current page is a user's Profile Settings page.
+ */
+function bp_is_user_settings_profile() {
+       if ( bp_is_user_settings() && bp_is_current_action( 'profile' ) )
+               return true;
+
+       return false;
+}
+
</ins><span class="cx"> /** Groups ********************************************************************/
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkbptemplatesbplegacybuddypressmemberssinglesettingsprofilephp"></a>
<div class="addfile"><h4>Added: trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php (0 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php                              (rev 0)
+++ trunk/bp-templates/bp-legacy/buddypress/members/single/settings/profile.php 2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+<?php do_action( 'bp_before_member_settings_template' ); ?>
+
+<form action="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/profile' ); ?>" method="post" class="standard-form" id="settings-form">
+
+       <?php if ( bp_xprofile_get_settings_fields() ) : ?>
+
+               <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
+
+                       <table class="profile-settings" id="xprofile-settings-<?php bp_the_profile_group_slug(); ?>">
+                               <thead>
+                                       <tr>
+                                               <th class="title field-group-name"><?php bp_the_profile_group_name(); ?></th>
+                                               <th class="title"><?php _e( 'Visibility', 'buddypress' ); ?></th>
+                                       </tr>
+                               </thead>
+
+                               <tbody>
+
+                                       <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
+
+                                               <tr <?php bp_field_css_class(); ?>>
+                                                       <td class="field-name"><?php bp_the_profile_field_name(); ?></td>
+                                                       <td class="field-visibility"><?php bp_xprofile_settings_visibility_select(); ?></td>
+                                               </tr>
+
+                                       <?php endwhile; ?>
+
+                               </tbody>
+                       </table>
+
+               <?php endwhile; ?>
+
+       <?php endif; ?>
+
+       <?php do_action( 'bp_core_xprofile_settings_before_submit' ); ?>
+
+       <div class="submit">
+               <input id="submit" type="submit" name="xprofile-settings-submit" value="<?php _e( 'Save Settings', 'buddypress' ); ?>" class="auto" />
+       </div>
+
+       <?php do_action( 'bp_core_xprofile_settings_after_submit' ); ?>
+
+       <?php wp_nonce_field( 'bp_xprofile_settings' ); ?>
+
+       <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
+
+</form>
+
+<?php do_action( 'bp_after_member_settings_template' );
</ins></span></pre></div>
<a id="trunkbptemplatesbplegacybuddypressmemberssinglesettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-templates/bp-legacy/buddypress/members/single/settings.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-templates/bp-legacy/buddypress/members/single/settings.php      2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-templates/bp-legacy/buddypress/members/single/settings.php 2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -34,7 +34,10 @@
</span><span class="cx">  case 'general'        :
</span><span class="cx">          bp_get_template_part( 'members/single/settings/general'        );
</span><span class="cx">          break;
</span><ins>+       case 'profile'        :
+               bp_get_template_part( 'members/single/settings/profile'        );
+               break;
</ins><span class="cx">   default:
</span><span class="cx">          bp_get_template_part( 'members/single/plugins'                 );
</span><span class="cx">          break;
</span><del>-endswitch;
</del><span class="cx">\ No newline at end of file
</span><ins>+endswitch;
</ins></span></pre></div>
<a id="trunkbptemplatesbplegacycssbuddypresscss"></a>
<div class="modfile"><h4>Modified: trunk/bp-templates/bp-legacy/css/buddypress.css (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-templates/bp-legacy/css/buddypress.css  2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-templates/bp-legacy/css/buddypress.css     2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -894,6 +894,7 @@
</span><span class="cx"> }
</span><span class="cx"> #buddypress table.notifications,
</span><span class="cx"> #buddypress table.notifications-settings,
</span><ins>+#buddypress table.profile-settings,
</ins><span class="cx"> #buddypress table.profile-fields,
</span><span class="cx"> #buddypress table.wp-profile-fields,
</span><span class="cx"> #buddypress table.messages-notices,
</span><span class="lines">@@ -902,6 +903,7 @@
</span><span class="cx"> }
</span><span class="cx"> #buddypress table.notifications thead tr,
</span><span class="cx"> #buddypress table.notifications-settings thead tr,
</span><ins>+#buddypress table.profile-settings thead tr,
</ins><span class="cx"> #buddypress table.profile-fields thead tr,
</span><span class="cx"> #buddypress table.wp-profile-fields thead tr,
</span><span class="cx"> #buddypress table.messages-notices thead tr,
</span><span class="lines">@@ -927,6 +929,7 @@
</span><span class="cx"> }
</span><span class="cx"> #buddypress table.notifications tr td,
</span><span class="cx"> #buddypress table.notifications-settings tr td,
</span><ins>+#buddypress table.profile-settings tr td,
</ins><span class="cx"> #buddypress table.profile-fields tr td,
</span><span class="cx"> #buddypress table.wp-profile-fields tr td,
</span><span class="cx"> #buddypress table.messages-notices tr td,
</span><span class="lines">@@ -963,6 +966,7 @@
</span><span class="cx"> }
</span><span class="cx"> #buddypress table.notifications tr.alt td,
</span><span class="cx"> #buddypress table.notifications-settings tr.alt td,
</span><ins>+#buddypress table.profile-settings tr.alt td,
</ins><span class="cx"> #buddypress table.profile-fields tr.alt td,
</span><span class="cx"> #buddypress table.wp-profile-fields tr.alt td,
</span><span class="cx"> #buddypress table.messages-notices tr.alt td,
</span><span class="lines">@@ -982,7 +986,8 @@
</span><span class="cx"> #buddypress table.notification-settings td:first-child {
</span><span class="cx">  display: none;
</span><span class="cx"> }
</span><del>-#buddypress table.notification-settings th.title {
</del><ins>+#buddypress table.notification-settings th.title,
+#buddypress table.profile-settings th.title {
</ins><span class="cx">   width: 80%;
</span><span class="cx"> }
</span><span class="cx"> #buddypress table.notification-settings .yes,
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_inccssdefaultcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/css/default.css (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/css/default.css  2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-themes/bp-default/_inc/css/default.css     2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -1953,7 +1953,8 @@
</span><span class="cx"> table tr.alt td {
</span><span class="cx">  background: #f5f5f5;
</span><span class="cx"> }
</span><del>-table.notification-settings {
</del><ins>+table.notification-settings,
+table.profile-settings {
</ins><span class="cx">   margin-bottom: 20px;
</span><span class="cx">  text-align: left;
</span><span class="cx"> }
</span><span class="lines">@@ -1964,7 +1965,8 @@
</span><span class="cx"> table.notification-settings td:first-child {
</span><span class="cx">  display: none;
</span><span class="cx"> }
</span><del>-table.notification-settings th.title {
</del><ins>+table.notification-settings th.title,
+table.profile-settings th.title {
</ins><span class="cx">   width: 80%;
</span><span class="cx"> }
</span><span class="cx"> table.notification-settings .yes,
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultmemberssinglesettingsprofilephp"></a>
<div class="addfile"><h4>Added: trunk/bp-themes/bp-default/members/single/settings/profile.php (0 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/members/single/settings/profile.php                           (rev 0)
+++ trunk/bp-themes/bp-default/members/single/settings/profile.php      2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+<?php
+
+/**
+ * BuddyPress Member Settings
+ *
+ * @package BuddyPress
+ * @subpackage bp-default
+ */
+
+get_header( 'buddypress' ); ?>
+
+       <div id="content">
+               <div class="padder">
+
+                       <?php do_action( 'bp_before_member_settings_template' ); ?>
+
+                       <div id="item-header">
+
+                               <?php locate_template( array( 'members/single/member-header.php' ), true ); ?>
+
+                       </div><!-- #item-header -->
+
+                       <div id="item-nav">
+                               <div class="item-list-tabs no-ajax" id="object-nav" role="navigation">
+                                       <ul>
+
+                                               <?php bp_get_displayed_user_nav(); ?>
+
+                                               <?php do_action( 'bp_member_options_nav' ); ?>
+
+                                       </ul>
+                               </div>
+                       </div><!-- #item-nav -->
+
+                       <div id="item-body" role="main">
+
+                               <?php do_action( 'bp_before_member_body' ); ?>
+
+                               <div class="item-list-tabs no-ajax" id="subnav">
+                                       <ul>
+
+                                               <?php bp_get_options_nav(); ?>
+
+                                               <?php do_action( 'bp_member_plugin_options_nav' ); ?>
+
+                                       </ul>
+                               </div><!-- .item-list-tabs -->
+
+                               <h3><?php _e( 'Profile Settings', 'buddypress' ); ?></h3>
+
+                               <?php do_action( 'bp_template_content' ); ?>
+
+                               <form action="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/profile' ); ?>" method="post" class="standard-form" id="settings-form">
+
+                                       <?php if ( bp_xprofile_get_settings_fields() ) : ?>
+
+                                               <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
+
+                                                       <table class="profile-settings" id="xprofile-settings-<?php bp_the_profile_group_slug(); ?>">
+                                                               <thead>
+                                                                       <tr>
+                                                                               <th class="title field-group-name"><?php bp_the_profile_group_name(); ?></th>
+                                                                               <th class="title"><?php _e( 'Visibility', 'buddypress' ); ?></th>
+                                                                       </tr>
+                                                               </thead>
+
+                                                               <tbody>
+
+                                                                       <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
+
+                                                                               <tr <?php bp_field_css_class(); ?>>
+                                                                                       <td class="field-name"><?php bp_the_profile_field_name(); ?></td>
+                                                                                       <td class="field-visibility"><?php bp_xprofile_settings_visibility_select(); ?></td>
+                                                                               </tr>
+
+                                                                       <?php endwhile; ?>
+
+                                                               </tbody>
+                                                       </table>
+
+                                               <?php endwhile; ?>
+
+                                       <?php endif; ?>
+
+                                       <?php do_action( 'bp_core_xprofile_settings_before_submit' ); ?>
+
+                                       <div class="submit">
+                                               <input id="submit" type="submit" name="xprofile-settings-submit" value="<?php _e( 'Save Settings', 'buddypress' ); ?>" class="auto" />
+                                       </div>
+
+                                       <?php do_action( 'bp_core_xprofile_settings_after_submit' ); ?>
+
+                                       <?php wp_nonce_field( 'bp_xprofile_settings' ); ?>
+
+                                       <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
+
+                               </form>
+
+                       </div><!-- #item-body -->
+
+                       <?php do_action( 'bp_after_member_settings_template' ); ?>
+
+               </div><!-- .padder -->
+       </div><!-- #content -->
+
+<?php get_sidebar( 'buddypress' ); ?>
+
+<?php get_footer( 'buddypress' ); ?>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultmemberssinglesettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/members/single/settings.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/members/single/settings.php   2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-themes/bp-default/members/single/settings.php      2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -30,9 +30,10 @@
</span><span class="cx"> elseif ( bp_is_current_action( 'general' ) ) :
</span><span class="cx">  locate_template( array( 'members/single/settings/general.php' ), true );
</span><span class="cx"> 
</span><ins>+elseif ( bp_is_current_action( 'profile' ) ) :
+       locate_template( array( 'members/single/settings/profile.php' ), true );
+
</ins><span class="cx"> else :
</span><span class="cx">  locate_template( array( 'members/single/plugins.php' ), true );
</span><span class="cx"> 
</span><span class="cx"> endif;
</span><del>-
-?>
</del></span></pre></div>
<a id="trunkbpxprofilebpxprofileactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-actions.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-actions.php        2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-xprofile/bp-xprofile-actions.php   2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -43,3 +43,66 @@
</span><span class="cx">  bp_core_redirect( wp_get_referer() );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'xprofile_action_delete_avatar' );
</span><ins>+
+/**
+ * Handles the saving of xprofile field visibilities
+ *
+ * @since BuddyPress (1.9)
+ */
+function bp_xprofile_action_settings() {
+
+       // Bail if not a POST action
+       if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
+               return;
+       }
+
+       // Bail if no submit action
+       if ( ! isset( $_POST['xprofile-settings-submit'] ) ) {
+               return;
+       }
+
+       // Bail if not in settings
+       if ( ! bp_is_user_settings_profile() ) {
+               return;
+       }
+
+       // 404 if there are any additional action variables attached
+       if ( bp_action_variables() ) {
+               bp_do_404();
+               return;
+       }
+
+       // Nonce check
+       check_admin_referer( 'bp_xprofile_settings' );
+
+       do_action( 'bp_xprofile_settings_before_save' );
+
+       /** Save ******************************************************************/
+
+       // Only save if there are field ID's being posted
+       if ( ! empty( $_POST['field_ids'] ) ) {
+
+               // Get the POST'ed field ID's
+               $posted_field_ids = explode( ',', $_POST['field_ids'] );
+
+               // Save the visibility settings
+               foreach ( $posted_field_ids as $field_id ) {
+
+                       $visibility_level = 'public';
+
+                       if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) ) {
+                               $visibility_level = $_POST['field_' . $field_id . '_visibility'];
+                       }
+
+                       xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level );
+               }
+       }
+
+       /** Other *****************************************************************/
+
+       do_action( 'bp_xprofile_settings_after_save' );
+
+       // Redirect to the root domain
+       bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/privacy' );
+}
+add_action( 'bp_actions', 'bp_xprofile_action_settings' );
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-loader.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-loader.php 2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-xprofile/bp-xprofile-loader.php    2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">                  'caps',
</span><span class="cx">                  'classes',
</span><span class="cx">                  'filters',
</span><ins>+                       'settings',
</ins><span class="cx">                   'template',
</span><span class="cx">                  'buddybar',
</span><span class="cx">                  'functions',
</span><span class="lines">@@ -219,6 +220,24 @@
</span><span class="cx">                  );
</span><span class="cx">          }
</span><span class="cx"> 
</span><ins>+               // Privacy Settings
+               if ( bp_is_active( 'settings' ) ) {
+
+                       // Get the settings slug
+                       $settings_slug = bp_get_settings_slug();
+
+                       // Add the sub-navigation
+                       $sub_nav[] = array(
+                               'name'            => __( 'Profile', 'buddypress' ),
+                               'slug'            => 'profile',
+                               'parent_url'      => trailingslashit( $user_domain . $settings_slug ),
+                               'parent_slug'     => $settings_slug,
+                               'screen_function' => 'bp_xprofile_screen_settings',
+                               'position'        => 30,
+                               'user_has_access' => bp_core_can_edit_settings()
+                       );
+               }
+
</ins><span class="cx">           parent::setup_nav( $main_nav, $sub_nav );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -271,6 +290,20 @@
</span><span class="cx">                          );
</span><span class="cx">                  }
</span><span class="cx"> 
</span><ins>+                       // Privacy Settings
+                       if ( bp_is_active( 'settings' ) ) {
+
+                               // Setup the logged in user variables
+                               $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );
+
+                               // Add main Settings menu
+                               $wp_admin_nav[] = array(
+                                       'parent' => 'my-account-' . $bp->settings->id,
+                                       'id'     => 'my-account-' . $bp->settings->id . '-profile',
+                                       'title'  => __( 'Profile', 'buddypress' ),
+                                       'href'   => trailingslashit( $settings_link . 'profile' )
+                               );
+                       }
</ins><span class="cx">           }
</span><span class="cx"> 
</span><span class="cx">          parent::setup_admin_bar( $wp_admin_nav );
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilescreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-screens.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-screens.php        2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-xprofile/bp-xprofile-screens.php   2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -208,3 +208,20 @@
</span><span class="cx"> 
</span><span class="cx">  bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'members/single/home' ) );
</span><span class="cx"> }
</span><ins>+
+/**
+ * Show the xprofile settings template
+ *
+ * @since BuddyPress (2.0.0)
+ */
+function bp_xprofile_screen_settings() {
+
+       // Redirect if no privacy settings page is accessible
+       if ( bp_action_variables() || ! bp_is_active( 'xprofile' ) ) {
+               bp_do_404();
+               return;
+       }
+
+       // Load the template
+       bp_core_load_template( apply_filters( 'bp_settings_screen_xprofile', '/members/single/plugin' ) );
+}
</ins></span></pre></div>
<a id="trunkbpxprofilebpxprofilesettingsphp"></a>
<div class="addfile"><h4>Added: trunk/bp-xprofile/bp-xprofile-settings.php (0 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-settings.php                               (rev 0)
+++ trunk/bp-xprofile/bp-xprofile-settings.php  2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+<?php
+
+/**
+ * Query all profile fields and their visibility data for display in settings
+ *
+ * @since BuddyPress (2.0.0)
+ *
+ * @param array $args
+ * 
+ * 
+ * @return array
+ */
+function bp_xprofile_get_settings_fields( $args = '' ) {
+
+       // Parse the possible arguments
+       $r = bp_parse_args( $args, array(
+               'user_id'                => bp_displayed_user_id(),
+               'profile_group_id'       => false,
+               'hide_empty_groups'      => false,
+               'hide_empty_fields'      => false,
+               'fetch_fields'           => true,
+               'fetch_field_data'       => false,
+               'fetch_visibility_level' => true,
+               'exclude_groups'         => false,
+               'exclude_fields'         => false
+       ), 'xprofile_get_settings_fields' );
+
+       return bp_has_profile( $r );
+}
+
+/**
+ * Adds feedback messages when successfully saving profile field settings
+ *
+ * @since BuddyPress (2.0.0)
+ *
+ * @uses bp_core_add_message()
+ * @usse bp_is_my_profile()
+ */
+function bp_xprofile_settings_add_feedback_message() {
+
+       // Default message type is success
+       $type    = 'success';
+       $message = __( 'Your profile settings have been saved.',        'buddypress' );
+
+       // Community moderator editing another user's settings
+       if ( ! bp_is_my_profile() && bp_core_can_edit_settings() ) {
+               $message = __( "This member's profile settings have been saved.", 'buddypress' );
+       }
+
+       // Add the message
+       bp_core_add_message( $message, $type );
+}
+add_action( 'bp_xprofile_settings_after_save', 'bp_xprofile_settings_add_feedback_message' );
</ins></span></pre></div>
<a id="trunkbpxprofilebpxprofiletemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-template.php (7959 => 7960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-template.php       2014-02-21 21:58:32 UTC (rev 7959)
+++ trunk/bp-xprofile/bp-xprofile-template.php  2014-02-21 23:08:04 UTC (rev 7960)
</span><span class="lines">@@ -936,6 +936,8 @@
</span><span class="cx">  ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/** Visibility ****************************************************************/
+
</ins><span class="cx"> /**
</span><span class="cx">  * Echo the field visibility radio buttons
</span><span class="cx">  */
</span><span class="lines">@@ -962,3 +964,56 @@
</span><span class="cx"> 
</span><span class="cx">          return apply_filters( 'bp_profile_get_visibility_radio_buttons', $html );
</span><span class="cx">  }
</span><ins>+
+/**
+ * Output the XProfile field visibility select list for settings
+ *
+ * @since BuddyPress (2.0.0)
+ */
+function bp_xprofile_settings_visibility_select( $args = '' ) {
+       echo bp_xprofile_get_settings_visibility_select( $args );
+}
+       /**
+        * Return the XProfile field visibility select list for settings
+        *
+        * @since BuddyPress (2.0.0)
+        */
+       function bp_xprofile_get_settings_visibility_select( $args = '' ) {
+
+               // Parse optional arguments
+               $r = bp_parse_args( $args, array(
+                       'before' => '',
+                       'after'  => '',
+                       'class'  => 'bp-xprofile-visibility'
+               ), 'xprofile_settings_visibility_select' );
+
+               // Start the output buffer
+               ob_start();
+
+               // Anything before
+               echo $r['before']; ?>
+
+               <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
+
+                       <select class="<?php echo esc_attr( $r['class'] ); ?>" name="field_<?php bp_the_profile_field_id(); ?>_visibility">
+
+                               <?php foreach ( bp_xprofile_get_visibility_levels() as $level ) : ?>
+
+                                       <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>
+
+                               <?php endforeach; ?>
+
+                       </select>
+
+               <?php else : ?>
+
+                       <span class="field-visibility-settings-notoggle" title="<?php _e( "This field's visibility cannot be changed.", 'buddypress' ); ?>"><?php bp_the_profile_field_visibility_level_label(); ?></span>
+
+               <?php endif;
+
+               // Anything after
+               echo $r['after'];
+
+               // Output the dropdown list
+               return apply_filters( 'bp_xprofile_settings_visibility_select', ob_get_clean() );
+       }
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>