Changeset 7525
- Timestamp:
- 11/08/2013 04:12:50 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-notifications/bp-notifications-classes.php
r7521 r7525 493 493 ) ); 494 494 495 $bp = buddypress();496 495 $bp = buddypress(); 496 $pag_sql = ''; 497 497 $select_sql = "SELECT *"; 498 498 $from_sql = "FROM {$bp->notifications->table_name}"; 499 500 $where_args = array( 499 $where_sql = self::get_where_sql( array( 501 500 'id' => $r['id'], 502 501 'user_id' => $r['user_id'], … … 507 506 'is_new' => $r['is_new'], 508 507 'search_terms' => $r['search_terms'], 509 ); 510 511 $where_sql = self::get_where_sql( $where_args ); 512 513 $pag_sql = ''; 508 ) ); 509 514 510 if ( ! empty( $r['page'] ) && ! empty( $r['per_page'] ) ) { 515 $page = absint( $r['page'] );511 $page = absint( $r['page'] ); 516 512 $per_page = absint( $r['per_page'] ); 517 513 $offset = $per_page * ( $page - 1 ); 518 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", $offset, $per_page );514 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", $offset, $per_page ); 519 515 } 520 516 … … 538 534 global $wpdb; 539 535 540 $bp = buddypress(); 541 536 $bp = buddypress(); 542 537 $select_sql = "SELECT COUNT(*)"; 543 538 $from_sql = "FROM {$bp->notifications->table_name}"; 544 539 $where_sql = self::get_where_sql( $args ); 545 546 $sql = "{$select_sql} {$from_sql} {$where_sql}"; 540 $sql = "{$select_sql} {$from_sql} {$where_sql}"; 547 541 548 542 return $wpdb->get_var( $sql ); … … 567 561 public static function update( $update_args = array(), $where_args = array() ) { 568 562 $update = self::get_query_clauses( $update_args ); 569 $where = self::get_query_clauses( $where_args );563 $where = self::get_query_clauses( $where_args ); 570 564 571 565 return self::_update( $update['data'], $where['data'], $update['format'], $where['format'] ); … … 591 585 } 592 586 593 594 /** Convenience methods **********************************************/ 587 /** Convenience methods ***************************************************/ 595 588 596 589 /** … … 623 616 */ 624 617 public static function get_all_for_user( $user_id, $status = 'is_new' ) { 625 $args =array(618 return self::get( array( 626 619 'user_id' => $user_id, 627 620 'is_new' => 'is_new' === $status, 628 ); 629 return self::get( $args ); 621 ) ); 630 622 } 631 623 … … 640 632 */ 641 633 public static function get_unread_for_user( $user_id = 0 ) { 642 $args =array(634 return self::get( array( 643 635 'user_id' => $user_id, 644 636 'is_new' => true, 645 ); 646 return self::get( $args ); 637 ) ); 647 638 } 648 639 … … 657 648 */ 658 649 public static function get_read_for_user( $user_id = 0 ) { 659 $args =array(650 return self::get( array( 660 651 'user_id' => $user_id, 661 652 'is_new' => false, 662 ); 663 return self::get( $args ); 653 ) ); 664 654 } 665 655 … … 708 698 } 709 699 710 /** Mark Read*************************************************************/700 /** Mark ******************************************************************/ 711 701 712 702 /** … … 731 721 ); 732 722 733 if ( $component_name ) { 723 if ( !empty( $item_id ) ) { 724 $where_args['item_id'] = $item_id; 725 } 726 727 if ( !empty( $component_name ) ) { 734 728 $where_args['component_name'] = $component_name; 735 729 } 736 730 737 if ( $component_action) {731 if ( !empty( $component_action ) ) { 738 732 $where_args['component_action'] = $component_action; 739 733 } 740 734 741 if ( $secondary_item_id) {735 if ( !empty( $secondary_item_id ) ) { 742 736 $where_args['secondary_item_id'] = $secondary_item_id; 743 737 } … … 766 760 ); 767 761 768 if ( $component_name) {762 if ( !empty( $component_name ) ) { 769 763 $where_args['component_name'] = $component_name; 770 764 } 771 765 772 if ( $component_action) {766 if ( !empty( $component_action ) ) { 773 767 $where_args['component_action'] = $component_action; 774 768 } 775 769 776 if ( $secondary_item_id) {770 if ( !empty( $secondary_item_id ) ) { 777 771 $where_args['secondary_item_id'] = $secondary_item_id; 778 772 } … … 808 802 ); 809 803 810 if ( $component_name) {804 if ( !empty( $component_name ) ) { 811 805 $where_args['component_name'] = $component_name; 812 806 } 813 807 814 if ( $component_action) {808 if ( !empty( $component_action ) ) { 815 809 $where_args['component_action'] = $component_action; 816 810 } 817 811 818 if ( $secondary_item_id) {812 if ( !empty( $secondary_item_id ) ) { 819 813 $where_args['secondary_item_id'] = $secondary_item_id; 820 814 }
Note: See TracChangeset
for help on using the changeset viewer.