Changeset 7308 for trunk/bp-friends/bp-friends-classes.php
- Timestamp:
- 07/25/2013 02:28:28 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-classes.php
r7298 r7308 11 11 12 12 class BP_Friends_Friendship { 13 var$id;14 var$initiator_user_id;15 var$friend_user_id;16 var$is_confirmed;17 var$is_limited;18 var$date_created;19 20 var$is_request;21 var$populate_friend_details;22 23 var$friend;24 25 function __construct( $id = null, $is_request = false, $populate_friend_details = true ) {13 public $id; 14 public $initiator_user_id; 15 public $friend_user_id; 16 public $is_confirmed; 17 public $is_limited; 18 public $date_created; 19 20 public $is_request; 21 public $populate_friend_details; 22 23 public $friend; 24 25 public function __construct( $id = null, $is_request = false, $populate_friend_details = true ) { 26 26 $this->is_request = $is_request; 27 27 … … 33 33 } 34 34 35 function populate() {35 public function populate() { 36 36 global $wpdb, $bp; 37 37 … … 53 53 } 54 54 55 function save() {55 public function save() { 56 56 global $wpdb, $bp; 57 57 … … 79 79 } 80 80 81 function delete() { 82 global $wpdb, $bp; 83 81 public function delete() { 82 global $wpdb, $bp; 84 83 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ); 85 84 } … … 87 86 /** Static Methods ********************************************************/ 88 87 89 function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {88 public static function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) { 90 89 global $wpdb, $bp; 91 90 … … 112 111 } 113 112 114 function get_friendship_id( $user_id, $friend_id ) {113 public static function get_friendship_id( $user_id, $friend_id ) { 115 114 global $wpdb, $bp; 116 115 … … 118 117 } 119 118 120 function get_friendship_request_user_ids( $user_id ) {119 public static function get_friendship_request_user_ids( $user_id ) { 121 120 global $wpdb, $bp; 122 121 … … 124 123 } 125 124 126 function total_friend_count( $user_id = 0 ) {125 public static function total_friend_count( $user_id = 0 ) { 127 126 global $wpdb, $bp; 128 127 … … 140 139 141 140 bp_update_user_meta( $user_id, 'total_friend_count', (int) $count ); 142 return (int) $count; 143 } 144 145 function search_friends( $filter, $user_id, $limit = null, $page = null ) { 141 142 return absint( $count ); 143 } 144 145 public static function search_friends( $filter, $user_id, $limit = null, $page = null ) { 146 146 global $wpdb, $bp; 147 147 … … 183 183 } 184 184 185 function check_is_friend( $loggedin_userid, $possible_friend_userid ) {185 public static function check_is_friend( $loggedin_userid, $possible_friend_userid ) { 186 186 global $wpdb, $bp; 187 187 … … 202 202 } 203 203 204 function get_bulk_last_active( $user_ids ) {204 public static function get_bulk_last_active( $user_ids ) { 205 205 global $wpdb; 206 206 … … 210 210 } 211 211 212 function accept($friendship_id) { 213 global $wpdb, $bp; 214 212 public static function accept($friendship_id) { 213 global $wpdb, $bp; 215 214 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, bp_loggedin_user_id() ) ); 216 215 } 217 216 218 function withdraw($friendship_id) { 219 global $wpdb, $bp; 220 217 public static function withdraw($friendship_id) { 218 global $wpdb, $bp; 221 219 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND initiator_user_id = %d", $friendship_id, bp_loggedin_user_id() ) ); 222 220 } 223 221 224 function reject($friendship_id) { 225 global $wpdb, $bp; 226 222 public static function reject($friendship_id) { 223 global $wpdb, $bp; 227 224 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, bp_loggedin_user_id() ) ); 228 225 } 229 226 230 function search_users( $filter, $user_id, $limit = null, $page = null ) {227 public static function search_users( $filter, $user_id, $limit = null, $page = null ) { 231 228 global $wpdb, $bp; 232 229 … … 254 251 } 255 252 256 function search_users_count( $filter ) {253 public static function search_users_count( $filter ) { 257 254 global $wpdb, $bp; 258 255 … … 277 274 } 278 275 279 function sort_by_name( $user_ids ) {276 public static function sort_by_name( $user_ids ) { 280 277 global $wpdb, $bp; 281 278 … … 288 285 } 289 286 290 function get_random_friends( $user_id, $total_friends = 5 ) {287 public static function get_random_friends( $user_id, $total_friends = 5 ) { 291 288 global $wpdb, $bp; 292 289 … … 306 303 } 307 304 308 function get_invitable_friend_count( $user_id, $group_id ) {305 public static function get_invitable_friend_count( $user_id, $group_id ) { 309 306 310 307 // Setup some data we'll use below … … 333 330 } 334 331 335 function get_user_ids_for_friendship( $friendship_id ) { 336 global $wpdb, $bp; 337 332 public static function get_user_ids_for_friendship( $friendship_id ) { 333 global $wpdb, $bp; 338 334 return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) ); 339 335 } 340 336 341 function delete_all_for_user( $user_id ) {337 public static function delete_all_for_user( $user_id ) { 342 338 global $wpdb, $bp; 343 339
Note: See TracChangeset
for help on using the changeset viewer.