Skip to:
Content

bbPress.org

Changeset 581


Ignore:
Timestamp:
01/10/2007 09:04:14 AM (19 years ago)
Author:
mdawaffe
Message:

axe resolution status. Relegate to plugin. re #496 props so1o

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/admin-ajax.php

    r541 r581  
    9191    break;
    9292
    93 case 'update-resolution' :
    94     $topic_id = (int) @$_POST['topic_id'];
    95     $resolved = @$_POST['resolved'];
    96 
    97     if ( !bb_current_user_can( 'edit_topic', $topic_id ) )
    98         die('-1');
    99 
    100     $topic = get_topic( $topic_id );
    101     if ( !$topic )
    102         die('0');
    103 
    104     if ( bb_resolve_topic( $topic_id, $resolved ) ) {
    105         $topic->topic_resolved = $resolved;
    106         ob_start();
    107             echo '<li id="resolution-flipper">' . __('This topic is') . ' ';
    108             topic_resolved();
    109             echo '</li>';
    110         $data = ob_get_contents();
    111         ob_end_clean();
    112         $x = new WP_Ajax_Response( array(
    113             'what' => 'resolution',
    114             'id' => 'flipper',
    115             'data' => $data
    116         ) );
    117         $x->send();
    118     }
    119     break;
    120 
    12193case 'delete-post' :
    12294    $post_id = (int) $_POST['id'];
  • trunk/bb-includes/functions.php

    r578 r581  
    8989function untagged( $where ) {
    9090    return $where . ' AND tag_count = 0 ';
    91 }
    92 
    93 function unresolved( $where ) {
    94     return $where . " AND topic_resolved = 'no' ";
    9591}
    9692
     
    920916        if ( $user = bb_get_user( $bb_post->poster_id ) )
    921917            bb_update_usermeta( $user->ID, $bb_table_prefix . 'topics_replied', $user->topics_replied + 1 );
    922 }
    923 
    924 function bb_resolve_topic( $topic_id, $resolved = 'yes' ) {
    925     global $bbdb, $bb_cache;
    926     $topic_id = (int) $topic_id;
    927     apply_filters( 'topic_resolution', $resolved, $topic_id );
    928     if ( ! in_array($resolved, array('yes', 'no', 'mu')) )
    929         return false;
    930     $bb_cache->flush_one( 'topic', $topic_id );
    931     $r = $bbdb->query("UPDATE $bbdb->topics SET topic_resolved = '$resolved' WHERE topic_id = '$topic_id'");
    932     do_action( 'resolve_topic', $topic_id, $resolved, $r );
    933     return $r;
    934918}
    935919
     
    15561540    if ( isset($views) && $cache )
    15571541        return $views;
    1558     $views = array('no-replies' => __('Topics with no replies'), 'untagged' => __('Topics with no tags'), 'unresolved' => __('Unresolved topics'));
    1559     return apply_filters('bb_views', $views);
     1542   
     1543    $views = array(
     1544        'no-replies' => __('Topics with no replies'),
     1545        'untagged' => __('Topics with no tags'),
     1546    );
     1547   
     1548    $views = apply_filters('bb_views', $views);
     1549    return $views;
    15601550}
    15611551
  • trunk/bb-includes/js/topic-js.php

    r516 r581  
    5959    favLinkSetup();
    6060           
    61     var resolvedSub = $('resolvedformsub');
    62     if ( !resolvedSub )
    63         return;
    64     resFunc = function(e) { return theTopicMeta.ajaxUpdater( 'resolution', 'resolved' ); }
    65     resolvedSub.onclick = resFunc;
    66     theTopicMeta.addComplete = function(what, where, update) {
    67         if ( update && 'resolved' == where )
    68             $('resolvedformsub').onclick = resFunc;
    69     }
    7061} );
    7162
  • trunk/bb-includes/template-functions.php

    r580 r581  
    599599}
    600600
    601 function topic_resolved( $yes = '', $no = '', $mu = '', $id = 0 ) {
    602     global $bb_current_user, $topic;
    603     if ( empty($yes) )
    604         $yes = __('resolved');
    605     if ( empty($no) )
    606         $no = __('not resolved');
    607     if ( empty($mu) )
    608         $mu = __('not a support question');
    609     if ( bb_current_user_can( 'edit_topic', $topic->topic_id ) ) :
    610         $resolved_form  = '<form id="resolved" method="post" action="' . bb_get_option('uri') . 'topic-resolve.php"><div>' . "\n";
    611         $resolved_form .= '<input type="hidden" name="id" value="' . $topic->topic_id . "\" />\n";
    612         $resolved_form .= '<select name="resolved" id="resolvedformsel" tabindex="2">' . "\n";
    613 
    614         $cases = array( 'yes', 'no', 'mu' );
    615         $resolved = get_topic_resolved( $id );
    616         foreach ( $cases as $case ) {
    617             $selected = ( $case == $resolved ) ? ' selected="selected"' : '';
    618             $resolved_form .= "<option value=\"$case\"$selected>${$case}</option>\n";
    619         }
    620 
    621         $resolved_form .= "</select>\n";
    622         $resolved_form .= '<input type="submit" name="submit" id="resolvedformsub" value="'. __('Change') .'" />' . "\n</div>";
    623         echo $resolved_form;
    624         bb_nonce_field( 'resolve-topic_' . $topic->topic_id );
    625         echo "\n</form>";
    626     else:
    627         switch ( get_topic_resolved( $id ) ) {
    628             case 'yes' : echo $yes; break;
    629             case 'no'  : echo $no;  break;
    630             case 'mu'  : echo $mu;  break;
    631         }
    632     endif;
    633 }
    634 
    635 function get_topic_resolved( $id = 0 ) {
    636     global $topic;
    637     if ( $id )
    638         $topic = get_topic( $id );
    639     return $topic->topic_resolved;
    640 }
    641 
    642601function topic_last_post_link( $id = 0 ) {
    643602    global $topic;
     
    784743    elseif ( 1 < $topic->topic_status && bb_current_user_can( 'browse_deleted' ) )
    785744        $class[] = 'bozo';
    786     if ( 'yes' == $topic->topic_resolved )
    787         $class[] = 'resolved';
    788745    if ( '0' === $topic->topic_open )
    789746        $class[] = 'closed';
  • trunk/bb-post.php

    r516 r581  
    2323    $topic = trim( $_POST['topic'] );
    2424    $tags  = trim( $_POST['tags']  );
    25     $support = (int) $_POST['support'];
    2625
    2726    if ('' == $topic)
     
    2928
    3029    $topic_id = bb_new_topic( $topic, $forum, $tags );
    31     if ( 1 != $support )
    32         bb_resolve_topic( $topic_id, 'mu' );
     30
    3331} elseif ( isset($_POST['topic_id'] ) ) {
    3432    $topic_id = (int) $_POST['topic_id'];
  • trunk/bb-templates/topic.php

    r528 r581  
    1212    <li><?php printf(__('<a href="%1$s">Latest reply</a> from %2$s'), get_topic_last_post_link(), get_topic_last_poster()) ?></li>
    1313<?php endif; ?>
    14     <li id="resolution-flipper"><?php _e('This topic is') ?> <?php topic_resolved(); ?></li>
    1514<?php if ( $bb_current_user ) : $class = 0 === is_user_favorite( $bb_current_user->ID ) ? ' class="is-not-favorite"' : ''; ?>
    1615    <li<?php echo $class;?> id="favorite-toggle"><?php user_favorites_link() ?></li>
  • trunk/topic-resolve.php

    r516 r581  
    1 <?php
    2 require('./bb-load.php');
    3 
    4 bb_auth();
    5 
    6 if ( !$bb_current_user )
    7     bb_die(__('You need to be logged in to add a tag.'));
    8 
    9 $topic_id = (int) @$_POST['id' ];
    10 $resolved =       @$_POST['resolved'];
    11 
    12 $topic = get_topic ( $topic_id );
    13 if ( !$topic )
    14     bb_die(__('Topic not found.'));
    15 
    16 if ( !bb_current_user_can( 'edit_topic', $topic_id ) )
    17     bb_die(__("You must be either the original poster or a moderator to change a topic's resolution status."));
    18 
    19 bb_check_admin_referer( 'resolve-topic_' . $topic_id );
    20 
    21 if ( bb_resolve_topic( $topic_id, $resolved ) )
    22     wp_redirect( get_topic_link( $topic_id ) );
    23 else
    24     bb_die(__('Invalid resolution status.'));
    25 ?>
  • trunk/view.php

    r516 r581  
    1818    $view_count = max($view_count, bb_count_last_query());
    1919    break; 
    20 case 'unresolved' :
    21     add_filter( 'get_latest_topics_where', 'unresolved' );
    22     $topics = get_latest_topics( 0, $page );
    23     $view_count = bb_count_last_query();
    24     break;
    2520default :
    26     do_action( 'bb_custom_view', $view );
     21    do_action( 'bb_custom_view', $view, $page );
    2722endswitch;
    2823
Note: See TracChangeset for help on using the changeset viewer.