WordPress.org

Plugin Directory

Changeset 603533


Ignore:
Timestamp:
09/25/12 10:01:02 (19 months ago)
Author:
simonwheatley
Message:

Tagged release 0.4

  • ENHANCEMENT: Allow admin to set different last tweet and last mention IDs.
  • ENHANCEMENT: Require POST request to unauthenticate user.
  • ENHANCEMENT: Introduce sanitise_id_str method to sanitise Twitter IDs while avoiding casting to integers (which corrupts data on 32 bit systems).
  • BUGFIX: Remove stray var_dump.
Location:
tweet-watcher
Files:
7 edited
8 copied

Legend:

Unmodified
Added
Removed
  • tweet-watcher/tags/0.4/class-tweet-watcher.php

    r601914 r603533  
    152152        $this->maybe_upgrade(); 
    153153        // A line to test queuing mentions on every admin page load 
    154         $this->queue_new_tweets(); 
     154//      $this->queue_new_tweets(); 
    155155        // Handy couple of lines to reset all the tweet collection 
    156156//      $this->init_oauth(); 
     
    181181        wp_enqueue_style( 'twtwchr-admin', $this->url( '/css/admin.css' ), array(), $this->version ); 
    182182        $this->init_oauth(); 
    183         if ( isset( $_GET[ 'twtwchr_unauthenticate' ] ) ) { 
    184             $user_id = absint( $_GET[ 'user_id' ] ); 
    185             check_admin_referer( "twtwchr_unauth_$user_id" ); 
     183         
     184        if ( isset( $_POST[ '_cftp_twtwchr_nonce_field' ] ) ) 
     185            check_admin_referer ( 'twtwchr_user_change', '_cftp_twtwchr_nonce_field' ); 
     186         
     187        // Request to change last tweet and last mention IDs 
     188        if ( isset( $_POST[ 'last_tweet_id' ] ) ) { 
     189            $users = $this->oauth->get_users(); 
     190            foreach ( $_POST[ 'last_tweet_id' ] as $user_id => $value ) { 
     191                $this->oauth->set_user_property( $user_id, 'last_tweet_id', $this->sanitise_id_str( $_POST[ 'last_tweet_id' ][ $user_id ] ) ); 
     192                $this->oauth->set_user_property( $user_id, 'last_mention_id', $this->sanitise_id_str( $_POST[ 'last_mention_id' ][ $user_id ] ) ); 
     193            } 
     194            $this->set_admin_notice( __( 'The ID change has been saved.', 'twtwchr' ) ); 
     195            wp_redirect( admin_url( 'options-general.php?page=twtwchr_auth&twtwchr_user_deleted=1' ) ); 
     196            exit; 
     197        } 
     198 
     199        // De-auth a particular user 
     200        if ( isset( $_POST[ '_twtwchr_unauth_nonce_field' ] ) ) { 
     201            $user_id = absint( $_POST[ 'user_id' ] ); 
     202            check_admin_referer ( "twtwchr_user_unauth_$user_id", '_twtwchr_unauth_nonce_field' ); 
    186203            $user = $this->oauth->get_user( $user_id ); 
    187204            $this->oauth->delete_user( $user_id ); 
     
    189206            wp_redirect( admin_url( 'options-general.php?page=twtwchr_auth&twtwchr_user_deleted=1' ) ); 
    190207            exit; 
    191         } elseif ( isset( $_GET[ 'twtwchr_authenticate' ] ) ) { 
     208        } 
     209         
     210        // Part of the oAuth process 
     211        if ( isset( $_GET[ 'twtwchr_authenticate' ] ) ) { 
    192212            check_admin_referer( 'twtwchr_auth' ); 
    193213            $this->oauth->delete_auth_properties(); 
     
    260280    public function settings() { 
    261281        $vars = array(); 
    262         $vars[ 'users' ] = $this->oauth->get_users(); 
    263         foreach ( $vars[ 'users' ] as $user_id => & $user ) { 
    264             $unauth_args = array( 'twtwchr_unauthenticate' => 1, 'user_id' => $user_id ); 
    265             $unauth_url = add_query_arg( $unauth_args ); 
    266             $unauth_url = wp_nonce_url( $unauth_url, "twtwchr_unauth_$user_id" ); 
    267             $user[ 'unauth_url' ] = $unauth_url; 
    268         } 
    269         $vars[ 'auth_url' ] = wp_nonce_url( add_query_arg( array( 'twtwchr_authenticate' => 1 ) ), 'twtwchr_auth' ); 
    270         $this->render_admin( 'settings.php', $vars ); 
     282        if ( isset( $_GET[ 'twtwchr_unauthenticate' ] ) ) { 
     283            $user_id_str = absint( $_GET[ 'user_id' ] ); 
     284            $vars[ 'unauthenticate_user_id' ] = $_GET[ 'twtwchr_unauthenticate' ]; 
     285            $vars[ 'user_id' ] = $user_id_str; 
     286            $vars[ 'user' ] = $this->oauth->get_user( $user_id_str ); 
     287            $this->render_admin( 'confirm-unauthenticate.php', $vars ); 
     288        } else { 
     289            $vars[ 'users' ] = $this->oauth->get_users(); 
     290            foreach ( $vars[ 'users' ] as $user_id => & $user ) { 
     291                $unauth_args = array( 'twtwchr_unauthenticate' => 1, 'user_id' => $user_id ); 
     292                $unauth_url = add_query_arg( $unauth_args ); 
     293                $user[ 'unauth_url' ] = $unauth_url; 
     294            } 
     295            $vars[ 'auth_url' ] = wp_nonce_url( add_query_arg( array( 'twtwchr_authenticate' => 1 ) ), 'twtwchr_auth' ); 
     296            $this->render_admin( 'settings.php', $vars ); 
     297        } 
    271298    } 
    272299 
     
    382409     
    383410    /** 
     411     * We cannot sanitise some ID strings by converting to integers, as  
     412     * they will overflow 32 bit systems and corrupt data. This method 
     413     * sanitises without converting to ints. 
     414     *  
     415     * @param string $id_str An integer ID represented as a string to be sanitised 
     416     * @return string A sanitised integer ID  
     417     */ 
     418    public function sanitise_id_str( $id_str ) { 
     419        $id_str = preg_replace( '/[^\d]/', '', (string) $id_str ); 
     420        return $id_str; 
     421    } 
     422     
     423    /** 
    384424     * Checks the DB structure is up to date. 
    385425     * 
  • tweet-watcher/tags/0.4/css/admin.css

    r600164 r603533  
    33} 
    44 
    5 p.twtwchr-auth { 
    6     margin-top: 5em; 
     5.settings_page_twtwchr_auth input.delete { 
     6    color: #900; 
     7    border-color: #900; 
    78} 
     9 
     10.settings_page_twtwchr_auth input.delete:hover { 
     11    color: #f00; 
     12    border-color: #f00; 
     13} 
  • tweet-watcher/tags/0.4/readme.txt

    r601915 r603533  
    1717== Changelog == 
    1818 
     19= 0.4 = 
     20 
     21Tuesday 25 September 2012 
     22 
     23* ENHANCEMENT: Allow admin to set different last tweet and last mention IDs. 
     24* ENHANCEMENT: Require POST request to unauthenticate user. 
     25* ENHANCEMENT: Introduce sanitise_id_str method to sanitise Twitter IDs while avoiding casting to integers (which corrupts data on 32 bit systems). 
     26* BUGFIX: Remove stray var_dump. 
     27 
    1928= 0.3 = 
    2029 
  • tweet-watcher/tags/0.4/templates-admin/settings.php

    r600164 r603533  
    77     
    88    <p>Note that the restrictions registered for this plugin with Twitter mean that it can only read your tweets and mentions, and see your followers, it cannot tweet on your behalf or see DMs.</p> 
    9      
     9         
    1010    <?php if ( $users ) : ?> 
    1111     
    12         <p>You are currently authenticated as the following users:</p> 
     12        <form action="" method="post"> 
     13            <?php wp_nonce_field( 'twtwchr_user_change', '_twtwchr_user_settings_nonce_field' ); ?> 
    1314 
    14         <ul class="twtwchr-users"> 
    15             <?php foreach( $users as $user_id => & $user ) : ?> 
    16                 <li> 
    17                     <a href="http://twitter.com/<?php echo esc_attr( $user[ 'screen_name' ] ); ?>">@<?php echo esc_html( $user[ 'screen_name' ] ); ?></a>:  
    18                     <a href="<?php echo esc_url( $user[ 'unauth_url' ] ); ?>" class="button">Unauthenticate</a> 
    19                 </li> 
    20             <?php endforeach; ?> 
    21         </ul> 
     15            <p>You are currently authenticated as the following users:</p> 
     16 
     17            <ul class="twtwchr-users"> 
     18                <?php foreach( $users as $user_id => & $user ) : ?> 
     19                    <li> 
     20                        <a href="http://twitter.com/<?php echo esc_attr( $user[ 'screen_name' ] ); ?>">@<?php echo esc_html( $user[ 'screen_name' ] ); ?></a>:  
     21 
     22                        <label for="last_tweet_id_<?php echo esc_attr( $user_id ); ?>" title="The Twitter Tweet ID of the last tweet FROM this account that has been seen"> 
     23                            Last tweeted ID 
     24                            <input type="text" id="last_tweet_id_<?php echo esc_attr( $user_id ); ?>" name="last_tweet_id[<?php echo esc_attr( $user_id ); ?>]" class="short-text" value="<?php echo esc_attr( $user[ 'last_tweet_id' ] ); ?>" /> 
     25                        </label> 
     26 
     27                        <label for="last_mention_id_<?php echo esc_attr( $user_id ); ?>" title="The Twitter Tweet ID of the last tweet AT this account that has been seen"> 
     28                            Last mentioned ID 
     29                            <input type="text" id="last_mention_id_<?php echo esc_attr( $user_id ); ?>" name="last_mention_id[<?php echo esc_attr( $user_id ); ?>]" class="short-text" value="<?php echo esc_attr( $user[ 'last_mention_id' ] ); ?>" /> 
     30                        </label> 
     31 
     32                        <a href="<?php echo esc_url( $user[ 'unauth_url' ] ); ?>" class="button">Unauthenticate</a> 
     33                    </li> 
     34                <?php endforeach; ?> 
     35            </ul> 
     36             
     37            <?php submit_button( __( 'Save Changes', 'twtwchr' ) ); ?> 
     38 
     39        </form> 
    2240     
    2341    <?php endif; ?> 
    2442         
    25     <p class="twtwchr-auth"><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new acccount</a></p> 
     43    <p><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new acccount</a></p> 
    2644     
    2745</div> 
  • tweet-watcher/tags/0.4/tweet-watcher.php

    r601914 r603533  
    55Plugin URI: https://github.com/simonwheatley/Tweet-Watcher/ 
    66Description: Authenticates with a number of Twitter accounts and fires actions for each mention or tweet. 
    7 Version: 0.3 
     7Version: 0.4 
    88Author: Simon Wheatley (Code for the People) 
    99Author URI: http://codeforthepeople.com/ 
  • tweet-watcher/trunk/class-tweet-watcher.php

    r601914 r603533  
    152152        $this->maybe_upgrade(); 
    153153        // A line to test queuing mentions on every admin page load 
    154         $this->queue_new_tweets(); 
     154//      $this->queue_new_tweets(); 
    155155        // Handy couple of lines to reset all the tweet collection 
    156156//      $this->init_oauth(); 
     
    181181        wp_enqueue_style( 'twtwchr-admin', $this->url( '/css/admin.css' ), array(), $this->version ); 
    182182        $this->init_oauth(); 
    183         if ( isset( $_GET[ 'twtwchr_unauthenticate' ] ) ) { 
    184             $user_id = absint( $_GET[ 'user_id' ] ); 
    185             check_admin_referer( "twtwchr_unauth_$user_id" ); 
     183         
     184        if ( isset( $_POST[ '_cftp_twtwchr_nonce_field' ] ) ) 
     185            check_admin_referer ( 'twtwchr_user_change', '_cftp_twtwchr_nonce_field' ); 
     186         
     187        // Request to change last tweet and last mention IDs 
     188        if ( isset( $_POST[ 'last_tweet_id' ] ) ) { 
     189            $users = $this->oauth->get_users(); 
     190            foreach ( $_POST[ 'last_tweet_id' ] as $user_id => $value ) { 
     191                $this->oauth->set_user_property( $user_id, 'last_tweet_id', $this->sanitise_id_str( $_POST[ 'last_tweet_id' ][ $user_id ] ) ); 
     192                $this->oauth->set_user_property( $user_id, 'last_mention_id', $this->sanitise_id_str( $_POST[ 'last_mention_id' ][ $user_id ] ) ); 
     193            } 
     194            $this->set_admin_notice( __( 'The ID change has been saved.', 'twtwchr' ) ); 
     195            wp_redirect( admin_url( 'options-general.php?page=twtwchr_auth&twtwchr_user_deleted=1' ) ); 
     196            exit; 
     197        } 
     198 
     199        // De-auth a particular user 
     200        if ( isset( $_POST[ '_twtwchr_unauth_nonce_field' ] ) ) { 
     201            $user_id = absint( $_POST[ 'user_id' ] ); 
     202            check_admin_referer ( "twtwchr_user_unauth_$user_id", '_twtwchr_unauth_nonce_field' ); 
    186203            $user = $this->oauth->get_user( $user_id ); 
    187204            $this->oauth->delete_user( $user_id ); 
     
    189206            wp_redirect( admin_url( 'options-general.php?page=twtwchr_auth&twtwchr_user_deleted=1' ) ); 
    190207            exit; 
    191         } elseif ( isset( $_GET[ 'twtwchr_authenticate' ] ) ) { 
     208        } 
     209         
     210        // Part of the oAuth process 
     211        if ( isset( $_GET[ 'twtwchr_authenticate' ] ) ) { 
    192212            check_admin_referer( 'twtwchr_auth' ); 
    193213            $this->oauth->delete_auth_properties(); 
     
    260280    public function settings() { 
    261281        $vars = array(); 
    262         $vars[ 'users' ] = $this->oauth->get_users(); 
    263         foreach ( $vars[ 'users' ] as $user_id => & $user ) { 
    264             $unauth_args = array( 'twtwchr_unauthenticate' => 1, 'user_id' => $user_id ); 
    265             $unauth_url = add_query_arg( $unauth_args ); 
    266             $unauth_url = wp_nonce_url( $unauth_url, "twtwchr_unauth_$user_id" ); 
    267             $user[ 'unauth_url' ] = $unauth_url; 
    268         } 
    269         $vars[ 'auth_url' ] = wp_nonce_url( add_query_arg( array( 'twtwchr_authenticate' => 1 ) ), 'twtwchr_auth' ); 
    270         $this->render_admin( 'settings.php', $vars ); 
     282        if ( isset( $_GET[ 'twtwchr_unauthenticate' ] ) ) { 
     283            $user_id_str = absint( $_GET[ 'user_id' ] ); 
     284            $vars[ 'unauthenticate_user_id' ] = $_GET[ 'twtwchr_unauthenticate' ]; 
     285            $vars[ 'user_id' ] = $user_id_str; 
     286            $vars[ 'user' ] = $this->oauth->get_user( $user_id_str ); 
     287            $this->render_admin( 'confirm-unauthenticate.php', $vars ); 
     288        } else { 
     289            $vars[ 'users' ] = $this->oauth->get_users(); 
     290            foreach ( $vars[ 'users' ] as $user_id => & $user ) { 
     291                $unauth_args = array( 'twtwchr_unauthenticate' => 1, 'user_id' => $user_id ); 
     292                $unauth_url = add_query_arg( $unauth_args ); 
     293                $user[ 'unauth_url' ] = $unauth_url; 
     294            } 
     295            $vars[ 'auth_url' ] = wp_nonce_url( add_query_arg( array( 'twtwchr_authenticate' => 1 ) ), 'twtwchr_auth' ); 
     296            $this->render_admin( 'settings.php', $vars ); 
     297        } 
    271298    } 
    272299 
     
    382409     
    383410    /** 
     411     * We cannot sanitise some ID strings by converting to integers, as  
     412     * they will overflow 32 bit systems and corrupt data. This method 
     413     * sanitises without converting to ints. 
     414     *  
     415     * @param string $id_str An integer ID represented as a string to be sanitised 
     416     * @return string A sanitised integer ID  
     417     */ 
     418    public function sanitise_id_str( $id_str ) { 
     419        $id_str = preg_replace( '/[^\d]/', '', (string) $id_str ); 
     420        return $id_str; 
     421    } 
     422     
     423    /** 
    384424     * Checks the DB structure is up to date. 
    385425     * 
  • tweet-watcher/trunk/css/admin.css

    r600164 r603533  
    33} 
    44 
    5 p.twtwchr-auth { 
    6     margin-top: 5em; 
     5.settings_page_twtwchr_auth input.delete { 
     6    color: #900; 
     7    border-color: #900; 
    78} 
     9 
     10.settings_page_twtwchr_auth input.delete:hover { 
     11    color: #f00; 
     12    border-color: #f00; 
     13} 
  • tweet-watcher/trunk/readme.txt

    r601915 r603533  
    1717== Changelog == 
    1818 
     19= 0.4 = 
     20 
     21Tuesday 25 September 2012 
     22 
     23* ENHANCEMENT: Allow admin to set different last tweet and last mention IDs. 
     24* ENHANCEMENT: Require POST request to unauthenticate user. 
     25* ENHANCEMENT: Introduce sanitise_id_str method to sanitise Twitter IDs while avoiding casting to integers (which corrupts data on 32 bit systems). 
     26* BUGFIX: Remove stray var_dump. 
     27 
    1928= 0.3 = 
    2029 
  • tweet-watcher/trunk/templates-admin/settings.php

    r600164 r603533  
    77     
    88    <p>Note that the restrictions registered for this plugin with Twitter mean that it can only read your tweets and mentions, and see your followers, it cannot tweet on your behalf or see DMs.</p> 
    9      
     9         
    1010    <?php if ( $users ) : ?> 
    1111     
    12         <p>You are currently authenticated as the following users:</p> 
     12        <form action="" method="post"> 
     13            <?php wp_nonce_field( 'twtwchr_user_change', '_twtwchr_user_settings_nonce_field' ); ?> 
    1314 
    14         <ul class="twtwchr-users"> 
    15             <?php foreach( $users as $user_id => & $user ) : ?> 
    16                 <li> 
    17                     <a href="http://twitter.com/<?php echo esc_attr( $user[ 'screen_name' ] ); ?>">@<?php echo esc_html( $user[ 'screen_name' ] ); ?></a>:  
    18                     <a href="<?php echo esc_url( $user[ 'unauth_url' ] ); ?>" class="button">Unauthenticate</a> 
    19                 </li> 
    20             <?php endforeach; ?> 
    21         </ul> 
     15            <p>You are currently authenticated as the following users:</p> 
     16 
     17            <ul class="twtwchr-users"> 
     18                <?php foreach( $users as $user_id => & $user ) : ?> 
     19                    <li> 
     20                        <a href="http://twitter.com/<?php echo esc_attr( $user[ 'screen_name' ] ); ?>">@<?php echo esc_html( $user[ 'screen_name' ] ); ?></a>:  
     21 
     22                        <label for="last_tweet_id_<?php echo esc_attr( $user_id ); ?>" title="The Twitter Tweet ID of the last tweet FROM this account that has been seen"> 
     23                            Last tweeted ID 
     24                            <input type="text" id="last_tweet_id_<?php echo esc_attr( $user_id ); ?>" name="last_tweet_id[<?php echo esc_attr( $user_id ); ?>]" class="short-text" value="<?php echo esc_attr( $user[ 'last_tweet_id' ] ); ?>" /> 
     25                        </label> 
     26 
     27                        <label for="last_mention_id_<?php echo esc_attr( $user_id ); ?>" title="The Twitter Tweet ID of the last tweet AT this account that has been seen"> 
     28                            Last mentioned ID 
     29                            <input type="text" id="last_mention_id_<?php echo esc_attr( $user_id ); ?>" name="last_mention_id[<?php echo esc_attr( $user_id ); ?>]" class="short-text" value="<?php echo esc_attr( $user[ 'last_mention_id' ] ); ?>" /> 
     30                        </label> 
     31 
     32                        <a href="<?php echo esc_url( $user[ 'unauth_url' ] ); ?>" class="button">Unauthenticate</a> 
     33                    </li> 
     34                <?php endforeach; ?> 
     35            </ul> 
     36             
     37            <?php submit_button( __( 'Save Changes', 'twtwchr' ) ); ?> 
     38 
     39        </form> 
    2240     
    2341    <?php endif; ?> 
    2442         
    25     <p class="twtwchr-auth"><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new acccount</a></p> 
     43    <p><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new acccount</a></p> 
    2644     
    2745</div> 
  • tweet-watcher/trunk/tweet-watcher.php

    r601914 r603533  
    55Plugin URI: https://github.com/simonwheatley/Tweet-Watcher/ 
    66Description: Authenticates with a number of Twitter accounts and fires actions for each mention or tweet. 
    7 Version: 0.3 
     7Version: 0.4 
    88Author: Simon Wheatley (Code for the People) 
    99Author URI: http://codeforthepeople.com/ 
Note: See TracChangeset for help on using the changeset viewer.