Making WordPress.org

Changeset 2034


Ignore:
Timestamp:
11/03/2015 05:26:50 AM (9 years ago)
Author:
nacin
Message:

Trac Notifications: Always work with arrays due to JSON use.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications
Files:
2 edited

Legend:

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

    r2030 r2034  
    8686        return $this->db->get_results( "SELECT name, completed FROM milestone
    8787            WHERE name <> 'WordPress.org' AND (completed = 0 OR completed >= 1386864000000000)
    88             ORDER BY (completed = 0) DESC, name DESC", OBJECT_K );
     88            ORDER BY (completed = 0) DESC, name DESC", ARRAY_A );
    8989    }
    9090
     
    104104        );
    105105
    106         if ( $meta['get_trac_ticket']->reporter !== $username ) {
    107             $meta['get_reporter_last_activity'] = $this->get_reporter_past_activity( $meta['get_trac_ticket']->reporter, $ticket_id );
     106        if ( $meta['get_trac_ticket']['reporter'] !== $username ) {
     107            $meta['get_reporter_last_activity'] = $this->get_reporter_past_activity( $meta['get_trac_ticket']['reporter'], $ticket_id );
    108108        }
    109109
     
    112112
    113113    function get_trac_ticket( $ticket_id ) {
    114         return $this->db->get_row( $this->db->prepare( "SELECT * FROM ticket WHERE id = %d", $ticket_id ) );
     114        return $this->db->get_row( $this->db->prepare( "SELECT * FROM ticket WHERE id = %d", $ticket_id ), ARRAY_A );
    115115    }
    116116
     
    164164
    165165        $activity['tickets'] = $this->db->get_results( $this->db->prepare( "SELECT id, summary, type, status, resolution
    166             FROM ticket WHERE reporter = %s AND id <= %d LIMIT 5", $reporter, $ticket ) );
     166            FROM ticket WHERE reporter = %s AND id <= %d LIMIT 5", $reporter, $ticket ), ARRAY_A );
    167167
    168168        if ( count( $previous_tickets ) === 1 ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php

    r2031 r2034  
    6161
    6262    function ticket_link( $ticket ) {
     63        $ticket = (object) $ticket;
    6364        $status_res = $ticket->status;
    6465        if ( $ticket->resolution ) {
     
    206207        $ticket               = $meta['get_trac_ticket'];
    207208        $focuses              = $meta['get_trac_ticket_focuses'];
    208         $notifications        = $meta['get_trac_ticket_focuses'];
     209        $notifications        = $meta['get_trac_notifications_for_user'];
    209210        $ticket_sub           = $meta['get_trac_ticket_subscription_status_for_user'];
    210211        $ticket_subscriptions = $meta['get_trac_ticket_subscriptions'];
     
    221222        $reasons = array();
    222223
    223         if ( $username == $ticket->reporter ) {
     224        if ( $username == $ticket['reporter'] ) {
    224225            $reasons['reporter'] = 'you reported this ticket';
    225226        }
    226         if ( $username == $ticket->owner ) {
     227        if ( $username == $ticket['owner'] ) {
    227228            $reasons['owner'] = 'you own this ticket';
    228229        }
     
    245246        }
    246247
    247         if ( ! empty( $notifications['component'][ $ticket->component ] ) ) {
    248             $reasons['component'] = sprintf( 'you have subscribed to the %s component', $ticket->component );
    249         }
    250         if ( ! empty( $notifiations['milestone'][ $ticket->milestone ] ) ) {
    251             $reasons['milestone'] = sprintf( 'you have subscribed to the %s milestone', $ticket->milestone );
     248        if ( ! empty( $notifications['component'][ $ticket['component'] ] ) ) {
     249            $reasons['component'] = sprintf( 'you have subscribed to the %s component', $ticket['component'] );
     250        }
     251        if ( ! empty( $notifiations['milestone'][ $ticket['milestone'] ] ) ) {
     252            $reasons['milestone'] = sprintf( 'you have subscribed to the %s milestone', $ticket['milestone'] );
    252253        }
    253254
     
    316317        $send = array( 'notifications-box' => ob_get_clean() );
    317318        if ( isset( $this->components ) ) {
    318             $send['maintainers'] = $this->components->get_component_maintainers( $ticket->component );
     319            $send['maintainers'] = $this->components->get_component_maintainers( $ticket['component'] );
    319320        }
    320321        wp_send_json_success( $send );
     
    323324
    324325    function ticket_notes( $ticket, $username, $meta ) {
    325         if ( $username == $ticket->reporter ) {
     326        if ( $username == $ticket['reporter'] ) {
    326327            return;
    327328        }
     
    334335
    335336        if ( 1 == count( $activity['tickets'] ) ) {
    336             $output = '<strong>Make sure ' . $ticket->reporter . ' receives a warm welcome.</strong><br/>';
     337            $output = sprintf( '<strong>Make sure %s receives a warm welcome.</strong><br/>', $ticket['reporter'] );
    337338
    338339            if ( ! empty( $activity['comments'] ) ) {
     
    344345            $mapping = array( 2 => 'second', 3 => 'third', 4 => 'fourth' );
    345346
    346             $output = '<strong>This is only ' . $ticket->reporter . '&#8217;s ' . $mapping[ count( $activity['tickets'] ) ] . ' ticket!</strong><br/>Previously:';
     347            $output = sprintf( '<strong>This is only %s&#8217;s %s ticket!</strong><br/>Previously:',
     348                $ticket['reporter'], $mapping[ count( $activity['tickets'] ) ] );
    347349
    348350                foreach ( $activity['tickets'] as $t ) {
    349                     if ( $t->id != $ticket->id ) {
     351                    if ( $t['id'] != $ticket['id'] ) {
    350352                        $output .= ' ' . $this->ticket_link( $t );
    351353                    }
     
    354356        }
    355357
    356         $gravatar_url = '//wordpress.org/grav-redirect.php?user=' . esc_attr( $ticket->reporter );
     358        $gravatar_url = 'https://wordpress.org/grav-redirect.php?user=' . esc_attr( $ticket['reporter'] );
    357359
    358360        echo '<p class="ticket-note note-new-reporter">';
    359         echo '<img width="36" height="36" src="'. $gravatar_url . '&amp;s=36" srcset="'. $gravatar_url . '&amp;s=72 2x" /> ';
     361        printf( '<img width="36" height="36" src="%1$s&amp;s=36" srcset="%1$s&amp;s=72 2x" /> ', $gravatar_url );
    360362        echo '<span class="note">' . $output . '</span>';
    361363        echo '<span class="dashicons dashicons-welcome-learn-more"></span>';
     
    399401            if ( empty( $_POST['notifications']['newticket'] ) && ! empty( $notifications['newticket'] ) ) {
    400402                $changes['delete'][] = array( 'username' => $username, 'type' => 'newticket' );
    401                 $notifications[ 'newticket' ] = false;
     403                $notifications['newticket'] = false;
    402404            } elseif ( ! empty( $_POST['notifications']['newticket'] ) && empty( $notifications['newticket'] ) ) {
    403405                $changes['insert'][] = array( 'username' => $username, 'type' => 'newticket', 'value' => '1' );
    404                 $notifications[ 'newticket' ] = true;
     406                $notifications['newticket'] = true;
    405407            }
    406408            $this->api->update_notifications( $changes );
     
    511513            echo '<ul>';
    512514            foreach ( $milestones as $milestone ) {
    513                 $checked = checked( ! empty( $notifications['milestone'][ $milestone->name ] ), true, false );
     515                $checked = checked( ! empty( $notifications['milestone'][ $milestone['name'] ] ), true, false );
    514516                $class = '';
    515                 if ( ! empty( $milestone->completed ) ) {
     517                if ( ! empty( $milestone['completed'] ) ) {
    516518                    $class = 'completed-milestone';
    517519                    if ( $checked ) {
     
    520522                    $class = ' class="' . $class . '"';
    521523                }
    522                 echo  '<li' . $class . '><label><input type="checkbox" ' . $checked . 'name="notifications[milestone][' . esc_attr( $milestone->name ) . ']" /> ' . $milestone->name . '</label></li>';
     524                echo  '<li' . $class . '><label><input type="checkbox" ' . $checked . 'name="notifications[milestone][' . esc_attr( $milestone['name'] ) . ']" /> ' . $milestone['name'] . '</label></li>';
    523525            }
    524526            echo '<li id="show-completed"><a href="#">Show recently completed&hellip;</a></li>';
Note: See TracChangeset for help on using the changeset viewer.