Ticket #520: categories-build670.patch
| File categories-build670.patch, 48.6 kB (added by sambauers, 2 years ago) |
|---|
-
bb-templates/kakumei/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; … … 180 180 181 181 .sticky { background: #a1d29a; } 182 182 183 tr.category { 184 background-color: #4fad4f; 185 color: #ffffff; 186 } 187 188 tr.category td { 189 border-top: 1px solid #91d691; 190 border-bottom: 1px solid #176e17; 191 } 192 193 .category:hover { background-color: #339a33 !important; } 194 195 tr.category a { color: #cdf6cd; } 196 197 tr.category h3 { display: inline; } 198 199 tr.category p { margin: 0.3em 0 0 0; } 200 183 201 /* Topic Page 184 202 =================================== */ 185 203 -
bb-templates/kakumei/category.php
old new 1 <?php bb_get_header(); ?> 2 3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » <?php category_name(); ?></h3> 4 5 <?php if ( $topics || $stickies ) : ?> 6 7 <h2><?php _e('Latest Discussions'); ?></h2> 8 9 <table id="latest"> 10 <tr> 11 <th><?php _e('Topic'); ?> — <?php new_topic(); ?></th> 12 <th><?php _e('Posts'); ?></th> 13 <th><?php _e('Last Poster'); ?></th> 14 <th><?php _e('Freshness'); ?></th> 15 </tr> 16 17 <?php if ( $stickies ) : foreach ( $stickies as $topic ) : ?> 18 <tr<?php topic_class(); ?>> 19 <td><?php _e('Sticky:'); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big></td> 20 <td class="num"><?php topic_posts(); ?></td> 21 <td class="num"><?php topic_last_poster(); ?></td> 22 <td class="num"><small><?php topic_time(); ?></small></td> 23 </tr> 24 <?php endforeach; endif; ?> 25 26 <?php if ( $topics ) : foreach ( $topics as $topic ) : ?> 27 <tr<?php topic_class(); ?>> 28 <td><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td> 29 <td class="num"><?php topic_posts(); ?></td> 30 <td class="num"><?php topic_last_poster(); ?></td> 31 <td class="num"><small><?php topic_time(); ?></small></td> 32 </tr> 33 <?php endforeach; endif; ?> 34 </table> 35 36 <?php endif; ?> 37 38 <h2><?php _e('Forums'); ?></h2> 39 40 <?php 41 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 42 $forums = get_forums(); 43 ?> 44 45 <p style="float:right;"><?php category_forums(); ?> <?php echo __ngettext('forum', 'forums', get_category_forums()); ?></p> 46 47 <p><?php category_description(); ?></p> 48 49 <?php if ( $forums ) : ?> 50 51 <table style="clear:both;" id="forumlist"> 52 53 <tr> 54 <th><?php _e('Main Theme'); ?></th> 55 <th><?php _e('Topics'); ?></th> 56 <th><?php _e('Posts'); ?></th> 57 </tr> 58 59 <?php foreach ( $forums as $forum ) : ?> 60 <tr<?php alt_class('forum'); ?>> 61 <td><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a> — <small><?php forum_description(); ?></small></td> 62 <td class="num"><?php forum_topics(); ?></td> 63 <td class="num"><?php forum_posts(); ?></td> 64 </tr> 65 <?php endforeach; // forums ?> 66 </table> 67 <?php endif; // forums ?> 68 69 <p><a href="<?php category_rss_link(); ?>"><?php _e('RSS feed for this category'); ?></a></p> 70 71 <?php bb_get_footer(); ?> -
bb-templates/kakumei/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 6 12 <div id="topic-info"> -
bb-templates/kakumei/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-templates/kakumei/front-page.php
old new 40 40 </table> 41 41 <?php endif; ?> 42 42 43 <?php if ( $categories ) : ?> 44 43 45 <h2><?php _e('Forums'); ?></h2> 46 44 47 <table id="forumlist"> 45 48 46 49 <tr> … … 49 52 <th><?php _e('Posts'); ?></th> 50 53 </tr> 51 54 55 <?php foreach ( $categories as $category ) : ?> 56 57 <?php if ( $category->category_id ) : ?> 58 <?php 59 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 60 $forums = get_forums(); 61 ?> 62 63 <?php if ( $forums ) : ?> 64 <tr class="category"> 65 <td colspan="3"> 66 <h3><a href="<?php category_link(); ?>"><?php category_name(); ?></a></h3> — <?php category_forums(); ?> <?php echo __ngettext('forum', 'forums', get_category_forums()); ?> 67 <?php if ( get_category_description() ) : ?> 68 <p><small><?php category_description(); ?></small></p> 69 <?php endif; ?> 70 </td> 71 </tr> 72 <?php endif; ?> 73 74 <?php endif; ?> 75 76 <?php if ( $forums ) : ?> 52 77 <?php foreach ( $forums as $forum ) : ?> 53 78 <tr<?php alt_class('forum'); ?>> 54 79 <td><a href="<?php forum_link(); ?>"><?php forum_name(); ?></a> — <small><?php forum_description(); ?></small></td> … … 56 81 <td class="num"><?php forum_posts(); ?></td> 57 82 </tr> 58 83 <?php endforeach; ?> 84 <?php elseif ( count($categories) < 2 ) : ?> 85 <tr> 86 <td colspan="3"><?php _e('No forums available.'); ?></td> 87 </tr> 88 <?php endif; ?> 89 90 <?php endforeach; // catagories ?> 91 59 92 </table> 60 93 94 <?php endif; // catagories ?> 95 61 96 <?php if ( $bb_current_user->ID ) : ?> 62 97 <div id="viewdiv"> 63 98 <h2><?php _e('Views'); ?></h2> -
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 'delete_topics' => true, … … 74 76 'edit_users' => true, //+ 75 77 'manage_tags' => true, //+ 76 78 'edit_others_favorites' => true, //+ 79 'manage_categories' => true, 80 'delete_categories' => true, 77 81 'manage_forums' => true, //+ 78 82 'delete_forums' => true, //+ 79 83 'delete_topics' => true, … … 435 439 $caps[] = 'edit_favorites'; 436 440 else $caps[] = 'edit_others_favorites'; 437 441 break; 442 case 'delete_category': 443 $caps[] = 'delete_categories'; 444 break; 438 445 case 'delete_forum': 439 446 $caps[] = 'delete_forums'; 440 447 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 = (array) $bbdb->get_results("SELECT * FROM $bbdb->forums $where ORDER BY forum_order"); 187 $forums = (array) $bbdb->get_results("SELECT * FROM $bbdb->forums $join $where $orderby"); 188 151 189 if ( $this->use_cache && $normal && $forums ) 152 190 $this->write_cache(BBPATH . 'bb-cache/bb_forums', $forums); 153 191 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( $callback = false, $callback_args = false ) { 4 14 global $bb_cache; 5 15 $forums = (array) apply_filters('get_forums',$bb_cache->get_forums()); … … 95 105 else return false; 96 106 } 97 107 108 function get_latest_category_topics( $category = 0, $page = 1, $exclude = '') { 109 global $bbdb, $bb_last_countable_query; 110 $category = (int) $category; 111 $page = (int) $page; 112 $where = 'WHERE topic_status = 0'; 113 if ( $category ) 114 $where .= " AND category_id = $category "; 115 if ( !empty( $exclude ) ) 116 $where .= " AND category_id NOT IN ('$exclude') "; 117 if ( is_category() || is_view() ) 118 $where .= " AND topic_sticky = 0 "; 119 $limit = bb_get_option('page_topics'); 120 $where = apply_filters('get_latest_category_topics_where', $where); 121 if ( 1 < $page ) 122 $limit = ($limit * ($page - 1)) . ", $limit"; 123 $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"; 124 if ( $topics = $bbdb->get_results($bb_last_countable_query) ) 125 return bb_append_meta( $topics, 'topic' ); 126 else 127 return false; 128 } 98 129 130 function get_sticky_category_topics( $category = 0, $display = 1 ) { 131 global $bbdb, $bb_last_countable_query; 132 if ( 1 != $display ) 133 return false; 134 $category = (int) $category; 135 $where = 'WHERE topic_sticky <> 0 AND topic_status = 0'; 136 if ( $category ) 137 $where .= " AND category_id = $category "; 138 $where = apply_filters('get_sticky_category_topics_where', $where); 139 $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"; 140 if ( $stickies = $bbdb->get_results($bb_last_countable_query) ) 141 return bb_append_meta( $stickies, 'topic' ); 142 else return false; 143 } 144 145 99 146 // Globalizes the result. 100 147 function bb_get_first_post( $_topic = false, $author_cache = true ) { 101 148 global $topic, $bb_first_post_cache, $bb_post; … … 229 276 return; 230 277 } 231 278 279 function bb_move_category_forums( $from_category_id, $to_category_id ) { 280 global $bb_cache, $bbdb; 281 282 $from_category_id = (int) $from_category_id ; 283 $to_category_id = (int) $to_category_id; 284 285 add_filter('get_category_where', 'no_where'); // Just in case 286 287 $from_category = get_category( $from_category_id ); 288 if ( !$to_category = get_category( $to_category_id ) ) 289 return false; 290 291 $bb_cache->flush_many( 'category', $from_category_id ); 292 $bb_cache->flush_many( 'category', $to_category_id ); 293 294 $forums = $to_category->forums + ( $from_category ? $from_category->forums : 0 ); 295 296 $bbdb->query("UPDATE $bbdb->categories SET forums = '$forums' WHERE category_id = '$to_category_id'"); 297 $bbdb->query("UPDATE $bbdb->categories SET forums = 0 WHERE category_id = '$from_category_id'"); 298 $forum_ids = $bbdb->get_col("SELECT forum_id FROM $bbdb->forums WHERE category_id = '$from_category_id'"); 299 $return = $bbdb->query("UPDATE $bbdb->forums SET category_id = '$to_category_id' WHERE category_id = '$from_category_id'"); 300 if ( $forum_ids ) 301 foreach ( $forum_ids as $forum_id ) { 302 $bb_cache->flush_one( 'forum', $forum_id ); 303 } 304 $bb_cache->flush_one( 'category', $to_category_id ); 305 $bb_cache->flush_many( 'category', $from_category_id ); 306 return $return; 307 } 308 232 309 function bb_move_forum_topics( $from_forum_id, $to_forum_id ) { 233 310 global $bb_cache, $bbdb; 234 311 … … 285 362 return $bbdb->get_results("SELECT * FROM $bbdb->posts $where ORDER BY post_time DESC LIMIT $limit"); 286 363 } 287 364 365 function get_latest_category_posts( $category_id, $limit = 0, $page = 1 ) { 366 global $bbdb; 367 $limit = (int) $limit; 368 $category_id = (int) $category_id; 369 if ( !$limit ) 370 $limit = bb_get_option( 'page_topics' ); 371 if ( 1 < $page ) 372 $limit = ($limit * ($page - 1)) . ", $limit"; 373 $where = apply_filters('get_latest_category_posts_where', "WHERE `" . $bbdb->forums . "`.category_id = '$category_id' AND post_status = 0"); 374 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"); 375 } 376 288 377 function get_user_favorites( $user_id, $list = false ) { 289 378 global $bbdb, $page; 290 379 $user = bb_get_user( $user_id ); … … 848 937 849 938 850 939 851 function bb_new_ forum( $name, $desc, $order = 0 ) {940 function bb_new_category( $name, $desc, $order = 0 ) { 852 941 global $bbdb, $bb_cache, $bb_current_user; 942 if ( !bb_current_user_can('manage_categories') ) 943 return false; 944 if ( strlen($name) < 1 ) 945 return false; 946 $bbdb->query("INSERT INTO $bbdb->categories (category_name, category_desc, category_order) VALUES ('$name', '$desc', '$order')"); 947 $bb_cache->flush_one( 'categories' ); 948 return $bbdb->insert_id; 949 } 950 951 function bb_update_category( $category_id, $name, $desc, $order = 0 ) { 952 global $bbdb, $bb_cache, $bb_current_user; 953 if ( !bb_current_user_can('manage_categories') ) 954 return false; 955 if ( !$category_id = (int) $category_id ) 956 return false; 957 $order = (int) $order; 958 if ( strlen($name) < 1 ) 959 return false; 960 $bb_cache->flush_many( 'category', $category_id ); 961 return $bbdb->query("UPDATE $bbdb->categories SET category_name = '$name', category_desc = '$desc', category_order = '$order' WHERE category_id = $category_id"); 962 } 963 964 // When you delete a category, the underlying forums are given a category_id of 0 965 function bb_delete_category( $category_id ) { 966 global $bbdb, $bb_cache; 967 if ( !bb_current_user_can( 'delete_category', $category_id ) ) 968 return false; 969 if ( !$category_id = (int) $category_id ) 970 return false; 971 972 $category = get_forum( $category_id ); 973 974 if ( $forum_ids = $bbdb->get_col("SELECT forum_id FROM $bbdb->forums WHERE category_id = '$category_id'") ) { 975 $_forum_ids = join(',', $forum_ids); 976 $bbdb->query("UPDATE $bbdb->forums SET category_id = 0 WHERE forum_id IN ($_forum_ids)"); 977 } 978 979 $return = $bbdb->query("DELETE FROM $bbdb->categories WHERE category_id = $category_id"); 980 981 if ( $forum_ids ) 982 foreach ( $forum_ids as $forum_id ) { 983 $bb_cache->flush_one( 'forum', $forum_id ); 984 } 985 986 $bb_cache->flush_one( 'categories' ); 987 return $return; 988 } 989 990 function bb_new_forum( $name, $desc, $order = 0, $category_id = 0 ) { 991 global $bbdb, $bb_cache, $bb_current_user; 853 992 if ( !bb_current_user_can('manage_forums') ) 854 993 return false; 855 994 if ( strlen($name) < 1 ) 856 995 return false; 857 $bbdb->query("INSERT INTO $bbdb->forums (forum_name, forum_desc, forum_order) VALUES ('$name', '$desc', '$order')"); 996 $bbdb->query("INSERT INTO $bbdb->forums (category_id, forum_name, forum_desc, forum_order) VALUES ($category_id, '$name', '$desc', '$order')"); 997 $bbdb->query("UPDATE $bbdb->categories SET forums = forums + 1 WHERE category_id = $category_id"); 858 998 $bb_cache->flush_one( 'forums' ); 999 $bb_cache->flush_many( 'category', $category_id ); 859 1000 return $bbdb->insert_id; 860 1001 } 861 1002 862 function bb_update_forum( $forum_id, $name, $desc, $order = 0 ) {1003 function bb_update_forum( $forum_id, $name, $desc, $order = 0, $category_id = 0 ) { 863 1004 global $bbdb, $bb_cache, $bb_current_user; 864 1005 if ( !bb_current_user_can('manage_forums') ) 865 1006 return false; … … 868 1009 $order = (int) $order; 869 1010 if ( strlen($name) < 1 ) 870 1011 return false; 1012 1013 $forum = get_forum( $forum_id ); 1014 1015 $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"); 1016 $bbdb->query("UPDATE $bbdb->categories SET forums = forums + 1 WHERE category_id = $category_id"); 1017 $bbdb->query("UPDATE $bbdb->categories SET forums = forums - 1 WHERE category_id = $forum->category_id"); 871 1018 $bb_cache->flush_many( 'forum', $forum_id ); 872 return $bbdb->query("UPDATE $bbdb->forums SET forum_name = '$name', forum_desc = '$desc', forum_order = '$order' WHERE forum_id = $forum_id"); 1019 $bb_cache->flush_one( 'categories' ); 1020 return $return; 873 1021 } 874 1022 875 1023 // When you delete a forum, you delete *everything* … … 880 1028 if ( !$forum_id = (int) $forum_id ) 881 1029 return false; 882 1030 1031 $forum = get_forum( $forum_id ); 1032 883 1033 if ( $topic_ids = $bbdb->get_col("SELECT topic_id FROM $bbdb->topics WHERE forum_id = '$forum_id'") ) { 884 1034 $_topic_ids = join(',', $topic_ids); 885 1035 $bbdb->query("DELETE FROM $bbdb->posts WHERE topic_id IN ($_topic_ids) AND topic_id != 0"); … … 888 1038 } 889 1039 890 1040 $return = $bbdb->query("DELETE FROM $bbdb->forums WHERE forum_id = $forum_id"); 1041 $bbdb->query("UPDATE $bbdb->categories SET forums = forums - 1 WHERE category_id = $forum->category_id"); 891 1042 892 1043 if ( $topic_ids ) 893 1044 foreach ( $topic_ids as $topic_id ) { … … 896 1047 } 897 1048 898 1049 $bb_cache->flush_many( 'forum', $forum_id ); 1050 $bb_cache->flush_one( 'categories' ); 899 1051 return $return; 900 1052 } 901 1053 … … 1578 1730 1579 1731 do_action( 'pre_permalink', $permalink ); 1580 1732 1581 if ( is_forum() ) { 1733 if ( is_category() ) { 1734 global $category_id; 1735 $category_id = $permalink; 1736 $permalink = get_category_link( $permalink, $page ); 1737 } elseif ( is_forum() ) { 1582 1738 global $forum_id; 1583 1739 $forum_id = $permalink; 1584 1740 $permalink = get_forum_link( $permalink, $page ); … … 1854 2010 $trans['update']['forums'] = array(__("Are you sure you want to update your forums?"), false); 1855 2011 $trans['delete']['forums'] = array(__("Are you sure you want to delete that forum?"), false); 1856 2012 2013 $trans['add']['category'] = array(__("Are you sure you want to add this category?"), false); 2014 $trans['update']['categories'] = array(__("Are you sure you want to update your categories?"), false); 2015 $trans['delete']['category'] = array(__("Are you sure you want to delete that category?"), false); 2016 1857 2017 $trans['do']['counts'] = array(__("Are you sure you want to recount these items?"), false); 1858 2018 1859 2019 $trans['switch']['theme'] = array(__("Are you sure you want to switch themes?"), false); -
bb-includes/bozo.php
old new 282 282 283 283 add_action( 'pre_permalink', 'bozo_pre_permalink' ); 284 284 add_action( 'bb_index.php_pre_db', 'bozo_latest_filter' ); 285 add_action( 'bb_category.php_pre_db', 'bozo_latest_filter' ); 285 286 add_action( 'bb_forum.php_pre_db', 'bozo_latest_filter' ); 286 287 add_action( 'bb_topic.php_pre_db', 'bozo_topic_db_filter' ); 287 288 add_action( 'bb_profile.php_pre_db', 'bozo_profile_db_filter' ); -
bb-includes/template-functions.php
old new 1 1 <?php 2 2 3 3 function bb_load_template( $file, $globals = false ) { 4 global $bb, $bbdb, $bb_current_user, $ page, $bb_cache,4 global $bb, $bbdb, $bb_current_user, $category, $categories, $page, $bb_cache, 5 5 $posts, $bb_post, $post_id, $topics, $topic, $topic_id, 6 6 $forums, $forum, $forum_id, $tags, $tag, $tag_name, $user, $user_id, $view; 7 7 … … 192 192 case 'index.php' : 193 193 return 'front-page'; 194 194 break; 195 case 'category.php' : 196 return 'category-page'; 197 break; 195 198 case 'forum.php' : 196 199 return 'forum-page'; 197 200 break; … … 235 238 return false; 236 239 } 237 240 241 function is_category() { 242 if ( 'category-page' == get_bb_location() ) 243 return true; 244 else 245 return false; 246 } 247 238 248 function is_forum() { 239 249 if ( 'forum-page' == get_bb_location() ) 240 250 return true; … … 309 319 $title = get_topic_title(). ' « '; 310 320 if ( is_forum() ) 311 321 $title = get_forum_name() . ' « '; 322 if ( is_category() ) 323 $title = get_category_name() . ' « '; 312 324 if ( is_tag() ) 313 325 $title = wp_specialchars( get_tag_name() ). ' « ' . __('Tags') . ' « '; 314 326 if ( is_bb_profile() ) … … 328 340 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Tag') . ': ' . wp_specialchars( get_tag_name(), 1 ) . '" href="' . get_tag_rss_link() . '" />'; 329 341 elseif ( is_forum() ) 330 342 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Forum') . ': ' . wp_specialchars( get_forum_name(), 1) . '" href="' . get_forum_rss_link() . '" />'; 343 elseif ( is_category() ) 344 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Category') . ': ' . wp_specialchars( get_category_name(), 1) . '" href="' . get_category_rss_link() . '" />'; 331 345 elseif ( is_front() ) 332 346 $feed_link = '<link rel="alternate" type="application/rss+xml" title="' . __('Recent Posts') . '" href="' . get_recent_rss_link() . '" />'; 333 347 echo apply_filters('bb_feed_head', $feed_link); … … 341 355 return apply_filters( 'get_recent_rss_link', $link ); 342 356 } 343 357 358 // CATEGORIES 359 360 function get_forums_where_in_category_filter() { 361 global $category; 362 if ($category->category_id) 363 return 'WHERE category_id = ' . $category->category_id; 364 else return NULL; 365 } 366 367 function get_forums_join_categories_filter() { 368 global $bbdb; 369 return 'LEFT JOIN `' . $bbdb->categories . '` ON `' . $bbdb->categories . '`.`category_id` = `' . $bbdb->forums . '`.`category_id`'; 370 } 371 372 function get_forums_orderby_category_order_filter() { 373 return 'ORDER BY `category_order`, `forum_order`'; 374 } 375 376 function category_id() { 377 echo apply_filters( 'category_id', get_category_id() ); 378 } 379 380 function get_category_id() { 381 global $category; 382 return $category->category_id; 383 } 384 385 function category_link( $category_id = 0, $page = 1 ) { 386 echo apply_filters('category_link', get_category_link( $category_id, $page ), $category_id ); 387 } 388 389 function get_category_link( $category_id = 0, $page = 1 ) { 390 global $category; 391 392 if ( $category_id ) 393 $category = get_category( $category_id ); 394 if ( bb_get_option( 'mod_rewrite' ) ) 395 $link = bb_get_option( 'uri' ) . "category/$category->category_id" . ( 1 < $page ? "/page/$page" : '' ); 396 else { 397 $args = array(); 398 $link = bb_get_option( 'uri' ) . 'category.php'; 399 $args['id'] = $category->category_id; 400 $args['page'] = 1 < $page ? $page : ''; 401 $link = add_query_arg( $args, $link ); 402 } 403 404 return apply_filters( 'get_category_link', $link, $category->category_id ); 405 } 406 407 function category_name( $category_id = 0 ) { 408 echo apply_filters( 'category_name', get_category_name( $category_id ), $category_id ); 409 } 410 411 function get_category_name( $category_id = 0 ) { 412 global $category; 413 if ( $category_id ) 414 $category = get_category( $category_id ); 415 return apply_filters( 'get_category_name', $category->category_name, $forum->category_id ); 416 } 417 418 function category_description( $category_id = 0 ) { 419 echo apply_filters( 'category_description', get_category_description( $category_id ), $category_id ); 420 } 421 422 function get_category_description( $category_id = 0 ) { 423 global $category; 424 if ( $category_id ) 425 $category = get_forum( $category_id ); 426 return apply_filters( 'get_category_description', $category->category_desc, $category->category_id ); 427 } 428 429 function category_forums( $category_id = 0 ) { 430 echo apply_filters( 'category_forums', get_category_forums( $category_id ), $category_id ); 431 } 432 433 function get_category_forums( $category_id = 0 ) { 434 global $category; 435 if ( $category_id ) 436 $category = get_category( $category_id ); 437 return apply_filters( 'get_category_forums', $category->forums, $category->category_id ); 438 } 439 440 function category_rss_link( $category_id = 0 ) { 441 echo apply_filters('category_rss_link', get_category_rss_link( $category_id ) ); 442 } 443 444 function get_category_rss_link( $category_id = 0 ) { 445 global $category; 446 447 if ( $category_id ) 448 $category = get_category( $category_id ); 449 450 if ( bb_get_option('mod_rewrite') ) 451 $link = bb_get_option('uri') . "rss/category/$category->category_id"; 452 else 453 $link = bb_get_option('uri') . "rss.php?category=$category->category_id"; 454 455 return apply_filters( 'get_category_rss_link', $link, $category_id ); 456 } 457 344 458 // FORUMS 345 459 346 460 function forum_link( $forum_id = 0, $page = 1 ) { … … 777 891 $class[] = 'bozo'; 778 892 if ( '0' === $topic->topic_open ) 779 893 $class[] = 'closed'; 780 if ( 1 == $topic->topic_sticky && is_forum() )894 if ( 1 == $topic->topic_sticky && ( is_forum() || is_category() ) ) 781 895 $class[] = 'sticky'; 782 elseif ( 2 == $topic->topic_sticky && ( is_front() || is_forum() ) )896 elseif ( 2 == $topic->topic_sticky && ( is_front() || is_forum() || is_category() ) ) 783 897 $class[] = 'sticky super-sticky'; 784 898 $class = apply_filters( 'topic_class', $class, $topic->topic_id ); 785 899 $class = join(' ', $class); … … 793 907 794 908 if ( is_forum() || is_tag() ) 795 909 $url = '#postform'; 796 elseif ( is_front() )910 elseif ( is_front() || is_category() ) 797 911 $url = add_query_arg( 'new', '1', bb_get_option( 'uri' ) ); 798 912 if ( !bb_is_user_logged_in() ) 799 913 $url = add_query_arg( 're', urlencode($url), bb_get_option( 'uri' ) . 'bb-login.php' ); … … 1555 1669 1556 1670 function bb_get_forum_dropdown( $callback = false, $callback_args = false ) { 1557 1671 global $forum_id; 1558 if ( !$forums = get_forums( $callback, $callback_args ) ) 1559 return; 1560 1672 $categories = get_categories(); 1673 1561 1674 $r = '<select name="forum_id" id="forum_id" tabindex="5">'; 1562 1563 foreach ( $forums as $forum ) : 1564 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1565 $r .= "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1566 endforeach; 1675 if ($categories) : 1676 global $category; 1677 foreach ( $categories as $category ) : 1678 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 1679 if ( !$forums = get_forums( $callback, $callback_args ) ) 1680 $forums = false; 1681 if ( $forums ) : 1682 $r .= "<optgroup label='$category->category_name'>"; 1683 foreach ( $forums as $forum ) : 1684 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1685 $r .= "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1686 endforeach; 1687 $r .= "</optgroup>"; 1688 endif; 1689 endforeach; 1690 else : 1691 if ( !$forums = get_forums( $callback, $callback_args ) ) 1692 return; 1693 foreach ( $forums as $forum ) : 1694 $selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : ''; 1695 $r .= "<option value='$forum->forum_id'$selected>$forum->forum_name</option>"; 1696 endforeach; 1697 endif; 1567 1698 $r .= '</select>'; 1568 1699 return $r; 1569 1700 } -
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]->forums = $forums ? count($forums) : 0; 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(); -
category.php
old new 1 <?php 2 3 require_once('./bb-load.php'); 4 5 $category_id = 0; 6 7 bb_repermalink(); 8 9 if ( !$category ) 10 bb_die(__('Category not found.')); 11 12 $bb_db_override = false; 13 do_action( 'bb_category.php_pre_db', $category_id ); 14 15 if ( !$bb_db_override ) : 16 add_filter('get_forums_where', 'get_forums_where_in_category_filter', 1); 17 $forums = get_forums(); 18 $topics = get_latest_category_topics( $category_id, $page ); 19 $stickies = get_sticky_category_topics( $category_id, $page ); 20 endif; 21 22 do_action( 'bb_category.php', $category_id ); 23 24 bb_load_template( 'category.php', array('bb_db_override', 'stickies') ); 25 26 ?> -
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 62 62 require( BBPATH . BBINC . 'db.php'); 63 63 } 64 64 65 $bbdb->categories = $bb_table_prefix . 'categories'; 65 66 $bbdb->forums = $bb_table_prefix . 'forums'; 66 67 $bbdb->posts = $bb_table_prefix . 'posts'; 67 68 $bbdb->topics = $bb_table_prefix . 'topics'; -
bb-admin/bb-do-counts.php
old new 124 124 echo "\n\t</li>\n"; 125 125 endif; 126 126 127 if ( isset($_POST['categories']) && 1 == $_POST['categories'] ): 128 echo "\t<li>\n"; 129 if ( $categories = (array) $bbdb->get_col("SELECT category_id, COUNT(forum_id) FROM $bbdb->forums GROUP BY category_id") ) : 130 echo "\t\t" . __('Counting category forums...') . "<br />\n"; 131 $counts = (array) $bbdb->get_col('', 1); 132 foreach ($categories as $t => $i) 133 $bbdb->query("UPDATE $bbdb->categories SET forums = '{$counts[$t]}' WHERE category_id = $i"); 134 unset($topics, $t, $i, $counts); 135 endif; 136 echo "\t\t" . __('Done counting category forums.'); 137 echo "\n\t</li>\n"; 138 endif; 139 127 140 bb_recount_list(); 128 141 if ( $recount_list ) 129 142 foreach ( (array) $recount_list as $item ) -
bb-admin/bb-category.php
old new 1 <?php 2 require_once('admin.php'); 3 4 if ( !bb_current_user_can('manage_categories') ) 5 bb_die(__("You don't have the authority to mess with the categories.")); 6 7 if ( !isset($_POST['action']) ) 8 wp_redirect( bb_get_option( 'uri' ) . 'bb-admin/content-categories.php' ); 9 10 $sent_from = wp_get_referer(); 11 12 switch ( $_POST['action'] ) : 13 case 'add' : 14 if ( !isset($_POST['category']) || '' === $_POST['category'] ) 15 bb_die(__('Bad category name. Go back and try again.')); 16 17 bb_check_admin_referer( 'add-category' ); 18 19 $category_name = $_POST['category']; 20 $category_desc = $_POST['category-desc']; 21 $category_order = ( '' === $_POST['category-order'] ) ? 0 : (int) $_POST['category-order']; 22 if ( false !== bb_new_category( $category_name, $category_desc, $category_order ) ) : 23 wp_redirect( $sent_from ); 24 exit; 25 else : 26 bb_die(__('The category was not added')); 27 endif; 28 break; 29 case 'update' : 30 bb_check_admin_referer( 'update-categories' ); 31 32 if ( !$categories = get_categories() ) 33 bb_die(__('No categories to update!')); 34 foreach ( $categories as $category ) : 35 if ( isset($_POST['name-' . $category->category_id]) && '' !== $_POST['name-' . $category->category_id] ) 36 bb_update_category( $category->category_id, $_POST[