Making WordPress.org


Ignore:
Timestamp:
01/08/2014 08:02:22 PM (11 years ago)
Author:
nacin
Message:

Trac Notifications: Gravatars for ticket watchers. see #127.

File:
1 edited

Legend:

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

    r236 r237  
    4848    }
    4949
    50     function get_trac_ticket_star_count( $ticket_id ) {
    51         return $this->trac->get_var( $this->trac->prepare( "SELECT COUNT(*) FROM _ticket_subs WHERE ticket = %s AND status = 1", $ticket_id ) );
     50    function get_trac_ticket_stars( $ticket_id ) {
     51        return $this->trac->get_col( $this->trac->prepare( "SELECT username FROM _ticket_subs WHERE ticket = %s AND status = 1", $ticket_id ) );
    5252    }
    5353
     
    148148        $ticket_sub = $this->get_trac_ticket_subscription_status_for_user( $ticket_id, $username );
    149149
    150         $stars = $this->get_trac_ticket_star_count( $ticket_id );
     150        $stars = $this->get_trac_ticket_stars( $ticket_id );
     151        $star_count = count( $stars );
    151152
    152153        $participants = $this->get_trac_ticket_participants( $ticket_id );
     
    182183            $class .= ' receiving';
    183184        }
    184         if ( $stars == 0 ) {
    185             $class .= ' count-0';
    186         } elseif ( $stars == 1 ) {
    187             $class .= ' count-1';
     185
     186        if ( $star_count === 0 || $star_count === 1 ) {
     187            $class .= ' count-' . $star_count;
    188188        }
    189189        ob_start();
     
    195195                    <a href="#" class="button button-large watching-ticket"><span class="dashicons dashicons-star-filled"></span> Watching ticket</a>
    196196                    <a href="#" class="button button-large watch-this-ticket"><span class="dashicons dashicons-star-empty"></span> Watch this ticket</a>
    197                     <span class="num-stars"><span class="count"><?php echo $stars; ?></span> <span class="count-1">star</span> <span class="count-many">stars</span></span>
     197                    <span class="num-stars"><span class="count"><?php echo $star_count; ?></span> <span class="count-1">star</span> <span class="count-many">stars</span></span>
     198                    <div class="star-list">
     199                <?php
     200                    foreach ( $stars as $follower ) :
     201                        if ( $username === $follower ) {
     202                            continue;
     203                        }
     204                        $follower = esc_attr( $follower );
     205                    ?>
     206                        <a title="<?php echo $follower; ?>" href="//profiles.wordpress.org/<?php echo $follower; ?>">
     207                            <img src="//wordpress.org/grav-redirect.php?user=<?php echo $follower; ?>&amp;s=36" />
     208                        </a>
     209                    <?php endforeach; ?>
     210                    <a title="you" class="star-you" href="//profiles.wordpress.org/<?php echo esc_attr( $username ); ?>">
     211                        <img src="//wordpress.org/grav-redirect.php?user=<?php echo esc_attr( $username ); ?>&amp;s=36" />
     212                    </a>
     213                    </div>
    198214                </p>
    199215                <p class="receiving-notifications">You are receiving notifications.</p>
Note: See TracChangeset for help on using the changeset viewer.