<!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][7995] trunk/bp-messages/bp-messages-classes.php: Add phpDoc for BP_Messages_Thread class.</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/7995">7995</a></dd>
<dt>Author</dt> <dd>r-a-y</dd>
<dt>Date</dt> <dd>2014-02-26 21:48:25 +0000 (Wed, 26 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add phpDoc for BP_Messages_Thread class.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmessagesbpmessagesclassesphp">trunk/bp-messages/bp-messages-classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpmessagesbpmessagesclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-classes.php (7994 => 7995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-classes.php 2014-02-26 21:37:39 UTC (rev 7994)
+++ trunk/bp-messages/bp-messages-classes.php 2014-02-26 21:48:25 UTC (rev 7995)
</span><span class="lines">@@ -10,18 +10,56 @@
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><ins>+/**
+ * BuddyPress Message Thread class.
+ *
+ * @since BuddyPress (1.0.0)
+ */
</ins><span class="cx"> class BP_Messages_Thread {
</span><ins>+ /**
+ * The message thread ID.
+ *
+ * @since BuddyPress (1.0.0)
+ * @var int
+ */
</ins><span class="cx"> public $thread_id;
</span><ins>+
+ /**
+ * The current messages.
+ *
+ * @since BuddyPress (1.0.0)
+ * @var object
+ */
</ins><span class="cx"> public $messages;
</span><ins>+
+ /**
+ * The current recipients in the message thread.
+ *
+ * @since BuddyPress (1.0.0)
+ * @var object
+ */
</ins><span class="cx"> public $recipients;
</span><ins>+
+ /**
+ * The user IDs of all messages in the message thread.
+ *
+ * @since BuddyPress (1.2.0)
+ * @var array
+ */
</ins><span class="cx"> public $sender_ids;
</span><span class="cx">
</span><ins>+ /**
+ * The unread count for the logged-in user.
+ *
+ * @since BuddyPress (1.2.0)
+ * @var int
+ */
</ins><span class="cx"> public $unread_count;
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * The content of the last message in this thread
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.2)
</del><ins>+ * @since BuddyPress (1.2.0)
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $last_message_content;
</span><span class="lines">@@ -29,7 +67,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * The date of the last message in this thread
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.2)
</del><ins>+ * @since BuddyPress (1.2.0)
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $last_message_date;
</span><span class="lines">@@ -37,7 +75,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * The ID of the last message in this thread
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.2)
</del><ins>+ * @since BuddyPress (1.2.0)
</ins><span class="cx"> * @var int
</span><span class="cx"> */
</span><span class="cx"> public $last_message_id;
</span><span class="lines">@@ -45,7 +83,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * The subject of the last message in this thread
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.2)
</del><ins>+ * @since BuddyPress (1.2.0)
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $last_message_subject;
</span><span class="lines">@@ -53,7 +91,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * The user ID of the author of the last message in this thread
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.2)
</del><ins>+ * @since BuddyPress (1.2.0)
</ins><span class="cx"> * @var int
</span><span class="cx"> */
</span><span class="cx"> public $last_sender_id;
</span><span class="lines">@@ -61,47 +99,91 @@
</span><span class="cx"> /**
</span><span class="cx"> * Sort order of the messages in this thread (ASC or DESC).
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.5)
</del><ins>+ * @since BuddyPress (1.5.0)
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $messages_order;
</span><span class="cx">
</span><ins>+ /**
+ * Constructor.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'.
+ */
</ins><span class="cx"> public function __construct( $thread_id = false, $order = 'ASC' ) {
</span><del>- if ( $thread_id )
</del><ins>+ if ( $thread_id ) {
</ins><span class="cx"> $this->populate( $thread_id, $order );
</span><ins>+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Populate method.
+ *
+ * Used in constructor.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'.
+ */
</ins><span class="cx"> public function populate( $thread_id, $order ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><del>- if( 'ASC' != $order && 'DESC' != $order )
</del><ins>+ if( 'ASC' != $order && 'DESC' != $order ) {
</ins><span class="cx"> $order= 'ASC';
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> $this->messages_order = $order;
</span><span class="cx"> $this->thread_id = $thread_id;
</span><span class="cx">
</span><del>- if ( !$this->messages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE thread_id = %d ORDER BY date_sent " . $order, $this->thread_id ) ) )
</del><ins>+ if ( !$this->messages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE thread_id = %d ORDER BY date_sent " . $order, $this->thread_id ) ) ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><del>- foreach ( (array) $this->messages as $key => $message )
</del><ins>+ foreach ( (array) $this->messages as $key => $message ) {
</ins><span class="cx"> $this->sender_ids[$message->sender_id] = $message->sender_id;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // Fetch the recipients
</span><span class="cx"> $this->recipients = $this->get_recipients();
</span><span class="cx">
</span><span class="cx"> // Get the unread count for the logged in user
</span><del>- if ( isset( $this->recipients[bp_loggedin_user_id()] ) )
</del><ins>+ if ( isset( $this->recipients[bp_loggedin_user_id()] ) ) {
</ins><span class="cx"> $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count;
</span><ins>+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Mark a thread initialized in this class as read.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @see BP_Messages_Thread::mark_as_read()
+ */
</ins><span class="cx"> public function mark_read() {
</span><span class="cx"> BP_Messages_Thread::mark_as_read( $this->thread_id );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Mark a thread initialized in this class as unread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @see BP_Messages_Thread::mark_as_unread()
+ */
</ins><span class="cx"> public function mark_unread() {
</span><span class="cx"> BP_Messages_Thread::mark_as_unread( $this->thread_id );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Returns recipients for a message thread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @return object
+ */
</ins><span class="cx"> public function get_recipients() {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -116,6 +198,14 @@
</span><span class="cx">
</span><span class="cx"> /** Static Functions ******************************************************/
</span><span class="cx">
</span><ins>+ /**
+ * Delete a message thread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID
+ * @return bool
+ */
</ins><span class="cx"> public static function delete( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -137,19 +227,36 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Get current message threads for a user.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $user_id The user ID.
+ * @param string $box The type of mailbox to get. Either 'inbox' or 'sentbox'.
+ * Defaults to 'inbox'.
+ * @param string $type The type of messages to get. Either 'all' or 'unread'
+ * or 'read'. Defaults to 'all'.
+ * @param int $limit The number of messages to get. Defaults to null.
+ * @param int $page The page number to get. Defaults to null.
+ * @param string $search_terms The search term to use. Defaults to ''.
+ * @return array|bool Array on success. Boolean false on failure.
+ */
</ins><span class="cx"> public static function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null, $search_terms = '' ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="cx"> $pag_sql = $type_sql = $search_sql = '';
</span><del>- if ( $limit && $page )
</del><ins>+ if ( $limit && $page ) {
</ins><span class="cx"> $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><ins>+ }
</ins><span class="cx">
</span><del>- if ( $type == 'unread' )
</del><ins>+ if ( $type == 'unread' ) {
</ins><span class="cx"> $type_sql = " AND r.unread_count != 0 ";
</span><del>- elseif ( $type == 'read' )
</del><ins>+ } elseif ( $type == 'read' ) {
</ins><span class="cx"> $type_sql = " AND r.unread_count = 0 ";
</span><ins>+ }
</ins><span class="cx">
</span><del>- if ( !empty( $search_terms ) ) {
</del><ins>+ if ( ! empty( $search_terms ) ) {
</ins><span class="cx"> $search_terms = like_escape( esc_sql( $search_terms ) );
</span><span class="cx"> $search_sql = "AND ( subject LIKE '%%$search_terms%%' OR message LIKE '%%$search_terms%%' )";
</span><span class="cx"> }
</span><span class="lines">@@ -162,22 +269,32 @@
</span><span class="cx"> $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} {$search_sql} ", $user_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if ( empty( $thread_ids ) )
</del><ins>+ if ( empty( $thread_ids ) ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // Sort threads by date_sent
</span><del>- foreach( (array) $thread_ids as $thread )
</del><ins>+ foreach( (array) $thread_ids as $thread ) {
</ins><span class="cx"> $sorted_threads[$thread->thread_id] = strtotime( $thread->date_sent );
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> arsort( $sorted_threads );
</span><span class="cx">
</span><span class="cx"> $threads = false;
</span><del>- foreach ( (array) $sorted_threads as $thread_id => $date_sent )
</del><ins>+ foreach ( (array) $sorted_threads as $thread_id => $date_sent ) {
</ins><span class="cx"> $threads[] = new BP_Messages_Thread( $thread_id );
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return array( 'threads' => &$threads, 'total' => (int) $total_threads );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Mark a thread as read.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ */
</ins><span class="cx"> public static function mark_as_read( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -185,6 +302,13 @@
</span><span class="cx"> $wpdb->query($sql);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Mark a thread as unread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ */
</ins><span class="cx"> public static function mark_as_unread( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -192,6 +316,18 @@
</span><span class="cx"> $wpdb->query($sql);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Returns the total number of message threads for a user.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $user_id The user ID.
+ * @param string $box The type of mailbox to get. Either 'inbox' or 'sentbox'.
+ * Defaults to 'inbox'.
+ * @param string $type The type of messages to get. Either 'all' or 'unread'
+ * or 'read'. Defaults to 'all'.
+ * @return int
+ */
</ins><span class="cx"> public static function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -207,41 +343,78 @@
</span><span class="cx"> return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0{$exclude_sender} {$type_sql}", $user_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Determine if the logged-in user is a sender of any message in a thread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @param bool
+ */
</ins><span class="cx"> public static function user_is_sender( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="cx"> $sender_ids = $wpdb->get_col( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
</span><span class="cx">
</span><del>- if ( !$sender_ids )
</del><ins>+ if ( ! $sender_ids ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return in_array( bp_loggedin_user_id(), $sender_ids );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Returns the userlink of the last sender in a message thread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @return string|bool The user link on success. Boolean false on failure.
+ */
</ins><span class="cx"> public static function get_last_sender( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><del>- if ( !$sender_id = $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d GROUP BY sender_id ORDER BY date_sent LIMIT 1", $thread_id ) ) )
</del><ins>+ if ( ! $sender_id = $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d GROUP BY sender_id ORDER BY date_sent LIMIT 1", $thread_id ) ) ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return bp_core_get_userlink( $sender_id, true );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Gets the inbox message count for a user.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $user_id The user ID.
+ * @return int
+ */
</ins><span class="cx"> public static function get_inbox_count( $user_id = 0 ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><del>- if ( empty( $user_id ) )
</del><ins>+ if ( empty( $user_id ) ) {
</ins><span class="cx"> $user_id = bp_loggedin_user_id();
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> $sql = $wpdb->prepare( "SELECT SUM(unread_count) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0 AND sender_only = 0", $user_id );
</span><span class="cx"> $unread_count = $wpdb->get_var( $sql );
</span><span class="cx">
</span><del>- if ( empty( $unread_count ) || is_wp_error( $unread_count ) )
</del><ins>+ if ( empty( $unread_count ) || is_wp_error( $unread_count ) ) {
</ins><span class="cx"> return 0;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return (int) $unread_count;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Checks whether a user is a part of a message thread discussion.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @param int $user_id The user ID.
+ * @return int The message ID on success.
+ */
</ins><span class="cx"> public static function check_access( $thread_id, $user_id = 0 ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -251,12 +424,33 @@
</span><span class="cx"> return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Checks whether a message thread exists.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param int $thread_id The message thread ID.
+ * @return int The message thread ID on success.
+ */
</ins><span class="cx"> public static function is_valid( $thread_id ) {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="cx"> return $wpdb->get_var( $wpdb->prepare( "SELECT thread_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d LIMIT 1", $thread_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Returns a string containing all the message recipient userlinks.
+ *
+ * String is comma-delimited.
+ *
+ * If a message thread has more than four users, the returned string is simply
+ * "X Recipients" where "X" is the number of recipients in the message thread.
+ *
+ * @since BuddyPress (1.0.0)
+ *
+ * @param object $recipients Object containing the message recipients.
+ * @return string
+ */
</ins><span class="cx"> public static function get_recipient_links( $recipients ) {
</span><span class="cx"> if ( count( $recipients ) >= 5 )
</span><span class="cx"> return sprintf( __( '%s Recipients', 'buddypress' ), number_format_i18n( count( $recipients ) ) );
</span><span class="lines">@@ -276,6 +470,14 @@
</span><span class="cx"> return implode( ', ', (array) $recipient_links );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Upgrade method for the older BP message thread DB table.
+ *
+ * @since BuddyPress (1.2.0)
+ *
+ * @todo We should remove this. No one is going to upgrade from v1.1, right?
+ * @return bool
+ */
</ins><span class="cx"> public static function update_tables() {
</span><span class="cx"> global $wpdb, $bp;
</span><span class="cx">
</span><span class="lines">@@ -284,8 +486,9 @@
</span><span class="cx"> $threads = $wpdb->get_results( "SELECT * FROM {$bp_prefix}bp_messages_threads" );
</span><span class="cx">
</span><span class="cx"> // Nothing to update, just return true to remove the table
</span><del>- if ( empty( $threads ) )
</del><ins>+ if ( empty( $threads ) ) {
</ins><span class="cx"> return true;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> foreach( (array) $threads as $thread ) {
</span><span class="cx"> $message_ids = maybe_unserialize( $thread->message_ids );
</span><span class="lines">@@ -294,13 +497,14 @@
</span><span class="cx"> $message_ids = implode( ',', $message_ids );
</span><span class="cx">
</span><span class="cx"> // Add the thread_id to the messages table
</span><del>- if ( !$wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_messages} SET thread_id = %d WHERE id IN ({$message_ids})", $thread->id ) ) )
</del><ins>+ if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_messages} SET thread_id = %d WHERE id IN ({$message_ids})", $thread->id ) ) )
</ins><span class="cx"> $errors = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if ( $errors )
</del><ins>+ if ( $errors ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>