Changeset 734
- Timestamp:
- 03/02/07 11:21:43 (2 years ago)
- Files:
-
- trunk/bb-admin/admin-ajax.php (modified) (2 diffs)
- trunk/bb-admin/admin-functions.php (modified) (1 diff)
- trunk/bb-admin/bb-forum.php (modified) (2 diffs)
- trunk/bb-admin/content-forums.php (modified) (4 diffs)
- trunk/bb-admin/js (added)
- trunk/bb-admin/js/content-forums.js (added)
- trunk/bb-admin/style.css (modified) (4 diffs)
- trunk/bb-admin/upgrade-schema.php (modified) (1 diff)
- trunk/bb-includes/cache.php (modified) (7 diffs)
- trunk/bb-includes/functions.php (modified) (4 diffs)
- trunk/bb-includes/js/add-load-event.js (added)
- trunk/bb-includes/js/jquery (added)
- trunk/bb-includes/js/jquery/interface.js (added)
- trunk/bb-includes/js/jquery/jquery.js (added)
- trunk/bb-includes/js/list-manipulation-js.php (modified) (1 diff)
- trunk/bb-includes/script-loader.php (modified) (1 diff)
- trunk/bb-includes/template-functions.php (modified) (3 diffs)
- trunk/bb-templates/kakumei/header.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bb-admin/admin-ajax.php
r671 r734 1 1 <?php 2 2 require_once('../bb-load.php'); 3 3 require_once(BBPATH . 'bb-admin/admin-functions.php'); 4 4 bb_check_ajax_referer(); 5 5 6 6 if ( !$bb_current_id = bb_get_current_user_info( 'id' ) ) 7 7 die('-1'); 8 8 9 define('DOING_AJAX', true); 9 10 … … 149 150 break; 150 151 152 case 'add-forum' : 153 if ( !bb_current_user_can( 'manage_forums' ) ) 154 die('-1'); 155 156 if ( !$forum_id = bb_new_forum( $_POST ) ) 157 die('0'); 158 159 global $forums_count; 160 $forums_count = 2; // Hack 161 162 $x = new WP_Ajax_Response( array( 163 'what' => 'forum', 164 'id' => $forum_id, 165 'data' => bb_forum_row( $forum_id, false ) 166 ) ); 167 $x->send(); 168 break; 169 170 case 'order-forums' : 171 if ( !is_array($_POST['order']) ) 172 die('0'); 173 174 global $bbdb; 175 176 $forums = array(); 177 178 get_forums(); // cache 179 180 foreach ( $_POST['order'] as $pos => $forum_id ) : 181 $forum = $bbdb->escape_deep( get_object_vars( get_forum( $forum_id ) ) ); 182 $forum['forum_order'] = $pos; 183 $forums[(int) $forum_id] = $forum; 184 endforeach; 185 186 foreach ( $_POST['root'] as $root => $ids ) 187 foreach ( $ids as $forum_id ) 188 $forums[(int) $forum_id]['forum_parent'] = (int) $root; 189 190 foreach ( $forums as $forum ) 191 bb_update_forum( $forum ); 192 193 194 die('1'); 195 break; 196 151 197 default : 152 198 do_action( 'bb_ajax_' . $_POST['action'] ); trunk/bb-admin/admin-functions.php
r702 r734 525 525 } 526 526 527 function bb_forum_row( $forum_id = 0, $echo = true, $close = true, $class = 'forum' ) { 528 global $forum, $forums_count; 529 if ( $forum_id ) 530 $_forum = get_forum( $forum_id ); 531 else 532 $_forum =& $forum; 533 534 if ( !$_forum ) 535 return; 536 537 $r = "\t<li id='forum-$_forum->forum_id'" . get_alt_class( 'forum', "$class clear list-block" ) . ">\n"; 538 $r .= "\t\t<div class='list-block posrel'>" . get_forum_name( $_forum->forum_id ) . ' — ' . get_forum_description( $_forum->forum_id ) . "\n"; 539 $r .= "\t\t\t<div class='abstop absright'>\n"; 540 if ( bb_current_user_can( 'manage_forums' ) ) 541 $r .= "\t\t\t\t<a class='edit' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=edit&id=$_forum->forum_id" ) . "'>" . __('Edit') . "</a>\n"; 542 if ( bb_current_user_can( 'delete_forum', $_forum->forum_id ) && 1 < $forums_count ) 543 $r .= "\t\t\t\t<a class='delete' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=delete&id=$_forum->forum_id" ) . "'>" . __('Delete') . "</a>\n"; 544 $r .= "\t\t\t</div>\n\t\t</div>\n"; 545 if ( $close ) 546 $r .= "\t</li>\n"; 547 548 if ( $echo ) 549 echo $r; 550 return $r; 551 } 552 553 function bb_forum_form( $forum_id = 0 ) { 554 $forum_id = (int) $forum_id; 555 if ( $forum_id && !$forum = get_forum( $forum_id ) ) 556 return; 557 $action = $forum_id ? 'update' : 'add'; 527 558 ?> 559 <form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 560 <fieldset> 561 <table><col /><col style="width: 80%" /> 562 <tr><th scope="row"><?php _e('Forum Name:'); ?></th> 563 <td><input type="text" name="forum_name" id="forum-name" value="<?php if ( $forum_id ) echo attribute_escape( get_forum_name( $forum_id ) ); ?>" tabindex="10" class="widefat" /></td> 564 </tr> 565 <tr><th scope="row"><?php _e('Forum Description:'); ?></th> 566 <td><input type="text" name="forum_desc" id="forum-desc" value="<?php if ( $forum_id ) echo attribute_escape( get_forum_description( $forum_id ) ); ?>" tabindex="11" class="widefat" /></td> 567 </tr> 568 <tr><th scope="row"><?php _e('Forum Parent:'); ?></th> 569 <td><?php bb_forum_dropdown( array('callback' => 'strcmp', 'callback_args' => array($forum_id), 'id' => 'forum_parent', 'none' => true, 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0) ); ?></td> 570 </tr> 571 <tr><th scope="row"><?php _e('Position:'); ?></th> 572 <td><input type="text" name="forum_order" id="forum-order" value="<?php if ( $forum_id ) echo get_forum_position( $forum_id ); ?>" tabindex="12" maxlength="10" class="widefat" /></td> 573 </tr> 574 </table> 575 <p class="submit"> 576 <?php if ( $forum_id ) : ?> 577 <input type="hidden" name="forum_id" value="<?php echo $forum_id; ?>" /> 578 <?php endif; ?> 579 <?php bb_nonce_field( "$action-forum" ); ?> 580 581 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 582 <input name="Submit" type="submit" value="<?php if ( $forum_id ) _e('Update Forum »'); else _e('Add Forum »'); ?>" tabindex="13" /> 583 </p> 584 </fieldset> 585 </form> 586 <?php 587 } 588 589 ?> trunk/bb-admin/bb-forum.php
r615 r734 12 12 switch ( $_POST['action'] ) : 13 13 case 'add' : 14 if ( !isset($_POST['forum ']) || '' === $_POST['forum'] )14 if ( !isset($_POST['forum_name']) || '' === $_POST['forum_name'] ) 15 15 bb_die(__('Bad forum name. Go back and try again.')); 16 16 17 17 bb_check_admin_referer( 'add-forum' ); 18 18 19 $forum_name = $_POST['forum']; 20 $forum_desc = $_POST['forum-desc']; 21 $forum_order = ( '' === $_POST['forum-order'] ) ? 0 : (int) $_POST['forum-order']; 22 if ( false !== bb_new_forum( $forum_name, $forum_desc, $forum_order ) ) : 19 if ( false !== bb_new_forum( $_POST ) ) : 23 20 wp_redirect( $sent_from ); 24 21 exit; … … 28 25 break; 29 26 case 'update' : 30 bb_check_admin_referer( 'update-forum s' );27 bb_check_admin_referer( 'update-forum' ); 31 28 32 29 if ( !$forums = get_forums() ) 33 30 bb_die(__('No forums to update!')); 34 foreach ( $forums as $forum ) :35 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 endforeach;38 wp_redirect( $sent_from);31 if ( (int) $_POST['forum_id'] && isset($_POST['forum_name']) && '' !== $_POST['forum_name'] ) 32 bb_update_forum( $_POST ); 33 foreach ( array('action', 'id') as $arg ) 34 $sent_from = remove_query_arg( $arg, $sent_from ); 35 wp_redirect( add_query_arg( 'message', 'updated', $sent_from ) ); 39 36 exit; 40 37 break; trunk/bb-admin/content-forums.php
r656 r734 14 14 if ( isset($_GET['message']) ) { 15 15 switch ( $_GET['message'] ) : 16 case 'updated' : 17 bb_admin_notice( __('Forum Updated.') ); 18 break; 16 19 case 'deleted' : 17 20 bb_admin_notice( sprintf(__('Forum deleted. You should have bbPress <a href="%s">recount your site information</a>.'), bb_get_option( 'uri' ) . 'bb-admin/site.php') ); … … 20 23 } 21 24 25 if ( !isset($_GET['action']) ) 26 bb_enqueue_script( 'content-forums' ); 27 22 28 bb_get_admin_header(); 23 29 ?> 24 30 25 31 <h2><?php _e('Forum Management'); ?></h2> 26 <?php if ( 'delete' == $_GET['action'] ) : ?> 32 <?php switch ( $_GET['action'] ) : ?> 33 <?php case 'edit' : ?> 34 <h3><?php _e('Update Forum'); ?></h3> 35 <?php bb_forum_form( (int) $_GET['id'] ); ?> 36 <?php break; case 'delete' : ?> 27 37 <div class="ays narrow"> 28 38 <p><big><?php printf(__('Are you sure you want to delete the "<strong>%s</strong>" forum?'), $deleted_forum->forum_name); ?></big></p> … … 37 47 <label for="move-topics-delete"><input type="radio" name="move_topics" id="move-topics-delete" value="delete" /> <?php _e('Delete all topics and posts in this forum. <em>This can never be undone.</em>'); ?></label><br /> 38 48 <label for="move-topics-move"><input type="radio" name="move_topics" id="move-topics-move" value="move" checked="checked" /> <?php _e('Move topics from this forum into'); ?></label> 39 <?php $forums = get_forums( ); ?>49 <?php $forums = get_forums( 'strcmp', array($deleted_forum->forum_id) ); ?> 40 50 <select name="move_topics_forum" id="move-topics-forum"> 41 <?php foreach ($forums as $forum ) : ?> 42 <?php if ($forum->forum_id != $deleted_forum->forum_id) : ?> 43 44 <option value="<?php forum_id(); ?>"><?php forum_name(); ?></option> 45 <?php endif; ?> 46 <?php endforeach; ?> 51 <?php foreach ($forums as $forum ) : ?> 52 <option value="<?php forum_id(); ?>"><?php forum_name(); ?></option> 53 <?php endforeach; ?> 47 54 </select> 48 55 … … 61 68 </form> 62 69 </div> 63 <?php else: // action?>70 <?php break; default : ?> 64 71 65 <form method="post" id="add-forum" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 66 <h3><?php _e('Add forum'); ?></h3> 67 <fieldset> 68 <table> 69 <tr><th scope="row"><?php _e('Forum Name:'); ?></th> 70 <td><input type="text" name="forum" id="forum" tabindex="10" /></td> 71 </tr> 72 <tr><th scope="row"><?php _e('Forum Description:'); ?></th> 73 <td><input type="text" name="forum-desc" id="forum-desc" tabindex="11" /></td> 74 </tr> 75 <tr><th scope="row"><?php _e('Position:'); ?></th> 76 <td><input type="text" name="forum-order" id="forum-order" tabindex="12" maxlength="10" /></td> 77 </tr> 78 </table> 79 <p class="submit alignleft"><input name="Submit" type="submit" value="<?php _e('Add Forum'); ?>" tabindex="13" /><input type="hidden" name="action" value="add" /></p> 80 </fieldset> 81 <?php bb_nonce_field( 'add-forum' ); ?> 82 </form> 83 <?php if ( $forums ) : ?> 84 <form method="post" id="update-forums" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 85 <h3><?php _e('Update forum information'); ?></h3> 86 <fieldset> 87 <table> 88 <tr><th><?php _e('Name'); ?></th> 89 <th><?php _e('Description'); ?></th> 90 <th><?php _e('Position'); ?></th> 91 <?php if ( bb_current_user_can( 'delete_forums' ) && 1 < $forums_count ) : ?> 92 <th><?php _e('Action'); ?></th> 93 <?php endif; ?> 94 </tr> 95 <?php $t = 20; foreach ( $forums as $forum ) : ?> 96 <tr><td><input type="text" name="name-<?php forum_id(); ?>" value="<?php echo wp_specialchars( get_forum_name(), 1 ); ?>" tabindex="<?php echo $t++; ?>" /></td> 97 <td><input type="text" name="desc-<?php forum_id(); ?>" value="<?php echo wp_specialchars( get_forum_description(), 1 ); ?>" tabindex="<?php echo $t++; ?>" /></td> 98 <td><input type="text" name="order-<?php forum_id(); ?>" value="<?php echo $forum->forum_order; ?>" maxlength="10" tabindex="<?php echo $t++; ?>" /></td> 99 <?php if ( bb_current_user_can( 'delete_forums' ) && 1 < $forums_count ) : ?> 100 <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> 101 <?php endif; ?> 102 </tr> 103 <?php endforeach; ?> 104 </table> 105 <p class="submit alignleft"><input name="Submit" type="submit" value="<?php _e('Update'); ?>" tabindex="<?php echo $t; ?>" /><input type="hidden" name="action" value="update" /></p> 106 </fieldset> 107 <?php bb_nonce_field( 'update-forums' ); ?> 108 </form> 72 <?php 73 function bb_list_h( $forums, $level = 0, $id = 0 ) { 74 $tabs = $level ? str_repeat( "\t", $level + 1 ) : ''; 75 if ( $level ) 76 echo "$tabs<ul id='forum-root-$id' class='list-block holder'>\n"; 77 foreach ( array_keys($forums) as $f ) { 78 echo "$tabs"; 79 bb_forum_row( $f, true, false, 'forum' ); 80 if ( is_array($forums[$f]) ) 81 bb_list_h( $forums[$f], $level + 1, $f ); 82 echo "$tabs\t</li>\n"; 83 } 84 if ( $level ) 85 echo "$tabs</ul>\n"; 86 } 87 ?> 88 89 <?php if ( $forums ) : $_forums = bb_get_forums_hierarchical(); ?> 90 91 <ul id="the-list" class="list-block holder"> 92 <li class="thead list-block"><div class="list-block">Name — Description</div></li> 93 <?php bb_list_h( $_forums ); ?> 94 </ul> 109 95 <?php endif; // $forums ?> 110 96 111 <?php endif; // action ?> 97 <h3><?php _e('Add Forum'); ?></h3> 98 <?php bb_forum_form(); ?> 99 100 <?php break; endswitch; // action ?> 101 102 <div id="ajax-response"></div> 112 103 113 104 <?php bb_get_admin_footer(); ?> trunk/bb-admin/style.css
r680 r734 1 .helper { border: 2px dashed #777; } 2 3 .sort-handle { cursor: move; } 4 1 5 a { 2 6 border-bottom: 1px solid #6c9; … … 15 19 } 16 20 21 ul.list-block { 22 margin: 0; 23 padding: 0; 24 background-color: #fff; 25 } 26 27 ul.list-block ul.list-block { 28 padding: 0 0 0 4ex; 29 } 30 31 li.list-block { 32 list-style: none; 33 margin: 0; 34 padding: 8px 0 0; 35 } 36 37 .absright { 38 position: absolute; 39 right: 0; 40 } 41 42 .abstop { 43 position: absolute; 44 top: 0; 45 } 46 47 .posrel { 48 position: relative; 49 } 50 51 div.list-block { 52 padding: 0 8px 8px; 53 } 54 17 55 a.edit, a.delete, a.edit:hover, a.delete:hover { 56 padding: 5px; 18 57 border-bottom: none; 19 display: block;20 padding: 5px 0;21 58 text-align: center; 22 59 } … … 247 284 248 285 thead, .thead { 249 background: #dfdfdf 286 background: #dfdfdf; 287 font-weight: bold; 250 288 } 251 289 … … 418 456 } 419 457 458 .clear { 459 clear: both; 460 } 461 420 462 br.clear { 421 clear: both;422 463 height: 1px; 423 464 font-size: 1px; trunk/bb-admin/upgrade-schema.php
r696 r734 6 6 forum_name varchar(150) NOT NULL default '', 7 7 forum_desc text NOT NULL, 8 forum_parent int(10) NOT NULL default '0', 8 9 forum_order int(10) NOT NULL default '0', 9 10 topics bigint(20) NOT NULL default '0', trunk/bb-includes/cache.php
r665 r734 139 139 140 140 function get_forums() { 141 global $bbdb ;141 global $bbdb, $bb_forum_cache; 142 142 143 143 $normal = true; 144 144 if ( '' != $where = apply_filters('get_forums_where', '') ) 145 145 $normal = false; 146 147 if ( $normal && isset($bb_forum_cache[-1]) && $bb_forum_cache[-1] ) { 148 $forums = $bb_forum_cache; 149 unset($forums[-1]); 150 return $forums; 151 } 146 152 147 153 if ( $this->use_cache && $normal && file_exists(BBPATH . 'bb-cache/bb_forums') ) … … 151 157 if ( $this->use_cache && $normal && $forums ) 152 158 $this->write_cache(BBPATH . 'bb-cache/bb_forums', $forums); 159 foreach ( $forums as $forum ) 160 $bb_forum_cache[(int) $forum->forum_id] = $forum; 161 162 $bb_forum_cache[-1] = true; 163 153 164 return $forums; 154 165 } 155 166 156 167 function get_forum( $forum_id ) { 157 global $bbdb ;168 global $bbdb, $bb_forum_cache; 158 169 $forum_id = (int) $forum_id; 159 170 … … 161 172 if ( '' != $where = apply_filters('get_forum_where', '') ) 162 173 $normal = false; 174 175 if ( $normal && $forum_id && isset($bb_forum_cache[$forum_id]) ) 176 return $bb_forum_cache[$forum_id]; 163 177 164 178 if ( $this->use_cache && $normal && file_exists(BBPATH . 'bb-cache/bb_forum-' . $forum_id) ) 165 179 return $this->read_cache(BBPATH . 'bb-cache/bb_forum-' . $forum_id); 166 180 167 $forum = $bbdb->get_row("SELECT * FROM $bbdb->forums WHERE forum_id = $forum_id $where"); 181 if ( $forum = $bbdb->get_row("SELECT * FROM $bbdb->forums WHERE forum_id = $forum_id $where") ) 182 $bb_forum_cache[$forum_id] = $forum; 183 168 184 if ( $this->use_cache && $normal && $forum ) 169 185 $this->write_cache(BBPATH . 'bb-cache/bb_forum-' . $forum_id, $forum); 186 170 187 return $forum; 171 188 } … … 187 204 188 205 function flush_one( $type, $id = 0, $page = 0 ) { 189 if ( !$this->use_cache )190 return;191 206 switch ( $type ) : 192 207 case 'user' : … … 197 212 break; 198 213 case 'forums' : 214 global $bb_forum_cache; 215 unset($bb_forum_cache[-1]); 199 216 $file = BBPATH . 'bb-cache/bb_forums'; 200 217 break; 201 218 endswitch; 219 220 if ( !$this->use_cache ) 221 return; 202 222 203 223 if ( file_exists($file) ) … … 206 226 207 227 function flush_many( $type, $id, $start = 0 ) { 208 if ( !$this->use_cache )209 return;210 228 switch ( $type ) : 211 229 case 'thread' : … … 213 231 break; 214 232 case 'forum' : 233 global $bb_forum_cache; 234 unset($bb_forum_cache[$id], $bb_forum_cache[-1]); 215 235 $files = array(BBPATH . 'bb-cache/bb_forum-' . $id, BBPATH . 'bb-cache/bb_forums'); 216 236 break; 217 237 endswitch; 238 239 if ( !$this->use_cache ) 240 return; 218 241 219 242 if ( is_array($files) ) trunk/bb-includes/functions.php
r730 r734 1 1 <?php 2 3 function bb_get_forums_hierarchical( $root = 0, $old_root = 0, $leaves = false ) { 4 static $tree = 0; 5 6 $root = (int) $root; 7 8 if ( 0 !== $tree ) 9 return $tree; 10 11 $_recursed = (bool) $leaves; 12 13 if ( false === $leaves ) 14 $leaves = get_forums(); 15 16 if ( !$leaves ) 17 return false; 18 19 $branch = array(); 20 21 foreach ( $leaves as $l => $leaf ) { 22 if ( $root == $leaf->forum_parent ) { 23 $new_root = (int) $leaf->forum_id; 24 unset($leaves[$l]); 25 $branch[$new_root] = bb_get_forums_hierarchical( $new_root, $root, $leaves ); 26 } 27 } 28 29 if ( !$_recursed ) 30 return $tree = empty($branch) ? false : $branch; 31 32 return $branch ? $branch : true; 33 } 2 34 3 35 function get_forums( $callback = false, $callback_args = false ) { … … 470 502 break; 471 503 case 'bb_db_version' : 472 return ' 688'; // Don't filter504 return '700'; // Don't filter 473 505 break; 474 506 case 'html_type' : … … 852 884 853 885 854 function bb_new_forum( $ name, $desc, $order = 0) {886 function bb_new_forum( $args ) { 855 887 global $bbdb, $bb_cache; 856 888 if ( !bb_current_user_can( 'manage_forums' ) ) 857 889 return false; 858 if ( strlen($name) < 1 ) 859 return false; 860 $bbdb->query("INSERT INTO $bbdb->forums (forum_name, forum_desc, forum_order) VALUES ('$name', '$desc', '$order')"); 890 891 $defaults = array( 'forum_name' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => false ); 892 $args = bb_parse_args( $args, $defaults ); 893 if ( 1 < func_num_args() ) : // For back compat 894 $args['forum_id'] = func_get_arg(0); 895 $args['forum_name'] = func_get_arg(1); 896 $args['forum_desc'] = 2 < func_num_args() ? func_get_arg(2) : ''; 897 $args['forum_order'] = 3 < func_num_args() && is_numeric(func_get_arg(3)) ? func_get_arg(3) : false; 898 endif; 899 900 extract($args); 901 902 if ( false === $forum_order ) 903 $forum_order = $bbdb->get_var("SELECT MAX(forum_order) FROM $bbdb->forums") + 1; 904 905 $forum_order = (int) $forum_order; 906 $forum_parent = (int) $forum_parent; 907 if ( strlen($forum_name) < 1 ) 908 return false; 909 $bbdb->query("INSERT INTO $bbdb->forums (forum_name, forum_desc, forum_parent, forum_order) VALUES ('$forum_name', '$forum_desc', '$forum_parent', '$forum_order')"); 861 910 $bb_cache->flush_one( 'forums' ); 862 911 return $bbdb->insert_id; 863 912 } 864 913 865 function bb_update_forum( $ forum_id, $name, $desc, $order = 0) {914 function bb_update_forum( $args ) { 866 915 global $bbdb, $bb_cache; 867 916 if ( !bb_current_user_can( 'manage_forums' ) ) 868 917 return false; 918 919 $defaults = array( 'forum_id' => 0, 'forum_name' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => 0 ); 920 $args = bb_parse_args( $args, $defaults ); 921 if ( 1 < func_num_args() ) : // For back compat 922 $args['forum_name'] = func_get_arg(0); 923 $args['forum_desc'] = func_get_arg(1); 924 $args['forum_order'] = 2 < func_num_args() ? func_get_arg(2) : 0; 925 endif; 926 927 extract($args); 928 869 929 if ( !$forum_id = (int) $forum_id ) 870 930 return false; 871 $order = (int) $order; 872 if ( strlen($name) < 1 ) 931 $forum_order = (int) $forum_order; 932 $forum_parent = (int) $forum_parent; 933 if ( strlen($forum_name) < 1 ) 873 934 return false; 874 935 $bb_cache->flush_many( 'forum', $forum_id ); 875 return $bbdb->query("UPDATE $bbdb->forums SET forum_name = '$name', forum_desc = '$desc', forum_order = '$order' WHERE forum_id = $forum_id"); 936 $bb_cache->flush_one( 'forums' ); 937 return $bbdb->query("UPDATE $bbdb->forums SET forum_name = '$forum_name', forum_desc = '$forum_desc', forum_parent = '$forum_parent', forum_order = '$forum_order' WHERE forum_id = $forum_id"); 876 938 } 877 939 … … 900 962 901 963 $bb_cache->flush_many( 'forum', $forum_id ); 964 $bb_cache->flush_one( 'forums' ); 902 965 return $return; 903 966 } trunk/bb-includes/js/list-manipulation-js.php
r632 r734 117 117 var id = this.topAdder ? this.theList.firstChild.id : this.theList.lastChild.id; 118 118 if ( this.alt ) 119 if ( this.theList.childNodes.length% 2 )119 if ( ( this.theList.childNodes.length + this.altOffset ) % 2 ) 120 120 $(id).addClassName(this.alt); 121 121 Fat.fade_element(id); trunk/bb-includes/script-loader.php
r708 r734 11 11 12 12 function default_scripts() { 13 $this->add( 'fat', '/' . BBINC . 'js/fat.js', false, '1.0-RC1_3660' );13 $this->add( 'fat', '/' . BBINC . 'js/fat.js', array('add-load-event'), '1.0-RC1_3660' ); 14 14 $this->add( 'prototype', '/' . BBINC . 'js/prototype.js', false, '1.5.0' ); 15 15 $this->add( 'wp-ajax', '/' . BBINC . 'js/wp-ajax-js.php', array('prototype'), '2.1-beta2' ); 16 $this->add( 'listman', '/' . BBINC . 'js/list-manipulation-js.php', array('wp-ajax', 'fat'), '440' ); 17 $this->add( 'topic', '/' . BBINC . 'js/topic-js.php', array('listman'), '433' ); 16 $this->add( 'listman', '/' . BBINC . 'js/list-manipulation-js.php', array('add-load-event', 'wp-ajax', 'fat'), '440' ); 17 $this->add( 'topic', '/' . BBINC . 'js/topic-js.php', array('add-load-event', 'listman'), '433' ); 18 $this->add( 'jquery', '/' . BBINC . 'js/jquery/jquery.js', false, '1.1.2'); 19 $this->add( 'interface', '/' . BBINC . 'js/jquery/interface.js', array('jquery'), '1.2'); 20 $this->add( 'add-load-event', '/' . BBINC . 'js/add-load-event.js' ); 21 $this->add( 'content-forums', '/bb-admin/js/content-forums.js', array('listman', 'interface'), 1 ); 18 22 } 19 23 trunk/bb-includes/template-functions.php
r727 r734 374 374 global $forum; 375 375 if ( $forum_id ) 376 $forum = get_forum( $forum_id ); 377 return apply_filters( 'get_forum_name', $forum->forum_name, $forum->forum_id ); 376 $_forum = get_forum( $forum_id ); 377 else 378 $_forum =& $forum; 379 return apply_filters( 'get_forum_name', $_forum->forum_name, $_forum->forum_id ); 378 380 } 379 381 … … 394 396 global $forum; 395 397 if ( $forum_id ) 396 $forum = get_forum( $forum_id ); 397 return apply_filters( 'get_forum_description', $forum->forum_desc, $forum->forum_id ); 398 $_forum = get_forum( $forum_id ); 399 else 400 $_forum =& $forum; 401 return apply_filters( 'get_forum_description', $_forum->forum_desc, $_forum->forum_id ); 402 } 403 404 function get_forum_parent( $forum_id = 0 ) { 405 global $forum; 406 if ( $forum_id ) 407 $_forum = get_forum( $forum_id ); 408 else 409 $_forum =& $forum; 410 return apply_filters( 'get_forum_parent', $_forum->forum_parent, $_forum->forum_id ); 411 } 412 413 function get_forum_position( $forum_id = 0 ) { 414 global $forum; 415 if ( $forum_id ) 416 $_forum = get_forum( $forum_id ); 417 else 418 $_forum =& $forum; 419 return apply_filters( 'get_forum_position', $_forum->forum_order, $_forum->forum_id ); 398 420 } 399 421 … … 1575 1597 } 1576 1598 1577 function bb_forum_dropdown( $callback = false, $callback_args = false ) { 1578 echo bb_get_forum_dropdown( $callback, $callback_args ); 1579 } 1580 1581 function bb_get_forum_dropdown( $callback = false, $callback_args = false ) { 1599 function bb_forum_dropdown( $args = '' ) { 1600 if ( $args && is_string($args) && false === strpos($args, '=') ) 1601 $args = array( 'callback' => $args ); 1602 if ( 1 < func_num_args() ) 1603 $args['callback_args'] = func_get_arg(1); 1604 echo bb_get_forum_dropdown( $args ); 1605 } 1606 1607 function bb_get_forum_dropdown( $args = '' ) { 1608 $defaults = array( 'callback' => false, 'callback_args' => false, 'id' => 'forum_id', 'none' => false, 'selected' => false, 'tab' => 5 ); 1609 if ( $args && is_string($args) && false === strpos($args, '=') ) 1610 $args = array( 'callback' => $args ); 1611 if ( 1 < func_num_args() ) 1612 $args['callback_args'] = func_get_arg(1); 1613 1614 extract($args = bb_parse_args( $args, $defaults )); 1615 1582 1616 global $forum_id; 1583 1617 if ( !$forums = get_forums( $callback, $callback_args ) ) 1584 1618 return; 1585 1619 1586 $r = '<select name="forum_id" id="forum_id" tabindex="5">'; 1620 $id = attribute_escape( $id ); 1621 $tab = (int) $tab; 1622 1623 $r = "<select name='$id' id='$id' tabindex='$tab'>\n"; 1624 if ( $none ) 1625 $r .= "\n<option value='0'>" . __('- None -') . "</option>\n"; 1587 1626 1588 1627 foreach ( $forums as $forum ) : 1589 $ selected = ( $forum_id == $forum->forum_id ) ? " selected='selected'" : '';1590 $r .= " <option value='$forum->forum_id'$selected>$forum->forum_name</option>";1628 $_selected = ( !$selected && $forum_id == $forum->forum_id || $selected == $forum->forum_id ) ? " selected='selected'" : ''; 1629 $r .= "\n<option value='$forum->forum_id'$_selected>$forum->forum_name</option>\n"; 1591 1630 endforeach; 1592 $r .= '</select>';1631 $r .= "</select>\n"; 1593 1632 return $r; 1594 1633 } trunk/bb-templates/kakumei/header.php
r671 r734 12 12 <?php if ( is_topic() && bb_is_user_logged_in() ) : ?> 13 13 <script type="text/javascript"> 14 function addLoadEvent(func) {15 var oldonload = window.onload;16 if (typeof window.onload != 'function') {17 window.onload = func;18 } else {19 window.onload = function() {20 oldonload();21 func();22 }23 }24 }25 26 14 var lastMod = <?php topic_time( 'timestamp' ); ?>; 27 15 var page = <?php global $page; echo $page; ?>;