Making WordPress.org

Changeset 2023


Ignore:
Timestamp:
11/01/2015 06:33:25 PM (10 years ago)
Author:
nacin
Message:

Trac Notifications: Fewer cross dependencies.

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

Legend:

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

    r2022 r2023  
    392392        }
    393393
    394         $history = $this->api->get_component_history( $component );
     394        $history = $this->api->get_component_history( $component, self::last_x_days );
    395395        $direction = '';
    396396        if ( $history['change'] > 0 ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications-db.php

    r2022 r2023  
    22/**
    33 * This class must execute queries valid for both MySQL and SQLite3.
     4 * The DB driver must be wpdb or Trac_Notifications_SQLite_Driver.
     5 * It must work without any other dependencies, such as WordPress.
    46 */
    5 class Trac_Notifications_DB {
     7class Trac_Notifications_DB implements Trac_Notifications_API {
    68    function __construct( $db ) {
    79        $this->db = $db;
     
    6062    }
    6163
    62     function get_component_history( $component ) {
    63         $days_ago = ( time() - ( 86400 * Make_Core_Trac_Components::last_x_days ) ) * 1000000;
     64    function get_component_history( $component, $last_x_days = 7 ) {
     65        $days_ago = ( time() - ( 86400 * $last_x_days ) ) * 1000000;
    6466        $closed_reopened = $this->db->get_results( $this->db->prepare( "SELECT newvalue, COUNT(DISTINCT ticket) as count
    6567            FROM ticket_change tc INNER JOIN ticket t ON tc.ticket = t.id
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php

    r2022 r2023  
    2424        }
    2525
    26         require __DIR__ . '/trac-notifications-db.php';
     26        spl_autoload_register( array( $this, 'autoload' ) );
    2727
    2828        if ( function_exists( 'add_db_table' ) ) {
     
    4444        add_action( 'template_redirect', array( $this, 'action_template_redirect' ) );
    4545        add_shortcode( 'trac-notifications', array( $this, 'notification_settings_page' ) );
     46    }
     47
     48    function autoload( $class ) {
     49        $class = strtolower( $class );
     50        if ( 0 === strpos( $class, 'trac_notifications_' ) ) {
     51            require __DIR__ . '/' . str_replace( '_', '-', $class ) . '.php';
     52        }
    4653    }
    4754
Note: See TracChangeset for help on using the changeset viewer.