Changeset 7407 for trunk/bp-blogs/bp-blogs-classes.php
- Timestamp:
- 10/10/2013 02:44:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-classes.php
r7317 r7407 2 2 3 3 /** 4 * BuddyPress Blogs Classes 4 * BuddyPress Blogs Classes. 5 5 * 6 6 * @package BuddyPress … … 12 12 13 13 /** 14 * The main BuddyPress blog class 14 * The main BuddyPress blog class. 15 * 16 * A BP_Blogs_Object represents a link between a specific WordPress blog on a 17 * network and a specific user on that blog. 15 18 * 16 19 * @since BuddyPress (1.0) 17 * @package BuddyPress18 * @subpackage BlogsClasses19 20 */ 20 21 class BP_Blogs_Blog { … … 23 24 public $blog_id; 24 25 26 /** 27 * Constructor method. 28 * 29 * @param int $id Optional. The ID of the blog. 30 */ 25 31 public function __construct( $id = null ) { 26 32 if ( !empty( $id ) ) { … … 30 36 } 31 37 38 /** 39 * Populate the object with data about the specific activity item. 40 */ 32 41 public function populate() { 33 42 global $wpdb, $bp; … … 39 48 } 40 49 50 /** 51 * Save the BP blog data to the database. 52 * 53 * @return bool True on success, false on failure. 54 */ 41 55 public function save() { 42 56 global $wpdb, $bp; … … 74 88 } 75 89 90 /** 91 * Check whether an association between this user and this blog exists. 92 * 93 * @return int The number of associations between the user and blog 94 * saved in the blog component tables. 95 */ 76 96 public function exists() { 77 97 global $bp, $wpdb; … … 80 100 } 81 101 82 /* Static Functions */ 83 102 /** Static Methods ***************************************************/ 103 104 /** 105 * Retrieve a set of blog-user associations. 106 * 107 * @param string $type The order in which results should be returned. 108 * 'active', 'alphabetical', 'newest', or 'random'. 109 * @param int|bool $limit Optional. The maximum records to return. 110 * Default: false. 111 * @param int|bool $page Optional. The page of records to return. 112 * Default: false (unlimited results). 113 * @param int $user_id Optional. ID of the user whose blogs are being 114 * retrieved. Default: 0. 115 * @param string|bool $search_terms Optional. Search by text stored in 116 * blogmeta (such as the blog name). Default: false. 117 * @return array Multidimensional results array, structured as follows: 118 * 'blogs' - Array of located blog objects 119 * 'total' - A count of the total blogs matching the filter params 120 */ 84 121 public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) { 85 122 global $bp, $wpdb; … … 128 165 } 129 166 167 /** 168 * Delete the record of a given blog for all users. 169 * 170 * @param int $blog_id The blog being removed from all users. 171 * @return int|bool Number of rows deleted on success, false on failure. 172 */ 130 173 public static function delete_blog_for_all( $blog_id ) { 131 174 global $wpdb, $bp; … … 135 178 } 136 179 180 /** 181 * Delete the record of a given blog for a specific user. 182 * 183 * @param int $blog_id The blog being removed. 184 * @param int $user_id Optional. The ID of the user from whom the blog 185 * is being removed. If absent, defaults to the logged-in user ID. 186 * @return int|bool Number of rows deleted on success, false on failure. 187 */ 137 188 public static function delete_blog_for_user( $blog_id, $user_id = null ) { 138 189 global $wpdb, $bp; … … 144 195 } 145 196 197 /** 198 * Delete all of a user's blog associations in the BP tables. 199 * 200 * @param int $user_id Optional. The ID of the user whose blog 201 * associations are being deleted. If absent, defaults to 202 * logged-in user ID. 203 * @return int|bool Number of rows deleted on success, false on failure. 204 */ 146 205 public static function delete_blogs_for_user( $user_id = null ) { 147 206 global $wpdb, $bp; … … 153 212 } 154 213 214 /** 215 * Get all of a user's blogs, as tracked by BuddyPress. 216 * 217 * Note that this is different from the WordPress function {@link get_blogs_of_user()}; 218 * the current method returns only those blogs that have been recorded 219 * by BuddyPress, while the WP function does a true query of a user's 220 * blog capabilities. 221 * 222 * @param int $user_id Optional. ID of the user whose blogs are being 223 * queried. Defaults to logged-in user. 224 * @param bool $show_hidden Optional. Whether to include blogs that are 225 * not marked public. Defaults to true when viewing one's own 226 * profile. 227 * @return array Multidimensional results array, structured as follows: 228 * 'blogs' - Array of located blog objects 229 * 'total' - A count of the total blogs for the user. 230 */ 155 231 public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) { 156 232 global $bp, $wpdb; … … 179 255 } 180 256 257 /** 258 * Get IDs of all of a user's blogs, as tracked by BuddyPress. 259 * 260 * This method always includes hidden blogs. 261 * 262 * @param int $user_id Optional. ID of the user whose blogs are being 263 * queried. Defaults to logged-in user. 264 * @return int The number of blogs associated with the user. 265 */ 181 266 public static function get_blog_ids_for_user( $user_id = 0 ) { 182 267 global $bp, $wpdb; … … 188 273 } 189 274 275 /** 276 * Check whether a blog has been recorded by BuddyPress. 277 * 278 * @param int $blog_id ID of the blog being queried. 279 * @return int|null The ID of the first located entry in the BP table 280 * on success, otherwise null. 281 */ 190 282 public static function is_recorded( $blog_id ) { 191 283 global $bp, $wpdb; … … 194 286 } 195 287 288 /** 289 * Return a count of associated blogs for a given user. 290 * 291 * Includes hidden blogs when the logged-in user is the same as the 292 * $user_id parameter, or when the logged-in user has the bp_moderate 293 * cap. 294 * 295 * @param int $user_id Optional. ID of the user whose blogs are being 296 * queried. Defaults to logged-in user. 297 * @return int Blog count for the user. 298 */ 196 299 public static function total_blog_count_for_user( $user_id = null ) { 197 300 global $bp, $wpdb; … … 208 311 } 209 312 313 /** 314 * Return a list of blogs matching a search term. 315 * 316 * Matches against blog names and descriptions, as stored in the BP 317 * blogmeta table. 318 * 319 * @param string $filter The search term. 320 * @param int $limit Optional. The maximum number of items to return. 321 * Default: null (no limit). 322 * @param int $page Optional. The page of results to return. Default: 323 * null (no limit). 324 * @return array Multidimensional results array, structured as follows: 325 * 'blogs' - Array of located blog objects 326 * 'total' - A count of the total blogs matching the query. 327 */ 210 328 public static function search_blogs( $filter, $limit = null, $page = null ) { 211 329 global $wpdb, $bp; … … 227 345 } 228 346 347 /** 348 * Retrieve a list of all blogs. 349 * 350 * Query will include hidden blogs if the logged-in user has the 351 * 'bp_moderate' cap. 352 * 353 * @param int $limit Optional. The maximum number of items to return. 354 * Default: null (no limit). 355 * @param int $page Optional. The page of results to return. Default: 356 * null (no limit). 357 * @return array Multidimensional results array, structured as follows: 358 * 'blogs' - Array of located blog objects 359 * 'total' - A count of the total blogs. 360 */ 229 361 public static function get_all( $limit = null, $page = null ) { 230 362 global $bp, $wpdb; … … 239 371 } 240 372 373 /** 374 * Retrieve a list of blogs whose names start with a given letter. 375 * 376 * Query will include hidden blogs if the logged-in user has the 377 * 'bp_moderate' cap. 378 * 379 * @param string $letter. The letter you're looking for. 380 * @param int $limit Optional. The maximum number of items to return. 381 * Default: null (no limit). 382 * @param int $page Optional. The page of results to return. Default: 383 * null (no limit). 384 * @return array Multidimensional results array, structured as follows: 385 * 'blogs' - Array of located blog objects. 386 * 'total' - A count of the total blogs matching the query. 387 */ 241 388 public static function get_by_letter( $letter, $limit = null, $page = null ) { 242 389 global $bp, $wpdb; … … 257 404 } 258 405 406 /** 407 * Fetch blog data not caught in the main query and append it to results array. 408 * 409 * Gets the following information, which is either unavailable at the 410 * time of the original query, or is more efficient to look up in one 411 * fell swoop: 412 * - The latest post for each blog, include Featured Image data 413 * - The blog description 414 * 415 * @param array $paged_blogs Array of results from the original query. 416 * @param array $blog_ids Array of IDs returned from the original query. 417 * @param string|bool $type Not currently used. Default: false. 418 * @return array $paged_blogs The located blogs array, with the extras added. 419 */ 259 420 public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) { 260 421 global $bp, $wpdb; … … 311 472 } 312 473 474 /** 475 * Check whether a given blog is hidden. 476 * 477 * Checks the 'public' column in the wp_blogs table. 478 * 479 * @param int $blog_id The ID of the blog being checked. 480 * @return bool True if hidden (public = 0), false otherwise. 481 */ 313 482 public static function is_hidden( $blog_id ) { 314 483 global $wpdb;
Note: See TracChangeset
for help on using the changeset viewer.