- Timestamp:
- 01/23/2015 10:40:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/mentions-handler.php
r1182 r1183 1 1 <?php 2 3 define( 'BLOCKED', 0 ); 4 define( 'SUBSCRIBED', 1 ); 5 define( 'MENTIONED', 2 ); 2 6 3 7 require dirname( dirname( __DIR__ ) ) . '/includes/slack-config.php'; … … 28 32 } 29 33 34 function wporg_get_trac_ticket_subscription_status( $username, $ticket ) { 35 global $wpdb; 36 add_db_table( 'trac_core', '_ticket_subs' ); // HyperDB 37 $status = $wpdb->get_var( $wpdb->prepare( 38 "SELECT status FROM _ticket_subs WHERE username = %s AND ticket = %s", 39 $username, $ticket 40 ) ); 41 42 if ( is_numeric( $status ) ) { 43 return (int) $status; 44 } 45 return false; 46 } 47 30 48 if ( ! wporg_user_has_visited_trac( $user_login ) ) { 31 49 $wpdb->insert( 'trac_users', compact( 'user_login' ) ); … … 33 51 34 52 add_filter( 'wporg_notifications_notify_username', function( $notify, $username ) use ( $type, $payload, $wpdb ) { 53 // Core Trac has notifications configured, see if the user has blocked the ticket. 54 if ( $payload->trac === 'core' ) { 55 $status = wporg_get_trac_ticket_subscription_status( $username, $payload->ticket_id ); 56 if ( BLOCKED === $status ) { 57 return false; 58 } 59 } 60 35 61 if ( $type === 'ticket' ) { 36 62 // Don't need a query to say we can notify the owner and reporter. … … 41 67 42 68 if ( wporg_user_has_visited_trac( $username ) ) { 69 // If on Core Trac, a user is not a reporter, owner, or subscriber, subscribe them. 70 if ( isset( $status ) && false === $status ) { 71 $wpdb->insert( '_ticket_subs', array( 72 'username' => $username, 73 'ticket' => $payload->ticket_id, 74 'status' => MENTIONED, 75 ) ); 76 } 77 43 78 return true; 44 79 }
Note: See TracChangeset
for help on using the changeset viewer.