Changeset 7898
- Timestamp:
- 02/16/2014 09:47:18 PM (11 years ago)
- Location:
- trunk/bp-groups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r7897 r7898 147 147 148 148 /** 149 * Raw arguments passed to the constructor. 150 * 151 * @since BuddyPress (2.0.0) 152 * @var array 153 */ 154 protected $args; 155 156 /** 149 157 * Constructor method. 150 158 * … … 152 160 * the object will be pre-populated with info about that group. 153 161 */ 154 public function __construct( $id = null ) { 162 public function __construct( $id = null, $args = array() ) { 163 $this->args = $args; 164 155 165 if ( !empty( $id ) ) { 156 166 $this->id = $id; … … 166 176 167 177 if ( $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id = %d", $this->id ) ) ) { 168 bp_groups_update_meta_cache( $this->id ); 178 if ( ! empty( $this->args['update_meta_cache'] ) ) { 179 bp_groups_update_meta_cache( $this->id ); 180 } 169 181 170 182 $this->id = $group->id; … … 176 188 $this->enable_forum = $group->enable_forum; 177 189 $this->date_created = $group->date_created; 178 $this->last_activity = groups_get_groupmeta( $this->id, 'last_activity' ); 179 $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' ); 180 $this->is_member = BP_Groups_Member::check_is_member( bp_loggedin_user_id(), $this->id ); 181 $this->is_invited = BP_Groups_Member::check_has_invite( bp_loggedin_user_id(), $this->id ); 182 $this->is_pending = BP_Groups_Member::check_for_membership_request( bp_loggedin_user_id(), $this->id ); 183 184 // If this is a private or hidden group, does the current user have access? 185 if ( 'private' == $this->status || 'hidden' == $this->status ) { 186 if ( $this->is_member && is_user_logged_in() || bp_current_user_can( 'bp_moderate' ) ) 190 191 if ( ! empty( $this->args['populate_extras'] ) ) { 192 $this->last_activity = groups_get_groupmeta( $this->id, 'last_activity' ); 193 $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' ); 194 $this->is_member = BP_Groups_Member::check_is_member( bp_loggedin_user_id(), $this->id ); 195 $this->is_invited = BP_Groups_Member::check_has_invite( bp_loggedin_user_id(), $this->id ); 196 $this->is_pending = BP_Groups_Member::check_for_membership_request( bp_loggedin_user_id(), $this->id ); 197 198 // If this is a private or hidden group, does the current user have access? 199 if ( 'private' == $this->status || 'hidden' == $this->status ) { 200 if ( $this->is_member && is_user_logged_in() || bp_current_user_can( 'bp_moderate' ) ) 201 $this->user_has_access = true; 202 else 203 $this->user_has_access = false; 204 } else { 187 205 $this->user_has_access = true; 188 else 189 $this->user_has_access = false; 190 } else { 191 $this->user_has_access = true; 192 } 193 194 // Get group admins and mods 195 $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) ) ); 196 foreach( (array) $admin_mods as $user ) { 197 if ( (int) $user->is_admin ) 198 $this->admins[] = $user; 199 else 200 $this->mods[] = $user; 206 } 207 208 // Get group admins and mods 209 $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) ) ); 210 foreach( (array) $admin_mods as $user ) { 211 if ( (int) $user->is_admin ) 212 $this->admins[] = $user; 213 else 214 $this->mods[] = $user; 215 } 201 216 } 202 217 } else { -
trunk/bp-groups/bp-groups-functions.php
r7897 r7898 42 42 function groups_get_group( $args = '' ) { 43 43 $defaults = array( 44 'group_id' => false, 45 'load_users' => false 44 'group_id' => false, 45 'load_users' => false, 46 'populate_extras' => true, 47 'update_meta_cache' => true, 46 48 ); 47 49 … … 52 54 53 55 if ( !$group = wp_cache_get( $cache_key, 'bp' ) ) { 54 $group = new BP_Groups_Group( $group_id, true, $load_users ); 56 $group_args = array( 57 'populate_extras' => $populate_extras, 58 'update_meta_cache' => $update_meta_cache, 59 ); 60 61 $group = new BP_Groups_Group( $group_id, $group_args ); 55 62 wp_cache_set( $cache_key, $group, 'bp' ); 56 63 }
Note: See TracChangeset
for help on using the changeset viewer.