<!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][6317] trunk/bp-settings: 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, #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/6317">6317</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2012-09-07 14:50:43 +0000 (Fri, 07 Sep 2012)</dd>
</dl>

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

* General code clean-up.
* php5ize the loader.
* Remove closing php tags.
* Limit creation of one-time-use variables.
* Bail early instead of wrap in big if statements.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpsettingsbpsettingsactionsphp">trunk/bp-settings/bp-settings-actions.php</a></li>
<li><a href="#trunkbpsettingsbpsettingsfunctionsphp">trunk/bp-settings/bp-settings-functions.php</a></li>
<li><a href="#trunkbpsettingsbpsettingsloaderphp">trunk/bp-settings/bp-settings-loader.php</a></li>
<li><a href="#trunkbpsettingsbpsettingsscreensphp">trunk/bp-settings/bp-settings-screens.php</a></li>
<li><a href="#trunkbpsettingsbpsettingstemplatephp">trunk/bp-settings/bp-settings-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpsettingsbpsettingsactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-actions.php (6316 => 6317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-actions.php        2012-09-07 14:20:06 UTC (rev 6316)
+++ trunk/bp-settings/bp-settings-actions.php        2012-09-07 14:50:43 UTC (rev 6317)
</span><span class="lines">@@ -26,12 +26,15 @@
</span><span class="cx">  * @return If no reason to proceed
</span><span class="cx">  */
</span><span class="cx"> function bp_settings_action_general() {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         // Bail if not a POST action
</span><span class="cx">         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><ins>+        // Bail if no submit action
+        if ( ! isset( $_POST['submit'] ) )
+                return;
+
</ins><span class="cx">         // Bail if not in settings
</span><span class="cx">         if ( ! bp_is_settings_component() || ! bp_is_current_action( 'general' ) )
</span><span class="cx">                 return;
</span><span class="lines">@@ -43,172 +46,169 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Define local defaults
</span><del>-        $email_error   = false;   // invalid|blocked|taken|empty|nochange
-        $pass_error    = false;   // invalid|mismatch|empty|nochange
-        $pass_changed  = false;   // true if the user changes their password
-        $email_changed = false;   // true if the user changes their email
-        $feedback_type = 'error'; // success|error
-        $feedback      = array(); // array of strings for feedback
</del><ins>+        $bp            = buddypress(); // The instance
+        $email_error   = false;        // invalid|blocked|taken|empty|nochange
+        $pass_error    = false;        // invalid|mismatch|empty|nochange
+        $pass_changed  = false;        // true if the user changes their password
+        $email_changed = false;        // true if the user changes their email
+        $feedback_type = 'error';      // success|error
+        $feedback      = array();      // array of strings for feedback
</ins><span class="cx"> 
</span><ins>+        // Nonce check
+        check_admin_referer('bp_settings_general');
</ins><span class="cx"> 
</span><del>-        if ( isset( $_POST['submit'] ) ) {
</del><ins>+        // Validate the user again for the current password when making a big change
+        if ( ( is_super_admin() ) || ( !empty( $_POST['pwd'] ) &amp;&amp; wp_check_password( $_POST['pwd'], $bp-&gt;displayed_user-&gt;userdata-&gt;user_pass, bp_displayed_user_id() ) ) ) {
</ins><span class="cx"> 
</span><del>-                // Nonce check
-                check_admin_referer('bp_settings_general');
</del><ins>+                $update_user = get_userdata( bp_displayed_user_id() );
</ins><span class="cx"> 
</span><del>-                // Validate the user again for the current password when making a big change
-                if ( ( is_super_admin() ) || ( !empty( $_POST['pwd'] ) &amp;&amp; wp_check_password( $_POST['pwd'], $bp-&gt;displayed_user-&gt;userdata-&gt;user_pass, bp_displayed_user_id() ) ) ) {
</del><ins>+                /** Email Change Attempt ******************************************/
</ins><span class="cx"> 
</span><del>-                        $update_user = get_userdata( bp_displayed_user_id() );
</del><ins>+                if ( !empty( $_POST['email'] ) ) {
</ins><span class="cx"> 
</span><del>-                        /** Email Change Attempt ******************************************/
</del><ins>+                        // What is missing from the profile page vs signup - lets double check the goodies
+                        $user_email = sanitize_email( esc_html( trim( $_POST['email'] ) ) );
</ins><span class="cx"> 
</span><del>-                        if ( !empty( $_POST['email'] ) ) {
</del><ins>+                        // User is changing email address
+                        if ( $bp-&gt;displayed_user-&gt;userdata-&gt;user_email != $user_email ) {
</ins><span class="cx"> 
</span><del>-                                // What is missing from the profile page vs signup - lets double check the goodies
-                                $user_email = sanitize_email( esc_html( trim( $_POST['email'] ) ) );
</del><ins>+                                // Run some tests on the email address
+                                $email_checks = bp_core_validate_email_address( $user_email );
</ins><span class="cx"> 
</span><del>-                                // User is changing email address
-                                if ( $bp-&gt;displayed_user-&gt;userdata-&gt;user_email != $user_email ) {
</del><ins>+                                if ( true !== $email_checks ) {
+                                        if ( isset( $email_checks['invalid'] ) ) {
+                                                $email_error = 'invalid';
+                                        }
</ins><span class="cx"> 
</span><del>-                                        // Run some tests on the email address
-                                        $email_checks = bp_core_validate_email_address( $user_email );
-
-                                        if ( true !== $email_checks ) {
-                                                if ( isset( $email_checks['invalid'] ) ) {
-                                                        $email_error = 'invalid';
-                                                }
-
-                                                if ( isset( $email_checks['domain_banned'] ) || isset( $email_checks['domain_not_allowed'] ) ) {
-                                                        $email_error = 'blocked';
-                                                }
-
-                                                if ( isset( $email_checks['in_use'] ) ) {
-                                                        $email_error = 'taken';
-                                                }
</del><ins>+                                        if ( isset( $email_checks['domain_banned'] ) || isset( $email_checks['domain_not_allowed'] ) ) {
+                                                $email_error = 'blocked';
</ins><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        // Yay we made it!
-                                        if ( false === $email_error ) {
-                                                $update_user-&gt;user_email = $user_email;
-                                                $email_changed = true;
</del><ins>+                                        if ( isset( $email_checks['in_use'] ) ) {
+                                                $email_error = 'taken';
</ins><span class="cx">                                         }
</span><ins>+                                }
</ins><span class="cx"> 
</span><del>-                                // No change
-                                } else {
-                                        $email_error = false;
</del><ins>+                                // Yay we made it!
+                                if ( false === $email_error ) {
+                                        $update_user-&gt;user_email = $user_email;
+                                        $email_changed = true;
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                        // Email address cannot be empty
</del><ins>+                        // No change
</ins><span class="cx">                         } else {
</span><del>-                                $email_error = 'empty';
</del><ins>+                                $email_error = false;
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        /** Password Change Attempt ***************************************/
</del><ins>+                // Email address cannot be empty
+                } else {
+                        $email_error = 'empty';
+                }
</ins><span class="cx"> 
</span><del>-                        if ( !empty( $_POST['pass1'] ) &amp;&amp; !empty( $_POST['pass2'] ) ) {
</del><ins>+                /** Password Change Attempt ***************************************/
</ins><span class="cx"> 
</span><del>-                                // Password change attempt is successful
-                                if ( ( $_POST['pass1'] == $_POST['pass2'] ) &amp;&amp; !strpos( &quot; &quot; . $_POST['pass1'], &quot;\\&quot; ) ) {
-                                        $update_user-&gt;user_pass = $_POST['pass1'];
-                                        $pass_changed = true;
</del><ins>+                if ( !empty( $_POST['pass1'] ) &amp;&amp; !empty( $_POST['pass2'] ) ) {
</ins><span class="cx"> 
</span><del>-                                // Password change attempt was unsuccessful
-                                } else {
-                                        $pass_error = 'mismatch';
-                                }
</del><ins>+                        // Password change attempt is successful
+                        if ( ( $_POST['pass1'] == $_POST['pass2'] ) &amp;&amp; !strpos( &quot; &quot; . $_POST['pass1'], &quot;\\&quot; ) ) {
+                                $update_user-&gt;user_pass = $_POST['pass1'];
+                                $pass_changed = true;
</ins><span class="cx"> 
</span><del>-                        // Both password fields were empty
-                        } elseif ( empty( $_POST['pass1'] ) &amp;&amp; empty( $_POST['pass2'] ) ) {
-                                $pass_error = false;
-
-                        // One of the password boxes was left empty
-                        } elseif ( ( empty( $_POST['pass1'] ) &amp;&amp; !empty( $_POST['pass2'] ) ) || ( !empty( $_POST['pass1'] ) &amp;&amp; empty( $_POST['pass2'] ) ) ) {
-                                $pass_error = 'empty';
</del><ins>+                        // Password change attempt was unsuccessful
+                        } else {
+                                $pass_error = 'mismatch';
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        // The structure of the $update_user object changed in WP 3.3, but
-                        // wp_update_user() still expects the old format
-                        if ( isset( $update_user-&gt;data ) &amp;&amp; is_object( $update_user-&gt;data ) ) {
-                                $update_user = $update_user-&gt;data;
-                                $update_user = get_object_vars( $update_user );
</del><ins>+                // Both password fields were empty
+                } elseif ( empty( $_POST['pass1'] ) &amp;&amp; empty( $_POST['pass2'] ) ) {
+                        $pass_error = false;
</ins><span class="cx"> 
</span><del>-                                // Unset the password field to prevent it from emptying out the
-                                // user's user_pass field in the database.
-                                // @see wp_update_user()
-                                if ( false === $pass_changed ) {
-                                        unset( $update_user['user_pass'] );
-                                }
-                        }
</del><ins>+                // One of the password boxes was left empty
+                } elseif ( ( empty( $_POST['pass1'] ) &amp;&amp; !empty( $_POST['pass2'] ) ) || ( !empty( $_POST['pass1'] ) &amp;&amp; empty( $_POST['pass2'] ) ) ) {
+                        $pass_error = 'empty';
+                }
</ins><span class="cx"> 
</span><del>-                        // Make sure these changes are in $bp for the current page load
-                        if ( ( false === $email_error ) &amp;&amp; ( false === $pass_error ) &amp;&amp; ( wp_update_user( $update_user ) ) ) {
-                                $bp-&gt;displayed_user-&gt;userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
</del><ins>+                // The structure of the $update_user object changed in WP 3.3, but
+                // wp_update_user() still expects the old format
+                if ( isset( $update_user-&gt;data ) &amp;&amp; is_object( $update_user-&gt;data ) ) {
+                        $update_user = $update_user-&gt;data;
+                        $update_user = get_object_vars( $update_user );
+
+                        // Unset the password field to prevent it from emptying out the
+                        // user's user_pass field in the database.
+                        // @see wp_update_user()
+                        if ( false === $pass_changed ) {
+                                unset( $update_user['user_pass'] );
</ins><span class="cx">                         }
</span><del>-
-                // Password Error
-                } else {
-                        $pass_error = 'invalid';
</del><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                // Email feedback
-                switch ( $email_error ) {
-                        case 'invalid' :
-                                $feedback['email_invalid']  = __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' );
-                                break;
-                        case 'blocked' :
-                                $feedback['email_blocked']  = __( 'That email address is currently unavailable for use.', 'buddypress' );
-                                break;
-                        case 'taken' :
-                                $feedback['email_taken']    = __( 'That email address is already taken.', 'buddypress' );
-                                break;
-                        case 'empty' :
-                                $feedback['email_empty']    = __( 'Email address cannot be empty.', 'buddypress' );
-                                break;
-                        case false :
-                                // No change
-                                break;
</del><ins>+                // Make sure these changes are in $bp for the current page load
+                if ( ( false === $email_error ) &amp;&amp; ( false === $pass_error ) &amp;&amp; ( wp_update_user( $update_user ) ) ) {
+                        $bp-&gt;displayed_user-&gt;userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                // Password feedback
-                switch ( $pass_error ) {
-                        case 'invalid' :
-                                $feedback['pass_error']    = __( 'Your current password is invalid.', 'buddypress' );
-                                break;
-                        case 'mismatch' :
-                                $feedback['pass_mismatch'] = __( 'The new password fields did not match.', 'buddypress' );
-                                break;
-                        case 'empty' :
-                                $feedback['pass_empty']    = __( 'One of the password fields was empty.', 'buddypress' );
-                                break;
-                        case false :
-                                // No change
-                                break;
-                }
</del><ins>+        // Password Error
+        } else {
+                $pass_error = 'invalid';
+        }
</ins><span class="cx"> 
</span><del>-                // No errors so show a simple success message
-                if ( ( ( false === $email_error ) || ( false == $pass_error ) ) &amp;&amp; ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) {
-                        $feedback[]    = __( 'Your settings have been saved.', 'buddypress' );
-                        $feedback_type = 'success';
</del><ins>+        // Email feedback
+        switch ( $email_error ) {
+                case 'invalid' :
+                        $feedback['email_invalid']  = __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' );
+                        break;
+                case 'blocked' :
+                        $feedback['email_blocked']  = __( 'That email address is currently unavailable for use.', 'buddypress' );
+                        break;
+                case 'taken' :
+                        $feedback['email_taken']    = __( 'That email address is already taken.', 'buddypress' );
+                        break;
+                case 'empty' :
+                        $feedback['email_empty']    = __( 'Email address cannot be empty.', 'buddypress' );
+                        break;
+                case false :
+                        // No change
+                        break;
+        }
</ins><span class="cx"> 
</span><del>-                // Some kind of errors occurred
-                } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) &amp;&amp; ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) {
-                        if ( bp_is_my_profile() ) {
-                                $feedback['nochange'] = __( 'No changes were made to your account.', 'buddypress' );
-                        } else {
-                                $feedback['nochange'] = __( 'No changes were made to this account.', 'buddypress' );
-                        }
</del><ins>+        // Password feedback
+        switch ( $pass_error ) {
+                case 'invalid' :
+                        $feedback['pass_error']    = __( 'Your current password is invalid.', 'buddypress' );
+                        break;
+                case 'mismatch' :
+                        $feedback['pass_mismatch'] = __( 'The new password fields did not match.', 'buddypress' );
+                        break;
+                case 'empty' :
+                        $feedback['pass_empty']    = __( 'One of the password fields was empty.', 'buddypress' );
+                        break;
+                case false :
+                        // No change
+                        break;
+        }
+
+        // No errors so show a simple success message
+        if ( ( ( false === $email_error ) || ( false == $pass_error ) ) &amp;&amp; ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) {
+                $feedback[]    = __( 'Your settings have been saved.', 'buddypress' );
+                $feedback_type = 'success';
+
+        // Some kind of errors occurred
+        } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) &amp;&amp; ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) {
+                if ( bp_is_my_profile() ) {
+                        $feedback['nochange'] = __( 'No changes were made to your account.', 'buddypress' );
+                } else {
+                        $feedback['nochange'] = __( 'No changes were made to this account.', 'buddypress' );
</ins><span class="cx">                 }
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-                // Set the feedback
-                bp_core_add_message( implode( '&lt;/p&gt;&lt;p&gt;', $feedback ), $feedback_type );
</del><ins>+        // Set the feedback
+        bp_core_add_message( implode( '&lt;/p&gt;&lt;p&gt;', $feedback ), $feedback_type );
</ins><span class="cx"> 
</span><del>-                // Execute additional code
-                do_action( 'bp_core_general_settings_after_save' );
</del><ins>+        // Execute additional code
+        do_action( 'bp_core_general_settings_after_save' );
</ins><span class="cx"> 
</span><del>-                // Redirect to prevent issues with browser back button
-                bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ) );
-        }
</del><ins>+        // Redirect to prevent issues with browser back button
+        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ) );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'bp_settings_action_general' );
</span><span class="cx"> 
</span><span class="lines">@@ -223,6 +223,10 @@
</span><span class="cx">         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><ins>+        // Bail if no submit action
+        if ( ! isset( $_POST['submit'] ) )
+                return;
+
</ins><span class="cx">         // Bail if not in settings
</span><span class="cx">         if ( ! bp_is_settings_component() || ! bp_is_current_action( 'notifications' ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -233,28 +237,26 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( isset( $_POST['submit'] ) ) {
-                check_admin_referer( 'bp_settings_notifications' );
</del><ins>+        check_admin_referer( 'bp_settings_notifications' );
</ins><span class="cx"> 
</span><del>-                if ( isset( $_POST['notifications'] ) ) {
-                        foreach ( (array) $_POST['notifications'] as $key =&gt; $value ) {
-                                if ( $meta_key = bp_get_user_meta_key( $key ) ) {
-                                        bp_update_user_meta( (int) bp_displayed_user_id(), $meta_key, $value );
-                                }
</del><ins>+        if ( isset( $_POST['notifications'] ) ) {
+                foreach ( (array) $_POST['notifications'] as $key =&gt; $value ) {
+                        if ( $meta_key = bp_get_user_meta_key( $key ) ) {
+                                bp_update_user_meta( (int) bp_displayed_user_id(), $meta_key, $value );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-                // Switch feedback for super admins
-                if ( bp_is_my_profile() ) {
-                        bp_core_add_message( __( 'Your notification settings have been saved.',        'buddypress' ), 'success' );
-                } else {
-                        bp_core_add_message( __( &quot;This user's notification settings have been saved.&quot;, 'buddypress' ), 'success' );
-                }
</del><ins>+        // Switch feedback for super admins
+        if ( bp_is_my_profile() ) {
+                bp_core_add_message( __( 'Your notification settings have been saved.',        'buddypress' ), 'success' );
+        } else {
+                bp_core_add_message( __( &quot;This user's notification settings have been saved.&quot;, 'buddypress' ), 'success' );
+        }
</ins><span class="cx"> 
</span><del>-                do_action( 'bp_core_notification_settings_after_save' );
</del><ins>+        do_action( 'bp_core_notification_settings_after_save' );
</ins><span class="cx"> 
</span><del>-                bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/notifications/' );
-        }
</del><ins>+        bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/notifications/' );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'bp_settings_action_notifications' );
</span><span class="cx"> 
</span><span class="lines">@@ -269,6 +271,10 @@
</span><span class="cx">         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><ins>+        // Bail if no submit action
+        if ( ! isset( $_POST['capabilities-submit'] ) )
+                return;
+
</ins><span class="cx">         // Bail if not in settings
</span><span class="cx">         if ( ! bp_is_settings_component() || ! bp_is_current_action( 'capabilities' ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -279,30 +285,27 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( isset( $_POST['capabilities-submit'] ) ) {
</del><ins>+        // Nonce check
+        check_admin_referer( 'capabilities' );
</ins><span class="cx"> 
</span><del>-                // Nonce check
-                check_admin_referer( 'capabilities' );
</del><ins>+        do_action( 'bp_settings_capabilities_before_save' );
</ins><span class="cx"> 
</span><del>-                do_action( 'bp_settings_capabilities_before_save' );
</del><ins>+        /** Spam **************************************************************/
</ins><span class="cx"> 
</span><del>-                /** Spam **************************************************************/
</del><ins>+        $is_spammer = !empty( $_POST['user-spammer'] ) ? true : false;
</ins><span class="cx"> 
</span><del>-                $is_spammer = !empty( $_POST['user-spammer'] ) ? true : false;
</del><ins>+        if ( bp_is_user_spammer( bp_displayed_user_id() ) != $is_spammer ) {
+                $status = ( true == $is_spammer ) ? 'spam' : 'ham';
+                bp_core_process_spammer_status( bp_displayed_user_id(), $status );
+                do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $status );
+        }
</ins><span class="cx"> 
</span><del>-                if ( bp_is_user_spammer( bp_displayed_user_id() ) != $is_spammer ) {
-                        $status = ( true == $is_spammer ) ? 'spam' : 'ham';
-                        bp_core_process_spammer_status( bp_displayed_user_id(), $status );
-                        do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $status );
-                }
</del><ins>+        /** Other *************************************************************/
</ins><span class="cx"> 
</span><del>-                /** Other *************************************************************/
</del><ins>+        do_action( 'bp_settings_capabilities_after_save' );
</ins><span class="cx"> 
</span><del>-                do_action( 'bp_settings_capabilities_after_save' );
-
-                // Redirect to the root domain
-                bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/capabilities/' );
-        }
</del><ins>+        // Redirect to the root domain
+        bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/capabilities/' );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'bp_settings_action_capabilities' );
</span><span class="cx"> 
</span><span class="lines">@@ -317,6 +320,10 @@
</span><span class="cx">         if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><ins>+        // Bail if no submit action
+        if ( ! isset( $_POST['delete-account-understand'] ) )
+                return;
+
</ins><span class="cx">         // Bail if not in settings
</span><span class="cx">         if ( ! bp_is_settings_component() || ! bp_is_current_action( 'delete-account' ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -327,25 +334,20 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( isset( $_POST['delete-account-understand'] ) ) {
</del><ins>+        // Nonce check
+        check_admin_referer( 'delete-account' );
</ins><span class="cx"> 
</span><del>-                // Nonce check
-                check_admin_referer( 'delete-account' );
</del><ins>+        // Get username now because it might be gone soon!
+        $username = bp_get_displayed_user_fullname();
</ins><span class="cx"> 
</span><del>-                // Get username now because it might be gone soon!
-                $username = bp_get_displayed_user_fullname();
</del><ins>+        // delete the users account
+        if ( bp_core_delete_account( bp_displayed_user_id() ) ) {
</ins><span class="cx"> 
</span><del>-                // delete the users account
-                if ( bp_core_delete_account( bp_displayed_user_id() ) ) {
</del><ins>+                // Add feedback ater deleting a user
+                bp_core_add_message( sprintf( __( '%s was successfully deleted.', 'buddypress' ), $username ), 'success' );
</ins><span class="cx"> 
</span><del>-                        // Add feedback ater deleting a user
-                        bp_core_add_message( sprintf( __( '%s was successfully deleted.', 'buddypress' ), $username ), 'success' );
-
-                        // Redirect to the root domain
-                        bp_core_redirect( bp_get_root_domain() );
-                }
</del><ins>+                // Redirect to the root domain
+                bp_core_redirect( bp_get_root_domain() );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'bp_settings_action_delete_account' );
</span><del>-
-?&gt;
</del></span></pre></div>
<a id="trunkbpsettingsbpsettingsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-functions.php (6316 => 6317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-functions.php        2012-09-07 14:20:06 UTC (rev 6316)
+++ trunk/bp-settings/bp-settings-functions.php        2012-09-07 14:50:43 UTC (rev 6317)
</span><span class="lines">@@ -9,5 +9,3 @@
</span><span class="cx"> 
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><del>-
-?&gt;
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpsettingsbpsettingsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-loader.php (6316 => 6317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-loader.php        2012-09-07 14:20:06 UTC (rev 6316)
+++ trunk/bp-settings/bp-settings-loader.php        2012-09-07 14:50:43 UTC (rev 6317)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx">          *
</span><span class="cx">          * @since BuddyPress (1.5)
</span><span class="cx">          */
</span><del>-        function __construct() {
</del><ins>+        public function __construct() {
</ins><span class="cx">                 parent::start(
</span><span class="cx">                         'settings',
</span><span class="cx">                         __( 'Settings', 'buddypress' ),
</span><span class="lines">@@ -30,16 +30,13 @@
</span><span class="cx">          *
</span><span class="cx">          * @global BuddyPress $bp The one true BuddyPress instance
</span><span class="cx">          */
</span><del>-        function includes() {
-                // Files to include
-                $includes = array(
</del><ins>+        public function includes() {
+                parent::includes( array(
</ins><span class="cx">                         'actions',
</span><span class="cx">                         'screens',
</span><span class="cx">                         'template',
</span><span class="cx">                         'functions',
</span><del>-                );
-
-                parent::includes( $includes );
</del><ins>+                ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -50,25 +47,23 @@
</span><span class="cx">          *
</span><span class="cx">          * @since BuddyPress (1.5)
</span><span class="cx">          */
</span><del>-        function setup_globals() {
</del><ins>+        public function setup_globals() {
</ins><span class="cx"> 
</span><span class="cx">                 // Define a slug, if necessary
</span><span class="cx">                 if ( !defined( 'BP_SETTINGS_SLUG' ) )
</span><span class="cx">                         define( 'BP_SETTINGS_SLUG', $this-&gt;id );
</span><span class="cx"> 
</span><span class="cx">                 // All globals for settings component.
</span><del>-                $globals = array(
</del><ins>+                parent::setup_globals( array(
</ins><span class="cx">                         'slug'          =&gt; BP_SETTINGS_SLUG,
</span><span class="cx">                         'has_directory' =&gt; false,
</span><del>-                );
-
-                parent::setup_globals( $globals );
</del><ins>+                ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Setup BuddyBar navigation
</span><span class="cx">          */
</span><del>-        function setup_nav() {
</del><ins>+        public function setup_nav() {
</ins><span class="cx"> 
</span><span class="cx">                 // Define local variable
</span><span class="cx">                 $sub_nav = array();
</span><span class="lines">@@ -146,12 +141,12 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Set up the Toolbar
</span><del>-         *
-         * @global BuddyPress $bp The one true BuddyPress instance
</del><span class="cx">          */
</span><del>-        function setup_admin_bar() {
-                global $bp;
</del><ins>+        public function setup_admin_bar() {
</ins><span class="cx"> 
</span><ins>+                // The instance
+                $bp = buddypress();
+
</ins><span class="cx">                 // Prevent debug notices
</span><span class="cx">                 $wp_admin_nav = array();
</span><span class="cx"> 
</span><span class="lines">@@ -202,9 +197,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_setup_settings() {
</span><del>-        global $bp;
-        $bp-&gt;settings = new BP_Settings_Component();
</del><ins>+        buddypress()-&gt;settings = new BP_Settings_Component();
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'bp_setup_components', 'bp_setup_settings', 6 );
</span><del>-
-?&gt;
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpsettingsbpsettingsscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-screens.php (6316 => 6317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-screens.php        2012-09-07 14:20:06 UTC (rev 6316)
+++ trunk/bp-settings/bp-settings-screens.php        2012-09-07 14:50:43 UTC (rev 6317)
</span><span class="lines">@@ -79,5 +79,3 @@
</span><span class="cx">         // Load the template
</span><span class="cx">         bp_core_load_template( apply_filters( 'bp_settings_screen_capabilities', 'members/single/settings/capabilities' ) );
</span><span class="cx"> }
</span><del>-
-?&gt;
</del></span></pre></div>
<a id="trunkbpsettingsbpsettingstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-template.php (6316 => 6317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-template.php        2012-09-07 14:20:06 UTC (rev 6316)
+++ trunk/bp-settings/bp-settings-template.php        2012-09-07 14:50:43 UTC (rev 6317)
</span><span class="lines">@@ -30,8 +30,7 @@
</span><span class="cx">          * @since BuddyPress (1.5)
</span><span class="cx">          */
</span><span class="cx">         function bp_get_settings_slug() {
</span><del>-                global $bp;
-                return apply_filters( 'bp_get_settings_slug', $bp-&gt;settings-&gt;slug );
</del><ins>+                return apply_filters( 'bp_get_settings_slug', buddypress()-&gt;settings-&gt;slug );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -54,8 +53,5 @@
</span><span class="cx">          * @since BuddyPress (1.5)
</span><span class="cx">          */
</span><span class="cx">         function bp_get_settings_root_slug() {
</span><del>-                global $bp;
-                return apply_filters( 'bp_get_settings_root_slug', $bp-&gt;settings-&gt;root_slug );
</del><ins>+                return apply_filters( 'bp_get_settings_root_slug', buddypress()-&gt;settings-&gt;root_slug );
</ins><span class="cx">         }
</span><del>-
-?&gt;
</del><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>