Changeset 9183
- Timestamp:
- 11/26/2014 06:08:23 AM (10 years ago)
- Location:
- trunk/src/bp-messages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-classes.php
r9166 r9183 110 110 * @since BuddyPress (1.0.0) 111 111 * 112 * @param bool|int $thread_id The message thread ID. 113 * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'. 114 */ 115 public function __construct( $thread_id = false, $order = 'ASC' ) { 112 * @see BP_Messages_Thread::populate() for full description of parameters 113 */ 114 public function __construct( $thread_id = false, $order = 'ASC', $args = array() ) { 116 115 if ( $thread_id ) { 117 $this->populate( $thread_id, $order );116 $this->populate( $thread_id, $order, $args ); 118 117 } 119 118 } … … 128 127 * @param int $thread_id The message thread ID. 129 128 * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'. 129 * @param array $args { 130 * Array of arguments. 131 * @type bool $update_meta_cache Whether to pre-fetch metadata for 132 * queried message items. Default: true. 133 * } 130 134 * @return bool False on failure. 131 135 */ 132 public function populate( $thread_id , $order) {136 public function populate( $thread_id = 0, $order = 'ASC', $args = array() ) { 133 137 global $wpdb, $bp; 134 138 135 139 if( 'ASC' != $order && 'DESC' != $order ) { 136 $order= 'ASC'; 137 } 140 $order = 'ASC'; 141 } 142 143 // merge $args with our defaults 144 $r = wp_parse_args( $args, array( 145 'update_meta_cache' => true 146 ) ); 138 147 139 148 $this->messages_order = $order; … … 154 163 if ( isset( $this->recipients[bp_loggedin_user_id()] ) ) { 155 164 $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count; 165 } 166 167 // Grab all message meta 168 if ( true === (bool) $r['update_meta_cache'] ) { 169 bp_messages_update_meta_cache( wp_list_pluck( $this->messages, 'id' ) ); 156 170 } 157 171 … … 326 340 $threads = false; 327 341 foreach ( (array) $sorted_threads as $thread_id => $date_sent ) { 328 $threads[] = new BP_Messages_Thread( $thread_id ); 342 $threads[] = new BP_Messages_Thread( $thread_id, 'ASC', array( 343 'update_meta_cache' => false 344 ) ); 329 345 } 330 346 -
trunk/src/bp-messages/bp-messages-template.php
r9161 r9183 1468 1468 * Constructor method. 1469 1469 * 1470 * @param int $thread_id ID of the message thread. 1471 * @param string $order 'ASC' or 'DESC'. 1472 */ 1473 public function __construct( $thread_id, $order ) { 1474 $this->thread = new BP_Messages_Thread( $thread_id, $order ); 1470 * @see BP_Messages_Thread::populate() for full parameter info 1471 */ 1472 public function __construct( $thread_id, $order, $args ) { 1473 $this->thread = new BP_Messages_Thread( $thread_id, $order, $args ); 1475 1474 $this->message_count = count( $this->thread->messages ); 1476 1475 … … 1573 1572 * the URL (bp_action_variable( 0 )). 1574 1573 * @type string $order 'ASC' or 'DESC'. Default: 'ASC'. 1574 * @type bool $update_meta_cache Whether to pre-fetch metadata for 1575 * queried message items. Default: true. 1575 1576 * } 1576 1577 * @return bool True if there are messages to display, otherwise false. … … 1580 1581 1581 1582 $r = bp_parse_args( $args, array( 1582 'thread_id' => false, 1583 'order' => 'ASC' 1583 'thread_id' => false, 1584 'order' => 'ASC', 1585 'update_meta_cache' => true, 1584 1586 ), 'thread_has_messages' ); 1585 1587 … … 1588 1590 } 1589 1591 1590 $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'] ); 1592 // Set up extra args 1593 $extra_args = $r; 1594 unset( $extra_args['thread_id'], $extra_args['order'] ); 1595 1596 $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'], $extra_args ); 1591 1597 1592 1598 return $thread_template->has_messages();
Note: See TracChangeset
for help on using the changeset viewer.