Making WordPress.org

Changeset 458


Ignore:
Timestamp:
03/06/2014 04:56:13 AM (13 years ago)
Author:
nacin
Message:

Trac Notifications: Allow showing of usernames via a cookie toggle. Also lays the foundation to show all users receiving notifications (including participants who have neither starred nor blocked the ticket).

File:
1 edited

Legend:

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

    r402 r458  
    9292        }
    9393
    94         function get_trac_ticket_stars( $ticket_id ) {
    95                 return $this->trac->get_col( $this->trac->prepare( "SELECT username FROM _ticket_subs WHERE ticket = %s AND status = 1", $ticket_id ) );
     94        function get_trac_ticket_subscriptions( $ticket_id ) {
     95                $by_status = array( 'blocked' => array(), 'starred' => array() );
     96                $subscriptions = $this->trac->get_results( $this->trac->prepare( "SELECT username, status FROM _ticket_subs WHERE ticket = %s", $ticket_id ) );
     97                foreach ( $subscriptions as $subscription ) {
     98                        $by_status[ $subscription->status ? 'starred' : 'blocked' ][] = $subscription->username;
     99                }
     100                return $by_status;
    96101        }
    97102
    … …  
    254259                $ticket_sub = $this->get_trac_ticket_subscription_status_for_user( $ticket_id, $username );
    255260
    256                 $stars = $this->get_trac_ticket_stars( $ticket_id );
     261                $ticket_subscriptions = $this->get_trac_ticket_subscriptions( $ticket_id );
     262                $stars = $ticket_subscriptions['starred'];
    257263                $star_count = count( $stars );
    258264
    259265                $participants = $this->get_trac_ticket_participants( $ticket_id );
     266
     267                $unblocked_participants = array_diff( $participants, $ticket_subscriptions['blocked'] );
     268                $all_receiving_notifications = array_unique( array_merge( $stars, $unblocked_participants ) );
     269                sort( $all_receiving_notifications );
    260270
    261271                $reasons = array();
    … …  
    310320                        $class .= ' count-' . $star_count;
    311321                }
     322                if ( ! empty( $_COOKIE['wp_trac_ngrid'] ) ) {
     323                        $class .= ' show-usernames';
     324                }
     325
    312326                ob_start();
    313327                ?>
    … …  
    322336                                <?php
    323337                                        foreach ( $stars as $follower ) :
     338                                        // foreach ( $all_receiving_notifications as $follower ) :
    324339                                                if ( $username === $follower ) {
    325340                                                        continue;
    326341                                                }
    327342                                                $follower = esc_attr( $follower );
     343                                                $class = ''; // in_array( $follower, $stars, true ) ? ' class="star"' : '';
    328344                                        ?>
    329                                                 <a title="<?php echo $follower; ?>" href="//profiles.wordpress.org/<?php echo $follower; ?>">
     345                                                <a<?php echo $class; ?> title="<?php echo $follower; ?>" href="//profiles.wordpress.org/<?php echo $follower; ?>">
    330346                                                        <img width="36" height="36" src="//wordpress.org/grav-redirect.php?user=<?php echo $follower; ?>&amp;s=36" />
     347                                                        <span class="username"><?php echo $follower; ?></span>
    331348                                                </a>
    332349                                        <?php endforeach; ?>
    333350                                        <a title="you" class="star-you" href="//profiles.wordpress.org/<?php echo esc_attr( $username ); ?>">
    334351                                                <img width="36" height="36" src="//wordpress.org/grav-redirect.php?user=<?php echo esc_attr( $username ); ?>&amp;s=36" />
     352                                                <span class="username"><?php echo $username; ?></span>
    335353                                        </a>
    336354                                        </div>
    … …  
    341359                        <?php endif ?>
    342360                                <p class="not-receiving-notifications">You do not receive notifications because you have blocked this ticket. <a href="#" class="button button-small unblock-notifications">Unblock</a></p>
    343                                 <a class="preferences" href="<?php echo home_url( 'notifications/' ); ?>">Preferences</a>
     361                                <span class="preferences"><span class="grid-toggle"><a href="#" class="grid dashicons dashicons-screenoptions"></a> <a href="#" class="names dashicons dashicons-exerpt-view dashicons-excerpt-view"></a></span> <a href="<?php echo home_url( 'notifications/' ); ?>">Preferences</a></span>
    344362                </fieldset>
    345363        </div>
Note: See TracChangeset for help on using the changeset viewer.