<!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][5305] trunk: Port user active/status functions from bbPress 2.</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/5305">5305</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-11-08 02:15:22 +0000 (Tue, 08 Nov 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Port user active/status functions from bbPress 2. Deprecate old _core_ functions into 1.6.php as wrappers. See <a href="http://buddypress.trac.wordpress.org/ticket/3739">#3739</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityfunctionsphp">trunk/bp-activity/bp-activity-functions.php</a></li>
<li><a href="#trunkbpactivitybpactivitytemplatephp">trunk/bp-activity/bp-activity-template.php</a></li>
<li><a href="#trunkbpcorebpcorecatchuriphp">trunk/bp-core/bp-core-catchuri.php</a></li>
<li><a href="#trunkbpcorebpcorefunctionsphp">trunk/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunkbpcoredeprecated16php">trunk/bp-core/deprecated/1.6.php</a></li>
<li><a href="#trunkbpforumsbpforumsfunctionsphp">trunk/bp-forums/bp-forums-functions.php</a></li>
<li><a href="#trunkbpmembersbpmembersfunctionsphp">trunk/bp-members/bp-members-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-functions.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-functions.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-activity/bp-activity-functions.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -870,7 +870,7 @@
</span><span class="cx">         if ( empty( $content ) || !strlen( trim( $content ) ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( bp_core_is_user_spammer( $user_id ) || bp_core_is_user_deleted( $user_id ) )
</del><ins>+        if ( bp_is_user_inactive( $user_id ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         // Record this on the user's profile
</span></span></pre></div>
<a id="trunkbpactivitybpactivitytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-template.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-template.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-activity/bp-activity-template.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -2045,7 +2045,7 @@
</span><span class="cx">                 if ( !$user_id )
</span><span class="cx">                         $user_id = bp_displayed_user_id();
</span><span class="cx">
</span><del>-                if ( bp_core_is_user_spammer( $user_id ) || bp_core_is_user_deleted( $user_id ) )
</del><ins>+                if ( bp_is_user_inactive( $user_id ) )
</ins><span class="cx">                         return false;
</span><span class="cx">
</span><span class="cx">                 if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
</span></span></pre></div>
<a id="trunkbpcorebpcorecatchuriphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-catchuri.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-catchuri.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-core/bp-core-catchuri.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -254,7 +254,7 @@
</span><span class="cx">
</span><span class="cx">                                 // If the displayed user is marked as a spammer, 404 (unless logged-
</span><span class="cx">                                 // in user is a super admin)
</span><del>-                                if ( bp_displayed_user_id() && bp_core_is_user_spammer( bp_displayed_user_id() ) ) {
</del><ins>+                                if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
</ins><span class="cx">                                         if ( is_super_admin() ) {
</span><span class="cx">                                                 bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
</span><span class="cx">                                         } else {
</span></span></pre></div>
<a id="trunkbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-functions.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-functions.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-core/bp-core-functions.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -703,7 +703,7 @@
</span><span class="cx">
</span><span class="cx">         $user_id = bp_loggedin_user_id();
</span><span class="cx">
</span><del>-        if ( bp_core_is_user_spammer( $user_id ) || bp_core_is_user_deleted( $user_id ) )
</del><ins>+        if ( bp_is_user_inactive( $user_id ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         $activity = bp_get_user_meta( $user_id, 'last_activity', true );
</span></span></pre></div>
<a id="trunkbpcoredeprecated16php"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/deprecated/1.6.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/deprecated/1.6.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-core/deprecated/1.6.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -38,4 +38,13 @@
</span><span class="cx">         _deprecated_function( __FUNCTION__, '1.6' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function bp_core_is_user_deleted( $user_id = 0 ) {
+        _deprecated_function( __FUNCTION__, '1.6' );
+        bp_is_user_deleted( $user_id );
+}
+
+function bp_core_is_user_spammer( $user_id = 0 ) {
+        _deprecated_function( __FUNCTION__, '1.6' );
+        bp_is_user_spammer( $user_id );
+}
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpforumsbpforumsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-functions.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-functions.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-forums/bp-forums-functions.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -168,7 +168,7 @@
</span><span class="cx">         if ( empty( $topic_poster ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( bp_core_is_user_spammer( $topic_poster ) || bp_core_is_user_deleted( $topic_poster ) )
</del><ins>+        if ( bp_is_user_inactive( $topic_poster ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         if ( empty( $topic_slug ) )
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         // Check if the user is a spammer
</span><del>-        if ( bp_core_is_user_spammer( bp_loggedin_user_id() ) || bp_core_is_user_deleted( bp_loggedin_user_id() ) )
</del><ins>+        if ( bp_is_user_inactive( bp_loggedin_user_id() ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
</span><span class="lines">@@ -514,7 +514,7 @@
</span><span class="cx">         if ( empty( $poster_id ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( bp_core_is_user_spammer( bp_loggedin_user_id() ) || bp_core_is_user_deleted( bp_loggedin_user_id() ) )
</del><ins>+        if ( bp_is_user_inactive( bp_loggedin_user_id() ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
</span></span></pre></div>
<a id="trunkbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-functions.php (5304 => 5305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-functions.php        2011-11-08 02:14:00 UTC (rev 5304)
+++ trunk/bp-members/bp-members-functions.php        2011-11-08 02:15:22 UTC (rev 5305)
</span><span class="lines">@@ -493,7 +493,7 @@
</span><span class="cx"> * @param int $user_id int The id for the user.
</span><span class="cx"> * @return bool True if spammer, False if not.
</span><span class="cx"> */
</span><del>-function bp_core_is_user_spammer( $user_id = 0 ) {
</del><ins>+function bp_is_user_spammer( $user_id = 0 ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">
</span><span class="cx">         // No user to check
</span><span class="lines">@@ -521,7 +521,7 @@
</span><span class="cx">                         $is_spammer = true;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return apply_filters( 'bp_core_is_user_spammer', (bool) $is_spammer );
</del><ins>+        return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -531,7 +531,7 @@
</span><span class="cx"> * @param int $user_id int The id for the user.
</span><span class="cx"> * @return bool True if deleted, False if not.
</span><span class="cx"> */
</span><del>-function bp_core_is_user_deleted( $user_id = 0 ) {
</del><ins>+function bp_is_user_deleted( $user_id = 0 ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">
</span><span class="cx">         // No user to check
</span><span class="lines">@@ -560,10 +560,71 @@
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return apply_filters( 'bp_core_is_user_deleted', (bool) $is_deleted );
</del><ins>+        return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Checks if user is active
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses is_user_logged_in() To check if user is logged in
+ * @uses bbp_get_displayed_user_id() To get current user ID
+ * @uses bbp_is_user_spammer() To check if user is spammer
+ * @uses bbp_is_user_deleted() To check if user is deleted
+ *
+ * @param int $user_id The user ID to check
+ * @return bool True if public, false if not
+ */
+function bp_is_user_active( $user_id = 0 ) {
+
+        // Default to current user
+        if ( empty( $user_id ) && is_user_logged_in() )
+                $user_id = bp_loggedin_user_id();
+
+        // No user to check
+        if ( empty( $user_id ) )
+                return false;
+
+        // Check spam
+        if ( bp_is_user_spammer( $user_id ) )
+                return false;
+
+        // Check deleted
+        if ( bp_is_user_deleted( $user_id ) )
+                return false;
+
+        // Assume true if not spam or deleted
+        return true;
+}
+
+/**
+ * Checks if user is not active.
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses is_user_logged_in() To check if user is logged in
+ * @uses bp_get_displayed_user_id() To get current user ID
+ * @uses bp_is_user_active() To check if user is active
+ *
+ * @param int $user_id The user ID to check
+ * @return bool True if inactive, false if active
+ */
+function bp_is_user_inactive( $user_id = 0 ) {
+
+        // Default to current user
+        if ( empty( $user_id ) && is_user_logged_in() )
+                $user_id = bp_loggedin_user_id();
+
+        // No user to check
+        if ( empty( $user_id ) )
+                return false;
+
+        // Return the inverse of active
+        return !bp_is_user_active( $user_id );
+}
+
+/**
</ins><span class="cx"> * Fetch every post that is authored by the given user for the current blog.
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span></span></pre>
</div>
</div>
</body>
</html>