Changeset 995
- Timestamp:
- 01/03/08 00:57:27 (11 months ago)
- Files:
-
- branches/0.8/bb-admin/admin-ajax.php (modified) (6 diffs)
- branches/0.8/bb-admin/admin-deprecated.php (copied) (copied from trunk/bb-admin/admin-deprecated.php)
- branches/0.8/bb-admin/admin-functions.php (modified) (19 diffs)
- branches/0.8/bb-admin/admin.php (modified) (1 diff)
- branches/0.8/bb-admin/bb-do-counts.php (modified) (5 diffs)
- branches/0.8/bb-admin/content-forums.php (modified) (2 diffs)
- branches/0.8/bb-admin/content-posts.php (modified) (1 diff)
- branches/0.8/bb-admin/content.php (modified) (2 diffs)
- branches/0.8/bb-admin/export.php (modified) (1 diff)
- branches/0.8/bb-admin/index.php (modified) (1 diff)
- branches/0.8/bb-admin/install.php (modified) (2 diffs)
- branches/0.8/bb-admin/js/content-forums.js (modified) (1 diff)
- branches/0.8/bb-admin/plugins.php (modified) (6 diffs)
- branches/0.8/bb-admin/rewrite-rules.php (modified) (2 diffs)
- branches/0.8/bb-admin/style.css (modified) (1 diff)
- branches/0.8/bb-admin/tag-destroy.php (modified) (1 diff)
- branches/0.8/bb-admin/tag-merge.php (modified) (1 diff)
- branches/0.8/bb-admin/tag-rename.php (modified) (1 diff)
- branches/0.8/bb-admin/themes.php (modified) (5 diffs)
- branches/0.8/bb-admin/upgrade-functions.php (modified) (3 diffs)
- branches/0.8/bb-admin/upgrade-schema.php (modified) (9 diffs)
- branches/0.8/bb-admin/view-ip.php (modified) (3 diffs)
- branches/0.8/bb-includes/akismet.php (modified) (1 diff)
- branches/0.8/bb-includes/bozo.php (modified) (6 diffs)
- branches/0.8/bb-includes/classes.php (modified) (4 diffs)
- branches/0.8/bb-includes/compat.php (modified) (1 diff)
- branches/0.8/bb-includes/db-base.php (copied) (copied from trunk/bb-includes/db-base.php)
- branches/0.8/bb-includes/db-mysqli.php (modified) (6 diffs)
- branches/0.8/bb-includes/db.php (modified) (6 diffs)
- branches/0.8/bb-includes/default-filters.php (modified) (4 diffs)
- branches/0.8/bb-includes/deprecated.php (modified) (3 diffs)
- branches/0.8/bb-includes/formatting-functions.php (modified) (4 diffs)
- branches/0.8/bb-includes/functions.php (modified) (58 diffs)
- branches/0.8/bb-includes/js/jquery/jquery.js (modified) (1 diff)
- branches/0.8/bb-includes/pluggable.php (modified) (7 diffs)
- branches/0.8/bb-includes/registration-functions.php (modified) (4 diffs)
- branches/0.8/bb-includes/script-loader.php (modified) (1 diff)
- branches/0.8/bb-includes/statistics-functions.php (modified) (1 diff)
- branches/0.8/bb-includes/template-functions.php (modified) (30 diffs)
- branches/0.8/bb-includes/wp-classes.php (modified) (4 diffs)
- branches/0.8/bb-includes/wp-functions.php (modified) (32 diffs)
- branches/0.8/bb-load.php (modified) (2 diffs)
- branches/0.8/bb-login.php (modified) (2 diffs)
- branches/0.8/bb-settings.php (modified) (8 diffs)
- branches/0.8/bb-templates/kakumei/favorites.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/forum.php (modified) (3 diffs)
- branches/0.8/bb-templates/kakumei/front-page.php (modified) (4 diffs)
- branches/0.8/bb-templates/kakumei/login.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/post-form.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/rss2.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/search.php (modified) (2 diffs)
- branches/0.8/bb-templates/kakumei/stats.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/style-rtl.css (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/style.css (modified) (4 diffs)
- branches/0.8/bb-templates/kakumei/tag-single.php (modified) (2 diffs)
- branches/0.8/bb-templates/kakumei/tags.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/topic-tags.php (modified) (2 diffs)
- branches/0.8/bb-templates/kakumei/topic.php (modified) (1 diff)
- branches/0.8/bb-templates/kakumei/view.php (modified) (2 diffs)
- branches/0.8/config-sample.php (modified) (1 diff)
- branches/0.8/license.txt (copied) (copied from trunk/license.txt)
- branches/0.8/profile-edit.php (modified) (2 diffs)
- branches/0.8/profile.php (modified) (1 diff)
- branches/0.8/readme.txt (copied) (copied from trunk/readme.txt)
- branches/0.8/register.php (modified) (2 diffs)
- branches/0.8/rss.php (modified) (1 diff)
- branches/0.8/search.php (modified) (1 diff)
- branches/0.8/tag-add.php (modified) (1 diff)
- branches/0.8/topic.php (modified) (1 diff)
- branches/0.8/view.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.8/bb-admin/admin-ajax.php
r830 r995 36 36 $tag_name = rawurldecode($tag_name); 37 37 $x = new WP_Ajax_Response(); 38 foreach ( add_topic_tags( $topic_id, $tag_name ) as $tag_id ) {39 if ( !is_numeric($tag_id) || !$tag = get_tag( $tag_id, bb_get_current_user_info( 'id' ), $topic->topic_id ) )40 if ( !$tag = get_tag( $tag_id ) )38 foreach ( bb_add_topic_tags( $topic_id, $tag_name ) as $tag_id ) { 39 if ( !is_numeric($tag_id) || !$tag = bb_get_tag( $tag_id, bb_get_current_user_info( 'id' ), $topic->topic_id ) ) 40 if ( !$tag = bb_get_tag( $tag_id ) ) 41 41 continue; 42 42 $tag_id_val = $tag->tag_id . '_' . $tag->user_id; … … 45 45 'what' => 'tag', 46 46 'id' => $tag_id_val, 47 'data' => "<li id='tag-$tag_id_val'><a href='" . bb_get_tag_link() . "' rel='tag'>$tag->raw_tag</a> " . get_tag_remove_link() . '</li>'47 'data' => "<li id='tag-$tag_id_val'><a href='" . bb_get_tag_link() . "' rel='tag'>$tag->raw_tag</a> " . bb_get_tag_remove_link() . '</li>' 48 48 ) ); 49 49 } … … 61 61 die('-1'); 62 62 63 $tag = get_tag( $tag_id );63 $tag = bb_get_tag( $tag_id ); 64 64 $user = bb_get_user( $user_id ); 65 65 $topic = get_topic ( $topic_id ); … … 111 111 die('1'); 112 112 break; 113 113 /* 114 114 case 'add-post' : // Can put last_modified stuff back in later 115 115 $error = false; … … 150 150 $x->send(); 151 151 break; 152 152 */ 153 153 case 'add-forum' : 154 154 if ( !bb_current_user_can( 'manage_forums' ) ) … … 164 164 'what' => 'forum', 165 165 'id' => $forum_id, 166 'data' => bb_forum_row( $forum_id, false )166 'data' => bb_forum_row( $forum_id, false, true ) 167 167 ) ); 168 168 $x->send(); branches/0.8/bb-admin/admin-functions.php
r867 r995 155 155 156 156 function bb_get_recently_moderated_objects( $num = 5 ) { 157 global $bbdb;158 $ posts = (array) bb_get_deleted_posts( 1, $num, -1 ); // post_time != moderation_time;159 $topics = (array) $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE topic_status <> 0 ORDER BY topic_time DESC LIMIT $num"); // topic_time == topic_start_time != moderation_time; 157 $post_query = new BB_Query( 'post', array( 'per_page' => $num, 'post_status' => '-normal', 'topic_status' => 0 ) ); // post_time != moderation_time; 158 $topic_query = new BB_Query( 'topic', array( 'per_page' => $num, 'topic_status' => '-normal' ) ); // topic_time == topic_start_time != moderation_time; 159 160 160 $objects = array(); 161 foreach ( array_keys($posts) as $key ) 162 $objects[bb_gmtstrtotime($posts[$key]->post_time)] = array('type' => 'post', 'data' => $posts[$key]); 163 foreach ( array_keys($topics) as $key ) 164 $objects[bb_gmtstrtotime($topics[$key]->topic_time)] = array('type' => 'topic', 'data' => $topics[$key]); 161 if ( $post_query->results ) 162 foreach ( array_keys($post_query->results) as $key ) 163 $objects[bb_gmtstrtotime($post_query->results[$key]->post_time)] = array('type' => 'post', 'data' => $post_query->results[$key]); 164 if ( $topic_query->results ) 165 foreach ( array_keys($topic_query->results) as $key ) 166 $objects[bb_gmtstrtotime($topic_query->results[$key]->topic_time)] = array('type' => 'topic', 'data' => $topic_query->results[$key]); 165 167 krsort($objects); 166 168 return array_slice($objects, 0, $num); … … 173 175 $sort = $sort ? 'DESC' : 'ASC'; 174 176 $key = $bb_table_prefix . 'capabilities'; 177 178 $role = $bbdb->escape_deep($role); 179 175 180 if ( is_array($role) ) 176 181 $and_where = "( meta_value LIKE '%" . join("%' OR meta_value LIKE '%", $role) . "%' )"; … … 178 183 $and_where = "meta_value LIKE '%$role%'"; 179 184 $bb_last_countable_query = "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = '$key' AND $and_where ORDER BY user_id $sort" . $limit_str; 180 if ( $ids = (array) $bbdb->get_col($bb_last_countable_query) ) 185 186 if ( $ids = (array) $bbdb->get_col( $bb_last_countable_query ) ) 181 187 bb_cache_users( $ids ); 182 188 return $ids; … … 398 404 /* Forums */ 399 405 406 // Expects forum_name, forum_desc to be pre-escaped 400 407 function bb_new_forum( $args ) { 401 408 global $bbdb, $bb_cache; … … 414 421 415 422 if ( !is_numeric($forum_order) ) 416 $forum_order = $bbdb->get_var("SELECT MAX(forum_order) FROM $bbdb->forums") + 1;423 $forum_order = (int) $bbdb->get_var("SELECT MAX(forum_order) FROM $bbdb->forums") + 1; 417 424 418 425 $forum_order = (int) $forum_order; 419 426 $forum_parent = (int) $forum_parent; 420 if ( strlen($forum_name) < 1 )421 return false;422 427 423 428 $forum_name = apply_filters( 'bb_pre_forum_name', stripslashes($forum_name) ); … … 428 433 $forum_desc = $bbdb->escape( $forum_desc ); 429 434 435 if ( strlen($forum_name) < 1 ) 436 return false; 437 430 438 $forum_slug = $_forum_slug = bb_slug_sanitize($forum_name); 431 439 while ( is_numeric($forum_slug) || $existing_slug = $bbdb->get_var("SELECT forum_slug FROM $bbdb->forums WHERE forum_slug = '$forum_slug'") ) … … 437 445 } 438 446 447 // Expects forum_name, forum_desc to be pre-escaped 439 448 function bb_update_forum( $args ) { 440 449 global $bbdb, $bb_cache; … … 457 466 $forum_order = (int) $forum_order; 458 467 $forum_parent = (int) $forum_parent; 468 469 $forum_name = apply_filters( 'bb_pre_forum_name', stripslashes($forum_name) ); 470 $forum_desc = apply_filters( 'bb_pre_forum_desc', stripslashes($forum_desc) ); 471 $forum_name = bb_trim_for_db( $forum_name, 150 ); 472 473 $forum_name = $bbdb->escape( $forum_name ); 474 $forum_desc = $bbdb->escape( $forum_desc ); 475 459 476 if ( strlen($forum_name) < 1 ) 460 477 return false; 478 461 479 $bb_cache->flush_many( 'forum', $forum_id ); 462 480 $bb_cache->flush_one( 'forums' ); … … 470 488 return false; 471 489 if ( !$forum_id = (int) $forum_id ) 490 return false; 491 492 if ( !$forum = get_forum( $forum_id ) ) 472 493 return false; 473 494 … … 479 500 } 480 501 502 $bbdb->query( "UPDATE $bbdb->forums SET forum_parent = '$forum->forum_parent' WHERE forum_parent = '$forum_id'" ); 503 481 504 $return = $bbdb->query("DELETE FROM $bbdb->forums WHERE forum_id = $forum_id"); 482 505 … … 492 515 } 493 516 494 function bb_forum_adminlistitems($forums, $depth = 0, $hierarchical = true) { 495 echo apply_filters('bb_get_forum_rows', bb_get_forum_adminlistitems($forums, $depth, $hierarchical)); 496 } 497 498 function bb_get_forum_adminlistitems($forums, $depth = 0, $hierarchical = true) { 499 $args = array( 500 $forums, 501 $depth, 502 array( 503 'hierarchical' => $hierarchical 504 ) 505 ); 506 507 $walker = new BB_Walker_ForumAdminlistitems(); 508 return call_user_func_array(array(&$walker, 'walk'), $args); 509 } 510 511 function bb_forum_row( $forum_id = 0, $echo = true, $close = true, $class = 'forum' ) { 517 function bb_forum_row( $forum_id = 0, $echo = true, $close = false ) { 512 518 global $forum, $forums_count; 513 519 if ( $forum_id ) … … 519 525 return; 520 526 521 $r = "\t<li id='forum-$_forum->forum_id'" . get_alt_class( 'forum', "$class clear list-block" ) . ">\n"; 522 $r .= "\t\t<div class='list-block posrel'>"; 527 $r = ''; 528 if ( $close ) 529 $r .= "\t<li id='forum-$_forum->forum_id'" . get_alt_class( 'forum', 'forum clear list-block' ) . ">\n"; 530 $r .= "\t\t<div class='list-block posrel'>\n"; 523 531 $r .= "\t\t\t<div class='alignright'>\n"; 524 532 if ( bb_current_user_can( 'manage_forums' ) ) … … 551 559 <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> 552 560 </tr> 553 <tr ><th scope="row"><?php _e('Forum Parent:'); ?></th>554 <td><?php bb_forum_dropdown( array('c allback' => 'strcmp', 'callback_args' => array($forum_id), 'id' => 'forum_parent', 'none' => true, 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0) ); ?></td>561 <tr id="forum-parent-row"><th scope="row"><?php _e('Forum Parent:'); ?></th> 562 <td><?php bb_forum_dropdown( array('cut_branch' => $forum_id, 'id' => 'forum_parent', 'none' => true, 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0) ); ?></td> 555 563 </tr> 556 <tr ><th scope="row"><?php _e('Position:'); ?></th>564 <tr id="forum-position-row"><th scope="row"><?php _e('Position:'); ?></th> 557 565 <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> 558 566 </tr> … … 576 584 var $db_fields = array ('parent' => 'forum_parent', 'id' => 'forum_id'); //TODO: decouple this 577 585 578 // Hack to get forum id into start_lvl579 var $forum_indexed;580 var $forum_position = -1;581 582 function BB_Walker_ForumAdminlistitems() {583 global $forums;584 // Hack to get forum id into start_lvl585 $this->forum_indexed = array_values($forums);586 }587 588 586 function start_lvl($output, $depth) { 589 // Hack to get forum id into start_lvl 590 $forum_id = $this->forum_indexed[$this->forum_position]->forum_id; 591 592 $indent = str_repeat("\t", $depth); 593 $output .= $indent . "<ul id=\"forum-root-" . $forum_id . "\" class=\"list-block holder\">\n"; 587 $indent = str_repeat("\t", $depth) . ' '; 588 $output .= $indent . "<ul id='forum-root-$this->forum_id' class='list-block holder'>\n"; 594 589 return $output; 595 590 } 596 591 597 592 function end_lvl($output, $depth) { 598 $indent = str_repeat("\t", $depth) ;593 $indent = str_repeat("\t", $depth) . ' '; 599 594 $output .= $indent . "</ul>\n"; 600 595 return $output; 601 596 } 602 597 603 function start_el($output, $forum, $depth, $args) { 604 global $forums_count; 605 606 extract($args, EXTR_SKIP); 607 608 $indent = str_repeat("\t", $depth); 609 610 $output .= $indent . "\t<li id=\"forum-" . $forum->forum_id . "\"" . get_alt_class('forum', 'forum clear list-block') . ">\n"; 611 $output .= $indent . "\t\t<div class=\"list-block posrel\">\n"; 612 $output .= $indent . "\t\t\t<div class=\"alignright\">\n"; 613 if (bb_current_user_can('manage_forums')) { 614 $edit_href = attribute_escape(bb_get_option('uri') . "bb-admin/content-forums.php?action=edit&id=" . $forum->forum_id); 615 $output .= $indent . "\t\t\t\t<a class=\"edit\" href=\"" . $edit_href . "\">" . __('Edit') . "</a>\n"; 616 } 617 if (bb_current_user_can('delete_forum', $forum->forum_id) && 1 < $forums_count) { 618 $delete_href = attribute_escape(bb_get_option('uri') . "bb-admin/content-forums.php?action=delete&id=" . $forum->forum_id); 619 $output .= $indent . "\t\t\t\t<a class=\"delete\" href=\"" . $delete_href . "\">" . __('Delete') . "</a>\n"; 620 } 621 $output .= $indent . "\t\t\t</div>\n"; 622 $output .= $indent . "\t\t\t" . get_forum_name($forum->forum_id) . " — " . get_forum_description($forum->forum_id) . "\n"; 623 $output .= $indent . "\t\t</div>\n"; 624 625 // Hack to get forum id into start_lvl 626 $this->forum_position++; 627 598 function start_el($output, $forum, $depth) { 599 $this->forum_id = $forum->forum_id; 600 $indent = str_repeat("\t", $depth + 1); 601 $output .= $indent . "<li id='forum-$this->forum_id'" . get_alt_class( 'forum', 'forum clear list-block' ) . ">\n"; 602 628 603 return $output; 629 604 } 630 605 631 function end_el($output, $forum, $depth , $args) {632 $indent = str_repeat("\t", $depth );633 $output .= $indent . " \t</li>\n";606 function end_el($output, $forum, $depth) { 607 $indent = str_repeat("\t", $depth + 1); 608 $output .= $indent . "</li>\n"; 634 609 return $output; 635 610 } … … 638 613 /* Tags */ 639 614 615 // Expects $tag to be pre-escaped 640 616 function rename_tag( $tag_id, $tag ) { 641 617 global $bbdb; 642 618 if ( !bb_current_user_can( 'manage_tags' ) ) 643 619 return false; 644 $raw_tag = $tag; 620 621 $tag_id = (int) $tag_id; 622 $raw_tag = bb_trim_for_db( $tag, 50 ); 645 623 $tag = tag_sanitize( $tag ); 646 624 … … 650 628 return false; 651 629 652 $old_tag = get_tag( $tag_id );630 $old_tag = bb_get_tag( $tag_id ); 653 631 654 632 if ( $bbdb->query("UPDATE $bbdb->tags SET tag = '$tag', raw_tag = '$raw_tag' WHERE tag_id = '$tag_id'") ) { 655 633 do_action('bb_tag_renamed', $tag_id, $old_tag->raw_tag, $raw_tag ); 656 return get_tag( $tag_id );634 return bb_get_tag( $tag_id ); 657 635 } 658 636 return false; … … 664 642 if ( !bb_current_user_can( 'manage_tags' ) ) 665 643 return false; 644 645 $old_id = (int) $old_id; 646 $new_id = (int) $new_id; 647 666 648 if ( $old_id == $new_id ) 667 649 return false; … … 672 654 if ( $old_topic_ids = (array) $bbdb->get_col( "SELECT topic_id FROM $bbdb->tagged WHERE tag_id = '$old_id'" ) ) { 673 655 $old_topic_ids = join(',', $old_topic_ids); 674 $shared_topics_u = (array) $bbdb->get_col( "SELECT user_id, topic_id FROM $bbdb->tagged WHERE tag_id = '$new_id' AND topic_id IN ($old_topic_ids)" ); 675 $shared_topics_i = (array) $bbdb->get_col( '', 1 ); 676 foreach ( $shared_topics_i as $t => $topic_id ) { 677 $tagged_del += $bbdb->query( "DELETE FROM $bbdb->tagged WHERE tag_id = '$old_id' AND user_id = '{$shared_topics_u[$t]}' AND topic_id = '$topic_id'" ); 678 $count = $bbdb->get_var( "SELECT COUNT(DISTINCT tag_id) FROM $bbdb->tagged WHERE topic_id = '$topic_id' GROUP BY topic_id" ); 679 $bbdb->query( "UPDATE $bbdb->topics SET tag_count = $count WHERE topic_id = '$topic_id'" ); 656 $shared_topics = (array) $bbdb->get_results( "SELECT user_id, topic_id FROM $bbdb->tagged WHERE tag_id = '$new_id' AND topic_id IN ($old_topic_ids)" ); 657 foreach ( $shared_topics as $st ) { 658 $tagged_del += $bbdb->query( "DELETE FROM $bbdb->tagged WHERE tag_id = '$old_id' AND user_id = '$st->user_id' AND topic_id = '$st->topic_id'" ); 659 $count = (int) $bbdb->get_var( "SELECT COUNT(DISTINCT tag_id) FROM $bbdb->tagged WHERE topic_id = '$st->topic_id' GROUP BY topic_id" ); 660 $bbdb->query( "UPDATE $bbdb->topics SET tag_count = $count WHERE topic_id = '$st->topic_id'" ); 680 661 } 681 662 } 682 663 683 664 if ( $diff_count = $bbdb->query( "UPDATE $bbdb->tagged SET tag_id = '$new_id' WHERE tag_id = '$old_id'" ) ) { 684 $count = $bbdb->get_var( "SELECT COUNT(DISTINCT topic_id) FROM $bbdb->tagged WHERE tag_id = '$new_id' GROUP BY tag_id" );665 $count = (int) $bbdb->get_var( "SELECT COUNT(DISTINCT topic_id) FROM $bbdb->tagged WHERE tag_id = '$new_id' GROUP BY tag_id" ); 685 666 $bbdb->query( "UPDATE $bbdb->tags SET tag_count = $count WHERE tag_id = '$new_id'" ); 686 667 } 687 668 688 669 // return values and destroy the old tag 689 return array( 'destroyed' => destroy_tag( $old_id, false ), 'old_count' => $diff_count + $tagged_del, 'diff_count' => $diff_count );670 return array( 'destroyed' => bb_destroy_tag( $old_id, false ), 'old_count' => $diff_count + $tagged_del, 'diff_count' => $diff_count ); 690 671 } 691 672 692 673 /* Topics */ 693 694 function bb_get_deleted_topics_count() {695 global $bbdb;696 return $bbdb->get_var("SELECT COUNT(*) FROM $bbdb->topics WHERE topic_status <> 0");697 }698 674 699 675 function bb_move_forum_topics( $from_forum_id, $to_forum_id ) { … … 731 707 732 708 /* Posts */ 733 734 function bb_get_deleted_posts( $page = 1, $limit = false, $status = 1, $topic_status = 0 ) {735 global $bbdb;736 $page = (int) $page;737 $status = (int) $status;738 if ( !$limit )739 $limit = bb_get_option('page_topics');740 if ( 1 < $page )741 $limit = ($limit * ($page - 1)) . ", $limit";742 if ( false === $topic_status )743 $where = '';744 else {745 $topic_status = (int) $topic_status;746 $where = "topic_status = '$topic_status' AND";747 }748 $status = ( 0 < $status ) ? "= '$status'" : "> '0'";749 return $bbdb->get_results("SELECT $bbdb->posts.* FROM $bbdb->posts LEFT JOIN $bbdb->topics USING (topic_id) WHERE $where post_status $status ORDER BY post_time DESC LIMIT $limit");750 }751 709 752 710 function bb_admin_list_posts() { branches/0.8/bb-admin/admin.php
r683 r995 8 8 9 9 require('admin-functions.php'); 10 require('admin-deprecated.php'); 10 11 11 12 nocache_headers(); branches/0.8/bb-admin/bb-do-counts.php
r612 r995 16 16 if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ): 17 17 echo "\t<li>\n"; 18 if ( $topics = (array) $bbdb->get_ col("SELECT topic_id, COUNT(post_id)FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) :18 if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) : 19 19 echo "\t\t" . __('Counting posts...') . "<br />\n"; 20 $counts = (array) $bbdb->get_col('', 1); 21 foreach ($topics as $t => $i) 22 $bbdb->query("UPDATE $bbdb->topics SET topic_posts = '{$counts[$t]}' WHERE topic_id = $i"); 23 unset($topics, $t, $i, $counts); 20 foreach ($topics as $topic) 21 $bbdb->query("UPDATE $bbdb->topics SET topic_posts = '$topic->count' WHERE topic_id = '$topic->topic_id'"); 22 unset($topics, $topic); 24 23 endif; 25 24 echo "\t\t" . __('Done counting posts.'); … … 31 30 $old = (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key = 'deleted_posts'"); 32 31 $old = array_flip($old); 33 if ( $topics = (array) $bbdb->get_ col("SELECT topic_id, COUNT(post_id)FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) :32 if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) : 34 33 echo "\t\t" . __('Counting deleted posts...') . "<br />\n"; 35 $counts = (array) $bbdb->get_col('', 1); 36 foreach ( $topics as $t => $i ) : 37 bb_update_topicmeta( $i, 'deleted_posts', $counts[$t] ); 38 unset($old[$i]); 34 foreach ( $topics as $topic ) : 35 bb_update_topicmeta( $topic->topic_id, 'deleted_posts', $topic->count ); 36 unset($old[$topic->topic_id]); 39 37 endforeach; 40 unset($topics, $t , $i, $counts);38 unset($topics, $topic); 41 39 endif; 42 40 if ( $old ) : … … 58 56 WHERE topic_status = 0 GROUP BY forum_id"); 59 57 foreach ( (array) $forums as $forum ) : 60 $bbdb->query("UPDATE $bbdb->forums SET topics = $forum->topic_count, posts = $forum->post_count WHERE forum_id = $forum->forum_id");58 $bbdb->query("UPDATE $bbdb->forums SET topics = '$forum->topic_count', posts = '$forum->post_count' WHERE forum_id = '$forum->forum_id'"); 61 59 unset($all_forums[$forum->forum_id]); 62 60 endforeach; … … 85 83 if ( isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count'] ) : 86 84 echo "\t<li>\n"; 87 if ( $topics = (array) $bbdb->get_ col("SELECT topic_id, COUNT(DISTINCT tag_id)FROM $bbdb->tagged GROUP BY topic_id") ) :85 if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(DISTINCT tag_id) AS count FROM $bbdb->tagged GROUP BY topic_id") ) : 88 86 echo "\t\t" . __('Counting topic tags...') . "<br />\n"; 89 $counts = (array) $bbdb->get_col('', 1); 90 foreach ( $topics as $t => $i) 91 $bbdb->query("UPDATE $bbdb->topics SET tag_count = '{$counts[$t]}' WHERE topic_id = $i"); 92 $not_tagged = array_diff( (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topics"), $topics); 93 foreach ( $not_tagged as $i ) 94 $bbdb->query("UPDATE $bbdb->topics SET tag_count = 0 WHERE topic_id = $i"); 95 unset($topics, $t, $i, $counts, $not_tagged); 87 $topic_col = array_flip( (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topics") ); 88 foreach ( $topics as $topic ) { 89 $bbdb->query("UPDATE $bbdb->topics SET tag_count = '$topic->count' WHERE topic_id = '$topic->topic_id'"); 90 unset($topic_col[$topic->topic_id]); 91 } 92 foreach ( $topic_col as $id => $i ) 93 $bbdb->query("UPDATE $bbdb->topics SET tag_count = 0 WHERE topic_id = '$id'"); 94 unset($topics, $topic, $topic_col, $id, $i); 96 95 endif; 97 96 echo "\t\t" . __('Done counting topic tags.'); … … 101 100 if ( isset($_POST['tags-tag-count']) && 1 == $_POST['tags-tag-count'] ) : 102 101 echo "\t<li>\n"; 103 if ( $tags = (array) $bbdb->get_ col("SELECT tag_id, COUNT(DISTINCT topic_id)FROM $bbdb->tagged GROUP BY tag_id") ) :102 if ( $tags = (array) $bbdb->get_results("SELECT tag_id, COUNT(DISTINCT topic_id) AS count FROM $bbdb->tagged GROUP BY tag_id") ) : 104 103 echo "\t\t" . __('Counting tagged topics...') . "<br />\n"; 105 $counts = (array) $bbdb->get_col('', 1); 106 foreach ( $tags as $t => $i ) 107 $bbdb->query("UPDATE $bbdb->tags SET tag_count = '{$counts[$t]}' WHERE tag_id = $i"); 108 $not_tagged = array_diff((array) $bbdb->get_col("SELECT tag_id FROM $bbdb->tags"), $tags); 109 foreach ( $not_tagged as $i ) 110 $bbdb->query("UPDATE $bbdb->tags SET tag_count = 0 WHERE tag_id = $i"); 111 unset($tags, $t, $i, $counts, $not_tagged); 104 $tag_col = array_flip( (array) $bbdb->get_col("SELECT tag_id FROM $bbdb->tags") ); 105 foreach ( $tags as $tag ) { 106 $bbdb->query("UPDATE $bbdb->tags SET tag_count = '$tag->count' WHERE tag_id = '$tag->tag_id'"); 107 unset($tag_col[$tag->tag_id]); 108 } 109 foreach ( $tag_col as $id => $i ) 110 $bbdb->query("UPDATE $bbdb->tags SET tag_count = 0 WHERE tag_id = '$id'"); 111 unset($tags, $tag, $tag_col, $id, $i); 112 112 else : 113 113 $bbdb->query("UPDATE $bbdb->tags SET tag_count = 0"); branches/0.8/bb-admin/content-forums.php
r826 r995 47 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 /> 48 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> 49 <?php $forums = get_forums( 'strcmp', array($deleted_forum->forum_id) ); ?> 50 <select name="move_topics_forum" id="move-topics-forum"> 51 <?php foreach ($forums as $forum ) : ?> 52 <option value="<?php forum_id(); ?>"><?php forum_name(); ?></option> 53 <?php endforeach; ?> 54 </select> 55 49 <?php bb_forum_dropdown( array('id' => 'move_topics_forum', 'callback' => 'strcmp', 'callback_args' => array($deleted_forum->forum_id), 'selected' => $deleted_forum->forum_parent) ); ?> 56 50 </p> 57 51 <p class="submit alignright"> … … 70 64 <?php break; default : ?> 71 65 72 <?php if ( $forums ) : ?>73 66 67 <?php if ( bb_forums( 'type=list&walker=BB_Walker_ForumAdminlistitems' ) ) : ?> 74 68 <ul id="the-list" class="list-block holder"> 75 <li class="thead list-block"><div class="list-block">Name — Description</div></li> 76 <?php 77 bb_forum_adminlistitems($forums); 78 ?> 69 <li class="thead list-block"><div class="list-block"><?php _e('Name — Description'); ?></div></li> 70 <?php while ( bb_forum() ) : ?> 71 <?php bb_forum_row(); ?> 72 <?php endwhile; ?> 73 <?php endif; // bb_forums() ?> 79 74 </ul> 80 <?php endif; // $forums ?>81 75 82 76 <h3><?php _e('Add Forum'); ?></h3> branches/0.8/bb-admin/content-posts.php
r792 r995 7 7 add_filter( 'get_topic_where', 'no_where' ); 8 8 add_filter( 'get_topic_link', 'bb_make_link_view_all' ); 9 $bb_posts = bb_get_deleted_posts( $page ); 10 $total = bb_count_last_query(); 9 $post_query = new BB_Query_Form( 'post', array( 'post_status' => 1, 'count' => true ) ); 10 $bb_posts =& $post_query->results; 11 $total = $post_query->found_rows; 11 12 ?> 12 13 13 <h2><?php _e('Deleted Posts'); ?></h2> 14 <h2><?php 15 $h2_search = $post_query->get( 'post_text' ); 16 $h2_forum = $post_query->get( 'forum_id' ); 17 $h2_tag = $post_query->get( 'tag_id' ); 18 $h2_author = $post_query->get( 'post_author_id' ); 19 $h2_status = $post_query->get( 'post_status' ); 20 21 $h2_search = $h2_search ? ' ' . sprintf( __('matching “%s”'), wp_specialchars( $h2_search ) ) : ''; 22 $h2_forum = $h2_forum ? ' ' . sprintf( __('in “%s”') , get_forum_name( $h2_forum ) ) : ''; 23 $h2_tag = $h2_tag ? ' ' . sprintf( __('with tag “%s”'), wp_specialchars( bb_get_tag_name( $h2_tag ) ) ) : ''; 24 $h2_author = $h2_author ? ' ' . sprintf( __('by %s') , wp_specialchars( get_user_name( $h2_author ) ) ) : ''; 25 26 $stati = array( 0 => __('Normal') . ' ', 1 => __('Deleted') . ' ', 'all' => '' ); 27 28 if ( 'all' == $h2_status ) 29 $h2_noun = __('Posts'); 30 else 31 $h2_noun = sprintf( __( '%1$sposts'), $stati[$h2_status], $topic_open[$h2_open] ); 32 33 printf( __( '%1$s%2$s%3$s%4$s%5$s' ), $h2_noun, $h2_search, $h2_forum, $h2_tag, $h2_author ); 34 35 ?></h2> 36 37 <?php $post_query->form( array('tag' => true, 'post_author' => true, 'post_status' => true, 'submit' => __('Filter »')) ); ?> 38 39 <br class="clear" /> 14 40 15 41 <ol id="the-list"> branches/0.8/bb-admin/content.php
r792 r995 2 2 <?php bb_get_admin_header(); ?> 3 3 4 <?php if ( !bb_current_user_can('browse_deleted') ) 4 <?php 5 if ( !bb_current_user_can('browse_deleted') ) 5 6 die(__("Now how'd you get here? And what did you think you'd being doing?")); //This should never happen. 6 add_filter( 'get_latest_topics_where', 'deleted_topics' );7 7 add_filter( 'topic_link', 'bb_make_link_view_all' ); 8 $topics = get_latest_topics( 0, $page ); 8 $topic_query_vars = array('topic_status' => 1, 'open' => 'all', 'count' => true); 9 if ( isset($_REQUEST['search']) && $_REQUEST['search'] ) 10 $topic_query_vars['post_status'] = 'all'; 11 $topic_query = new BB_Query_Form( 'topic', $topic_query_vars ); 12 $topics = $topic_query->results; 9 13 ?> 10 14 11 <h2><?php _e('Deleted Topics') ?></h2> 15 <h2><?php 16 $h2_search = $topic_query->get( 'search' ); 17 $h2_forum = $topic_query->get( 'forum_id' ); 18 $h2_tag = $topic_query->get( 'tag_id' ); 19 $h2_author = $topic_query->get( 'topic_author_id' ); 20 $h2_status = $topic_query->get( 'topic_status' ); 21 $h2_open = $topic_query->get( 'open' ); 22 23 $h2_search = $h2_search ? ' ' . sprintf( __('matching “%s”'), wp_specialchars( $h2_search ) ) : ''; 24 $h2_forum = $h2_forum ? ' ' . sprintf( __('in “%s”') , get_forum_name( $h2_forum ) ) : ''; 25 $h2_tag = $h2_tag ? ' ' . sprintf( __('with tag “%s”'), wp_specialchars( bb_get_tag_name( $h2_tag ) ) ) : ''; 26 $h2_author = $h2_author ? ' ' . sprintf( __('by %s') , wp_specialchars( get_user_name( $h2_author ) ) ) : ''; 27 28 $topic_stati = array( 0 => __('Normal') . ' ', 1 => __('Deleted') . ' ', 'all' => '' ); 29 $topic_open = array( 0 => __('Closed') . ' ', 1 => __('Open') . ' ' , 'all' => '' ); 30 31 if ( 'all' == $h2_status && 'all' == $h2_open ) 32 $h2_noun = __('Topics'); 33 else 34 $h2_noun = sprintf( __( '%1$s%2$stopics'), $topic_stati[$h2_status], $topic_open[$h2_open] ); 35 36 printf( __( '%1$s%2$s%3$s%4$s%5$s' ), $h2_noun, $h2_search, $h2_forum, $h2_tag, $h2_author ); 37 38 ?></h2> 39 40 <?php $topic_query->form( array('tag' => true, 'topic_author' => true, 'topic_status' => true, 'open' => true, 'submit' => __('Filter »')) ); ?> 41 42 <br class="clear" /> 12 43 13 44 <table class="widefat"> … … 20 51 <?php if ( $topics ) : foreach ( $topics as $topic ) : ?> 21 52 <tr<?php alt_class('topic'); ?>> 22 <td>< a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>53 <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td> 23 54 <td class="num"><?php topic_last_poster(); ?></td> 24 55 <td class="num"><small><?php topic_time(); ?></small></td> 25 56 </tr> 26 <?php endforeach; endif; ?> 57 <?php endforeach; else : ?> 58 <tr> 59 <td colspan="3"><?php _e('No Topics Found'); ?></td> 60 </tr> 61 <?php endif; ?> 27 62 </table> 28 63 29 <?php $total = bb_get_deleted_topics_count(); echo get_page_number_links( $page, $total); ?>64 <?php echo get_page_number_links( $page, $topic_query->found_rows ); ?> 30 65 31 66 <?php bb_get_admin_footer(); ?> branches/0.8/bb-admin/export.php
r735 r995 207 207 return; 208 208 209 if ( !$tags = get_topic_tags( $topic_id ) )209 if ( !$tags = bb_get_topic_tags( $topic_id ) ) 210 210 return $r; 211 211 branches/0.8/bb-admin/index.php
r817 r995 13 13 </ul> 14 14 15 <?php if ( $objects = bb_get_recently_moderated_objects() ) : ?> 15 16 <h3><?php _e('Recently Moderated'); ?></h3> 16 17 <ul class="posts"> 17 <?php if ( $objects = bb_get_recently_moderated_objects() ) :add_filter( 'get_topic_where', 'no_where' ); foreach ( $objects as $object ) : ?>18 <?php add_filter( 'get_topic_where', 'no_where' ); foreach ( $objects as $object ) : ?> 18 19 <?php if ( 'post' == $object['type'] ) : global $bb_post; $bb_post = $object['data']; ?> 19 20 <li><a href="<?php echo attribute_escape( add_query_arg( 'view', 'all', get_post_link() ) ); ?>"><?php _e('Post'); ?></a> <?php _e('on'); ?> <a href="<?php topic_link( $bb_post->topic_id ); ?>"><?php topic_title( $bb_post->topic_id ); ?></a> <?php _e('by'); ?> <a href="<?php user_profile_link( $bb_post->poster_id ); ?>"><?php post_author(); ?></a>.</li> 20 21 <?php elseif ( 'topic' == $object['type'] ) : global $topic; $topic = $object['data']; ?> 21 22 <li><?php _e('Topic titled'); ?> <a href="<?php echo attribute_escape( add_query_arg( 'view', 'all', get_topic_link() ) ); ?>"><?php topic_title(); ?></a> <?php _e('started by'); ?> <a href="<?php user_profile_link( $topic->topic_poster ); ?>"><?php topic_author(); ?></a>.</li> 22 <?php endif; endforeach; remove_filter( 'get_topic_where', 'no_where' ); endif;?>23 <?php endif; endforeach; remove_filter( 'get_topic_where', 'no_where' ); ?> 23 24 </ul> 25 <?php endif; ?> 26 24 27 </div> 25 26 28 <div id="bb-statistics"> 27 29 <h3><?php _e('Statistics'); ?></h3> branches/0.8/bb-admin/install.php
r792 r995 279 279 bb_new_post(1, __('First Post! w00t.')); 280 280 281 $message_headers = 'From: ' . $forum_name . ' <' . bb_get_option( 'admin_email' ) . '>';282 281 $message = sprintf(__("Your new bbPress site has been successfully set up at: 283 282 … … 295 294 "), bb_get_option( 'uri' ), $admin_login, $password); 296 295 297 @mail(bb_get_option( 'admin_email' ), __('New bbPress installation'), $message, $message_headers);?>296 bb_mail(bb_get_option( 'admin_email' ), __('New bbPress installation'), $message);?> 298 297 299 298 <p><em><?php _e('Finished!'); ?></em></p> branches/0.8/bb-admin/js/content-forums.js
r745 r995 63 63 this.saveText = div.childNodes[0].nodeValue; 64 64 div = null; 65 66 $('#forum-parent-row, #forum-position-row').remove(); 65 67 66 68 $('#add-forum').submit( function() { branches/0.8/bb-admin/plugins.php
r835 r995 3 3<