Changeset 528
- Timestamp:
- 11/10/2008 01:53:30 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
bp-blogs.php (modified) (2 diffs)
-
bp-blogs/bp-blogs-classes.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs.php
r518 r528 69 69 $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['blogs']['table_name_blog_posts'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) ); 70 70 $wpdb->query( $wpdb->prepare( "ALTER TABLE " . $bp['blogs']['table_name_blog_comments'] . " DEFAULT CHARACTER SET %s", $wpdb->charset ) ); 71 72 // On first installation - record all existing blogs in the system. 73 if ( !(int)get_site_option( 'bp-blogs-first-install') ) { 74 bp_blogs_record_existing_blogs(); 75 add_site_option( 'bp-blogs-first-install', 1 ); 76 } 71 77 72 78 add_site_option( 'bp-blogs-version', $version ); … … 248 254 } 249 255 256 function bp_blogs_record_existing_blogs() { 257 global $wpdb; 258 259 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) ); 260 261 if ( $blog_ids ) { 262 foreach( $blog_ids as $blog_id ) { 263 $users = get_users_of_blog( $blog_id ); 264 265 if ( $users ) { 266 foreach ( $users as $user ) { 267 $role = unserialize( $user->meta_value ); 268 269 if ( !isset( $role['subscriber'] ) ) 270 bp_blogs_record_blog( $blog_id, $user->user_id ); 271 } 272 } 273 } 274 } 275 } 276 250 277 251 278 function bp_blogs_record_blog( $blog_id, $user_id ) { -
trunk/bp-blogs/bp-blogs-classes.php
r511 r528 30 30 global $wpdb, $bp; 31 31 32 if ( !$this->user_id ) 32 // Don't try and save if there is no user ID or blog ID set. 33 if ( !$this->user_id || !$this->blog_id ) 33 34 return false; 34 35 36 // Don't save if this blog has already been recorded for the user. 37 if ( !$this->id && $this->exists() ) 38 return false; 39 35 40 if ( $this->id ) { 36 41 // Update … … 48 53 else 49 54 return $wpdb->insert_id; 55 } 56 57 function exists() { 58 global $bp, $wpdb; 59 60 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['blogs']['table_name'] . " WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) ); 50 61 } 51 62
Note:
See TracChangeset
for help on using the changeset viewer.