Changeset 267 for sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php
- Timestamp:
- 01/10/2014 09:55:09 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php
r265 r267 8 8 class wporg_trac_notifications { 9 9 10 protected $trac_subdomain; 11 10 12 function __construct() { 11 13 $this->set_trac( 'core' ); … … 16 18 17 19 function set_trac( $trac ) { 20 $this->trac_subdomain = $trac; 18 21 if ( function_exists( 'add_db_table' ) ) { 19 22 $tables = array( 'ticket', '_ticket_subs', '_notifications', 'ticket_change', 'component', 'milestone' ); … … 25 28 } 26 29 30 function trac_url() { 31 return 'https://' . $this->trac_subdomain . '.trac.wordpress.org'; 32 } 33 27 34 function filter_allowed_http_origins( $origins ) { 28 $origins[] = 'https://core.trac.wordpress.org';35 $origins[] = $this->trac_url(); 29 36 return $origins; 37 } 38 39 function ticket_link( $ticket ) { 40 $status_res = $ticket->status; 41 if ( $ticket->resolution ) { 42 $status_res .= ': ' . $ticket->resolution; 43 } 44 return sprintf( '<a href="%s" class="%s ticket" title="%s">#%s</a>', 45 $this->trac_url() . '/ticket/' . $ticket->id, 46 $ticket->status, 47 esc_attr( sprintf( "%s: %s (%s)", $ticket->type, $ticket->summary, $status_res ) ), 48 $ticket->id ); 30 49 } 31 50 … … 247 266 </div> 248 267 <?php 268 $this->ticket_notes( $ticket, $username ); 249 269 wp_send_json_success( array( 'notifications-box' => ob_get_clean() ) ); 250 270 exit; 271 } 272 273 function ticket_notes( $ticket, $username ) { 274 if ( $username != $ticket->reporter ) { 275 $previous_tickets = $this->trac->get_results( $this->trac->prepare( "SELECT id, summary, type, status, resolution 276 FROM ticket WHERE reporter = %s AND id <= %d LIMIT 5", $ticket->reporter, $ticket->id ) ); 277 278 if ( count( $previous_tickets ) < 5 ) { 279 $dashicon = '<span class="dashicons dashicons-welcome-learn-more"></span> '; 280 $dashicon .= '<img width="36" height="36" src="//wordpress.org/grav-redirect.php?user=' . esc_attr( $ticket->reporter ) . '&s=36" /> '; 281 } 282 283 if ( 1 == count( $previous_tickets ) ) { 284 $previous_comments = $this->trac->get_var( $this->trac->prepare( "SELECT ticket FROM ticket_change 285 WHERE field = 'comment' AND author = %s AND ticket <> %d LIMIT 1", $ticket->reporter, $ticket->id ) ); 286 287 echo '<p class="ticket-note note-new-reporter">' . $dashicon . '<strong>Make sure ' . $ticket->reporter . ' receives a warm welcome</strong> — '; 288 289 if ( $previous_comments ) { 290 echo 'they’ve commented before, but it᾿s their first bug report!</p>'; 291 } else { 292 echo 'it᾿s their first bug report!</p>'; 293 } 294 295 } elseif ( count( $previous_tickets ) < 5 ) { 296 $mapping = array( 2 => 'second', 3 => 'third', 4 => 'fourth' ); 297 298 echo '<p>' . $dashicon . '<strong>This is only ' . $ticket->reporter . '’s ' . $mapping[ count( $previous_tickets ) ] . ' ticket!</strong> Previously:'; 299 300 foreach ( $previous_tickets as $t ) { 301 if ( $t->id != $ticket->id ) { 302 echo ' ' . $this->ticket_link( $t ); 303 } 304 } 305 echo '.'; 306 } 307 } 251 308 } 252 309
Note: See TracChangeset
for help on using the changeset viewer.