<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [1784] trunk:
Added ability for admins to disable account deletion.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>1784</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-03 19:48:41 +0000 (Thu, 03 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Added ability for admins to disable account deletion.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreadminphp">trunk/bp-core/bp-core-admin.php</a></li>
<li><a href="#trunkbpcorebpcoresettingsphp">trunk/bp-core/bp-core-settings.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-admin.php (1783 => 1784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-admin.php        2009-09-03 19:34:39 UTC (rev 1783)
+++ trunk/bp-core/bp-core-admin.php        2009-09-03 19:48:41 UTC (rev 1784)
</span><span class="lines">@@ -84,8 +84,14 @@
</span><span class="cx">                                                 <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
</span><span class="cx">                                         </td>                        
</span><span class="cx">                                 </tr>
</span><del>-                                <?php } ?>
-                                
</del><ins>+                                <?php } ?>                                
+                                <tr>
+                                        <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
+                                        <td>
+                                                <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
+                                                <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) || '' == get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
+                                        </td>                        
+                                </tr>                                
</ins><span class="cx">                                 <?php if ( !locate_template( array( 'registration/register.php' ) ) ) :?>
</span><span class="cx">                                 <tr>
</span><span class="cx">                                         <th scope="row"><?php _e('Select theme to use for BuddyPress generated pages', 'buddypress' ) ?>:</th>
</span></span></pre></div>
<a id="trunkbpcorebpcoresettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-settings.php (1783 => 1784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-settings.php        2009-09-03 19:34:39 UTC (rev 1783)
+++ trunk/bp-core/bp-core-settings.php        2009-09-03 19:48:41 UTC (rev 1784)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">         bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_home() ) );
</span><span class="cx">         bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_home() ) );
</span><span class="cx">         
</span><del>-        if ( !is_site_admin() )
</del><ins>+        if ( !is_site_admin() && 1 != (int)get_site_option( 'bp-disable-account-deletion' ) )
</ins><span class="cx">                 bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_home() ) );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'bp_core_add_settings_nav', 2 );
</span><span class="lines">@@ -35,7 +35,9 @@
</span><span class="cx">         $bp_settings_updated = false;
</span><span class="cx">         $pass_error = false;
</span><span class="cx">         
</span><del>-        if ( isset($_POST['submit']) && check_admin_referer('bp_settings_general') ) {
</del><ins>+        if ( isset($_POST['submit']) ) {
+                check_admin_referer('bp_settings_general');
+                
</ins><span class="cx">                 require_once( WPINC . '/registration.php' );
</span><span class="cx">                 
</span><span class="cx">                 // Form has been submitted and nonce checks out, lets do it.
</span><span class="lines">@@ -104,7 +106,9 @@
</span><span class="cx">         
</span><span class="cx">         $bp_settings_updated = false;
</span><span class="cx">         
</span><del>-        if ( $_POST['submit'] && check_admin_referer('bp_settings_notifications') ) {
</del><ins>+        if ( $_POST['submit'] ) {
+                check_admin_referer('bp_settings_notifications');
+                
</ins><span class="cx">                 if ( $_POST['notifications'] ) {
</span><span class="cx">                         foreach ( $_POST['notifications'] as $key => $value ) {
</span><span class="cx">                                 update_usermeta( (int)$current_user->id, $key, $value );
</span><span class="lines">@@ -152,9 +156,8 @@
</span><span class="cx"> function bp_core_screen_delete_account() {
</span><span class="cx">         global $current_user, $bp_settings_updated, $pass_error;
</span><span class="cx">         
</span><del>-        if ( isset( $_POST['delete-account-button'] ) && check_admin_referer('delete-account') ) {
-                if ( !check_admin_referer( 'delete-account' ) )
-                        return false;
</del><ins>+        if ( isset( $_POST['delete-account-button'] ) ) {
+                check_admin_referer( 'delete-account' );
</ins><span class="cx">                 
</span><span class="cx">                 // delete the users account
</span><span class="cx">                 if ( bp_core_delete_account() )
</span><span class="lines">@@ -164,7 +167,9 @@
</span><span class="cx">         $bp_settings_updated = false;
</span><span class="cx">         $pass_error = false;
</span><span class="cx">         
</span><del>-        if ( isset($_POST['submit']) && check_admin_referer('bp_settings_general') ) {
</del><ins>+        if ( isset($_POST['submit']) ) {
+                check_admin_referer('bp_settings_general');
+                
</ins><span class="cx">                 require_once( WPINC . '/registration.php' );
</span><span class="cx">                 
</span><span class="cx">                 // Form has been submitted and nonce checks out, lets do it.
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (1783 => 1784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2009-09-03 19:34:39 UTC (rev 1783)
+++ trunk/bp-core.php        2009-09-03 19:48:41 UTC (rev 1784)
</span><span class="lines">@@ -1325,12 +1325,14 @@
</span><span class="cx"> function bp_core_delete_account() {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><del>-        // Be careful with this function!
-        
</del><ins>+        /* Make sure account deletion is not disabled */
+        if ( 1 == (int)get_site_option( 'bp-disable-account-deletion' ) )
+                return false;
+
</ins><span class="cx">         /* Site admins should not be allowed to delete their accounts */
</span><span class="cx">         if ( is_site_admin() )
</span><span class="cx">                 return false;
</span><del>-        
</del><ins>+
</ins><span class="cx">         require_once( ABSPATH . '/wp-admin/includes/mu.php' );
</span><span class="cx">         require_once( ABSPATH . '/wp-admin/includes/user.php' );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>