Changeset 2077 for trunk/bp-forums.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-forums.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums.php
r2033 r2077 4 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 5 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 6 6 7 7 if ( !defined( 'BP_FORUMS_SLUG' ) ) 8 8 define( 'BP_FORUMS_SLUG', 'forums' ); … … 19 19 /* For internal identification */ 20 20 $bp->forums->id = 'forums'; 21 21 22 22 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 23 23 $bp->forums->bbconfig = get_site_option( 'bb-config-location' ); 24 24 $bp->forums->slug = BP_FORUMS_SLUG; 25 25 26 26 /* Register this in the active components array */ 27 27 $bp->active_components[$bp->forums->slug] = $bp->forums->id; … … 34 34 function bp_forums_is_installed_correctly() { 35 35 global $bp; 36 36 37 37 if ( file_exists( $bp->forums->bbconfig ) ) 38 38 return true; 39 39 40 40 return false; 41 41 } … … 53 53 if ( (int) get_site_option( 'bp-disable-forum-directory' ) || !function_exists( 'groups_install' ) ) 54 54 return false; 55 55 56 56 if ( !bp_forums_is_installed_correctly() ) { 57 57 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 58 58 bp_core_redirect( $bp->root_domain ); 59 59 } 60 60 61 61 $bp->is_directory = true; 62 63 do_action( 'bbpress_init' ); 62 63 do_action( 'bbpress_init' ); 64 64 do_action( 'bp_forums_directory_forums_setup' ); 65 65 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) ); … … 70 70 function bp_forums_add_admin_menu() { 71 71 global $bp; 72 72 73 73 if ( !is_site_admin() ) 74 74 return false; 75 75 76 76 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 77 77 78 78 /* Add the administration tab under the "Site Admin" tab for site administrators */ 79 79 add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); … … 90 90 function bp_forums_new_forum( $args = '' ) { 91 91 do_action( 'bbpress_init' ); 92 93 $defaults = array( 94 'forum_name' => '', 95 'forum_desc' => '', 96 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 97 'forum_order' => false, 92 93 $defaults = array( 94 'forum_name' => '', 95 'forum_desc' => '', 96 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 97 'forum_order' => false, 98 98 'forum_is_category' => 0 99 99 ); … … 101 101 $r = wp_parse_args( $args, $defaults ); 102 102 extract( $r, EXTR_SKIP ); 103 103 104 104 return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 105 105 } … … 107 107 function bp_forums_get_forum_topicpost_count( $forum_id ) { 108 108 global $wpdb, $bbdb; 109 109 110 110 do_action( 'bbpress_init' ); 111 111 … … 118 118 function bp_forums_get_forum_topics( $args = '' ) { 119 119 global $bp; 120 121 do_action( 'bbpress_init' ); 122 120 121 do_action( 'bbpress_init' ); 122 123 123 $defaults = array( 124 124 'type' => 'newest', 125 'forum_id' => false, 126 'page' => 1, 127 'per_page' => 15, 125 'forum_id' => false, 126 'page' => 1, 127 'per_page' => 15, 128 128 'exclude' => false, 129 129 'show_stickies' => 'all', 130 130 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on. 131 131 ); 132 132 133 133 $r = wp_parse_args( $args, $defaults ); 134 134 extract( $r, EXTR_SKIP ); … … 139 139 $topics = $query->results; 140 140 break; 141 141 142 142 case 'popular': 143 143 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 144 144 $topics =& $query->results; 145 145 break; 146 146 147 147 case 'unreplied': 148 148 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 149 149 $topics =& $query->results; 150 break; 151 150 break; 151 152 152 case 'personal': 153 153 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' ); 154 154 $topics =& $query->results; 155 155 break; 156 156 157 157 case 'tag': 158 158 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); … … 167 167 do_action( 'bbpress_init' ); 168 168 169 $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 169 $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 170 170 171 171 return $query->results[0]; … … 179 179 function bp_forums_new_topic( $args = '' ) { 180 180 global $bp; 181 182 do_action( 'bbpress_init' ); 183 181 182 do_action( 'bbpress_init' ); 183 184 184 $defaults = array( 185 185 'topic_title' => '', … … 198 198 $r = wp_parse_args( $args, $defaults ); 199 199 extract( $r, EXTR_SKIP ); 200 200 201 201 if ( empty( $topic_slug ) ) 202 202 $topic_slug = sanitize_title( $topic_title ); 203 203 204 204 if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) ) 205 205 return false; … … 208 208 if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) ) 209 209 return false; 210 210 211 211 return $topic_id; 212 212 } … … 214 214 function bp_forums_update_topic( $args = '' ) { 215 215 global $bp; 216 217 do_action( 'bbpress_init' ); 218 216 217 do_action( 'bbpress_init' ); 218 219 219 $defaults = array( 220 220 'topic_id' => false, … … 225 225 $r = wp_parse_args( $args, $defaults ); 226 226 extract( $r, EXTR_SKIP ); 227 227 228 228 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 229 229 return false; 230 230 231 231 if ( !$post = bb_get_first_post( $topic_id ) ) 232 232 return false; … … 235 235 if ( !$post = bb_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 ) ) ) 236 236 return false; 237 237 238 238 return bp_forums_get_topic_details( $topic_id ); 239 239 } … … 241 241 function bp_forums_sticky_topic( $args = '' ) { 242 242 global $bp; 243 244 do_action( 'bbpress_init' ); 245 243 244 do_action( 'bbpress_init' ); 245 246 246 $defaults = array( 247 247 'topic_id' => false, … … 251 251 $r = wp_parse_args( $args, $defaults ); 252 252 extract( $r, EXTR_SKIP ); 253 253 254 254 if ( 'stick' == $mode ) 255 255 return bb_stick_topic( $topic_id ); … … 262 262 function bp_forums_openclose_topic( $args = '' ) { 263 263 global $bp; 264 265 do_action( 'bbpress_init' ); 266 264 265 do_action( 'bbpress_init' ); 266 267 267 $defaults = array( 268 268 'topic_id' => false, … … 272 272 $r = wp_parse_args( $args, $defaults ); 273 273 extract( $r, EXTR_SKIP ); 274 274 275 275 if ( 'close' == $mode ) 276 276 return bb_close_topic( $topic_id ); … … 283 283 function bp_forums_delete_topic( $args = '' ) { 284 284 global $bp; 285 286 do_action( 'bbpress_init' ); 287 285 286 do_action( 'bbpress_init' ); 287 288 288 $defaults = array( 289 289 'topic_id' => false … … 296 296 } 297 297 298 /* Post Functions */ 298 /* Post Functions */ 299 299 300 300 function bp_forums_get_topic_posts( $args = '' ) { 301 301 do_action( 'bbpress_init' ); 302 303 $defaults = array( 304 'topic_id' => false, 302 303 $defaults = array( 304 'topic_id' => false, 305 305 'page' => 1, 306 306 'per_page' => 15, … … 321 321 function bp_forums_delete_post( $args = '' ) { 322 322 global $bp; 323 324 do_action( 'bbpress_init' ); 325 323 324 do_action( 'bbpress_init' ); 325 326 326 $defaults = array( 327 327 'post_id' => false … … 331 331 extract( $r, EXTR_SKIP ); 332 332 333 return bb_delete_post( $post_id, 1 ); 333 return bb_delete_post( $post_id, 1 ); 334 334 } 335 335 336 336 function bp_forums_insert_post( $args = '' ) { 337 337 global $bp; 338 339 do_action( 'bbpress_init' ); 340 341 $defaults = array( 342 'post_id' => false, 338 339 do_action( 'bbpress_init' ); 340 341 $defaults = array( 342 'post_id' => false, 343 343 'topic_id' => false, 344 344 'post_text' => '', … … 352 352 $r = wp_parse_args( $args, $defaults ); 353 353 extract( $r, EXTR_SKIP ); 354 354 355 355 if ( !$post = bp_forums_get_post( $post_id ) ) 356 356 $post_id = false; … … 358 358 if ( !isset( $topic_id ) ) 359 359 $topic_id = $post->topic_id; 360 360 361 361 if ( empty( $post_text ) ) 362 362 $post_text = $post->post_text; 363 363 364 364 if ( !isset( $post_time ) ) 365 365 $post_time = $post->post_time; … … 378 378 function bp_forums_filter_caps( $allcaps ) { 379 379 global $bp, $wp_roles, $bb_table_prefix; 380 380 381 381 $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' ); 382 382 383 383 if ( empty( $bb_cap ) ) 384 384 return $allcaps; 385 385 386 386 $bb_cap = array_keys($bb_cap); 387 387 $bb_cap = $wp_roles->get_role( $bb_cap[0] ); 388 388 $bb_cap = $bb_cap->capabilities; 389 389 390 390 return array_merge( (array) $allcaps, (array) $bb_cap ); 391 391 }
Note: See TracChangeset
for help on using the changeset viewer.