Changeset 11027 for trunk/src/bp-groups/classes/class-bp-groups-member.php
- Timestamp:
- 08/22/2016 10:11:20 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-groups-member.php
r10794 r11027 186 186 187 187 if ( !empty( $member ) ) { 188 $this->id = $member->id;189 $this->group_id = $member->group_id;190 $this->user_id = $member->user_id;191 $this->inviter_id = $member->inviter_id;192 $this->is_admin = $member->is_admin;193 $this->is_mod = $member->is_mod;194 $this->is_banned = $member->is_banned;188 $this->id = (int) $member->id; 189 $this->group_id = (int) $member->group_id; 190 $this->user_id = (int) $member->user_id; 191 $this->inviter_id = (int) $member->inviter_id; 192 $this->is_admin = (int) $member->is_admin; 193 $this->is_mod = (int) $member->is_mod; 194 $this->is_banned = (int) $member->is_banned; 195 195 $this->user_title = $member->user_title; 196 196 $this->date_modified = $member->date_modified; 197 $this->is_confirmed = $member->is_confirmed;197 $this->is_confirmed = (int) $member->is_confirmed; 198 198 $this->comments = $member->comments; 199 $this->invite_sent = $member->invite_sent;199 $this->invite_sent = (int) $member->invite_sent; 200 200 201 201 $this->user = new BP_Core_User( $this->user_id ); … … 787 787 * @param string $type If 'sent', results are limited to those invitations 788 788 * that have actually been sent (non-draft). Default: 'sent'. 789 * @return int|null The ID of the invitation if found , otherwise null.789 * @return int|null The ID of the invitation if found; null if not found. 790 790 */ 791 791 public static function check_has_invite( $user_id, $group_id, $type = 'sent' ) { … … 801 801 $sql .= " AND invite_sent = 1"; 802 802 803 return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) ); 803 $query = $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) ); 804 805 return is_numeric( $query ) ? (int) $query : $query; 804 806 } 805 807 … … 932 934 * @param int $user_id ID of the user. 933 935 * @param int $group_id ID of the group. 934 * @return mixed 936 * @return int|null int 1 if user is banned; int 0 if user is not banned; 937 * null if user is not part of the group or if group doesn't exist. 935 938 */ 936 939 public static function check_is_banned( $user_id, $group_id ) { … … 942 945 $bp = buddypress(); 943 946 944 return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 947 $query = $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 948 949 return is_numeric( $query ) ? (int) $query : $query; 945 950 } 946 951 … … 952 957 * @param int $user_id ID of the user. 953 958 * @param int $group_id ID of the group. 954 * @return int|null ID of the group if the user is the creator, 955 * otherwise false. 959 * @return int|null int of group ID if user is the creator; null on failure. 956 960 */ 957 961 public static function check_is_creator( $user_id, $group_id ) { … … 963 967 $bp = buddypress(); 964 968 965 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) ); 969 $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) ); 970 971 return is_numeric( $query ) ? (int) $query : $query; 966 972 } 967 973 … … 973 979 * @param int $user_id ID of the user. 974 980 * @param int $group_id ID of the group. 975 * @return int |null ID of the membership if found, otherwise false.981 * @return int Database ID of the membership if found; int 0 on failure. 976 982 */ 977 983 public static function check_for_membership_request( $user_id, $group_id ) { … … 1002 1008 // If the user is logged in and viewing their random groups, we can show hidden and private groups. 1003 1009 if ( bp_is_my_profile() ) { 1004 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT %d", $user_id, $total_groups) );1010 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT %d", $user_id, $total_groups ) ) ); 1005 1011 } else { 1006 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT %d", $user_id, $total_groups) );1012 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT %d", $user_id, $total_groups ) ) ); 1007 1013 } 1008 1014 } … … 1021 1027 $bp = buddypress(); 1022 1028 1023 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id) );1029 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) ) ); 1024 1030 } 1025 1031 … … 1044 1050 } 1045 1051 1052 // Integer casting. 1053 foreach ( (array) $group_admins as $key => $data ) { 1054 $group_admins[ $key ]->user_id = (int) $group_admins[ $key ]->user_id; 1055 } 1056 1046 1057 return $group_admins; 1047 1058 } … … 1060 1071 $bp = buddypress(); 1061 1072 1062 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) ); 1073 $group_mods = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) ); 1074 1075 // Integer casting. 1076 foreach ( (array) $group_mods as $key => $data ) { 1077 $group_mods[ $key ]->user_id = (int) $group_mods[ $key ]->user_id; 1078 } 1079 1080 return $group_mods; 1063 1081 } 1064 1082 … … 1093 1111 $bp = buddypress(); 1094 1112 1095 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id) );1113 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) ) ); 1096 1114 } 1097 1115
Note: See TracChangeset
for help on using the changeset viewer.