Ticket #520: categories-build619.patch
| File categories-build619.patch, 33.4 kB (added by SamBauers, 2 years ago) |
|---|
-
bb-templates/style.css
old new 169 169 padding-bottom: 10px; 170 170 } 171 171 172 #front-page #main h2, h2.post-form, #userlogin, #currentfavorites, #register {172 #front-page #main h2, #category-page #main h2, h2.post-form, #userlogin, #currentfavorites, #register { 173 173 color: #333; 174 174 border-bottom: 1px solid #ddd; 175 175 margin: 0 0 10px; -
bb-templates/front-page.php
old new 40 40 </table> 41 41 <?php endif; ?> 42 42 43 <h2><?php _e('Forums'); ?></h2> 44 <table id="forumlist"> 43 <?php if ( $categories ) : ?> 45 44 45 <?php foreach ( $categories as $category ) : ?> 46 <?php 47 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 48 $forums = get_forums(); 49 ?> 50 <?php if ( $forums ) : ?> 51 <h2><a href="<?php category_link(); ?>"><?php category_name(); ?></a></h2> 52 53 <p style="float:right;"><?php category_forums(); ?> <?php echo __ngettext('forum', 'forums', get_category_forums()); ?></p> 54 55 <p><?php category_description(); ?></p> 56 57 <table style="clear:both;" id="forumlist"> 58 46 59 <tr> 47 60 <th><?php _e('Main Theme'); ?></th> 48 61 <th><?php _e('Topics'); ?></th> … … 55 68 <td class="num"><?php forum_topics(); ?></td> 56 69 <td class="num"><?php forum_posts(); ?></td> 57 70 </tr> 58 <?php endforeach; ?>71 <?php endforeach; // forums ?> 59 72 </table> 73 <?php endif; // forums ?> 60 74 75 <?php endforeach; // catagories ?> 76 <?php endif; // catagories ?> 77 61 78 <?php if ( $bb_current_user->ID ) : ?> 62 79 <div id="viewdiv"> 63 80 <h2><?php _e('Views'); ?></h2> -
bb-templates/topic.php
old new 1 1 <?php bb_get_header(); ?> 2 2 3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » <a href="<?php forum_link(); ?>"><?php forum_name(); ?></a></h3> 3 <h3 class="bbcrumb"> 4 <a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » 5 <?php if ( $category ): ?> 6 <a href="<?php category_link(); ?>"><?php category_name(); ?></a> » 7 <?php endif; ?> 8 <a href="<?php forum_link(); ?>"><?php forum_name(); ?></a> 9 </h3> 4 10 <div class="infobox"> 5 11 <h2<?php topic_class( 'topictitle' ); ?>><?php topic_title(); ?></h2> <span id="topic_posts">(<?php topic_posts_link(); ?>)</span> 6 12 -
bb-templates/forum.php
old new 1 1 <?php bb_get_header(); ?> 2 2 3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » <?php forum_name(); ?></h3> 3 <h3 class="bbcrumb"> 4 <a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » 5 <?php if ( $category ): ?> 6 <a href="<?php category_link(); ?>"><?php category_name(); ?></a> » 7 <?php endif; ?> 8 <?php forum_name(); ?> 9 </h3> 4 10 5 11 <?php if ( $topics || $stickies ) : ?> 6 12 -
bb-includes/capabilities.php
old new 37 37 'edit_users' => true, 38 38 'manage_tags' => true, // Rename, Merge, Destroy 39 39 'edit_others_favorites' => true, 40 'manage_categories' => true, 41 'delete_categories' => true, 40 42 'manage_forums' => true, // Add/Rename forum 41 43 'delete_forums' => true, // Delete forum 42 44 'manage_topics' => true, // Delete/Close/Stick … … 71 73 'edit_users' => true, //+ 72 74 'manage_tags' => true, //+ 73 75 'edit_others_favorites' => true, //+ 76 'manage_categories' => true, 77 'delete_categories' => true, 74 78 'manage_forums' => true, //+ 75 79 'delete_forums' => true, //+ 76 80 'manage_topics' => true, … … 404 408 case 'write_post': 405 409 $caps[] = 'write_posts'; 406 410 break; 411 case 'delete_category': 412 $caps[] = 'delete_categories'; 413 break; 407 414 case 'delete_forum': 408 415 $caps[] = 'delete_forums'; 409 416 break; -
bb-includes/cache.php
old new 137 137 return $posts; 138 138 } 139 139 140 function get_categories() { 141 global $bbdb; 142 143 $normal = true; 144 if ( '' != $where = apply_filters('get_categories_where', '') ) 145 $normal = false; 146 147 if ( $this->use_cache && $normal && file_exists(BBPATH . 'bb-cache/bb_categories') ) 148 return $this->read_cache(BBPATH . 'bb-cache/bb_categories'); 149 150 $categories = $bbdb->get_results("SELECT * FROM $bbdb->categories $where ORDER BY category_order"); 151 if ( $this->use_cache && $normal && $categories ) 152 $this->write_cache(BBPATH . 'bb-cache/bb_categories', $categories); 153 return $categories; 154 } 155 156 function get_category( $category_id ) { 157 global $bbdb; 158 $category_id = (int) $category_id; 159 160 $normal = true; 161 if ( '' != $where = apply_filters('get_category_where', '') ) 162 $normal = false; 163 164 if ( $this->use_cache && $normal && file_exists(BBPATH . 'bb-cache/bb_category-' . $category_id) ) 165 return $this->read_cache(BBPATH . 'bb-cache/bb_category-' . $category_id); 166 167 $category = $bbdb->get_row("SELECT * FROM $bbdb->categories WHERE category_id = $category_id $where"); 168 if ( $this->use_cache && $normal && $category ) 169 $this->write_cache(BBPATH . 'bb-cache/bb_category-' . $category_id, $category); 170 return $category; 171 } 172 140 173 function get_forums() { 141 174 global $bbdb; 142 175 143 176 $normal = true; 177 if ( '' != $join = apply_filters('get_forums_join', '') ) 178 $normal = false; 144 179 if ( '' != $where = apply_filters('get_forums_where', '') ) 145 180 $normal = false; 181 if ( 'ORDER BY forum_order' != $orderby = apply_filters('get_forums_orderby', 'ORDER BY forum_order')) 182 $normal = false; 146 183 147 184 if ( $this->use_cache && $normal && file_exists(BBPATH . 'bb-cache/bb_forums') ) 148 185 return $this->read_cache(BBPATH . 'bb-cache/bb_forums'); 149 186 150 $forums = $bbdb->get_results("SELECT * FROM $bbdb->forums $ where ORDER BY forum_order");187 $forums = $bbdb->get_results("SELECT * FROM $bbdb->forums $join $where $orderby"); 151 188 if ( $this->use_cache && $normal && $forums ) 152 189 $this->write_cache(BBPATH . 'bb-cache/bb_forums', $forums); 153 190 return $forums; -
bb-includes/functions.php
old new 1 1 <?php 2 2 3 function get_categories() { 4 global $bb_cache; 5 return apply_filters('get_categories',$bb_cache->get_categories()); 6 } 7 8 function get_category( $id ) { 9 global $bb_cache; 10 return $bb_cache->get_category( $id ); 11 } 12 3 13 function get_forums() { 4 14 global $bb_cache; 5 15 return apply_filters('get_forums',$bb_cache->get_forums()); … … 82 92 else return false; 83 93 } 84 94 95 function get_latest_category_topics( $category = 0, $page = 1, $exclude = '') { 96 global $bbdb, $bb_last_countable_query; 97 $category = (int) $category; 98 $page = (int) $page; 99 $where = 'WHERE topic_status = 0'; 100 if ( $category ) 101 $where .= " AND category_id = $category "; 102 if ( !empty( $exclude ) ) 103 $where .= " AND category_id NOT IN ('$exclude') "; 104 if ( is_category() || is_view() ) 105 $where .= " AND topic_sticky = 0 "; 106 $limit = bb_get_option('page_topics'); 107 $where = apply_filters('get_latest_category_topics_where', $where); 108 if ( 1 < $page ) 109 $limit = ($limit * ($page - 1)) . ", $limit"; 110 $bb_last_countable_query = "SELECT * FROM $bbdb->topics LEFT JOIN $bbdb->forums ON " . $bbdb->forums . ".forum_id = " . $bbdb->topics . ".forum_id $where ORDER BY topic_time DESC LIMIT $limit"; 111 if ( $topics = $bbdb->get_results($bb_last_countable_query) ) 112 return bb_append_meta( $topics, 'topic' ); 113 else 114 return false; 115 } 116 117 function get_sticky_category_topics( $category = 0, $display = 1 ) { 118 global $bbdb, $bb_last_countable_query; 119 if ( 1 != $display ) 120 return false; 121 $category = (int) $category; 122 $where = 'WHERE topic_sticky <> 0 AND topic_status = 0'; 123 if ( $category ) 124 $where .= " AND category_id = $category "; 125 $where = apply_filters('get_sticky_category_topics_where', $where); 126 $bb_last_countable_query = "SELECT * FROM $bbdb->topics LEFT JOIN $bbdb->forums ON " . $bbdb->forums . ".forum_id = " . $bbdb->topics . ".forum_id $where ORDER BY topic_time DESC"; 127 if ( $stickies = $bbdb->get_results($bb_last_countable_query) ) 128 return bb_append_meta( $stickies, 'topic' ); 129 else return false; 130 } 131 85 132 function no_replies( $where ) { 86 133 return $where . ' AND topic_posts = 1 '; 87 134 } … … 98 145 return; 99 146 } 100 147 148 function bb_move_category_forums( $from_category_id, $to_category_id ) { 149 global $bb_cache, $bbdb; 150 151 $from_category_id = (int) $from_category_id ; 152 $to_category_id = (int) $to_category_id; 153 154 add_filter('get_category_where', 'no_where'); // Just in case 155 156 $from_category = get_category( $from_category_id ); 157 if ( !$to_category = get_category( $to_category_id ) ) 158 return false; 159 160 $bb_cache->flush_many( 'category', $from_category_id ); 161 $bb_cache->flush_many( 'category', $to_category_id ); 162 163 $forums = $to_category->forums + ( $from_category ? $from_category->forums : 0 ); 164 165 $bbdb->query("UPDATE $bbdb->categories SET forums = '$forums' WHERE category_id = '$to_category_id'"); 166 $bbdb->query("UPDATE $bbdb->categories SET forums = 0 WHERE category_id = '$from_category_id'"); 167 $forum_ids = $bbdb->get_col("SELECT forum_id FROM $bbdb->forums WHERE category_id = '$from_category_id'"); 168 $return = $bbdb->query("UPDATE $bbdb->forums SET category_id = '$to_category_id' WHERE category_id = '$from_category_id'"); 169 if ( $forum_ids ) 170 foreach ( $forum_ids as $forum_id ) { 171 $bb_cache->flush_one( 'forum', $forum_id ); 172 } 173 $bb_cache->flush_one( 'category', $to_category_id ); 174 $bb_cache->flush_many( 'category', $from_category_id ); 175 return $return; 176 } 177 101 178 function bb_move_forum_topics( $from_forum_id, $to_forum_id ) { 102 179 global $bb_cache, $bbdb; 103 180 … … 154 231 return $bbdb->get_results("SELECT * FROM $bbdb->posts $where ORDER BY post_time DESC LIMIT $limit"); 155 232 } 156 233 234 function get_latest_category_posts( $category_id, $limit = 0, $page = 1 ) { 235 global $bbdb; 236 $limit = (int) $limit; 237 $category_id = (int) $category_id; 238 if ( !$limit ) 239 $limit = bb_get_option( 'page_topics' ); 240 if ( 1 < $page ) 241 $limit = ($limit * ($page - 1)) . ", $limit"; 242 $where = apply_filters('get_latest_category_posts_where', "WHERE `" . $bbdb->forums . "`.category_id = '$category_id' AND post_status = 0"); 243 return $bbdb->get_results("SELECT * FROM $bbdb->posts LEFT JOIN $bbdb->forums ON `" . $bbdb->forums . "`.forum_id = `" . $bbdb->posts . "`.forum_id $where ORDER BY post_time DESC LIMIT $limit"); 244 } 245 157 246 function get_user_favorites( $user_id, $list = false ) { 158 247 global $bbdb, $page; 159 248 $user = bb_get_user( $user_id ); … … 705 794 706 795 707 796 708 function bb_new_ forum( $name, $desc, $order = 0 ) {797 function bb_new_category( $name, $desc, $order = 0 ) { 709 798 global $bbdb, $bb_cache, $bb_current_user; 799 if ( !bb_current_user_can('manage_categories') ) 800 return false; 801 if ( strlen($name) < 1 ) 802 return false; 803 $bbdb->query("INSERT INTO $bbdb->categories (category_name, category_desc, category_order) VALUES ('$name', '$desc', '$order')"); 804 $bb_cache->flush_one( 'categories' ); 805 return $bbdb->insert_id; 806 } 807 808 function bb_update_category( $category_id, $name, $desc, $order = 0 ) { 809 global $bbdb, $bb_cache, $bb_current_user; 810 if ( !bb_current_user_can('manage_categories') ) 811 return false; 812 if ( !$category_id = (int) $category_id ) 813 return false; 814 $order = (int) $order; 815 if ( strlen($name) < 1 ) 816 return false; 817 $bb_cache->flush_many( 'category', $category_id ); 818 return $bbdb->query("UPDATE $bbdb->categories SET category_name = '$name', category_desc = '$desc', category_order = '$order' WHERE category_id = $category_id"); 819 } 820 821 // When you delete a category, the underlying forums are given a category_id of 0 822 function bb_delete_category( $category_id ) { 823 global $bbdb, $bb_cache; 824 if ( !bb_current_user_can( 'delete_category', $category_id ) ) 825 return false; 826 if ( !$category_id = (int) $category_id ) 827 return false; 828 829 $category = get_forum( $category_id ); 830 831 if ( $forum_ids = $bbdb->get_col("SELECT forum_id FROM $bbdb->forums WHERE category_id = '$category_id'") ) { 832 $_forum_ids = join(',', $forum_ids); 833 $bbdb->query("UPDATE $bbdb->forums SET category_id = 0 WHERE forum_id IN ($_forum_ids)"); 834 } 835 836 $return = $bbdb->query("DELETE FROM $bbdb->categories WHERE category_id = $category_id"); 837 838 if ( $forum_ids ) 839 foreach ( $forum_ids as $forum_id ) { 840 $bb_cache->flush_one( 'forum', $forum_id ); 841 } 842 843 $bb_cache->flush_one( 'categories' ); 844 return $return; 845 } 846 847 function bb_new_forum( $name, $desc, $order = 0, $category_id = 0 ) { 848 global $bbdb, $bb_cache, $bb_current_user; 710 849 if ( !bb_current_user_can('manage_forums') ) 711 850 return false; 712 851 if ( strlen($name) < 1 ) 713 852 return false; 714 $bbdb->query("INSERT INTO $bbdb->forums (forum_name, forum_desc, forum_order) VALUES ('$name', '$desc', '$order')"); 853 $bbdb->query("INSERT INTO $bbdb->forums (category_id, forum_name, forum_desc, forum_order) VALUES ($category_id, '$name', '$desc', '$order')"); 854 $bbdb->query("UPDATE $bbdb->categories SET forums = forums + 1 WHERE category_id = $category_id"); 715 855 $bb_cache->flush_one( 'forums' ); 856 $bb_cache->flush_many( 'category', $category_id ); 716 857 return $bbdb->insert_id; 717 858 } 718 859 719 function bb_update_forum( $forum_id, $name, $desc, $order = 0 ) {860 function bb_update_forum( $forum_id, $name, $desc, $order = 0, $category_id = 0 ) { 720 861 global $bbdb, $bb_cache, $bb_current_user; 721 862 if ( !bb_current_user_can('manage_forums') ) 722 863 return false; … … 725 866 $order = (int) $order; 726 867 if ( strlen($name) < 1 ) 727 868 return false; 869 870 $forum = get_forum( $forum_id ); 871 872 $return = $bbdb->query("UPDATE $bbdb->forums SET category_id = $category_id, forum_name = '$name', forum_desc = '$desc', forum_order = '$order' WHERE forum_id = $forum_id"); 873 $bbdb->query("UPDATE $bbdb->categories SET forums = forums + 1 WHERE category_id = $category_id"); 874 $bbdb->query("UPDATE $bbdb->categories SET forums = forums - 1 WHERE category_id = $forum->category_id"); 728 875 $bb_cache->flush_many( 'forum', $forum_id ); 729 return $bbdb->query("UPDATE $bbdb->forums SET forum_name = '$name', forum_desc = '$desc', forum_order = '$order' WHERE forum_id = $forum_id"); 876 $bb_cache->flush_one( 'categories' ); 877 return $return; 730 878 } 731 879 732 880 // When you delete a forum, you delete *everything* … … 737 885 if ( !$forum_id = (int) $forum_id ) 738 886 return false; 739 887 888 $forum = get_forum( $forum_id ); 889 740 890 if ( $topic_ids = $bbdb->get_col("SELECT topic_id FROM $bbdb->topics WHERE forum_id = '$forum_id'") ) { 741 891 $_topic_ids = join(',', $topic_ids); 742 892 $bbdb->query("DELETE FROM $bbdb->posts WHERE topic_id IN ($_topic_ids) AND topic_id != 0"); … … 745 895 } 746 896 747 897 $return = $bbdb->query("DELETE FROM $bbdb->forums WHERE forum_id = $forum_id"); 898 $bbdb->query("UPDATE $bbdb->categories SET forums = forums - 1 WHERE category_id = $forum->category_id"); 748 899 749 900 if ( $topic_ids ) 750 901 foreach ( $topic_ids as $topic_id ) { … … 753 904 } 754 905 755 906 $bb_cache->flush_many( 'forum', $forum_id ); 907 $bb_cache->flush_one( 'categories' ); 756 908 return $return; 757 909 } 758 910 … … 1429 1581 1430 1582 do_action( 'pre_permalink', $permalink ); 1431 1583 1432 if ( is_forum() ) { 1584 if ( is_category() ) { 1585 global $category_id; 1586 $category_id = $permalink; 1587 $permalink = get_category_link( $permalink, $page ); 1588 } elseif ( is_forum() ) { 1433 1589 global $forum_id; 1434 1590 $forum_id = $permalink; 1435 1591 $permalink = get_forum_link( $permalink, $page ); -
bb-includes/bozo.php
old new 279 279 280 280 add_action( 'pre_permalink', 'bozo_pre_permalink' ); 281 281 add_action( 'bb_index.php_pre_db', 'bozo_latest_filter' ); 282 add_action( 'bb_category.php_pre_db', 'bozo_latest_filter' ); 282 283 add_action( 'bb_forum.php_pre_db', 'bozo_latest_filter' ); 283 284 add_action( 'bb_topic.php_pre_db', 'bozo_topic_db_filter' ); 284 285 add_action( 'bb_profile.php_pre_db', 'bozo_profile_db_filter' ); -
bb-includes/template-functions.php
old new 183 183 case 'index.php' : 184 184 return 'front-page'; 185 185 break; 186 case 'category.php' : 187 return 'category-page'; 188 break; 186 189 case 'forum.php' : 187 190 return 'forum-page'; 188 191 break; … … 226 229 return false; 227 230 } 228 231 232 function is_category() { 233 if ( 'category-page' == get_bb_location() ) 234 return true; 235 else 236 return false; 237 } 238 229 239 function is_forum() { 230 240 if ( 'forum-page' == get_bb_location() ) 231 241 return true; … … 300 310 $title = get_topic_title(). ' « '; 301 311 if ( is_forum() ) 302 312 $title = get_forum_name() . ' « '; 313 if ( is_category() ) 314 $title = get_category_name() . ' « '; 303 315 if ( is_tag() ) 304 316 $title = wp_specialchars( get_tag_name() ). ' « ' . __('Tags') . ' « '; 305 317 if ( is_bb_profile() ) … … 319 331 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Tag') . ': ' . wp_specialchars( get_tag_name(), 1 ) . '" href="' . get_tag_rss_link() . '" />'; 320 332 elseif ( is_forum() ) 321 333 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Forum') . ': ' . wp_specialchars( get_forum_name(), 1) . '" href="' . get_forum_rss_link() . '" />'; 334 elseif ( is_category() ) 335 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Category') . ': ' . wp_specialchars( get_category_name(), 1) . '" href="' . get_category_rss_link() . '" />'; 322 336 elseif ( is_front() ) 323 337 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Recent Posts') . '" href="' . get_recent_rss_link() . '" />'; 324 338 echo apply_filters('bb_feed_head', $feed_link); … … 332 346 return apply_filters( 'get_recent_rss_link', $link ); 333 347 } 334 348 349 // CATEGORIES 350 351 function get_forums_where_in_category_filter() { 352 global $category; 353 if ($category->category_id) 354 return 'WHERE category_id = ' . $category->category_id; 355 else return NULL; 356 } 357 358 function get_forums_join_categories_filter() { 359 global $bbdb; 360 return 'LEFT JOIN `' . $bbdb->categories . '` ON `' . $bbdb->categories . '`.`category_id` = `' . $bbdb->forums . '`.`category_id`'; 361 } 362 363 function get_forums_orderby_category_order_filter() { 364 return 'ORDER BY `category_order`, `forum_order`'; 365 } 366 367 function category_id() { 368 echo apply_filters( 'category_id', get_category_id() ); 369 } 370 371 function get_category_id() { 372 global $category; 373 return $category->category_id; 374 } 375 376 function category_link( $category_id = 0, $page = 1 ) { 377 echo apply_filters('category_link', get_category_link( $category_id, $page ), $category_id ); 378 } 379 380 function get_category_link( $category_id = 0, $page = 1 ) { 381 global $category; 382 383 if ( $category_id ) 384 $category = get_category( $category_id ); 385 if ( bb_get_option( 'mod_rewrite' ) ) 386 $link = bb_get_option( 'uri' ) . "category/$category->category_id" . ( 1 < $page ? "/page/$page" : '' ); 387 else { 388 $args = array(); 389 $link = bb_get_option( 'uri' ) . 'category.php'; 390 $args['id'] = $category->category_id; 391 $args['page'] = 1 < $page ? $page : ''; 392 $link = add_query_arg( $args, $link ); 393 } 394 395 return apply_filters( 'get_category_link', $link, $category->category_id ); 396 } 397 398 function category_name( $category_id = 0 ) { 399 echo apply_filters( 'category_name', get_category_name( $category_id ), $category_id ); 400 } 401 402 function get_category_name( $category_id = 0 ) { 403 global $category; 404 if ( $category_id ) 405 $category = get_category( $category_id ); 406 return apply_filters( 'get_category_name', $category->category_name, $forum->category_id ); 407 } 408 409 function category_description( $category_id = 0 ) { 410 echo apply_filters( 'category_description', get_category_description( $category_id ), $category_id ); 411 } 412 413 function get_category_description( $category_id = 0 ) { 414 global $category; 415 if ( $category_id ) 416 $category = get_forum( $category_id ); 417 return apply_filters( 'get_category_description', $category->category_desc, $category->category_id ); 418 } 419 420 function category_forums( $category_id = 0 ) { 421 echo apply_filters( 'category_forums', get_category_forums( $category_id ), $category_id ); 422 } 423 424 function get_category_forums( $category_id = 0 ) { 425 global $category; 426 if ( $category_id ) 427 $category = get_category( $category_id ); 428 return apply_filters( 'get_category_forums', $category->forums, $category->category_id ); 429 } 430 431 function category_rss_link( $category_id = 0 ) { 432 echo apply_filters('category_rss_link', get_category_rss_link( $category_id ) ); 433 } 434 435 function get_category_rss_link( $category_id = 0 ) { 436 global $category; 437 438 if ( $category_id ) 439 $category = get_category( $category_id ); 440 441 if ( bb_get_option('mod_rewrite') ) 442 $link = bb_get_option('uri') . "rss/category/$category->category_id"; 443 else 444 $link = bb_get_option('uri') . "rss.php?category=$category->category_id"; 445 446 return apply_filters( 'get_category_rss_link', $link, $category_id ); 447 } 448 335 449 // FORUMS 336 450 337 451 function forum_link( $forum_id = 0, $page = 1 ) { … … 760 874 761 875 if ( is_forum() || is_tag() ) 762 876 $url = '#postform'; 763 elseif ( is_front() )877 elseif ( is_front() || is_category() ) 764 878 $url = add_query_arg( 'new', '1', bb_get_option( 'uri' ) ); 765 879 if ( !bb_is_user_logged_in() ) 766 880 $url = add_query_arg( 're', urlencode($url), bb_get_option( 'uri' ) . 'bb-login.php' ); … … 1333 1447 1334 1448 function forum_dropdown() { 1335 1449 global $forum_id; 1336 $ forums = get_forums();1450 $categories = get_categories(); 1337 1451 echo '<select name="forum_id" id="forum_id" tabindex="5">'; 1338 1339 foreach ( $forums as $forum ) : 1340 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1341 echo "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1342 endforeach; 1452 if ($categories) : 1453 global $category; 1454 foreach ( $categories as $category ) : 1455 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 1456 $forums = get_forums(); 1457 if ( $forums ) : 1458 echo "<optgroup label='$category->category_name'>"; 1459 foreach ( $forums as $forum ) : 1460 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1461 echo "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1462 endforeach; 1463 echo "</optgroup>"; 1464 endif; 1465 endforeach; 1466 else : 1467 $forums = get_forums(); 1468 foreach ( $forums as $forum ) : 1469 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1470 echo "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1471 endforeach; 1472 endif; 1343 1473 echo '</select>'; 1344 1474 } 1345 1475 -
bb-includes/db.php
old new 17 17 var $queries; 18 18 19 19 // Our tables 20 var $categories; 20 21 var $forums; 21 22 var $posts; 22 23 var $topics; -
index.php
old new 6 6 do_action( 'bb_index.php_pre_db', '' ); 7 7 8 8 if ( isset($_GET['new']) && '1' == $_GET['new'] ) : 9 $categories = false; 9 10 $forums = false; 10 11 elseif ( !$bb_db_override ) : 12 $categories = get_categories(); // Comment to hide categories 11 13 $forums = get_forums(); // Comment to hide forums 12 14 $topics = get_latest_topics(); 13 15 $super_stickies = get_sticky_topics(); 16 17 if ( $forums && !$categories ) : 18 $categories = array( 19 0 => new stdClass() 20 ); 21 $categories[0]->category_id = 0; 22 $categories[0]->category_name = __('Forums'); 23 endif; 14 24 endif; 15 25 16 26 do_action( 'bb_index.php', '' ); -
rss.php
old new 22 22 elseif ( 'forum' == get_path() ) 23 23 $forum_id = (int) get_path(2); 24 24 25 elseif ( isset($_GET['category']) ) 26 $category_id = (int) $_GET['category']; 27 elseif ( 'category' == get_path() ) 28 $category_id = (int) get_path(2); 29 25 30 $bb_db_override = false; 26 31 do_action( 'bb_rss.php_pre_db', '' ); 27 32 … … 48 53 if ( !$posts = get_latest_forum_posts( $forum_id ) ) 49 54 die(); 50 55 $title = wp_specialchars( bb_get_option( 'name' ) ) . ' ' . __('Forum') . ': ' . get_forum_name( $forum_id ); 56 } elseif ( isset($category_id) ) { 57 if ( !$posts = get_latest_category_posts( $category_id ) ) 58 die(); 59 $title = wp_specialchars( bb_get_option( 'name' ) ) . ' ' . __('Category') . ': ' . get_category_name( $category_id ); 51 60 } else { 52 61 if ( !$posts = get_latest_posts( 35 ) ) 53 62 die(); -
topic.php
old new 20 20 if ( !$bb_db_override ) : 21 21 $posts = get_thread( $topic_id, $page ); 22 22 $forum = get_forum ( $topic->forum_id ); 23 $category = get_category( $forum->category_id ); 23 24 24 25 $tags = get_topic_tags ( $topic_id ); 25 26 if ( $bb_current_user && $tags ) { -
bb-settings.php
old new 60 60 require( BBPATH . BBINC . '/db.php'); 61 61 } 62 62 63 $bbdb->categories = $bb_table_prefix . 'categories'; 63 64 $bbdb->forums = $bb_table_prefix . 'forums'; 64 65 $bbdb->posts = $bb_table_prefix . 'posts'; 65 66 $bbdb->topics = $bb_table_prefix . 'topics'; -
bb-admin/bb-do-counts.php
old new 70 70 echo "\n\t</li>\n"; 71 71 endif; 72 72 73 if ( isset($_POST['categories']) && 1 == $_POST['categories'] ): 74 echo "\t<li>\n"; 75 if ( $categories = (array) $bbdb->get_col("SELECT category_id, COUNT(forum_id) FROM $bbdb->forums GROUP BY category_id") ) : 76 echo "\t\t" . __('Counting category forums...') . "<br />\n"; 77 $counts = (array) $bbdb->get_col('', 1); 78 foreach ($categories as $t => $i) 79 $bbdb->query("UPDATE $bbdb->categories SET forums = '{$counts[$t]}' WHERE category_id = $i"); 80 unset($topics, $t, $i, $counts); 81 endif; 82 echo "\t\t" . __('Done counting category forums.'); 83 echo "\n\t</li>\n"; 84 endif; 85 73 86 if ( isset($_POST['topics-replied']) && 1 == $_POST['topics-replied'] ) : 74 87 echo "\t<li>\n"; 75 88 if ( $users = (array) $bbdb->get_col("SELECT ID FROM $bbdb->users") ) : -
bb-admin/content-forums.php
old new 1 1 <?php 2 2 require_once('admin.php'); 3 3 4 add_filter( 'get_forums_join', 'get_forums_join_categories_filter', 1 ); 5 add_filter( 'get_forums_orderby', 'get_forums_orderby_category_order_filter', 1 ); 4 6 $forums = get_forums(); 5 7 $forums_count = $forums ? count($forums) : 0; 6 8 … … 12 14 } 13 15 14 16 bb_get_admin_header(); 17 18 $categories = get_categories(); 15 19 ?> 16 20 17 21 <h2><?php _e('Forum Management'); ?></h2> … … 79 83 <tr><th scope="row"><?php _e('Position:'); ?></th> 80 84 <td><input type="text" name="forum-order" id="forum-order" tabindex="12" maxlength="10" /></td> 81 85 </tr> 86 <?php if ($categories) : ?> 87 <tr><th scope="row"><?php _e('Category:'); ?></th> 88 <td> 89 <select name="forum-category" tabindex="<?php echo $t++; ?>"> 90 <?php foreach ( $categories as $category ) : ?> 91 <option value="<?php echo $category->category_id; ?>"><?php category_name(); ?></option> 92 <?php endforeach; ?> 93 </select> 94 </td> 95 </tr> 96 <?php endif; ?> 82 97 </table> 83 98 <p class="submit alignleft"><input name="Submit" type="submit" value="<?php _e('Add Forum'); ?>" tabindex="13" /><input type="hidden" name="action" value="add" /></p> 84 99 </fieldset> … … 92 107 <tr><th><?php _e('Name'); ?></th> 93 108 <th><?php _e('Description'); ?></th> 94 109 <th><?php _e('Position'); ?></th> 110 <?php if ($categories) : ?> 111 <th><?php _e('Category'); ?></th> 112 <?php endif; ?> 95 113 <?php if ( bb_current_user_can( 'delete_forums' ) && 1 < $forums_count ) : ?> 96 114 <th><?php _e('Action'); ?></th> 97 115 <?php endif; ?> … … 100 118 <tr><td><input type="text" name="name-<?php forum_id(); ?>" value="<?php echo wp_specialchars( get_forum_name(), 1 ); ?>" tabindex="<?php echo $t++; ?>" /></td> 101 119 <td><input type="text" name="desc-<?php forum_id(); ?>" value="<?php echo wp_specialchars( get_forum_description(), 1 ); ?>" tabindex="<?php echo $t++; ?>" /></td> 102 120 <td><input type="text" name="order-<?php forum_id(); ?>" value="<?php echo $forum->forum_order; ?>" maxlength="10" tabindex="<?php echo $t++; ?>" /></td> 121 <?php if ($categories) : ?> 122 <td> 123 <select name="category-<?php forum_id(); ?>" tabindex="<?php echo $t++; ?>"> 124 <?php if ( !$forum->category_id ) : ?> 125 <option value=""><?php _e('No category!!!'); ?></option> 126 <?php endif; ?> 127 <?php foreach ( $categories as $category ) : ?> 128 <?php 129 if ($forum->category_id == $category->category_id) { 130 $category_selected = ' selected="selected"'; 131 } else 132 $category_selected = ''; 133 ?> 134 <option value="<?php echo $category->category_id; ?>"<?php echo $category_selected; ?>><?php category_name(); ?></option> 135 <?php endforeach; ?> 136 </select> 137 </td> 138 <?php endif; ?> 103 139 <?php if ( bb_current_user_can( 'delete_forums' ) && 1 < $forums_count ) : ?> 104 140 <td><?php if ( bb_current_user_can( 'delete_forum', $forum->forum_id ) ) : ?><a class="delete" href="<?php bb_option('uri'); ?>bb-admin/content-forums.php?action=delete&id=<?php forum_id();?>"><?php _e('Delete'); ?></a><?php endif; ?></td> 105 141 <?php endif; ?> -
bb-admin/admin-functions.php
old new 27 27 $bb_submenu['content.php'][5] = array(__('Topics'), 'moderate', 'content.php'); 28 28 $bb_submenu['content.php'][10] = array(__('Posts'), 'moderate', 'content-posts.php'); 29 29 $bb_submenu['content.php'][15] = array(__('Forums'), 'moderate', 'content-forums.php'); 30 $bb_submenu['content.php'][20] = array(__('Categories'), 'moderate', 'content-categories.php'); 30 31 31 32 $bb_submenu['site.php'][5] = array(__('Recount'), 'recount', 'site.php'); 32 33 … … 160 161 $recount_list[25] = array('topic-tag-count', __('Count tags for every topic')); 161 162 $recount_list[30] = array('tags-tag-count', __('Count topics for every tag')); 162 163 $recount_list[35] = array('zap-tags', __('DELETE tags with no topics. Only functions if the above checked')); 164 $recount_list[40] = array('categories', __('Count forums in every category')); 163 165 do_action('bb_recount_list'); 164 166 ksort($recount_list); 165 167 return $recount_list; -
bb-admin/bb-forum.php
old new 19 19 $forum_name = $_POST['forum']; 20 20 $forum_desc = $_POST['forum-desc']; 21 21 $forum_order = ( '' === $_POST['forum-order'] ) ? 0 : (int) $_POST['forum-order']; 22 if ( false !== bb_new_forum( $forum_name, $forum_desc, $forum_order ) ) : 22 $forum_category = $_POST['forum-category']; 23 if ( false !== bb_new_forum( $forum_name, $forum_desc, $forum_order, $forum_category ) ) : 23 24 wp_redirect( $sent_from ); 24 25 exit; 25 26 else : … … 33 34 bb_die(__('No forums to update!')); 34 35 foreach ( $forums as $forum ) : 35 36 if ( isset($_POST['name-' . $forum->forum_id]) && '' !== $_POST['name-' . $forum->forum_id] ) 36 bb_update_forum( $forum->forum_id, $_POST['name-' . $forum->forum_id], $_POST['desc-' . $forum->forum_id], $_POST['order-' . $forum->forum_id] );37 bb_update_forum( $forum->forum_id, $_POST['name-' . $forum->forum_id], $_POST['desc-' . $forum->forum_id], $_POST['order-' . $forum->forum_id], $_POST['category-' . $forum->forum_id]); 37 38 endforeach; 38 39 wp_redirect( $sent_from ); 39 40 exit; -
bb-admin/upgrade-schema.php
old new 2 2 require_once('../bb-load.php'); 3 3 set_time_limit(600); 4 4 5 $bb_queries = "CREATE TABLE $bbdb->forums ( 5 $bb_queries = "CREATE TABLE $bbdb->categories ( 6 category_id int(10) NOT NULL auto_increment, 7 category_name varchar(150) NOT NULL default '', 8 category_desc text NOT NULL, 9 category_order int(10) NOT NULL default '0', 10 forums bigint(20) NOT NULL default '0', 11 PRIMARY KEY (category_id) 12 ); 13 CREATE TABLE $bbdb->forums ( 6 14 forum_id int(10) NOT NULL auto_increment, 15 category_id int(10) NOT NULL default '0', 7 16 forum_name varchar(150) NOT NULL default '', 8 17 forum_desc text NOT NULL, 9 18 forum_order int(10) NOT NULL default '0', 10 19 topics bigint(20) NOT NULL default '0', 11 20 posts bigint(20) NOT NULL default '0', 12 21 PRIMARY KEY (forum_id) 22 KEY category_id (category_id), 13 23 ); 14 24 CREATE TABLE $bbdb->posts ( 15 25 post_id bigint(20) NOT NULL auto_increment, -
forum.php
old new 13 13 do_action( 'bb_forum.php_pre_db', $forum_id ); 14 14 15 15 if ( !$bb_db_override ) : 16 $category = get_category( $forum->category_id ); 16 17 $topics = get_latest_topics( $forum_id, $page ); 17 18 $stickies = get_sticky_topics( $forum_id, $page ); 18 19 endif;