Changeset 995

Show
Ignore:
Timestamp:
01/03/08 00:57:27 (11 months ago)
Author:
mdawaffe
Message:

bring branches/0.8 in line with trunk@971

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.8/bb-admin/admin-ajax.php

    r830 r995  
    3636        $tag_name = rawurldecode($tag_name); 
    3737        $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 ) ) 
    4141                                continue; 
    4242                $tag_id_val = $tag->tag_id . '_' . $tag->user_id; 
     
    4545                        'what' => 'tag', 
    4646                        '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>'  
    4848                ) ); 
    4949        } 
     
    6161                die('-1'); 
    6262 
    63         $tag   = get_tag( $tag_id ); 
     63        $tag   = bb_get_tag( $tag_id ); 
    6464        $user  = bb_get_user( $user_id ); 
    6565        $topic = get_topic ( $topic_id ); 
     
    111111                die('1'); 
    112112        break; 
    113  
     113/* 
    114114case 'add-post' : // Can put last_modified stuff back in later 
    115115        $error = false; 
     
    150150        $x->send(); 
    151151        break; 
    152  
     152*/ 
    153153case 'add-forum' : 
    154154        if ( !bb_current_user_can( 'manage_forums' ) ) 
     
    164164                'what' => 'forum', 
    165165                'id' => $forum_id, 
    166                 'data' => bb_forum_row( $forum_id, false
     166                'data' => bb_forum_row( $forum_id, false, true
    167167        ) ); 
    168168        $x->send(); 
  • branches/0.8/bb-admin/admin-functions.php

    r867 r995  
    155155 
    156156function 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 
    160160        $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]); 
    165167        krsort($objects); 
    166168        return array_slice($objects, 0, $num); 
     
    173175        $sort = $sort ? 'DESC' : 'ASC'; 
    174176        $key = $bb_table_prefix . 'capabilities'; 
     177 
     178        $role = $bbdb->escape_deep($role); 
     179 
    175180        if ( is_array($role) ) 
    176181                $and_where = "( meta_value LIKE '%" . join("%' OR meta_value LIKE '%", $role) . "%' )"; 
     
    178183                $and_where = "meta_value LIKE '%$role%'"; 
    179184        $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 ) ) 
    181187                bb_cache_users( $ids ); 
    182188        return $ids; 
     
    398404/* Forums */ 
    399405 
     406// Expects forum_name, forum_desc to be pre-escaped 
    400407function bb_new_forum( $args ) { 
    401408        global $bbdb, $bb_cache; 
     
    414421 
    415422        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; 
    417424 
    418425        $forum_order = (int) $forum_order; 
    419426        $forum_parent = (int) $forum_parent; 
    420         if ( strlen($forum_name) < 1 ) 
    421                 return false; 
    422427 
    423428        $forum_name = apply_filters( 'bb_pre_forum_name', stripslashes($forum_name) ); 
     
    428433        $forum_desc = $bbdb->escape( $forum_desc ); 
    429434 
     435        if ( strlen($forum_name) < 1 ) 
     436                return false; 
     437 
    430438        $forum_slug = $_forum_slug = bb_slug_sanitize($forum_name); 
    431439        while ( is_numeric($forum_slug) || $existing_slug = $bbdb->get_var("SELECT forum_slug FROM $bbdb->forums WHERE forum_slug = '$forum_slug'") ) 
     
    437445} 
    438446 
     447// Expects forum_name, forum_desc to be pre-escaped 
    439448function bb_update_forum( $args ) { 
    440449        global $bbdb, $bb_cache; 
     
    457466        $forum_order = (int) $forum_order; 
    458467        $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 
    459476        if ( strlen($forum_name) < 1 ) 
    460477                return false; 
     478 
    461479        $bb_cache->flush_many( 'forum', $forum_id ); 
    462480        $bb_cache->flush_one( 'forums' ); 
     
    470488                return false; 
    471489        if ( !$forum_id = (int) $forum_id ) 
     490                return false; 
     491 
     492        if ( !$forum = get_forum( $forum_id ) ) 
    472493                return false; 
    473494 
     
    479500        } 
    480501         
     502        $bbdb->query( "UPDATE $bbdb->forums SET forum_parent = '$forum->forum_parent' WHERE forum_parent = '$forum_id'" ); 
     503 
    481504        $return = $bbdb->query("DELETE FROM $bbdb->forums WHERE forum_id = $forum_id"); 
    482505 
     
    492515} 
    493516 
    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' ) { 
     517function bb_forum_row( $forum_id = 0, $echo = true, $close = false ) { 
    512518        global $forum, $forums_count; 
    513519        if ( $forum_id ) 
     
    519525                return; 
    520526 
    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"; 
    523531        $r .= "\t\t\t<div class='alignright'>\n"; 
    524532        if ( bb_current_user_can( 'manage_forums' ) ) 
     
    551559                        <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> 
    552560                </tr> 
    553                 <tr><th scope="row"><?php _e('Forum Parent:'); ?></th> 
    554                         <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> 
     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> 
    555563                </tr> 
    556                 <tr><th scope="row"><?php _e('Position:'); ?></th> 
     564                <tr id="forum-position-row"><th scope="row"><?php _e('Position:'); ?></th> 
    557565                        <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> 
    558566                </tr> 
     
    576584        var $db_fields = array ('parent' => 'forum_parent', 'id' => 'forum_id'); //TODO: decouple this 
    577585         
    578         // Hack to get forum id into start_lvl 
    579         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_lvl 
    585                 $this->forum_indexed = array_values($forums); 
    586         } 
    587          
    588586        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"; 
    594589                return $output; 
    595590        } 
    596591         
    597592        function end_lvl($output, $depth) { 
    598                 $indent = str_repeat("\t", $depth)
     593                $indent = str_repeat("\t", $depth) . '    '
    599594                $output .= $indent . "</ul>\n"; 
    600595                return $output; 
    601596        } 
    602597         
    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) . " &#8212; " . 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 
    628603                return $output; 
    629604        } 
    630605         
    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"; 
    634609                return $output; 
    635610        } 
     
    638613/* Tags */ 
    639614 
     615// Expects $tag to be pre-escaped 
    640616function rename_tag( $tag_id, $tag ) { 
    641617        global $bbdb; 
    642618        if ( !bb_current_user_can( 'manage_tags' ) ) 
    643619                return false; 
    644         $raw_tag = $tag; 
     620 
     621        $tag_id = (int) $tag_id; 
     622        $raw_tag = bb_trim_for_db( $tag, 50 ); 
    645623        $tag     = tag_sanitize( $tag );  
    646624 
     
    650628                return false; 
    651629 
    652         $old_tag = get_tag( $tag_id ); 
     630        $old_tag = bb_get_tag( $tag_id ); 
    653631 
    654632        if ( $bbdb->query("UPDATE $bbdb->tags SET tag = '$tag', raw_tag = '$raw_tag' WHERE tag_id = '$tag_id'") ) { 
    655633                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 ); 
    657635        } 
    658636        return false; 
     
    664642        if ( !bb_current_user_can( 'manage_tags' ) ) 
    665643                return false; 
     644 
     645        $old_id = (int) $old_id; 
     646        $new_id = (int) $new_id; 
     647 
    666648        if ( $old_id == $new_id ) 
    667649                return false; 
     
    672654        if ( $old_topic_ids = (array) $bbdb->get_col( "SELECT topic_id FROM $bbdb->tagged WHERE tag_id = '$old_id'" ) ) { 
    673655                $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'" ); 
    680661                } 
    681662        } 
    682663 
    683664        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" ); 
    685666                $bbdb->query( "UPDATE $bbdb->tags SET tag_count = $count WHERE tag_id = '$new_id'" ); 
    686667        } 
    687668 
    688669        // 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 ); 
    690671} 
    691672 
    692673/* 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 } 
    698674 
    699675function bb_move_forum_topics( $from_forum_id, $to_forum_id ) { 
     
    731707 
    732708/* 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 } 
    751709 
    752710function bb_admin_list_posts() { 
  • branches/0.8/bb-admin/admin.php

    r683 r995  
    88 
    99require('admin-functions.php'); 
     10require('admin-deprecated.php'); 
    1011 
    1112nocache_headers(); 
  • branches/0.8/bb-admin/bb-do-counts.php

    r612 r995  
    1616if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ): 
    1717        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") ) : 
    1919                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); 
    2423        endif; 
    2524        echo "\t\t" . __('Done counting posts.'); 
     
    3130        $old = (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key = 'deleted_posts'"); 
    3231        $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") ) : 
    3433                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]); 
    3937                endforeach; 
    40                 unset($topics, $t, $i, $counts); 
     38                unset($topics, $topic); 
    4139        endif; 
    4240        if ( $old ) : 
     
    5856                        WHERE topic_status = 0 GROUP BY forum_id"); 
    5957                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'"); 
    6159                        unset($all_forums[$forum->forum_id]); 
    6260                endforeach; 
     
    8583if ( isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count'] ) : 
    8684        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") ) : 
    8886                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); 
    9695        endif; 
    9796        echo "\t\t" . __('Done counting topic tags.'); 
     
    101100if ( isset($_POST['tags-tag-count']) && 1 == $_POST['tags-tag-count'] ) : 
    102101        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") ) : 
    104103                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); 
    112112        else : 
    113113                $bbdb->query("UPDATE $bbdb->tags SET tag_count = 0"); 
  • branches/0.8/bb-admin/content-forums.php

    r826 r995  
    4747                        <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 /> 
    4848                        <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) ); ?> 
    5650                </p> 
    5751                <p class="submit alignright"> 
     
    7064<?php break; default : ?> 
    7165 
    72 <?php if ( $forums ) : ?> 
    7366 
     67<?php if ( bb_forums( 'type=list&walker=BB_Walker_ForumAdminlistitems' ) ) : ?> 
    7468<ul id="the-list" class="list-block holder"> 
    75         <li class="thead list-block"><div class="list-block">Name &#8212; Description</div></li> 
    76 <?php 
    77 bb_forum_adminlistitems($forums); 
    78 ?> 
     69        <li class="thead list-block"><div class="list-block"><?php _e('Name &#8212; Description'); ?></div></li> 
     70<?php while ( bb_forum() ) : ?> 
     71<?php bb_forum_row(); ?> 
     72<?php endwhile; ?> 
     73<?php endif; // bb_forums() ?> 
    7974</ul> 
    80 <?php endif; // $forums ?> 
    8175 
    8276<h3><?php _e('Add Forum'); ?></h3> 
  • branches/0.8/bb-admin/content-posts.php

    r792 r995  
    77        add_filter( 'get_topic_where', 'no_where' ); 
    88        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; 
    1112?> 
    1213 
    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 &#8220;%s&#8221;'), wp_specialchars( $h2_search ) ) : ''; 
     22$h2_forum  = $h2_forum  ? ' ' . sprintf( __('in &#8220;%s&#8221;')      , get_forum_name( $h2_forum ) ) : ''; 
     23$h2_tag    = $h2_tag    ? ' ' . sprintf( __('with tag &#8220;%s&#8221;'), 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 
     28if ( 'all' == $h2_status ) 
     29        $h2_noun = __('Posts'); 
     30else 
     31        $h2_noun = sprintf( __( '%1$sposts'), $stati[$h2_status], $topic_open[$h2_open] ); 
     32 
     33printf( __( '%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 &#187;')) ); ?> 
     38 
     39<br class="clear" /> 
    1440 
    1541<ol id="the-list"> 
  • branches/0.8/bb-admin/content.php

    r792 r995  
    22<?php bb_get_admin_header(); ?> 
    33 
    4 <?php   if ( !bb_current_user_can('browse_deleted') ) 
     4<?php 
     5        if ( !bb_current_user_can('browse_deleted') ) 
    56                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' ); 
    77        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; 
    913?> 
    1014 
    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 &#8220;%s&#8221;'), wp_specialchars( $h2_search ) ) : ''; 
     24$h2_forum  = $h2_forum  ? ' ' . sprintf( __('in &#8220;%s&#8221;')      , get_forum_name( $h2_forum ) ) : ''; 
     25$h2_tag    = $h2_tag    ? ' ' . sprintf( __('with tag &#8220;%s&#8221;'), 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 
     31if ( 'all' == $h2_status && 'all' == $h2_open ) 
     32        $h2_noun = __('Topics'); 
     33else 
     34        $h2_noun = sprintf( __( '%1$s%2$stopics'), $topic_stati[$h2_status], $topic_open[$h2_open] ); 
     35 
     36printf( __( '%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 &#187;')) ); ?> 
     41 
     42<br class="clear" /> 
    1243 
    1344<table class="widefat"> 
     
    2051<?php if ( $topics ) : foreach ( $topics as $topic ) : ?> 
    2152<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> 
    2354        <td class="num"><?php topic_last_poster(); ?></td> 
    2455        <td class="num"><small><?php topic_time(); ?></small></td> 
    2556</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; ?> 
    2762</table> 
    2863 
    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 ); ?> 
    3065 
    3166<?php bb_get_admin_footer(); ?> 
  • branches/0.8/bb-admin/export.php

    r735 r995  
    207207                return; 
    208208 
    209         if ( !$tags = get_topic_tags( $topic_id ) ) 
     209        if ( !$tags = bb_get_topic_tags( $topic_id ) ) 
    210210                return $r; 
    211211 
  • branches/0.8/bb-admin/index.php

    r817 r995  
    1313</ul> 
    1414 
     15<?php if ( $objects = bb_get_recently_moderated_objects() ) : ?> 
    1516<h3><?php _e('Recently Moderated'); ?></h3> 
    1617<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 ) : ?> 
    1819<?php if ( 'post' == $object['type'] ) : global $bb_post; $bb_post = $object['data']; ?> 
    1920        <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> 
    2021<?php elseif ( 'topic' == $object['type'] ) : global $topic; $topic = $object['data']; ?> 
    2122        <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' ); ?> 
    2324</ul> 
     25<?php endif; ?> 
     26 
    2427</div> 
    25  
    2628<div id="bb-statistics"> 
    2729<h3><?php _e('Statistics'); ?></h3> 
  • branches/0.8/bb-admin/install.php

    r792 r995  
    279279bb_new_post(1, __('First Post!  w00t.')); 
    280280 
    281 $message_headers = 'From: ' . $forum_name . ' <' . bb_get_option( 'admin_email' ) . '>'; 
    282281$message = sprintf(__("Your new bbPress site has been successfully set up at: 
    283282 
     
    295294"), bb_get_option( 'uri' ), $admin_login, $password); 
    296295 
    297 @mail(bb_get_option( 'admin_email' ), __('New bbPress installation'), $message, $message_headers);?> 
     296bb_mail(bb_get_option( 'admin_email' ), __('New bbPress installation'), $message);?> 
    298297 
    299298<p><em><?php _e('Finished!'); ?></em></p> 
  • branches/0.8/bb-admin/js/content-forums.js

    r745 r995  
    6363                this.saveText = div.childNodes[0].nodeValue; 
    6464                div = null; 
     65 
     66                $('#forum-parent-row, #forum-position-row').remove(); 
    6567 
    6668                $('#add-forum').submit( function() { 
  • branches/0.8/bb-admin/plugins.php

    r835 r995  
    33<