Changeset 10183
- Timestamp:
- 10/04/2015 07:29:24 AM (9 years ago)
- Location:
- trunk/src/bp-forums
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-forums/bp-forums-bbpress-sa.php
r10096 r10183 56 56 require( bp_get_option( 'bb-config-location' ) ); 57 57 58 // Setup the global database connection 58 // Setup the global database connection. 59 59 $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST ); 60 60 61 // Set the table names 61 // Set the table names. 62 62 $bbdb->forums = $bb_table_prefix . 'forums'; 63 63 $bbdb->meta = $bb_table_prefix . 'meta'; … … 116 116 $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' ); 117 117 118 // Set a site id if there isn't one already 118 // Set a site id if there isn't one already. 119 119 if ( !isset( $bb->site_id ) ) 120 120 $bb->site_id = bp_get_root_blog_id(); 121 121 122 // Check if the tables are installed, if not, install them 122 // Check if the tables are installed, if not, install them. 123 123 if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) { 124 124 require( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' ); … … 130 130 bb_update_db_version(); 131 131 132 // Set the site admins as the keymasters 132 // Set the site admins as the keymasters. 133 133 $site_admins = get_site_option( 'site_admins', array('admin') ); 134 134 foreach ( (array) $site_admins as $site_admin ) … … 138 138 bb_new_forum( array( 'forum_name' => 'Default Forum' ) ); 139 139 140 // Set the site URI 140 // Set the site URI. 141 141 bb_update_option( 'uri', BB_URL ); 142 142 } … … 173 173 * Noop. 174 174 * 175 * @param array $users 175 * @param array $users Array of users. 176 176 */ 177 177 function bb_cache_users( $users ) {} 178 178 179 179 /** 180 * bbPressneeds this class for its usermeta manipulation.180 * The bbPress plugin needs this class for its usermeta manipulation. 181 181 */ 182 182 class BP_Forums_BB_Auth { … … 191 191 192 192 /** 193 * bbPressneeds the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.193 * The bbPress plugin needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this. 194 194 * 195 195 * The class is pluggable, so that plugins that swap out WPDB with a custom … … 202 202 203 203 /** 204 * Constructor 204 * Constructor. 205 205 * 206 206 * @see WPDB::__construct() for description of parameters. … … 247 247 * 248 248 * @see BBDB::__construct() for a description of params. 249 * 250 * @param array $args Array of args to parse. 251 * @return array $args. 249 252 */ 250 253 function init( $args ) { … … 286 289 } 287 290 } 288 endif; // class_exists( 'BPDB' )291 endif; // End class_exists( 'BPDB' ). 289 292 290 293 /** 291 294 * Convert object to given output format. 292 295 * 293 * bbPressneeds this to convert vars.296 * The bbPress plugin needs this to convert vars. 294 297 * 295 298 * @param object $object Object to convert. … … 318 321 * 319 322 * @param array $queries See {@link dbDelta()}. 320 * @param bool $execute See {@link dbDelta()}.323 * @param bool $execute See {@link dbDelta()}. 321 324 * @return array See {@link dbDelta()}. 322 325 */ … … 324 327 global $wpdb; 325 328 326 // Separate individual queries into an array 329 // Separate individual queries into an array. 327 330 if ( !is_array($queries) ) { 328 331 $queries = explode( ';', $queries ); … … 330 333 } 331 334 332 $cqueries = array(); // Creation Queries 333 $iqueries = array(); // Insertion Queries 335 $cqueries = array(); // Creation Queries. 336 $iqueries = array(); // Insertion Queries. 334 337 $for_update = array(); 335 338 336 // Create a tablename index for an array ($cqueries) of queries 339 // Create a tablename index for an array ($cqueries) of queries. 337 340 foreach($queries as $qry) { 338 341 if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { … … 346 349 $iqueries[] = $qry; 347 350 } else { 348 // Unrecognized query type 349 } 350 } 351 352 // Check to see which tables and fields exist 351 // Unrecognized query type. 352 } 353 } 354 355 // Check to see which tables and fields exist. 353 356 if ($tables = $wpdb->get_col('SHOW TABLES;')) { 354 // For every table in the database 357 // For every table in the database. 355 358 foreach ($tables as $table) { 356 359 // Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined. … … 360 363 // If a table query exists for the database table... 361 364 if ( array_key_exists(strtolower($table), $cqueries) ) { 362 // Clear the field and index arrays 365 // Clear the field and index arrays. 363 366 $cfields = $indices = array(); 364 // Get all of the field names in the query from between the parents 367 // Get all of the field names in the query from between the parents. 365 368 preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2); 366 369 $qryline = trim($match2[1]); 367 370 368 // Separate field lines into an array 371 // Separate field lines into an array. 369 372 $flds = explode("\n", $qryline); 370 373 371 374 //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>"; 372 375 373 // For every field line specified in the query 376 // For every field line specified in the query. 374 377 foreach ($flds as $fld) { 375 // Extract the field name 378 // Extract the field name. 376 379 preg_match("|^([^ ]*)|", trim($fld), $fvals); 377 380 $fieldname = trim( $fvals[1], '`' ); 378 381 379 // Verify the found field name 382 // Verify the found field name. 380 383 $validfield = true; 381 384 switch (strtolower($fieldname)) { … … 392 395 $fld = trim($fld); 393 396 394 // If it's a valid field, add it to the field array 397 // If it's a valid field, add it to the field array. 395 398 if ($validfield) { 396 399 $cfields[strtolower($fieldname)] = trim($fld, ", \n"); … … 398 401 } 399 402 400 // Fetch the table column structure from the database 403 // Fetch the table column structure from the database. 401 404 $tablefields = $wpdb->get_results("DESCRIBE {$table};"); 402 405 403 // For every field in the table 406 // For every field in the table. 404 407 foreach ($tablefields as $tablefield) { 405 408 // If the table field exists in the field array... 406 409 if (array_key_exists(strtolower($tablefield->Field), $cfields)) { 407 // Get the field type from the query 410 // Get the field type from the query. 408 411 preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches); 409 412 $fieldtype = $matches[1]; … … 411 414 // Is actual field type different from the field type in query? 412 415 if ($tablefield->Type != $fieldtype) { 413 // Add a query to change the column type 416 // Add a query to change the column type. 414 417 $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)]; 415 418 $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; 416 419 } 417 420 418 // Get the default value from the array 421 // Get the default value from the array. 419 422 //echo "{$cfields[strtolower($tablefield->Field)]}<br>"; 420 423 if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) { 421 424 $default_value = $matches[1]; 422 425 if ($tablefield->Default != $default_value) { 423 // Add a query to change the column's default value 426 // Add a query to change the column's default value. 424 427 $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'"; 425 428 $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}"; … … 427 430 } 428 431 429 // Remove the field from the array (so it's not added) 432 // Remove the field from the array (so it's not added). 430 433 unset($cfields[strtolower($tablefield->Field)]); 431 434 } else { … … 434 437 } 435 438 436 // For every remaining field specified for the table 439 // For every remaining field specified for the table. 437 440 foreach ($cfields as $fieldname => $fielddef) { 438 // Push a query line into $cqueries that adds the field to that table 441 // Push a query line into $cqueries that adds the field to that table. 439 442 $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef"; 440 443 $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname; … … 442 445 443 446 // Index stuff goes here 444 // Fetch the table index structure from the database 447 // Fetch the table index structure from the database. 445 448 $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); 446 449 447 450 if ($tableindices) { 448 // Clear the index array 451 // Clear the index array. 449 452 unset($index_ary); 450 453 451 // For every index in the table 454 // For every index in the table. 452 455 foreach ($tableindices as $tableindex) { 453 // Add the index to the index data array 456 // Add the index to the index data array. 454 457 $keyname = $tableindex->Key_name; 455 458 $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); … … 457 460 } 458 461 459 // For each actual index in the index array 462 // For each actual index in the index array. 460 463 foreach ($index_ary as $index_name => $index_data) { 461 // Build a create string to compare to the query 464 // Build a create string to compare to the query. 462 465 $index_string = ''; 463 466 if ($index_name == 'PRIMARY') { … … 471 474 } 472 475 $index_columns = ''; 473 // For each column in the index 476 // For each column in the index. 474 477 foreach ($index_data['columns'] as $column_data) { 475 478 if ($index_columns != '') $index_columns .= ','; 476 // Add the field to the column list string 479 // Add the field to the column list string. 477 480 $index_columns .= $column_data['fieldname']; 478 481 if ($column_data['subpart'] != '') { … … 480 483 } 481 484 } 482 // Add the column list to the index create string 485 // Add the column list to the index create string. 483 486 $index_string .= ' ('.$index_columns.')'; 484 487 if (!(($aindex = array_search($index_string, $indices)) === false)) { … … 490 493 } 491 494 492 // For every remaining index specified for the table 495 // For every remaining index specified for the table. 493 496 foreach ( (array) $indices as $index ) { 494 // Push a query line into $cqueries that adds the index to that table 497 // Push a query line into $cqueries that adds the index to that table. 495 498 $cqueries[] = "ALTER TABLE {$table} ADD $index"; 496 499 $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index; 497 500 } 498 501 499 // Remove the original table creation query from processing 502 // Remove the original table creation query from processing. 500 503 unset($cqueries[strtolower($table)]); 501 504 unset($for_update[strtolower($table)]); -
trunk/src/bp-forums/bp-forums-filters.php
r10096 r10183 98 98 * Get a link for a forum topic tags directory. 99 99 * 100 * @param string $link Link passed from filter.101 * @param string $tag Name of the tag.102 * @param string $page Page number, passed from the filter.100 * @param string $link Link passed from filter. 101 * @param string $tag Name of the tag. 102 * @param string $page Page number, passed from the filter. 103 103 * @param string $context Passed from the filter but unused here. 104 104 * @return string Link of the form http://example.com/forums/tag/tagname/. … … 142 142 * @see bp_modify_page_title() 143 143 * 144 * @param string $title New page title; see {@link bp_modify_page_title()}.144 * @param string $title New page title; see {@link bp_modify_page_title()}. 145 145 * @param string $original_title Original page title. 146 * @param string $sep How to separate the various items within the page title.147 * @param string $seplocation Direction to display title.146 * @param string $sep How to separate the various items within the page title. 147 * @param string $seplocation Direction to display title. 148 148 * @return string Page title with forum topic title appended. 149 149 */ … … 232 232 $sql .= $wpdb->prepare( " AND p.poster_id = %s ", bp_displayed_user_id() ); 233 233 234 // Remove any topic_author information 234 // Remove any topic_author information. 235 235 $sql = str_replace( " AND t.topic_poster = '" . bp_displayed_user_id() . "'", '', $sql ); 236 236 -
trunk/src/bp-forums/bp-forums-functions.php
r10096 r10183 21 21 function bp_forums_is_bbpress_active() { 22 22 23 // Single site 23 // Single site. 24 24 if ( is_plugin_active( 'bbpress/bbpress.php' ) ) 25 25 return true; 26 26 27 // Network active 27 // Network active. 28 28 if ( is_plugin_active_for_network( 'bbpress/bbpress.php' ) ) 29 29 return true; 30 30 31 // Nope 31 // Nope. 32 32 return false; 33 33 } … … 57 57 * Does the forums component have a directory page registered? 58 58 * 59 * Checks $bp pages global and looks for directory page 59 * Checks $bp pages global and looks for directory page. 60 60 * 61 61 * @since 1.5.0 … … 81 81 function bp_forums_get_forum( $forum_id ) { 82 82 83 /** This action is documented in bp-forums/bp-forums-screens */83 /** This action is documented in bp-forums/bp-forums-screens.php */ 84 84 do_action( 'bbpress_init' ); 85 85 return bb_get_forum( $forum_id ); … … 91 91 * Wrapper for {@link bb_new_forum()}. 92 92 * 93 * @param array $args {93 * @param array|string $args { 94 94 * Forum setup arguments. 95 * @type string $forum_name Name of the forum.96 * @type string $forum_desc Description of the forum.97 * @type int $forum_parent_idID of the forum parent. Default: value of98 * {@link bp_forums_parent_forums_id()}.99 * @type bool $forum_orderOrder.100 * @type int $forum_is_category Whether the forum is a category. Default: 0.95 * @type string $forum_name Name of the forum. 96 * @type string $forum_desc Description of the forum. 97 * @type int $forum_parent_id ID of the forum parent. Default: value of 98 * {@link bp_forums_parent_forums_id()}. 99 * @type bool $forum_order Order. 100 * @type int $forum_is_category Whether the forum is a category. Default: 0. 101 101 * } 102 102 * @return int ID of the newly created forum. … … 104 104 function bp_forums_new_forum( $args = '' ) { 105 105 106 /** This action is documented in bp-forums/bp-forums-screens */106 /** This action is documented in bp-forums/bp-forums-screens.php */ 107 107 do_action( 'bbpress_init' ); 108 108 … … 124 124 * Wrapper for {@link bb_update_forum(}. 125 125 * 126 * @param array $args {126 * @param array|string $args { 127 127 * Forum setup arguments. 128 * @type int $forum_idID of the forum to be updated.129 * @type string $forum_name Name of the forum.130 * @type string $forum_desc Description of the forum.131 * @type int $forum_parent_idID of the forum parent. Default: value of132 * {@link bp_forums_parent_forums_id()}.133 * @type bool $forum_orderOrder.134 * @type int $forum_is_category Whether the forum is a category. Default: 0.128 * @type int $forum_id ID of the forum to be updated. 129 * @type string $forum_name Name of the forum. 130 * @type string $forum_desc Description of the forum. 131 * @type int $forum_parent_id ID of the forum parent. Default: value of 132 * {@link bp_forums_parent_forums_id()}. 133 * @type bool $forum_order Order. 134 * @type int $forum_is_category Whether the forum is a category. Default: 0. 135 135 * } 136 136 * @return bool True on success, false on failure. … … 138 138 function bp_forums_update_forum( $args = '' ) { 139 139 140 /** This action is documented in bp-forums/bp-forums-screens */140 /** This action is documented in bp-forums/bp-forums-screens.php */ 141 141 do_action( 'bbpress_init' ); 142 142 … … 165 165 if ( !empty( $forum_id ) && is_int( $forum_id ) ) { 166 166 167 /** This action is documented in bp-forums/bp-forums-screens */167 /** This action is documented in bp-forums/bp-forums-screens.php */ 168 168 do_action( 'bbpress_init' ); 169 169 bb_delete_forum( $forum_id ); … … 177 177 * Fetch a set of forum topics. 178 178 * 179 * @param array $args {180 * @type string @typeOrder or filter type. Default: 'newest'.181 * @type int $forum_idOptional. Pass a forum ID to limit results to topics182 * associated with that forum.183 * @type int $user_idOptional. Pass a user ID to limit results to topics184 * belonging to that user.185 * @type int $pageOptional. Number of the results page to return.186 * Default: 1.187 * @type int $per_pageOptional. Number of results to return per page.188 * Default: 15.189 * @type int $offsetOptional. Numeric offset for results.190 * @type int $number191 * @type array $excludeOptional. Topic IDs to exclude.179 * @param array|string $args { 180 * @type string $type Order or filter type. Default: 'newest'. 181 * @type int $forum_id Optional. Pass a forum ID to limit results to topics 182 * associated with that forum. 183 * @type int $user_id Optional. Pass a user ID to limit results to topics 184 * belonging to that user. 185 * @type int $page Optional. Number of the results page to return. 186 * Default: 1. 187 * @type int $per_page Optional. Number of results to return per page. 188 * Default: 15. 189 * @type int $offset Optional. Numeric offset for results. 190 * @type int $number Amount to query for. 191 * @type array $exclude Optional. Topic IDs to exclude. 192 192 * @type string $show_stickies Whether to show sticky topics. 193 * @type mixed $filterIf $type = 'tag', filter is the tag name. Otherwise,194 * $filter is terms to search on.193 * @type mixed $filter If $type = 'tag', filter is the tag name. Otherwise, 194 * $filter is terms to search on. 195 195 * } 196 196 * @return array Found topics. … … 198 198 function bp_forums_get_forum_topics( $args = '' ) { 199 199 200 /** This action is documented in bp-forums/bp-forums-screens */200 /** This action is documented in bp-forums/bp-forums-screens.php */ 201 201 do_action( 'bbpress_init' ); 202 202 … … 211 211 'exclude' => false, 212 212 'show_stickies' => 'all', 213 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.213 'filter' => false // If $type = tag then filter is the tag name, otherwise it's terms to search on. 214 214 ) ); 215 215 extract( $r, EXTR_SKIP ); … … 260 260 function bp_forums_get_topic_details( $topic_id ) { 261 261 262 /** This action is documented in bp-forums/bp-forums-screens */262 /** This action is documented in bp-forums/bp-forums-screens.php */ 263 263 do_action( 'bbpress_init' ); 264 264 … … 278 278 function bp_forums_get_topic_id_from_slug( $topic_slug ) { 279 279 280 /** This action is documented in bp-forums/bp-forums-screens */280 /** This action is documented in bp-forums/bp-forums-screens.php */ 281 281 do_action( 'bbpress_init' ); 282 282 … … 290 290 * Create a new forum topic. 291 291 * 292 * @param array $args {293 * @type string $topic_titleTitle of the new topic.294 * @type string $topic_slugSlug of the new topic.295 * @type string $topic_textText of the new topic.296 * @type int $topic_posterID of the user posting the topic. Default: ID of297 * the logged-in user.298 * @type string $topic_poster_nameDisplay name of the user posting the299 * topic. Default: 'fullname' of the logged-in user.300 * @type i d $topic_last_posterID of the user who last posted to the topic.301 * Default: ID of the logged-in user.302 * @type string $topic_last_poster_name Display name of the user who last303 * posted to the topic. Default: 'fullname' of the logged-in user.304 * @type string $topic_start_timeDate/time when the topic was created.305 * Default: the current time, as reported by bp_core_current_time().306 * @type string $topic_timeDate/time when the topic was created.307 * Default: the current time, as reported by bp_core_current_time().308 * @type int $topic_openWhether the topic is open. Default: 1 (open).309 * @type array|string|bool $topic_tags Array or comma-separated list of310 * topic tags. False to leave empty. Default: false.311 * @type int $forum_idID of the forum to which the topic belongs.312 * Default: 0.292 * @param array|string $args { 293 * @type string $topic_title Title of the new topic. 294 * @type string $topic_slug Slug of the new topic. 295 * @type string $topic_text Text of the new topic. 296 * @type int $topic_poster ID of the user posting the topic. Default: ID of 297 * the logged-in user. 298 * @type string $topic_poster_name Display name of the user posting the 299 * topic. Default: 'fullname' of the logged-in user. 300 * @type int $topic_last_poster ID of the user who last posted to the topic. 301 * Default: ID of the logged-in user. 302 * @type string $topic_last_poster_name Display name of the user who last 303 * posted to the topic. Default: 'fullname' of the logged-in user. 304 * @type string $topic_start_time Date/time when the topic was created. 305 * Default: the current time, as reported by bp_core_current_time(). 306 * @type string $topic_time Date/time when the topic was created. 307 * Default: the current time, as reported by bp_core_current_time(). 308 * @type int $topic_open Whether the topic is open. Default: 1 (open). 309 * @type array|string|bool $topic_tags Array or comma-separated list of 310 * topic tags. False to leave empty. Default: false. 311 * @type int $forum_id ID of the forum to which the topic belongs. 312 * Default: 0. 313 313 * } 314 314 * @return object Details about the new topic, as returned by 315 * {@link bp_forums_get_topic_details()}.315 * {@link bp_forums_get_topic_details()}. 316 316 */ 317 317 function bp_forums_new_topic( $args = '' ) { 318 318 $bp = buddypress(); 319 319 320 /** This action is documented in bp-forums/bp-forums-screens */320 /** This action is documented in bp-forums/bp-forums-screens.php */ 321 321 do_action( 'bbpress_init' ); 322 322 … … 325 325 'topic_slug' => '', 326 326 'topic_text' => '', 327 'topic_poster' => bp_loggedin_user_id(), // accepts ids328 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names329 'topic_last_poster' => bp_loggedin_user_id(), // accepts ids330 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names327 'topic_poster' => bp_loggedin_user_id(), // Accepts ids. 328 'topic_poster_name' => $bp->loggedin_user->fullname, // Accept names. 329 'topic_last_poster' => bp_loggedin_user_id(), // Accepts ids. 330 'topic_last_poster_name' => $bp->loggedin_user->fullname, // Accept names. 331 331 'topic_start_time' => bp_core_current_time(), 332 332 'topic_time' => bp_core_current_time(), 333 333 'topic_open' => 1, 334 'topic_tags' => false, // accepts array or comma delimited335 'forum_id' => 0 // accepts ids or slugs334 'topic_tags' => false, // Accepts array or comma delimited. 335 'forum_id' => 0 // Accepts ids or slugs. 336 336 ) ); 337 337 extract( $r, EXTR_SKIP ); … … 373 373 * Update a topic's details. 374 374 * 375 * @param array $args {375 * @param array|string $args { 376 376 * Array of arguments. 377 * @type int $topic_id ID of the topic being updated. 378 * @type string $topic_title Updated title of the topic. 379 * @type string $topic_title Updated text of the topic. 380 * @type array|string|bool $topic_tags Array or comma-separated list of 381 * topic tags. False to leave empty. Default: false. 377 * @type int $topic_id ID of the topic being updated. 378 * @type string $topic_title Updated title of the topic. 379 * @type string $topic_text Updated text of the topic. 380 * @type array|string|bool $topic_tags Array or comma-separated list of 381 * topic tags. False to leave empty. 382 * Default false. 382 383 * } 383 384 * @return object Details about the new topic, as returned by 384 * {@link bp_forums_get_topic_details()}.385 * {@link bp_forums_get_topic_details()}. 385 386 */ 386 387 function bp_forums_update_topic( $args = '' ) { 387 388 388 /** This action is documented in bp-forums/bp-forums-screens */389 /** This action is documented in bp-forums/bp-forums-screens.php */ 389 390 do_action( 'bbpress_init' ); 390 391 … … 397 398 extract( $r, EXTR_SKIP ); 398 399 399 // Check if the user is a spammer 400 // Check if the user is a spammer. 400 401 if ( bp_is_user_inactive( bp_loggedin_user_id() ) ) 401 402 return false; 402 403 403 // bb_insert_topic()will append tags, but not remove them. So we remove all existing tags.404 // The bb_insert_topic() function will append tags, but not remove them. So we remove all existing tags. 404 405 bb_remove_topic_tags( $topic_id ); 405 406 … … 410 411 return false; 411 412 412 // Update the first post 413 // Update the first post. 413 414 if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) 414 415 return false; … … 419 420 function bp_forums_sticky_topic( $args = '' ) { 420 421 421 /** This action is documented in bp-forums/bp-forums-screens */422 /** This action is documented in bp-forums/bp-forums-screens.php */ 422 423 do_action( 'bbpress_init' ); 423 424 424 425 $r = wp_parse_args( $args, array( 425 426 'topic_id' => false, 426 'mode' => 'stick' // stick/unstick427 'mode' => 'stick' // Stick/unstick. 427 428 ) ); 428 429 extract( $r, EXTR_SKIP ); … … 439 440 * Set a topic's open/closed status. 440 441 * 441 * @param array $args {442 * @type int $topic_id ID of the topic whose status is being changed.443 * @type string $mode New status of the topic. 'open' or 'close'.444 * Default: 'close'.442 * @param array|string $args { 443 * @type int $topic_id ID of the topic whose status is being changed. 444 * @type string $mode New status of the topic. 'open' or 'close'. 445 * Default: 'close'. 445 446 * } 446 447 * @return bool True on success, false on failure. … … 448 449 function bp_forums_openclose_topic( $args = '' ) { 449 450 450 /** This action is documented in bp-forums/bp-forums-screens */451 /** This action is documented in bp-forums/bp-forums-screens.php */ 451 452 do_action( 'bbpress_init' ); 452 453 453 454 $r = wp_parse_args( $args, array( 454 455 'topic_id' => false, 455 'mode' => 'close' // stick/unstick456 'mode' => 'close' // Stick/unstick. 456 457 ) ); 457 458 extract( $r, EXTR_SKIP ); … … 468 469 * Delete a topic. 469 470 * 470 * @param array $args {471 * @param array|string $args { 471 472 * @type int $topic_id ID of the topic being deleted. 472 473 * } … … 475 476 function bp_forums_delete_topic( $args = '' ) { 476 477 477 /** This action is documented in bp-forums/bp-forums-screens */478 /** This action is documented in bp-forums/bp-forums-screens.php */ 478 479 do_action( 'bbpress_init' ); 479 480 … … 494 495 global $bbdb; 495 496 496 /** This action is documented in bp-forums/bp-forums-screens */497 /** This action is documented in bp-forums/bp-forums-screens.php */ 497 498 do_action( 'bbpress_init' ); 498 499 … … 528 529 * @since 1.6.0 529 530 * 530 * @param string $text The text of the comment.531 * @param int $topic_id The topic id.532 * @param int $user_idThe user id.531 * @param string $text The text of the comment. 532 * @param int $topic_id The topic id. 533 * @param int $user_id The user id. 533 534 * @return bool True if a duplicate reply exists, otherwise false. 534 535 */ … … 539 540 if ( $text && $topic_id && $user_id ) { 540 541 541 /** This action is documented in bp-forums/bp-forums-screens */542 /** This action is documented in bp-forums/bp-forums-screens.php */ 542 543 do_action( 'bbpress_init' ); 543 544 … … 547 548 ); 548 549 549 // Set the reply_exists_text so we can check it in the filter below 550 // Set the reply_exists_text so we can check it in the filter below. 550 551 buddypress()->forums->reply_exists_text = $text; 551 552 552 // BB_Query's post_text parameter does a MATCH, while we need exact matches 553 // BB_Query's post_text parameter does a MATCH, while we need exact matches. 553 554 add_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' ); 554 555 $query = new BB_Query( 'post', $args ); 555 556 remove_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' ); 556 557 557 // Cleanup 558 // Cleanup. 558 559 unset( buddypress()->forums->reply_exists_text ); 559 560 … … 574 575 } 575 576 /** 576 * Private one-time-use function used in conjunction with bp_forums_reply_exists() 577 * Private one-time-use function used in conjunction with bp_forums_reply_exists(). 577 578 * 578 579 * @access private … … 591 592 * Get a total "Topics Started" count for a given user. 592 593 * 593 * @param int $user_id ID of the user being queried. Falls back on displayed594 * user, then loggedin.595 * @param string $type The current filter/sort type. 'active', 'popular',596 * 'unreplied'.594 * @param int $user_id ID of the user being queried. Falls back on displayed 595 * user, then loggedin. 596 * @param string $type The current filter/sort type. 'active', 'popular', 597 * 'unreplied'. 597 598 * @return int $count The topic count. 598 599 */ 599 600 function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) { 600 601 601 /** This action is documented in bp-forums/bp-forums-screens */602 /** This action is documented in bp-forums/bp-forums-screens.php */ 602 603 do_action( 'bbpress_init' ); 603 604 … … 634 635 * @since 1.5.0 635 636 * 636 * @param int $user_id ID of the user whose replied topics are being counted. 637 * Defaults to displayed user, then to logged-in user. 637 * @param int $user_id ID of the user whose replied topics are being counted. 638 * Defaults to displayed user, then to logged-in user. 639 * @param string $type Forum thread type. 638 640 * @return int $count Topic count. 639 641 */ 640 642 function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) { 641 643 642 /** This action is documented in bp-forums/bp-forums-screens */644 /** This action is documented in bp-forums/bp-forums-screens.php */ 643 645 do_action( 'bbpress_init' ); 644 646 … … 652 654 $query = new BB_Query( 'post', array( 'post_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) ); 653 655 654 // Count the unique topics. No better way to do this in the bbPress query API 656 // Count the unique topics. No better way to do this in the bbPress query API. 655 657 $topics = array(); 656 658 foreach( $query->results as $result ) { … … 659 661 } 660 662 661 // Even more unfortunate. If this is filtered by 'unreplied', we have to requery 663 // Even more unfortunate. If this is filtered by 'unreplied', we have to requery. 662 664 if ( 'unreplied' == $type ) { 663 665 $topic_ids = implode( ',', $topics ); … … 702 704 $bp = buddypress(); 703 705 704 // Get the topic ids 706 // Get the topic ids. 705 707 foreach ( (array) $topics as $topic ) $topic_ids[] = $topic->topic_id; 706 708 $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) ); 707 709 708 // Fetch the topic's last poster details 710 // Fetch the topic's last poster details. 709 711 $poster_details = $wpdb->get_results( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ); 710 712 for ( $i = 0, $count = count( $topics ); $i < $count; ++$i ) { … … 719 721 } 720 722 721 // Fetch fullname for the topic's last poster 723 // Fetch fullname for the topic's last poster. 722 724 if ( bp_is_active( 'xprofile' ) ) { 723 725 $poster_names = $wpdb->get_results( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ); … … 731 733 732 734 // Loop through to make sure that each topic has the proper values set. This covers the 733 // case of deleted users 735 // case of deleted users. 734 736 foreach ( (array) $topics as $key => $topic ) { 735 737 if ( !isset( $topic->topic_last_poster_email ) ) … … 754 756 * Get the posts belonging to a topic. 755 757 * 756 * @param array $args {757 * @type int $topic_id ID of the topic for which posts are being fetched.758 * @type int $pageOptional. Page of results to return. Default: 1.759 * @type int $pageOptional. Number of results to return per page.760 * Default: 15.761 * @type string $order 'ASC' or 'DESC'. Default: 'ASC'.758 * @param array|string $args { 759 * @type int $topic_id ID of the topic for which posts are being fetched. 760 * @type int $page Optional. Page of results to return. Default: 1. 761 * @type int $page Optional. Number of results to return per page. 762 * Default: 15. 763 * @type string $order 'ASC' or 'DESC'. Default: 'ASC'. 762 764 * } 763 765 * @return array List of posts. … … 765 767 function bp_forums_get_topic_posts( $args = '' ) { 766 768 767 /** This action is documented in bp-forums/bp-forums-screens */769 /** This action is documented in bp-forums/bp-forums-screens.php */ 768 770 do_action( 'bbpress_init' ); 769 771 … … 791 793 function bp_forums_get_post( $post_id ) { 792 794 793 /** This action is documented in bp-forums/bp-forums-screens */795 /** This action is documented in bp-forums/bp-forums-screens.php */ 794 796 do_action( 'bbpress_init' ); 795 797 return bb_get_post( $post_id ); … … 801 803 * Wrapper for {@link bb_delete_post()}. 802 804 * 803 * @param array $args {805 * @param array|string $args { 804 806 * @type int $post_id ID of the post being deleted. 805 807 * } … … 808 810 function bp_forums_delete_post( $args = '' ) { 809 811 810 /** This action is documented in bp-forums/bp-forums-screens */812 /** This action is documented in bp-forums/bp-forums-screens.php */ 811 813 do_action( 'bbpress_init' ); 812 814 … … 823 825 * Create a new post. 824 826 * 825 * @param array $args {826 * @type int $post_idOptional. ID of an existing post, if you want to827 * update rather than create. Default: false.828 * @type int $topic_idID of the topic to which the post belongs.829 * @type string $post_text Contents of the post.830 * @type string $post_time Optional. Time when the post was recorded.831 * Default: current time, as reported by {@link bp_core_current_time()}.832 * @type int $poster_idOptional. ID of the user creating the post.833 * Default: ID of the logged-in user.834 * @type string $poster_ip Optional. IP address of the user creating the835 * post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].836 * @type int $post_statusPost status. Default: 0.837 * @type int $post_position Optional. Default: false (auto).827 * @param array|string $args { 828 * @type int $post_id Optional. ID of an existing post, if you want to 829 * update rather than create. Default: false. 830 * @type int $topic_id ID of the topic to which the post belongs. 831 * @type string $post_text Contents of the post. 832 * @type string $post_time Optional. Time when the post was recorded. 833 * Default: current time, as reported by {@link bp_core_current_time()}. 834 * @type int $poster_id Optional. ID of the user creating the post. 835 * Default: ID of the logged-in user. 836 * @type string $poster_ip Optional. IP address of the user creating the 837 * post. Default: the IP address found in $_SERVER['REMOTE_ADDR']. 838 * @type int $post_status Post status. Default: 0. 839 * @type int $post_position Optional. Default: false (auto). 838 840 * } 839 841 * @return int|bool ID of the new post on success, false on failure. … … 841 843 function bp_forums_insert_post( $args = '' ) { 842 844 843 /** This action is documented in bp-forums/bp-forums-screens */845 /** This action is documented in bp-forums/bp-forums-screens.php */ 844 846 do_action( 'bbpress_init' ); 845 847 … … 849 851 'post_text' => '', 850 852 'post_time' => bp_core_current_time(), 851 'poster_id' => bp_loggedin_user_id(), // accepts ids or names853 'poster_id' => bp_loggedin_user_id(), // Accepts ids or names. 852 854 'poster_ip' => $_SERVER['REMOTE_ADDR'], 853 'post_status' => 0, // use bb_delete_post() instead855 'post_status' => 0, // Use bb_delete_post() instead. 854 856 'post_position' => false 855 857 ); … … 914 916 $bp = buddypress(); 915 917 916 // Get the user ids 918 // Get the user ids. 917 919 foreach ( (array) $posts as $post ) $user_ids[] = $post->poster_id; 918 920 $user_ids = implode( ',', wp_parse_id_list( $user_ids ) ); 919 921 920 // Fetch the poster's user_email, user_nicename and user_login 922 // Fetch the poster's user_email, user_nicename and user_login. 921 923 $poster_details = $wpdb->get_results( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ); 922 924 … … 958 960 * @param int $forum_id ID of the forum. 959 961 * @return object Object with properties $topics (topic count) and $posts 960 * (post count).962 * (post count). 961 963 */ 962 964 function bp_forums_get_forum_topicpost_count( $forum_id ) { 963 965 global $wpdb, $bbdb; 964 966 965 /** This action is documented in bp-forums/bp-forums-screens */966 do_action( 'bbpress_init' ); 967 968 // Need to find a bbPress function that does this 967 /** This action is documented in bp-forums/bp-forums-screens.php */ 968 do_action( 'bbpress_init' ); 969 970 // Need to find a bbPress function that does this. 969 971 return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) ); 970 972 } … … 1023 1025 * 1024 1026 * @return bool True if stickies should be displayed at the top of the global 1025 * directory, otherwise false.1027 * directory, otherwise false. 1026 1028 */ 1027 1029 function bp_forums_enable_global_directory_stickies() { … … 1045 1047 */ 1046 1048 1047 // List actions to clear super cached pages on, if super cache is installed 1049 // List actions to clear super cached pages on, if super cache is installed. 1048 1050 add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' ); 1049 1051 add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' ); … … 1077 1079 * Wrapper function for {@link bb_get_postmeta()}. 1078 1080 * 1079 * @package BuddyPress_Forums1080 1081 * @since 1.5.0 1082 * 1083 * @param object $cache Cache object. 1084 * @param int $id ID of the forum being cached. 1085 * @param string $cachekey Key to use with forum embed cache. 1081 1086 */ 1082 1087 function bp_embed_forum_cache( $cache, $id, $cachekey ) { … … 1090 1095 * 1091 1096 * @since 1.5.0 1097 * 1098 * @param object $cache Cache object. 1099 * @param string $cachekey Key to use with forum embed cache. 1100 * @param int $id ID of the forum being cached. 1092 1101 */ 1093 1102 function bp_embed_forum_save_cache( $cache, $cachekey, $id ) { -
trunk/src/bp-forums/bp-forums-loader.php
r10096 r10183 1 1 <?php 2 2 /** 3 * BuddyPress Forums Loader 3 * BuddyPress Forums Loader. 4 4 * 5 5 * A discussion forums component. Comes bundled with bbPress stand-alone. … … 48 48 $bp = buddypress(); 49 49 50 // Define the parent forum ID 50 // Define the parent forum ID. 51 51 if ( ! defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) { 52 52 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 53 53 } 54 54 55 // Define a slug, if necessary 55 // Define a slug, if necessary. 56 56 if ( ! defined( 'BP_FORUMS_SLUG' ) ) { 57 57 define( 'BP_FORUMS_SLUG', $this->id ); 58 58 } 59 59 60 // The location of the bbPress stand-alone config file 60 // The location of the bbPress stand-alone config file. 61 61 $bbconfig = bp_core_get_root_option( 'bb-config-location' ); 62 62 if ( '' !== $bbconfig ) { … … 86 86 public function includes( $includes = array() ) { 87 87 88 // Files to include 88 // Files to include. 89 89 $includes = array( 90 90 'actions', … … 96 96 ); 97 97 98 // bbPress stand-alone 98 // bbPress stand-alone. 99 99 if ( ! defined( 'BB_PATH' ) ) { 100 100 $includes[] = 'bbpress-sa'; 101 101 } 102 102 103 // Admin-specific code 103 // Admin-specific code. 104 104 if ( is_admin() ) { 105 105 $includes[] = 'deprecated/1.6'; … … 118 118 * 119 119 * @param array $main_nav Optional. See BP_Component::setup_nav() for 120 * description.121 * @param array $sub_nav Optional. See BP_Component::setup_nav() for122 * description.120 * description. 121 * @param array $sub_nav Optional. See BP_Component::setup_nav() for 122 * description. 123 123 */ 124 124 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 125 125 126 // Stop if forums haven't been set up yet 126 // Stop if forums haven't been set up yet. 127 127 if ( ! bp_forums_is_installed_correctly() ) { 128 128 return; 129 129 } 130 130 131 // Stop if there is no user displayed or logged in 131 // Stop if there is no user displayed or logged in. 132 132 if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) { 133 133 return; 134 134 } 135 135 136 // Determine user to use 136 // Determine user to use. 137 137 if ( bp_displayed_user_domain() ) { 138 138 $user_domain = bp_displayed_user_domain(); … … 143 143 } 144 144 145 // User link 145 // User link. 146 146 $slug = bp_get_forums_slug(); 147 147 $forums_link = trailingslashit( $user_domain . $slug ); 148 148 149 // Add 'Forums' to the main navigation 149 // Add 'Forums' to the main navigation. 150 150 $main_nav = array( 151 151 'name' => __( 'Forums', 'buddypress' ), … … 157 157 ); 158 158 159 // Topics started 159 // Topics started. 160 160 $sub_nav[] = array( 161 161 'name' => __( 'Topics Started', 'buddypress' ), … … 168 168 ); 169 169 170 // Topics replied to 170 // Topics replied to. 171 171 $sub_nav[] = array( 172 172 'name' => __( 'Replied To', 'buddypress' ), … … 190 190 * 191 191 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() 192 * for description.192 * for description. 193 193 */ 194 194 public function setup_admin_bar( $wp_admin_nav = array() ) { 195 195 196 // Menus for logged in user 196 // Menus for logged in user. 197 197 if ( is_user_logged_in() ) { 198 198 199 // Setup the logged in user variables 199 // Setup the logged in user variables. 200 200 $forums_link = trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() ); 201 201 202 // Add the "My Account" sub menus 202 // Add the "My Account" sub menus. 203 203 $wp_admin_nav[] = array( 204 204 'parent' => buddypress()->my_account_menu_id, … … 208 208 ); 209 209 210 // Topics 210 // Topics. 211 211 $wp_admin_nav[] = array( 212 212 'parent' => 'my-account-' . $this->id, … … 216 216 ); 217 217 218 // Replies 218 // Replies. 219 219 $wp_admin_nav[] = array( 220 220 'parent' => 'my-account-' . $this->id, … … 224 224 ); 225 225 226 // Favorites 226 // Favorites. 227 227 $wp_admin_nav[] = array( 228 228 'parent' => 'my-account-' . $this->id, … … 241 241 public function setup_title() { 242 242 243 // Adjust title based on view 243 // Adjust title based on view. 244 244 if ( bp_is_forums_component() ) { 245 245 $bp = buddypress(); -
trunk/src/bp-forums/bp-forums-screens.php
r10096 r10183 15 15 function bp_forums_directory_forums_setup() { 16 16 17 // Get BuddyPress once 17 // Get BuddyPress once. 18 18 $bp = buddypress(); 19 19 … … 42 42 $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ); 43 43 if ( !empty( $bp->groups->current_group->id ) ) { 44 // Auto join this user if they are not yet a member of this group 44 // Auto join this user if they are not yet a member of this group. 45 45 if ( !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) 46 46 groups_join_group( $bp->groups->current_group->id ); … … 75 75 } 76 76 77 } 77 } else { 78 78 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' ); 79 79 bp_core_redirect( add_query_arg( 'new', '', bp_get_forums_directory_permalink() ) ); … … 249 249 public function is_legacy_forum() { 250 250 251 // Bail if not looking at a group 251 // Bail if not looking at a group. 252 252 if ( ! bp_is_forums_component() ) 253 253 return; 254 254 255 // forum Directory255 // Forum Directory. 256 256 if ( ( ! bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && ! bp_current_item() ) { 257 257 … … 284 284 public function directory_dummy_post() { 285 285 286 // Title based on ability to create groups 286 // Title based on ability to create groups. 287 287 if ( is_user_logged_in() ) { 288 288 $title = __( 'Forums', 'buddypress' ) . ' <a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>'; -
trunk/src/bp-forums/bp-forums-template.php
r10126 r10183 213 213 * Constructor method. 214 214 * 215 * @param string $type The 'type' is the sort order/kind. 'newest', 216 * 'popular', 'unreplied', 'tags'. 217 * @param int $forum_id The ID of the forum for which topics are being 218 * queried. 219 * @param int $user_id The ID of the user to whom topics should be 220 * limited. Pass false to remove this filter. 221 * @param int $page The number of the page being requested. 222 * @param int $per_page The number of items being requested per page. 223 * @param string $no_stickies Requested sticky format. 224 * @param string $search_terms Filter results by a string. 225 * @param int $offset Optional. Offset results by a given numeric value. 226 * @param int $number Optional. Total number of items to retrieve. 215 * @param string $type The 'type' is the sort order/kind. 'newest', 216 * 'popular', 'unreplied', 'tags'. 217 * @param int $forum_id The ID of the forum for which topics are being 218 * queried. 219 * @param int $user_id The ID of the user to whom topics should be 220 * limited. Pass false to remove this filter. 221 * @param int $page The number of the page being requested. 222 * @param int $per_page The number of items being requested per page. 223 * @param int $max Max amount to retrieve. 224 * @param string $no_stickies Requested sticky format. 225 * @param string $search_terms Filter results by a string. 226 * @param int|bool $offset Optional. Offset results by a given numeric value. 227 * @param int|bool $number Optional. Total number of items to retrieve. 227 228 */ 228 229 function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) { … … 275 276 } else { 276 277 // Get a total topic count, for use in pagination. This value will differ 277 // depending on scope 278 // depending on scope. 278 279 if ( !empty( $forum_id ) ) { 279 // Group forums 280 // Group forums. 280 281 $topic_count = bp_forums_get_forum( $forum_id ); 281 282 $topic_count = (int) $topic_count->topics; … … 284 285 } else if ( bp_is_user_forums_started() || ( bp_is_directory() && $user_id ) ) { 285 286 // This covers the case of Profile > Forums > Topics Started, as 286 // well as Forum Directory > My Topics 287 // well as Forum Directory > My Topics. 287 288 $topic_count = bp_forums_total_topic_count_for_user( bp_displayed_user_id(), $type ); 288 289 } else if ( bp_is_user_forums_replied_to() ) { 289 // Profile > Forums > Replied To 290 // Profile > Forums > Replied To. 290 291 $topic_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id(), $type ); 291 292 } else if ( 'tags' == $type ) { … … 294 295 } else { 295 296 // For forum directories (All Topics), get a true count 296 $status = bp_current_user_can( 'bp_moderate' ) ? 'all' : 'public'; // todo: member-of297 $status = bp_current_user_can( 'bp_moderate' ) ? 'all' : 'public'; // @todo: member-of. 297 298 $topic_count = (int)groups_total_forum_topic_count( $status, $search_terms ); 298 299 } … … 348 349 $this->total_topic_count = apply_filters_ref_array( 'bp_forums_template_total_topic_count', array( $this->total_topic_count, $this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies ) ); 349 350 350 // Fetch extra information for topics, so we don't have to query inside the loop 351 // Fetch extra information for topics, so we don't have to query inside the loop. 351 352 $this->topics = bp_forums_get_topic_extras( $this->topics ); 352 353 … … 373 374 */ 374 375 function has_topics() { 375 if ( $this->topic_count ) 376 if ( $this->topic_count ) { 376 377 return true; 378 } 377 379 378 380 return false; … … 423 425 */ 424 426 do_action('forum_loop_end'); 425 // Do some cleaning up after the loop 427 // Do some cleaning up after the loop. 426 428 $this->rewind_topics(); 427 429 } … … 466 468 * of has_topics(). 467 469 * 468 * @param array $args {470 * @param array|string $args { 469 471 * Arguments for limiting the contents of the forum topics loop. 470 472 * 471 * @type string $typeThe 'type' is the sort order/kind. 'newest',472 * 'popular', 'unreplied', 'tags'. Default: 'newest'.473 * @type int $forum_idThe ID of the forum for which topics are being474 * queried. Default: the ID of the forum belonging to the current475 * group, if available.476 * @type int $user_idThe ID of a user to whom to limit results. If viewing477 * a member's profile, defaults to that member's ID; otherwise478 * defaults to 0.479 * @type int $pageThe number of the page being requested. Default: 1, or480 * the value of $_GET['p'].481 * @type int $per_pagThe number items to return per page. Default: 20, or482 * the value of $_GET['n'].483 * @type int $maxOptional. Max records to return. Default: false (no max).484 * @type int $numberOptional. Number of records to return. Default: false.485 * @type int $offsetOptional. Offset results by a given value.486 * Default: false.487 * @type string $search_terms Optional. A string to which results should be488 * limited. Default: false, or the value of $_GET['fs'].489 * @type string|bool $do_stickies Whether to move stickies to the top of490 * the sort order. Default: true if looking at a group forum,491 * otherwise false.473 * @type string $type The 'type' is the sort order/kind. 'newest', 474 * 'popular', 'unreplied', 'tags'. Default: 'newest'. 475 * @type int $forum_id The ID of the forum for which topics are being 476 * queried. Default: the ID of the forum belonging to the current 477 * group, if available. 478 * @type int $user_id The ID of a user to whom to limit results. If viewing 479 * a member's profile, defaults to that member's ID; otherwise 480 * defaults to 0. 481 * @type int $page The number of the page being requested. Default: 1, or 482 * the value of $_GET['p']. 483 * @type int $per_pag The number items to return per page. Default: 20, or 484 * the value of $_GET['n']. 485 * @type int $max Optional. Max records to return. Default: false (no max). 486 * @type int $number Optional. Number of records to return. Default: false. 487 * @type int $offset Optional. Offset results by a given value. 488 * Default: false. 489 * @type string $search_terms Optional. A string to which results should be 490 * limited. Default: false, or the value of $_GET['fs']. 491 * @type string|bool $do_stickies Whether to move stickies to the top of 492 * the sort order. Default: true if looking at a group forum, 493 * otherwise false. 492 494 * } 493 495 * @return bool True when forum topics are found corresponding to the args, … … 499 501 $bp = buddypress(); 500 502 501 /* **503 /* 502 504 * Set the defaults based on the current page. Any of these will be overridden 503 505 * if arguments are directly passed into the loop. Custom plugins should always … … 510 512 $do_stickies = false; 511 513 512 // User filtering 514 // User filtering. 513 515 if ( bp_displayed_user_id() ) 514 516 $user_id = bp_displayed_user_id(); … … 516 518 // "Replied" query must be manually modified 517 519 if ( 'replies' == bp_current_action() ) { 518 $user_id = 0; // User id must be handled manually by the filter, not by BB_Query 520 $user_id = 0; // User id must be handled manually by the filter, not by BB_Query. 519 521 520 522 add_filter( 'get_topics_distinct', 'bp_forums_add_replied_distinct_sql', 20 ); … … 523 525 } 524 526 525 // If we're in a single group, set this group's forum_id 527 // If we're in a single group, set this group's forum_id. 526 528 if ( !$forum_id && !empty( $bp->groups->current_group ) ) { 527 529 $bp->groups->current_group->forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 528 530 529 531 // If it turns out there is no forum for this group, return false so 530 // we don't fetch all global topics 532 // we don't fetch all global topics. 531 533 if ( empty( $bp->groups->current_group->forum_id ) ) 532 534 return false; … … 535 537 } 536 538 537 // If $_GET['fs'] is set, let's auto populate the search_terms var 539 // If $_GET['fs'] is set, let's auto populate the search_terms var. 538 540 if ( bp_is_directory() && !empty( $_GET['fs'] ) ) 539 541 $search_terms = $_GET['fs']; 540 542 541 // Get the pagination arguments from $_REQUEST 543 // Get the pagination arguments from $_REQUEST. 542 544 $page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1; 543 545 $per_page = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : 20; 544 546 545 // By default, stickies are only pushed to the top of the order on individual group forums 547 // By default, stickies are only pushed to the top of the order on individual group forums. 546 548 if ( bp_is_group_forum() ) 547 549 $do_stickies = true; … … 564 566 565 567 // If we're viewing a tag URL in the directory, let's override the type and 566 // set it to tags and the filter to the tag name 568 // set it to tags and the filter to the tag name. 567 569 if ( bp_is_current_action( 'tag' ) && $search_terms = bp_action_variable( 0 ) ) { 568 570 $type = 'tags'; … … 572 574 573 575 if ( $do_stickies ) { 574 // Fetch the stickies 576 // Fetch the stickies. 575 577 $stickies_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 0, 0, $max, 'sticky', $search_terms ); 576 578 577 // If stickies are found, try merging them 579 // If stickies are found, try merging them. 578 580 if ( $stickies_template->has_topics() ) { 579 581 580 // If stickies are for current $page 582 // If stickies are for current $page. 581 583 $page_start_num = ( ( $page - 1 ) * $per_page ) + 1; 582 584 $page_end_num = $page * $per_page <= $stickies_template->total_topic_count ? $page * $per_page : $stickies_template->total_topic_count; 583 585 584 // Calculate the number of sticky topics that will be shown on this page 586 // Calculate the number of sticky topics that will be shown on this page. 585 587 if ( $stickies_template->topic_count < $page_start_num ) { 586 588 $this_page_stickies = 0; 587 589 } else { 588 $this_page_stickies = $stickies_template->topic_count - $per_page * floor( $stickies_template->topic_count / $per_page ) * ( $page - 1 ); // Total stickies minus sticky count through this page 590 $this_page_stickies = $stickies_template->topic_count - $per_page * floor( $stickies_template->topic_count / $per_page ) * ( $page - 1 ); // Total stickies minus sticky count through this page. 589 591 590 592 // $this_page_stickies cannot be more than $per_page or less than 0 … … 595 597 } 596 598 597 // Calculate the total number of topics that will be shown on this page 599 // Calculate the total number of topics that will be shown on this page. 598 600 $this_page_topics = $stickies_template->total_topic_count >= ( $page * $per_page ) ? $per_page : $page_end_num - ( $page_start_num - 1 ); 599 601 600 602 // If the number of stickies to be shown is less than $per_page, fetch some 601 // non-stickies to fill in the rest 603 // non-stickies to fill in the rest. 602 604 if ( $this_page_stickies < $this_page_topics ) { 603 605 // How many non-stickies do we need? … … 609 611 610 612 // The offset is the number of total non-stickies, less the number 611 // to be shown on this page 613 // to be shown on this page. 612 614 $non_sticky_offset = $non_sticky_total - $non_sticky_number; 613 615 614 // Fetch the non-stickies 616 // Fetch the non-stickies. 615 617 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 1, $per_page, $max, 'no', $search_terms, $non_sticky_offset, $non_sticky_number ); 616 618 617 // If there are stickies to merge on this page, do it now 619 // If there are stickies to merge on this page, do it now. 618 620 if ( $this_page_stickies ) { 619 // Correct the topic_count 621 // Correct the topic_count. 620 622 $forum_template->topic_count += (int) $this_page_stickies; 621 623 622 // Figure out which stickies need to be included 624 // Figure out which stickies need to be included. 623 625 $this_page_sticky_topics = array_slice( $stickies_template->topics, 0 - $this_page_stickies ); 624 626 625 // Merge these topics into the forum template 627 // Merge these topics into the forum template. 626 628 $forum_template->topics = array_merge( $this_page_sticky_topics, (array) $forum_template->topics ); 627 629 } 628 630 } else { 629 // This page has no non-stickies 631 // This page has no non-stickies. 630 632 $forum_template = $stickies_template; 631 633 632 // Adjust the topic count and trim the topics 634 // Adjust the topic count and trim the topics. 633 635 $forum_template->topic_count = $this_page_stickies; 634 636 $forum_template->topics = array_slice( $forum_template->topics, $page - 1 ); … … 636 638 637 639 // Because we're using a manual offset and number for the topic query, we 638 // must set the page number manually, and recalculate the pagination links 640 // must set the page number manually, and recalculate the pagination links. 639 641 $forum_template->pag_num = $per_page; 640 642 $forum_template->pag_page = $page; … … 652 654 653 655 } else { 654 // Fetch the non-sticky topics if no stickies were found 656 // Fetch the non-sticky topics if no stickies were found. 655 657 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, 'all', $search_terms ); 656 658 } 657 659 } else { 658 // When skipping the sticky logic, just pull up the forum topics like usual 660 // When skipping the sticky logic, just pull up the forum topics like usual. 659 661 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, 'all', $search_terms ); 660 662 } … … 822 824 * @see bp_get_the_topic_poster_avatar() for a description of arguments. 823 825 * 824 * @param array $args See {@link bp_get_the_topic_poster_avatar()}.826 * @param array|string $args See {@link bp_get_the_topic_poster_avatar()}. 825 827 */ 826 828 function bp_the_topic_poster_avatar( $args = '' ) { … … 830 832 * Return the avatar of the user who posted the current topic in the loop. 831 833 * 832 * @param array $args {834 * @param array|string $args { 833 835 * Arguments for building the avatar. 834 * @type string $type Avatar type. 'thumb' or 'full'. Default:835 * 'thumb'.836 * @type int $widthWidth of the avatar, in pixels. Default: the837 * width corresponding to $type.838 * See {@link bp_core_fetch_avatar()}.839 * @type int $height Height of the avatar, in pixels. Default: the840 * height corresponding to $type.841 * See {@link bp_core_fetch_avatar()}.842 * @type string $alt The text of the image's 'alt' attribute.843 * Default: 'Profile picture of [user name]'.836 * @type string $type Avatar type. 'thumb' or 'full'. Default: 837 * 'thumb'. 838 * @type int $width Width of the avatar, in pixels. Default: the 839 * width corresponding to $type. 840 * See {@link bp_core_fetch_avatar()}. 841 * @type int $height Height of the avatar, in pixels. Default: the 842 * height corresponding to $type. 843 * See {@link bp_core_fetch_avatar()}. 844 * @type string $alt The text of the image's 'alt' attribute. 845 * Default: 'Profile picture of [user name]'. 844 846 * } 845 847 * @return string HTML of user avatar. … … 1006 1008 function bp_get_the_topic_object_permalink() { 1007 1009 1008 // Currently this will only work with group forums, extended support in the future 1010 // Currently this will only work with group forums, extended support in the future. 1009 1011 if ( bp_is_active( 'groups' ) ) { 1010 1012 $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_get_the_topic_object_slug() . '/forum' ); … … 1036 1038 * 1037 1039 * @return string HTML link to the profile of the user who last posted 1038 * to the current topic.1040 * to the current topic. 1039 1041 */ 1040 1042 function bp_get_the_topic_last_poster_name() { … … 1044 1046 1045 1047 // In the case where no user is found, bp_core_get_user_domain() may return the URL 1046 // of the Members directory 1048 // of the Members directory. 1047 1049 if ( empty( $domain ) || ( bp_get_members_directory_permalink() === $domain ) ) { 1048 1050 return __( 'Deleted User', 'buddypress' ); … … 1064 1066 * @see bp_get_the_topic_object_avatar() for description of arguments. 1065 1067 * 1066 * @param array $args See {@bp_get_the_topic_object_avatar()}.1068 * @param array|string $args See {@bp_get_the_topic_object_avatar()}. 1067 1069 */ 1068 1070 function bp_the_topic_object_avatar( $args = '' ) { … … 1075 1077 * avatar of the group associated with the forum topic, if it exists. 1076 1078 * 1077 * @param array $args {1079 * @param array|string $args { 1078 1080 * Arguments for building the avatar. 1079 * @type string $type Avatar type. 'thumb' or 'full'. Default:1080 * 'thumb'.1081 * @type int $widthWidth of the avatar, in pixels. Default: the1082 * width corresponding to $type.1083 * See {@link bp_core_fetch_avatar()}.1084 * @type int $height Height of the avatar, in pixels. Default:1085 * the height corresponding to $type.1086 * See {@link bp_core_fetch_avatar()}.1087 * @type string $alt The text of the image's 'alt' attribute.1088 * Default: 'Group logo for [group name]'.1081 * @type string $type Avatar type. 'thumb' or 'full'. Default: 1082 * 'thumb'. 1083 * @type int $width Width of the avatar, in pixels. Default: the 1084 * width corresponding to $type. 1085 * See {@link bp_core_fetch_avatar()}. 1086 * @type int $height Height of the avatar, in pixels. Default: 1087 * the height corresponding to $type. 1088 * See {@link bp_core_fetch_avatar()}. 1089 * @type string $alt The text of the image's 'alt' attribute. 1090 * Default: 'Group logo for [group name]'. 1089 1091 * } 1090 1092 * @return string Object avatar. … … 1121 1123 * @see bp_get_the_topic_last_poster_avatar() for description of arguments. 1122 1124 * 1123 * @param array $args See {@bp_get_the_topic_last_poster_avatar()}.1125 * @param array|string $args See {@bp_get_the_topic_last_poster_avatar()}. 1124 1126 */ 1125 1127 function bp_the_topic_last_poster_avatar( $args = '' ) { … … 1129 1131 * Return the avatar for the user who last posted to the current topic in the loop. 1130 1132 * 1131 * @param array $args {1133 * @param array|string $args { 1132 1134 * Arguments for building the avatar. 1133 * @type string $type Avatar type. 'thumb' or 'full'. Default:1134 * 'thumb'.1135 * @type int $widthWidth of the avatar, in pixels. Default: the1136 * width corresponding to $type.1137 * See {@link bp_core_fetch_avatar()}.1138 * @type int $height Height of the avatar, in pixels. Default:1139 * the height corresponding to $type.1140 * See {@link bp_core_fetch_avatar()}.1141 * @type string $alt The text of the image's 'alt' attribute.1142 * Default: 'Profile picture of [group name]'.1135 * @type string $type Avatar type. 'thumb' or 'full'. Default: 1136 * 'thumb'. 1137 * @type int $width Width of the avatar, in pixels. Default: the 1138 * width corresponding to $type. 1139 * See {@link bp_core_fetch_avatar()}. 1140 * @type int $height Height of the avatar, in pixels. Default: 1141 * the height corresponding to $type. 1142 * See {@link bp_core_fetch_avatar()}. 1143 * @type string $alt The text of the image's 'alt' attribute. 1144 * Default: 'Profile picture of [group name]'. 1143 1145 * } 1144 1146 * @return string User avatar. … … 1272 1274 * Return whether the current topic in the loop is open. 1273 1275 * 1274 * @return unknown1276 * @return string 1275 1277 */ 1276 1278 function bp_get_the_topic_is_topic_open() { … … 1320 1322 * Return whether the current topic in the loop is sticky. 1321 1323 * 1322 * @return unknown1324 * @return bool 1323 1325 */ 1324 1326 function bp_get_the_topic_is_sticky() { … … 1428 1430 global $forum_template; 1429 1431 1430 // The topic is in a loop where its parent object is loaded 1432 // The topic is in a loop where its parent object is loaded. 1431 1433 if ( bp_get_the_topic_object_slug() ) { 1432 1434 $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_get_the_topic_object_slug() . '/forum' ); 1433 1435 1434 // We are viewing a single group topic, so use the current item 1436 // We are viewing a single group topic, so use the current item. 1435 1437 } elseif ( bp_is_group_forum_topic() ) { 1436 1438 $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_current_item() . '/forum' ); 1437 1439 1438 // We are unsure what the context is, so fallback to forum root slug 1440 // We are unsure what the context is, so fallback to forum root slug. 1439 1441 } elseif ( bp_is_single_item() ) { 1440 1442 $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' . bp_current_item() ); 1441 1443 1442 // This is some kind of error situation, so use forum root 1444 // This is some kind of error situation, so use forum root. 1443 1445 } else { 1444 1446 $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ); … … 1483 1485 /** 1484 1486 * Output an excerpt from the latest post of the current topic in the loop. 1487 * 1488 * @param array|string $args See {@bp_get_the_topic_latest_post_excerpt()}. 1485 1489 */ 1486 1490 function bp_the_topic_latest_post_excerpt( $args = '' ) { … … 1490 1494 * Return an excerpt from the latest post of the current topic in the loop. 1491 1495 * 1492 * @param array $args {1496 * @param array|string $args { 1493 1497 * @type int $length The length of the excerpted text. Default: 225. 1494 1498 * } … … 1555 1559 * 1556 1560 * @return bool True if the current topic in the loop was created by 1557 * the logged-in user, otherwise false.1561 * the logged-in user, otherwise false. 1558 1562 */ 1559 1563 function bp_get_the_topic_is_mine() { … … 1568 1572 * @see bp_get_the_topic_admin_links() for a description of arguments. 1569 1573 * 1570 * @param array $args See {@link bp_get_the_topic_admin_links()}.1574 * @param array|string $args See {@link bp_get_the_topic_admin_links()}. 1571 1575 */ 1572 1576 function bp_the_topic_admin_links( $args = '' ) { … … 1576 1580 * Return the admin links for the current topic in the loop. 1577 1581 * 1578 * @param array $args { 1579 * @type string $separator The character to use when separating 1580 * links. Default: '|'. 1582 * @param array|string $args { 1583 * @type string $separator The character to use when separating links. Default: '|'. 1581 1584 * } 1582 * @return HTML string containing the admin links for the current topic.1585 * @return string HTML string containing the admin links for the current topic. 1583 1586 */ 1584 1587 function bp_get_the_topic_admin_links( $args = '' ) { … … 1785 1788 * @uses apply_filters() Filter bp_get_forum_topic_new_reply_link to 1786 1789 * modify. 1790 * 1787 1791 * @return string The URL for the New Reply link. 1788 1792 */ … … 1791 1795 1792 1796 if ( $topic_template->pag->total_pages == $topic_template->pag_page ) { 1793 // If we are on the last page, no need for a URL base 1797 // If we are on the last page, no need for a URL base. 1794 1798 $link = ''; 1795 1799 } else { 1796 // Create a link to the last page for the topic 1800 // Create a link to the last page for the topic. 1797 1801 $link = add_query_arg( array( 1798 1802 'topic_page' => $topic_template->pag->total_pages, … … 1994 1998 * 1995 1999 * @access public 1996 * @var public2000 * @var int 1997 2001 */ 1998 2002 public $pag_page; … … 2002 2006 * 2003 2007 * @access public 2004 * @var public2008 * @var int 2005 2009 */ 2006 2010 public $pag_num; … … 2049 2053 * Constructor method. 2050 2054 * 2051 * @param int $topic_id ID of the topic whose posts are being requested.2052 * @param int $per_page Number of items to return per page.2053 * @param int $max Max records to return.2055 * @param int $topic_id ID of the topic whose posts are being requested. 2056 * @param int $per_page Number of items to return per page. 2057 * @param int $max Max records to return. 2054 2058 * @param string $order Direction to order results. 2055 2059 */ … … 2092 2096 } 2093 2097 2094 // Load topic tags 2098 // Load topic tags. 2095 2099 $this->topic_tags = bb_get_topic_tags( $this->topic_id ); 2096 2100 … … 2173 2177 */ 2174 2178 do_action('topic_loop_end'); 2175 // Do some cleaning up after the loop 2179 // Do some cleaning up after the loop. 2176 2180 $this->rewind_posts(); 2177 2181 } … … 2207 2211 * Initiate the loop for a single topic's posts. 2208 2212 * 2209 * @param array $args {2213 * @param array|string $args { 2210 2214 * Arguments for limiting the contents of the topic posts loop. 2211 * @type int $topic_id ID of the topic to which the posts belong.2212 * @type int $per_page Number of items to return per page. Default: 15.2213 * @type int $maxMax items to return. Default: false.2214 * @type string $order 'ASC' or 'DESC'.2215 * @type int $topic_id ID of the topic to which the posts belong. 2216 * @type int $per_page Number of items to return per page. Default: 15. 2217 * @type int $max Max items to return. Default: false. 2218 * @type string $order 'ASC' or 'DESC'. 2215 2219 * } 2216 2220 * @return bool True when posts are found corresponding to the args, 2217 * otherwise false.2221 * otherwise false. 2218 2222 */ 2219 2223 function bp_has_forum_topic_posts( $args = '' ) { … … 2241 2245 $topic_template = new BP_Forums_Template_Topic( (int) $topic_id, $per_page, $max, $order ); 2242 2246 2243 // Current topic forum_id needs to match current_group forum_id 2247 // Current topic forum_id needs to match current_group forum_id. 2244 2248 if ( bp_is_groups_component() && $topic_template->forum_id != groups_get_groupmeta( bp_get_current_group_id(), 'forum_id' ) ) 2245 2249 return false; … … 2338 2342 * 2339 2343 * @return string String to put in the 'class' attribute of the current 2340 * post.2344 * post. 2341 2345 */ 2342 2346 function bp_get_the_topic_post_css_class() { … … 2372 2376 * @see bp_get_the_topic_post_poster_avatar() for a description of arguments. 2373 2377 * 2374 * @param array $args See {@link bp_get_the_topic_post_poster_avatar()}.2378 * @param array|string $args See {@link bp_get_the_topic_post_poster_avatar()}. 2375 2379 */ 2376 2380 function bp_the_topic_post_poster_avatar( $args = '' ) { … … 2380 2384 * Return the avatar of the user who posted the current post in the loop. 2381 2385 * 2382 * @param array $args {2386 * @param array|string $args { 2383 2387 * Arguments for building the avatar. 2384 * @type string $type Avatar type. 'thumb' or 'full'. Default:2385 * 'thumb'.2386 * @type int $widthWidth of the avatar, in pixels. Default: the2387 * width corresponding to $type.2388 * See {@link bp_core_fetch_avatar()}.2389 * @type int $height Height of the avatar, in pixels. Default: the2390 * height corresponding to $type.2391 * See {@link bp_core_fetch_avatar()}.2392 * @type string $alt The text of the image's 'alt' attribute.2393 * Default: 'Profile picture of [user name]'.2388 * @type string $type Avatar type. 'thumb' or 'full'. Default: 2389 * 'thumb'. 2390 * @type int $width Width of the avatar, in pixels. Default: the 2391 * width corresponding to $type. 2392 * See {@link bp_core_fetch_avatar()}. 2393 * @type int $height Height of the avatar, in pixels. Default: the 2394 * height corresponding to $type. 2395 * See {@link bp_core_fetch_avatar()}. 2396 * @type string $alt The text of the image's 'alt' attribute. 2397 * Default: 'Profile picture of [user name]'. 2394 2398 * } 2395 2399 * @return string HTML of user avatar. … … 2455 2459 * 2456 2460 * @return string Link to the profile of the user who posted the 2457 * current post.2461 * current post. 2458 2462 */ 2459 2463 function bp_get_the_topic_post_poster_link() { … … 2506 2510 * 2507 2511 * @return bool True if the current post in the loop was created by 2508 * the logged-in user, otherwise false.2512 * the logged-in user, otherwise false. 2509 2513 */ 2510 2514 function bp_get_the_topic_post_is_mine() { … … 2519 2523 * @see bp_get_the_post_admin_links() for a description of arguments. 2520 2524 * 2521 * @param array $args See {@link bp_get_the_post_admin_links()}.2525 * @param array|string $args See {@link bp_get_the_post_admin_links()}. 2522 2526 */ 2523 2527 function bp_the_topic_post_admin_links( $args = '' ) { … … 2527 2531 * Return the admin links for the current post in the loop. 2528 2532 * 2529 * @param array $args {2533 * @param array|string $args { 2530 2534 * @type string $separator The character to use when separating 2531 * links. Default: '|'.2535 * links. Default: '|'. 2532 2536 * } 2533 * @return HTML string containing the admin links for the current post.2537 * @return string HTML string containing the admin links for the current post. 2534 2538 */ 2535 2539 function bp_get_the_topic_post_admin_links( $args = '' ) { … … 2618 2622 * 2619 2623 * The "count" is a string of the form "Viewing x of y posts". 2620 *2621 * @return string2622 2624 */ 2623 2625 function bp_the_topic_pagination_count() { … … 2658 2660 * 2659 2661 * @return bool True if this is the last page of posts for the current 2660 * topic, otherwise false.2662 * topic, otherwise false. 2661 2663 */ 2662 2664 function bp_get_the_topic_is_last_page() { … … 2690 2692 * @since 1.9.0 2691 2693 * 2692 * @param string HTML search form for the forums directory.2694 * @param string $search_form_html HTML search form for the forums directory. 2693 2695 */ 2694 2696 echo apply_filters( 'bp_directory_forums_search_form', $search_form_html ); … … 2709 2711 * 2710 2712 * @param int $forum_id Optional. Defaults to the current forum, if 2711 * there is one.2713 * there is one. 2712 2714 * @return string|bool False on failure, a URL on success. 2713 2715 */ … … 2753 2755 * 2754 2756 * @param int $forum_id Optional. Defaults to the current forum, if 2755 * there is one.2757 * there is one. 2756 2758 * @return string|bool False on failure, a name on success. 2757 2759 */ … … 2786 2788 * defaults. 2787 2789 * 2788 * @param array $args {2790 * @param array|string $args { 2789 2791 * An array of optional arguments. 2790 * @type int $smallest Size of the smallest link. Default: 10.2791 * @type int $largestSize of the largest link. Default: 42.2792 * @type string $sizing Unit for $largest and $smallest. Default: 'px'.2793 * @type int $limitMax number of tags to display. Default: 50.2792 * @type int $smallest Size of the smallest link. Default: 10. 2793 * @type int $largest Size of the largest link. Default: 42. 2794 * @type string $sizing Unit for $largest and $smallest. Default: 'px'. 2795 * @type int $limit Max number of tags to display. Default: 50. 2794 2796 * } 2795 2797 */ … … 2809 2811 2810 2812 /** 2811 * Output the current topic's tag list, comma-separated 2813 * Output the current topic's tag list, comma-separated. 2812 2814 * 2813 2815 * @since 1.5.0 … … 2822 2824 * 2823 2825 * @param string $format 'string' returns comma-separated string; 2824 * otherwise returns array.2826 * otherwise returns array. 2825 2827 * @return mixed $tags 2826 2828 */ -
trunk/src/bp-forums/deprecated/1.6.php
r9819 r10183 1 1 <?php 2 3 2 /** 4 * BuddyPress Forums Deprecated Functions 3 * BuddyPress Forums Deprecated Functions. 5 4 * 6 5 * This file contains all the deprecated functions for BuddyPress forums since … … 12 11 */ 13 12 14 // Exit if accessed directly 13 // Exit if accessed directly. 15 14 defined( 'ABSPATH' ) || exit; 16 15 … … 21 20 22 21 // The text and URL of the Site Wide Forums button differs depending on whether bbPress 23 // is running 22 // is running. 24 23 if ( is_plugin_active( 'bbpress/bbpress.php' ) ) { 25 24 // The bbPress admin page will always be on the root blog. switch_to_blog() will … … 54 53 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : 55 54 56 // Delete the bb-config.php location option 55 // Delete the bb-config.php location option. 57 56 bp_delete_option( 'bb-config-location' ); 58 57 59 // Now delete the bb-config.php file 58 // Now delete the bb-config.php file. 60 59 @unlink( ABSPATH . 'bb-config.php' ); 61 60 62 // show the updated wizard61 // Show the updated wizard. 63 62 bp_forums_bbpress_install_wizard(); 64 63 … … 121 120 122 121 // The text and URL of the Site Wide Forums button differs depending on whether bbPress 123 // is running 122 // is running. 124 123 if ( is_plugin_active( 'bbpress/bbpress.php' ) ) { 125 124 $bbpress_plugin_is_active = true; … … 172 171 break; 173 172 default: 174 // Just write the contents to screen 173 // Just write the contents to screen. 175 174 _e( '<p>A configuration file could not be created. No problem, but you will need to save the text shown below into a file named <code>bb-config.php</code> in the root directory of your WordPress installation before you can start using the forum functionality.</p>', 'buddypress' ); ?> 176 175 … … 200 199 <?php } else { 201 200 202 // Include the plugin install 203 201 // Include the plugin install. 204 202 add_thickbox(); 205 203 wp_enqueue_script( 'plugin-install' ); -
trunk/src/bp-forums/deprecated/1.7.php
r9819 r10183 1 1 <?php 2 3 2 /** 4 * BuddyPress Forums Deprecated Functions 3 * BuddyPress Forums Deprecated Functions. 5 4 * 6 5 * This file contains all the deprecated functions for BuddyPress forums since … … 12 11 */ 13 12 14 // Exit if accessed directly 13 // Exit if accessed directly. 15 14 defined( 'ABSPATH' ) || exit; 16 15 … … 22 21 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 23 22 24 // Add the administration tab under the "Site Admin" tab for site administrators 23 // Add the administration tab under the "Site Admin" tab for site administrators. 25 24 $hook = add_submenu_page( $page, __( 'Forums', 'buddypress' ), __( 'Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); 26 25 27 // Fudge the highlighted subnav item when on the BuddyPress Forums admin page 26 // Fudge the highlighted subnav item when on the BuddyPress Forums admin page. 28 27 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 29 28 } … … 35 34 check_admin_referer( 'bp_forums_existing_install_init' ); 36 35 37 // Sanitize $_REQUEST['bbconfigloc'] 36 // Sanitize $_REQUEST['bbconfigloc']. 38 37 $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] ); 39 38 … … 65 64 $bp = buddypress(); 66 65 67 // Create the bb-config.php file 66 // Create the bb-config.php file. 68 67 $initial_write = bp_forums_bbpress_write( 69 68 $bp->plugin_dir . '/bp-forums/bbpress/bb-config-sample.php', … … 85 84 ); 86 85 87 // Add the custom user and usermeta entries to the config file 86 // Add the custom user and usermeta entries to the config file. 88 87 if ( $initial_write == 1 ) { 89 88 $file = file_get_contents( $location ); … … 147 146 } 148 147 149 // Get the existing lines in the file 148 // Get the existing lines in the file. 150 149 $lines = file( $file_source ); 151 150 152 // Initialise an array to store the modified lines 151 // Initialise an array to store the modified lines. 153 152 $modified_lines = array(); 154 153 155 // Loop through the lines and modify them 154 // Loop through the lines and modify them. 156 155 foreach ( (array) $lines as $line ) { 157 156 if ( isset( $alterations[substr( $line, 0, 20 )] ) ) { … … 184 183 } 185 184 186 // Open the file for writing - rewrites the whole file 185 // Open the file for writing - rewrites the whole file. 187 186 $file_handle = fopen( $file_target, 'w' ); 188 187 189 // Write lines one by one to avoid OS specific newline hassles 188 // Write lines one by one to avoid OS specific newline hassles. 190 189 foreach ( (array) $modified_lines as $modified_line ) { 191 190 if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?>' ) ) { … … 199 198 } 200 199 201 // Close the config file 200 // Close the config file. 202 201 fclose( $file_handle ); 203 202
Note: See TracChangeset
for help on using the changeset viewer.