Changeset 7308 for trunk/bp-messages/bp-messages-classes.php
- Timestamp:
- 07/25/2013 02:28:28 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/bp-messages/bp-messages-classes.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages/bp-messages-classes.php
r7307 r7308 12 12 13 13 class BP_Messages_Thread { 14 var$thread_id;15 var$messages;16 var$recipients;17 var$sender_ids;18 19 var$unread_count;14 public $thread_id; 15 public $messages; 16 public $recipients; 17 public $sender_ids; 18 19 public $unread_count; 20 20 21 21 /** … … 67 67 public $messages_order; 68 68 69 function __construct( $thread_id = false, $order = 'ASC' ) {69 public function __construct( $thread_id = false, $order = 'ASC' ) { 70 70 if ( $thread_id ) 71 71 $this->populate( $thread_id, $order ); 72 72 } 73 73 74 function populate( $thread_id, $order ) {74 private function populate( $thread_id, $order ) { 75 75 global $wpdb, $bp; 76 76 … … 95 95 } 96 96 97 function mark_read() {97 public function mark_read() { 98 98 BP_Messages_Thread::mark_as_read( $this->thread_id ); 99 99 } 100 100 101 function mark_unread() {101 public function mark_unread() { 102 102 BP_Messages_Thread::mark_as_unread( $this->thread_id ); 103 103 } 104 104 105 function get_recipients() {105 public function get_recipients() { 106 106 global $wpdb, $bp; 107 107 … … 115 115 } 116 116 117 /** Static Functions **/ 118 119 function delete( $thread_id ) { 120 global $wpdb, $bp; 121 122 $delete_for_user = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) ); 117 /** Static Functions ******************************************************/ 118 119 public static function delete( $thread_id ) { 120 global $wpdb, $bp; 121 122 // Mark messages as deleted 123 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) ); 123 124 124 125 // Check to see if any more recipients remain for this message … … 137 138 } 138 139 139 function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null, $search_terms = '' ) {140 public static function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null, $search_terms = '' ) { 140 141 global $wpdb, $bp; 141 142 … … 178 179 } 179 180 180 function mark_as_read( $thread_id ) {181 public static function mark_as_read( $thread_id ) { 181 182 global $wpdb, $bp; 182 183 … … 185 186 } 186 187 187 function mark_as_unread( $thread_id ) {188 public static function mark_as_unread( $thread_id ) { 188 189 global $wpdb, $bp; 189 190 … … 192 193 } 193 194 194 function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {195 public static function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) { 195 196 global $wpdb, $bp; 196 197 … … 207 208 } 208 209 209 function user_is_sender( $thread_id ) {210 public static function user_is_sender( $thread_id ) { 210 211 global $wpdb, $bp; 211 212 … … 218 219 } 219 220 220 function get_last_sender( $thread_id ) {221 public static function get_last_sender( $thread_id ) { 221 222 global $wpdb, $bp; 222 223 … … 242 243 } 243 244 244 function check_access( $thread_id, $user_id = 0 ) {245 public static function check_access( $thread_id, $user_id = 0 ) { 245 246 global $wpdb, $bp; 246 247 … … 251 252 } 252 253 253 function is_valid( $thread_id ) {254 public static function is_valid( $thread_id ) { 254 255 global $wpdb, $bp; 255 256 … … 257 258 } 258 259 259 function get_recipient_links( $recipients ) {260 public static function get_recipient_links( $recipients ) { 260 261 if ( count( $recipients ) >= 5 ) 261 262 return sprintf( __( '%s Recipients', 'buddypress' ), number_format_i18n( count( $recipients ) ) ); … … 276 277 } 277 278 278 // Update Functions 279 280 function update_tables() { 279 public static function update_tables() { 281 280 global $wpdb, $bp; 282 281 … … 309 308 310 309 class BP_Messages_Message { 311 var$id;312 var$thread_id;313 var$sender_id;314 var$subject;315 var$message;316 var$date_sent;317 318 var$recipients = false;319 320 function __construct( $id = null ) {310 public $id; 311 public $thread_id; 312 public $sender_id; 313 public $subject; 314 public $message; 315 public $date_sent; 316 317 public $recipients = false; 318 319 public function __construct( $id = null ) { 321 320 $this->date_sent = bp_core_current_time(); 322 321 $this->sender_id = bp_loggedin_user_id(); 323 322 324 if ( !empty( $id ) ) 323 if ( !empty( $id ) ) { 325 324 $this->populate( $id ); 326 } 327 328 function populate( $id ) { 325 } 326 } 327 328 private function populate( $id ) { 329 329 global $wpdb, $bp; 330 330 … … 339 339 } 340 340 341 function send() {341 public function send() { 342 342 global $wpdb, $bp; 343 343 … … 392 392 } 393 393 394 function get_recipients() {394 public function get_recipients() { 395 395 global $bp, $wpdb; 396 397 396 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) ); 398 397 } 399 398 400 / / Static Functions401 402 function get_recipient_ids( $recipient_usernames ) {399 /** Static Functions ******************************************************/ 400 401 public static function get_recipient_ids( $recipient_usernames ) { 403 402 if ( !$recipient_usernames ) 404 403 return false; … … 415 414 } 416 415 417 function get_last_sent_for_user( $thread_id ) { 418 global $wpdb, $bp; 419 416 public static function get_last_sent_for_user( $thread_id ) { 417 global $wpdb, $bp; 420 418 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND thread_id = %d ORDER BY date_sent DESC LIMIT 1", bp_loggedin_user_id(), $thread_id ) ); 421 419 } 422 420 423 function is_user_sender( $user_id, $message_id ) {421 public static function is_user_sender( $user_id, $message_id ) { 424 422 global $wpdb, $bp; 425 423 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) ); 426 424 } 427 425 428 function get_message_sender( $message_id ) {426 public static function get_message_sender( $message_id ) { 429 427 global $wpdb, $bp; 430 428 return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) ); … … 433 431 434 432 class BP_Messages_Notice { 435 var$id = null;436 var$subject;437 var$message;438 var$date_sent;439 var$is_active;440 441 function __construct( $id = null ) {433 public $id = null; 434 public $subject; 435 public $message; 436 public $date_sent; 437 public $is_active; 438 439 public function __construct( $id = null ) { 442 440 if ( $id ) { 443 441 $this->id = $id; … … 446 444 } 447 445 448 function populate() {446 private function populate() { 449 447 global $wpdb, $bp; 450 448 … … 459 457 } 460 458 461 function save() {459 private function save() { 462 460 global $wpdb, $bp; 463 461 … … 488 486 } 489 487 490 function activate() {488 public function activate() { 491 489 $this->is_active = 1; 492 if ( !$this->save() ) 493 return false; 494 495 return true; 496 } 497 498 function deactivate() { 490 return (bool) $this->save(); 491 } 492 493 public function deactivate() { 499 494 $this->is_active = 0; 500 if ( !$this->save() ) 501 return false; 502 503 return true; 504 } 505 506 function delete() { 495 return (bool) $this->save(); 496 } 497 498 public function delete() { 507 499 global $wpdb, $bp; 508 500
Note: See TracChangeset
for help on using the changeset viewer.