Changeset 12806
- Timestamp:
- 01/22/2010 11:35:59 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/ms-edit.php
r12796 r12806 184 184 185 185 // themes 186 if ( is _array( $_POST[ 'theme' ] ) )186 if ( isset($_POST[ 'theme' ]) && is_array( $_POST[ 'theme' ] ) ) 187 187 $_POST[ 'option' ][ 'allowedthemes' ] = $_POST[ 'theme' ]; 188 188 else … … 216 216 // update blogs table 217 217 $blog_data = stripslashes_deep($_POST[ 'blog' ]); 218 $result = $wpdb->update( $wpdb->blogs, $blog_data, array('blog_id' => $id) ); 219 220 update_blog_status( $id, 'spam', $_POST[ 'blog' ][ 'spam' ] ); 221 update_option( 'blog_public', $_POST[ 'blog' ][ 'public' ] ); 218 update_blog_details($id, $blog_data); 222 219 223 220 // get blog prefix … … 238 235 239 236 // remove user 240 if ( is _array( $_POST[ 'blogusers' ] ) ) {237 if ( isset($_POST[ 'blogusers' ]) && is_array( $_POST[ 'blogusers' ] ) ) { 241 238 reset( $_POST[ 'blogusers' ] ); 242 239 foreach ( (array) $_POST[ 'blogusers' ] as $key => $val ) -
trunk/wp-includes/ms-functions.php
r12800 r12806 18 18 } 19 19 20 // @todo use update_blog_details 20 21 function wpmu_update_blogs_date() { 21 22 global $wpdb; … … 93 94 } 94 95 96 // @todo Use get_user_by() and deprecate. 95 97 function get_user_details( $username ) { 96 98 global $wpdb; … … 123 125 } 124 126 125 function get_blog_details( $id, $getall = true ) { 126 global $wpdb; 127 128 if ( !is_numeric( $id ) ) 129 $id = get_id_from_blogname( $id ); 130 131 $id = (int) $id; 132 133 $all = $getall == true ? '' : 'short'; 134 $details = wp_cache_get( $id . $all, 'blog-details' ); 127 /** 128 * Retrieve the details for a blog from the blogs table and blog options. 129 * 130 * @since 3.0 131 * @param int $blog_id Blog ID 132 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. 133 * @return object Blog details. 134 */ 135 function get_blog_details( $blog_id, $get_all = true ) { 136 global $wpdb; 137 138 if ( !is_numeric( $blog_id ) ) 139 $blog_id = get_id_from_blogname( $blog_id ); 140 141 $blog_id = (int) $blog_id; 142 143 $all = $get_all == true ? '' : 'short'; 144 $details = wp_cache_get( $blog_id . $all, 'blog-details' ); 135 145 136 146 if ( $details ) { … … 138 148 return false; 139 149 elseif ( !is_object($details) ) // Clear old pre-serialized objects. Cache clients do better with that. 140 wp_cache_delete( $ id . $all, 'blog-details' );150 wp_cache_delete( $blog_id . $all, 'blog-details' ); 141 151 else 142 152 return $details; 143 153 } 144 154 145 $details = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $ id) );155 $details = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id) ); 146 156 if ( !$details ) { 147 wp_cache_set( $ id . $all, -1, 'blog-details' );157 wp_cache_set( $blog_id . $all, -1, 'blog-details' ); 148 158 return false; 149 159 } 150 160 151 if ( !$get all ) {152 wp_cache_set( $ id . $all, $details, 'blog-details' );161 if ( !$get_all ) { 162 wp_cache_set( $blog_id . $all, $details, 'blog-details' ); 153 163 return $details; 154 164 } 155 165 156 166 $wpdb->suppress_errors(); 157 switch_to_blog( $ id );167 switch_to_blog( $blog_id ); 158 168 $details->blogname = get_option( 'blogname' ); 159 169 $details->siteurl = get_option( 'siteurl' ); … … 164 174 $details = apply_filters('blog_details', $details); 165 175 166 wp_cache_set( $ id . $all, $details, 'blog-details' );176 wp_cache_set( $blog_id . $all, $details, 'blog-details' ); 167 177 168 178 $key = md5( $details->domain . $details->path ); … … 172 182 } 173 183 174 function refresh_blog_details( $id ) { 175 $id = (int) $id; 176 $details = get_blog_details( $id, false ); 177 178 wp_cache_delete( $id , 'blog-details' ); 179 wp_cache_delete( $id . 'short' , 'blog-details' ); 184 /** 185 * Clear the blog details cache. 186 * 187 * @since 3.0 188 * 189 * @param int $blog_id Blog ID 190 */ 191 function refresh_blog_details( $blog_id ) { 192 $blog_id = (int) $blog_id; 193 $details = get_blog_details( $blog_id, false ); 194 195 wp_cache_delete( $blog_id , 'blog-details' ); 196 wp_cache_delete( $blog_id . 'short' , 'blog-details' ); 180 197 wp_cache_delete( md5( $details->domain . $details->path ) , 'blog-lookup' ); 181 198 wp_cache_delete( 'current_blog_' . $details->domain, 'site-options' ); … … 183 200 } 184 201 202 /** 203 * Update the details for a blog. Updates the blogs table for a given blog id. 204 * 205 * @since 3.0 206 * 207 * @param int $blog_id Blog ID 208 * @param array $details Array of details keyed by blogs table field names. 209 * @return bool True if update succeeds, false otherwise. 210 */ 211 function update_blog_details( $blog_id, $details = array() ) { 212 global $wpdb; 213 214 if ( empty($details) ) 215 return false; 216 217 if ( is_object($details) ) 218 $details = get_object_vars($details); 219 220 $current_details = get_blog_details($blog_id, false); 221 if ( empty($current_details) ) 222 return false; 223 224 $current_details = get_object_vars($current_details); 225 226 $details = array_merge($current_details, $details); 227 $details['last_updated'] = current_time('mysql', true); 228 229 $update_details = array(); 230 $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); 231 foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) 232 $update_details[$field] = $details[$field]; 233 234 $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); 235 236 // If spam status changed, issue actions. 237 if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) { 238 if ( $details[ 'spam' ] == 1 ) 239 do_action( "make_spam_blog", $blog_id ); 240 else 241 do_action( "make_ham_blog", $blog_id ); 242 } 243 244 if ( isset($details[ 'public' ]) ) 245 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ], false ); 246 247 refresh_blog_details($blog_id); 248 249 return true; 250 } 251 252 // @todo move to user.php 185 253 function get_current_user_id() { 186 254 global $current_user; … … 508 576 } 509 577 510 function update_blog_status( $id, $pref, $value, $refresh = 1 ) { 578 /** 579 * Update a blog details field. 580 * 581 * @since 3.0 582 * 583 * @param int $blog_id BLog ID 584 * @param string $pref A field name 585 * @param string $value Value for $pref 586 * @param bool $refresh Whether to refresh the blog details cache. Default is true. 587 */ 588 function update_blog_status( $blog_id, $pref, $value, $refresh = true ) { 511 589 global $wpdb; 512 590 … … 514 592 return $value; 515 593 516 $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $id) ); 517 if ( $refresh == 1 ) 594 $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); 595 596 if ( $refresh ) 518 597 refresh_blog_details($id); 519 598 … … 535 614 return $details->$pref; 536 615 537 return $wpdb->get_var( $wpdb->prepare("SELECT $pref FROM {$wpdb->blogs} WHERE blog_id = %d", $id) );616 return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) ); 538 617 } 539 618
Note: See TracChangeset
for help on using the changeset viewer.