Changeset 2182
- Timestamp:
- 12/15/2009 02:37:11 PM (17 years ago)
- Location:
- trunk/bp-messages
- Files:
-
- 2 edited
-
bp-messages-classes.php (modified) (3 diffs)
-
bp-messages-templatetags.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages/bp-messages-classes.php
r2114 r2182 191 191 $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " ); 192 192 193 $sql = $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id ); 194 195 if ( !$thread_ids = $wpdb->get_results($sql) ) 196 return false; 193 $exclude_sender = false; 194 if ( 'inbox' == $box ) 195 $exclude_sender = $wpdb->prepare( " AND r.sender_only = 0" ); 196 197 $thread_ids = $wpdb->get_col( $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id ) ); 198 $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(r.thread_id) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql", $bp->loggedin_user->id ) ); 197 199 198 200 $threads = false; 199 200 for ( $i = 0; $i < count($thread_ids); $i++) {201 $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );202 203 if ( !$threads[$i]->message_ids )204 unset($threads[$i]); 205 }206 207 // reset keys 208 return array _reverse( array_reverse( $threads ));201 foreach ( $thread_ids as $thread_id ) { 202 if ( 'sentbox' == $box && !BP_Messages_Thread::user_is_sender( $thread_id ) ) { 203 $total_threads--; 204 continue; 205 } 206 207 $threads[] = new BP_Messages_Thread( $thread_id, false, $box ); 208 } 209 210 return array( 'threads' => &$threads, 'total' => (int)$total_threads ); 209 211 } 210 212 … … 396 398 return false; 397 399 398 399 400 $this->thread_id = $wpdb->insert_id; 400 401 … … 406 407 if ( !in_array( $this->sender_id, (array)$this->recipients ) ) { 407 408 // Finally, add a recipient entry for the sender, as replies need to go to this person too. 408 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count, sender_only ) VALUES ( %d, %d, 0, 0)", $this->sender_id, $this->thread_id ) );409 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count, sender_only ) VALUES ( %d, %d, 0, 1 )", $this->sender_id, $this->thread_id ) ); 409 410 } 410 411 } -
trunk/bp-messages/bp-messages-templatetags.php
r2168 r2182 28 28 if ( 'notices' == $this->box ) 29 29 $this->threads = BP_Messages_Notice::get_notices(); 30 else 31 $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type ); 30 else { 31 $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type ); 32 33 $this->threads = $threads['threads']; 34 $this->total_thread_count = $threads['total']; 35 } 32 36 33 37 if ( !$this->threads ) { … … 40 44 if ( 'notices' == $this->box ) 41 45 $this->total_thread_count = (int)$total_notice_count; 42 else43 $this->total_thread_count = (int)BP_Messages_Thread::get_total_threads_for_user( $this->user_id, $this->box, $type );44 46 } else { 45 47 $this->total_thread_count = (int)$max; … … 61 63 'total' => ceil($this->total_thread_count / $this->pag_num), 62 64 'current' => $this->pag_page, 63 'prev_text' => '&la quo;',64 'next_text' => '&ra quo;',65 'prev_text' => '←', 66 'next_text' => '→', 65 67 'mid_size' => 1 66 68 ));
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)