Plugin Directory

Changeset 1669999


Ignore:
Timestamp:
06/03/2017 05:59:36 AM (9 years ago)
Author:
nepirity
Message:

Adding version 1.0.2 files

Location:
nepirity-analytics/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • nepirity-analytics/trunk/modules/admin.php

    r1666843 r1669999  
    5656
    5757        if (NP()->settings()->is_configured()) {
    58             add_submenu_page(self::MENU_SLUG_INDEX, 'nepirity_admin_index title', np_translate('Dashboard'),
     58            add_submenu_page(self::MENU_SLUG_INDEX, 'Nepirity Analytics Dashboard', np_translate('Dashboard'),
    5959                'manage_options', self::MENU_SLUG_INDEX, array(__CLASS__, 'index_page'));
    6060
    61             add_submenu_page(self::MENU_SLUG_INDEX, 'nepirity_admin_settings title', np_translate('Settings'),
     61            add_submenu_page(self::MENU_SLUG_INDEX, 'Nepirity Analytics Settings', np_translate('Settings'),
    6262                'manage_options', 'nepirity_admin_settings', array(__CLASS__, 'settings_page'));
    6363        }
  • nepirity-analytics/trunk/modules/analytics.php

    r1669213 r1669999  
    1616        $npkey = NP()->settings()->get_nepirity_key();
    1717
    18         if (!sizeof($token)) {
     18        if (!count($token)) {
    1919            $auth = NP()->settings()->get_google_account_auth_config();
    2020            $token = $google->get_access_token($npkey, $auth);
     
    2626
    2727    protected function get_googleauth_oauth_access_token($key) {
    28         $npkey = NP()->settings()->get_nepirity_key();
    2928        $google = NP()->jsonrpc()->google();
    30         $token = $google->get_access_token_using_authkey($npkey, $key);
     29
     30        if ($key) {
     31            $npkey = NP()->settings()->get_nepirity_key();
     32            return $google->get_access_token_using_authkey($npkey, $key);
     33        }
     34
     35        $token = NP()->settings()->get_saved_google_token();
     36
     37        if (!count($token)) {
     38            $refresh = NP()->settings()->get_saved_refresh_token();
     39            $token = $google->get_refresh_token($refresh);
     40            NP()->settings()->save_google_token($token);
     41        }
    3142
    3243        return $token;
     
    3849        switch ($auth_type) {
    3950            case Setting::GOOGLE_AUTHTYPE_OAUTH: {
    40                 if ($key == null) {
    41                     return  NP()->settings()->get_saved_google_token();
    42                 }
    43 
    4451                return $this->get_googleauth_oauth_access_token($key);
    4552            }
  • nepirity-analytics/trunk/modules/settings.php

    r1669213 r1669999  
    480480        $token = json_decode($this->get_option_value(self::FIELD_GOOGLE_ACCESS_TOKEN), true);
    481481
    482         if ($this->is_google_oauth_type()) {
    483             return $token;
    484         }
    485 
    486482        if (sizeof($token) && isset($token['created']) && isset($token['expires_in'])) {
    487483            if ($diff = time() + 30 < $token['created'] + $token['expires_in']) {
     
    496492        $this->update_option_value(self::FIELD_GOOGLE_ACCESS_TOKEN, json_encode($token));
    497493    }
     494
     495    public function get_saved_refresh_token() {
     496        $token = json_decode($this->get_option_value(self::FIELD_GOOGLE_ACCESS_TOKEN), true);
     497
     498        if (isset($token['refresh_token'])) return $token['refresh_token'];
     499
     500        return "";
     501    }
    498502}
    499503
  • nepirity-analytics/trunk/nepirity-analytics.php

    r1669213 r1669999  
    33Plugin Name: Nepirity Analytics
    44Description: Nepirity Analytics is a plugin that provides web traffic data analysis feature with data gathered from Google Analytics.
    5 Version:     1.0.1
     5Version:     1.0.2
    66Author:      Nepirity Corp.
    77Author URI:  https://www.nepirity.com/
  • nepirity-analytics/trunk/readme.txt

    r1669213 r1669999  
    55Requires at least: 4.6.5
    66Tested up to: 4.7.5
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    35351. Start activating the plugin with a Nepirity Service key.
    3636
    37 2. Enter in your Google Service Account Key in the plugin settings.
     372. Enter your Google Account Information in the plugin settings.
    3838
    39393. Check [Read & Analyze] option in your Google Analytics settings.
     
    6262
    6363== Changelog ==
     64= 1.0.2 =
     65Fixed Google authentication method.
     66
    6467= 1.0.1 =
    6568Added Google authentication method.
     
    6972
    7073== Upgrade Notice ==
    71 = 1.0.1 =
    72 New Google authentication method has been added. You can install the plugin a little easier and more convenient.
     74= 1.0.2 =
     75OAuth authentication has been modified so that tokens can be updated if the token expires.
  • nepirity-analytics/trunk/sdk/classes/google.php

    r1669213 r1669999  
    99}
    1010
    11 abstract class GoogleAuth {
    12     protected $jsonrpc;
    13 
    14     function __construct($server) {
    15         $this->jsonrpc = new Google($server);
    16     }
    17 
    18     abstract public function get_access_token($npkey, $googlekey);
    19     abstract public function get_profiles($npkey, $googlekey);
    20 }
    21 
    22 class GoogleAuthAccount extends GoogleAuth {
    23     function __construct($server) {
    24         parent::__construct($server);
    25     }
    26 
    27     public function get_access_token($npkey, $googlekey) {
    28         return $this->jsonrpc->get_access_token($npkey, $googlekey);
    29     }
    30 
    31     public function get_profiles($npkey, $googlekey) {
    32         return $this->jsonrpc->get_profiles($npkey, $googlekey);
    33     }
    34 }
    35 
    36 class GoogleAuthOauth extends GoogleAuth {
    37     function __construct($server) {
    38         parent::__construct($server);
    39     }
    40 
    41     public function get_access_token($npkey, $googlekey) {
    42     }
    43 
    44     public function get_profiles($npkey, $googlekey) {
    45     }
    46 }
    47 
    4811}
    4912
Note: See TracChangeset for help on using the changeset viewer.