Making WordPress.org


Ignore:
Timestamp:
10/11/2014 06:37:35 PM (10 years ago)
Author:
nacin
Message:

Trac components page: Another column.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-components.php

    r903 r904  
    1313        add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
    1414        add_action( 'component_table_row', array( $this, 'component_table_row' ) );
     15        add_filter( 'manage_component_posts_columns', array( $this, 'manage_posts_columns' ) );
     16        add_action( 'manage_component_posts_custom_column', array( $this, 'manage_posts_custom_column' ), 10, 2 );
    1517        $this->trac = $GLOBALS['wpdb'];
    1618    }
     
    147149    function admin_menu() {
    148150        remove_submenu_page( 'edit.php?post_type=component', 'post-new.php?post_type=component' );
     151    }
     152
     153    function manage_posts_columns( $columns ) {
     154        return array_merge(
     155            array_slice( $columns, 0, 2 ),
     156            array( 'maintainers' => 'Maintainers' ),
     157            array_slice( $columns, 2 )
     158        );
     159    }
     160
     161    function manage_posts_custom_column( $column_name, $post_id ) {
     162        switch ( $column_name ) {
     163            case 'maintainers' :
     164                echo esc_html( get_post_meta( $post_id, '_active_maintainers', true ) );
     165                break;
     166        }
    149167    }
    150168
     
    204222
    205223        $post = get_post();
    206         if ( ! $this->page_is_component( $post ) ) {
     224        if ( ! $this->page_is_component( $post ) || doing_action( 'wp_head' ) || ! did_action( 'wp_head' ) ) {
    207225            return $content;
    208226        }   
     
    230248        ) );
    231249
     250        $subcomponents = array();
    232251        if ( $subcomponents_query->have_posts() ) {
    233             $subcomponents = array();
    234252            foreach ( $subcomponents_query->posts as $subcomponent ) {
    235253                $subcomponents[ $subcomponent->ID ] = '<a href="' . get_permalink( $subcomponent ) . '">' . $subcomponent->post_title . '</a>';
     
    279297        }
    280298
    281         $this->maintainers_note();
    282299        echo "\n" . "Many contributors help maintain one or more components. These maintainers are vital to keeping WordPress development running as smoothly as possible. They triage new tickets, look after existing ones, spearhead or mentor tasks, pitch new ideas, curate roadmaps, and provide feedback to other contributors. Longtime maintainers with a deep understanding of particular areas of core are always seeking to mentor others to impart their knowledge.\n\n";
    283300        echo "<strong>Want to help? Start following this component!</strong> <a href='/core/notifications/'>Adjust your notifications here</a>. Feel free to dig into any ticket." . "\n\n";
     
    302319
    303320    function generate_component_breakdowns() {
    304         if ( isset( $this->breakdown_component_type, $this->breakdown_component_milestone_type ) ) {
     321        if ( isset( $this->breakdown_component_type, $this->breakdown_component_milestone_type, $this->breakdown_component_unreplied ) ) {
    305322            return;
    306323        }
     
    326343        }
    327344
     345        $component_unreplied = wp_cache_get( 'trac_tickets_by_component_unreplied' );
     346        if ( ! $component_unreplied ) {
     347            $rows = $this->trac->get_results( $this->trac->prepare( "SELECT id, component FROM ticket t
     348                WHERE id NOT IN (SELECT ticket FROM ticket_change WHERE ticket = t.id AND t.reporter <> author AND field = 'comment' AND newvalue <> '')
     349                AND status <> 'closed'" ) );
     350            $component_unreplied = array();
     351            foreach ( $rows as $row ) {
     352                $component_unreplied[ $row->component ][] = $row->id;
     353            }
     354            wp_cache_add( 'trac_tickets_by_component_unreplied', $component_unreplied, '', 300 );
     355        }
     356
    328357        $this->breakdown_component_type = $component_type;
    329358        $this->breakdown_component_milestone_type = $component_milestone_type;
     359        $this->breakdown_component_unreplied = $component_unreplied;
    330360    }
    331361
     
    539569        if ( $once ) {
    540570            $once = false;
    541             echo '<thead><tr><th>Component</th><th style="width: 50px">Tickets</th><th style="width: 50px">7 Days</th><th>Maintainers</th></tr></thead>';
     571            echo '<thead><tr><th>Component</th><th style="width: 50px">Tickets</th><th style="width: 50px">7 Days</th><th style="width: 50px">0&nbsp;Replies</th><th>Maintainers</th></tr></thead>';   
    542572        }
    543573
     
    567597        }
    568598
     599        if ( isset( $this->breakdown_component_unreplied[ $component ] ) ) {
     600            $unreplied = $this->breakdown_component_unreplied[ $component ];
     601            echo '<td class="right">' . $this->trac_query_link( count( $unreplied ), array( 'component' => $component, 'id' => $unreplied ) );
     602            echo ' <span style="color: red; font-weight: bold">!!</span></td>';
     603        } else {
     604            echo '<td></td>';
     605        }
     606
    569607        $maintainers = get_post_meta( $post->ID, '_active_maintainers', true );
    570608        $maintainers = array_filter( array_map( 'trim', explode( ',', $maintainers ) ) );
Note: See TracChangeset for help on using the changeset viewer.