Skip to:
Content

bbPress.org

Changeset 2150


Ignore:
Timestamp:
06/10/2009 02:45:35 PM (17 years ago)
Author:
sambauers
Message:

Add topic voices. Fixes #746. Props nightgunner5.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/bb-do-counts.php

    r2118 r2150  
    3131    }
    3232    echo "\t\t" . __('Done counting posts.');
     33    echo "\n\t</li>\n";
     34}
     35
     36if ( isset($_POST['topic-voices']) && 1 == $_POST['topic-voices'] ) {
     37    echo "\t<li>\n";
     38    if ( $topics = (array) $bbdb->get_results("SELECT topic_id FROM $bbdb->topics ORDER BY topic_id") ) {
     39        echo "\t\t" . __('Counting voices&#8230;') . "<br />\n";
     40        foreach ($topics as $topic) {
     41            $topic_id = (int) $topic->topic_id;
     42            if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
     43                $voices = count( $voices );
     44                bb_update_topicmeta( $topic_id, 'voices_count', $voices );
     45            }
     46        }
     47        unset($topics, $topic, $topic_id);
     48    }
     49    echo "\t\t" . __('Done counting voices.');
    3350    echo "\n\t</li>\n";
    3451}
  • trunk/bb-admin/includes/functions.bb-admin.php

    r2147 r2150  
    967967    $recount_list = array();
    968968    $recount_list[5] = array('topic-posts', __('Count posts of every topic'));
     969    $recount_list[6] = array('topic-voices', __('Count voices of every topic'));
    969970    $recount_list[10] = array('topic-deleted-posts', __('Count deleted posts on every topic'));
    970971    $recount_list[15] = array('forums', __('Count topics and posts in every forum (relies on the above)'));
  • trunk/bb-includes/functions.bb-posts.php

    r2147 r2150  
    278278            $topic_last_poster_name = $user->user_login;
    279279
    280             $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->forums SET posts = posts + 1 WHERE forum_id = %d", $topic->forum_id ) );
     280            $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->forums SET posts = posts + 1 WHERE forum_id = %d;", $topic->forum_id ) );
    281281            $bbdb->update(
    282282                $bbdb->topics,
     
    288288            if ( !$query->results )
    289289                bb_update_usermeta( $poster_id, $bbdb->prefix . 'topics_replied', $user->topics_replied + 1 );
     290
     291            if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
     292                $voices = count( $voices );
     293                bb_update_topicmeta( $topic_id, 'voices_count', $voices );
     294            }
    290295        } else {
    291296            bb_update_topicmeta( $topic->topic_id, 'deleted_posts', isset($topic->deleted_posts) ? $topic->deleted_posts + 1 : 1 );
  • trunk/bb-includes/functions.bb-template.php

    r2147 r2150  
    11371137
    11381138    return apply_filters( 'get_topic_page_links', $r, $_links, $topic->topic_id );
     1139}
     1140
     1141function bb_topic_voices( $id = 0 ) {
     1142    echo apply_filters( 'bb_topic_voices', bb_get_topic_voices( $id ), get_topic_id( $id ) );
     1143}
     1144
     1145function bb_get_topic_voices( $id = 0 ) {
     1146    $topic = get_topic( get_topic_id( $id ) );
     1147
     1148    if ( empty( $topic->voices_count ) ) {
     1149        global $bbdb;
     1150
     1151        if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic->topic_id ) ) ) {
     1152            $voices = count( $voices );
     1153            bb_update_topicmeta( $topic->topic_id, 'voices_count', $voices );
     1154        }
     1155    } else {
     1156        $voices = $topic->voices_count;
     1157    }
     1158
     1159    return apply_filters( 'bb_get_topic_voices', $voices, $topic->topic_id );
    11391160}
    11401161
  • trunk/bb-templates/kakumei/favorites.php

    r2125 r2150  
    1616    <th><?php _e('Topic'); ?></th>
    1717    <th><?php _e('Posts'); ?></th>
     18    <!-- <th><?php _e('Voices'); ?></th> -->
    1819    <th><?php _e('Freshness'); ?></th>
    1920<?php if ( bb_current_user_can( 'edit_favorites_of', $user_id ) ) : ?>
     
    2627    <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>
    2728    <td class="num"><?php topic_posts(); ?></td>
     29    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2830    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
    2931<?php if ( bb_current_user_can( 'edit_favorites_of', $user_id ) ) : ?>
  • trunk/bb-templates/kakumei/forum.php

    r2125 r2150  
    99    <th><?php _e('Topic'); ?> &#8212; <?php bb_new_topic_link(); ?></th>
    1010    <th><?php _e('Posts'); ?></th>
     11    <!-- <th><?php _e('Voices'); ?></th> -->
    1112    <th><?php _e('Last Poster'); ?></th>
    1213    <th><?php _e('Freshness'); ?></th>
     
    1718    <td><?php bb_topic_labels(); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big><?php topic_page_links(); ?></td>
    1819    <td class="num"><?php topic_posts(); ?></td>
     20    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    1921    <td class="num"><?php topic_last_poster(); ?></td>
    2022    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     
    2628    <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?></td>
    2729    <td class="num"><?php topic_posts(); ?></td>
     30    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2831    <td class="num"><?php topic_last_poster(); ?></td>
    2932    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
  • trunk/bb-templates/kakumei/front-page.php

    r2125 r2150  
    1717    <th><?php _e('Topic'); ?> &#8212; <?php bb_new_topic_link(); ?></th>
    1818    <th><?php _e('Posts'); ?></th>
     19    <!-- <th><?php _e('Voices'); ?></th> -->
    1920    <th><?php _e('Last Poster'); ?></th>
    2021    <th><?php _e('Freshness'); ?></th>
     
    2526    <td><?php bb_topic_labels(); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big><?php topic_page_links(); ?></td>
    2627    <td class="num"><?php topic_posts(); ?></td>
     28    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2729    <td class="num"><?php topic_last_poster(); ?></td>
    2830    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     
    3436    <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?></td>
    3537    <td class="num"><?php topic_posts(); ?></td>
     38    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    3639    <td class="num"><?php topic_last_poster(); ?></td>
    3740    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
  • trunk/bb-templates/kakumei/tag-single.php

    r2125 r2150  
    1111    <th><?php _e('Topic'); ?> &#8212; <?php bb_new_topic_link(); ?></th>
    1212    <th><?php _e('Posts'); ?></th>
     13    <!-- <th><?php _e('Voices'); ?></th> -->
    1314    <th><?php _e('Last Poster'); ?></th>
    1415    <th><?php _e('Freshness'); ?></th>
     
    1920    <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?></td>
    2021    <td class="num"><?php topic_posts(); ?></td>
     22    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2123    <td class="num"><?php topic_last_poster(); ?></td>
    2224    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
  • trunk/bb-templates/kakumei/topic.php

    r2144 r2150  
    88<h2<?php topic_class( 'topictitle' ); ?>><?php topic_title(); ?></h2>
    99<span id="topic_posts">(<?php topic_posts_link(); ?>)</span>
     10<span id="topic_voices">(<?php printf( __( '%s voices' ), bb_get_topic_voices() ); ?>)</span>
    1011
    1112<ul class="topicmeta">
  • trunk/bb-templates/kakumei/view.php

    r2125 r2150  
    99    <th><?php _e('Topic'); ?></th>
    1010    <th><?php _e('Posts'); ?></th>
     11    <!-- <th><?php _e('Voices'); ?></th> -->
    1112    <th><?php _e('Last Poster'); ?></th>
    1213    <th><?php _e('Freshness'); ?></th>
     
    1718    <td><?php bb_topic_labels(); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big></td>
    1819    <td class="num"><?php topic_posts(); ?></td>
     20    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    1921    <td class="num"><?php topic_last_poster(); ?></td>
    2022    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
     
    2628    <td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?></td>
    2729    <td class="num"><?php topic_posts(); ?></td>
     30    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    2831    <td class="num"><?php topic_last_poster(); ?></td>
    2932    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>
Note: See TracChangeset for help on using the changeset viewer.