Plugin Directory

Changeset 1669213


Ignore:
Timestamp:
06/02/2017 04:36:50 AM (9 years ago)
Author:
nepirity
Message:

Adding version 1.0.1 files

Location:
nepirity-analytics/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • nepirity-analytics/trunk/languages/nepirity-services-ko_KR.po

    r1666843 r1669213  
    99"Project-Id-Version: nepirity-services\n"
    1010"Report-Msgid-Bugs-To: \n"
    11 "POT-Creation-Date: 2017-05-28 11:47+0000\n"
    12 "PO-Revision-Date: 2017-05-28 11:47+0000\n"
     11"POT-Creation-Date: 2017-06-02 04:11+0000\n"
     12"PO-Revision-Date: 2017-06-02 04:11+0000\n"
    1313"Last-Translator: Automatically generated\n"
    1414"Language-Team: none\n"
     
    2323msgstr "구글 프로파일 정보를 가져올 수 없습니다. 플러그인을 다시 설정해 주시기 바랍니다."
    2424
    25 #: modules/settings.php:119
     25#: modules/settings.php:126
    2626msgid "Click, if you want to bring up the Nepirity Setup Wizard."
    2727msgstr "네피리티 설정 마법사를 다시 실행하실 수 있습니다."
     
    3131msgstr "대시보드"
    3232
    33 #: modules/settings.php:47
     33#: modules/settings.php:54
    3434msgid "Dismiss this notice."
    3535msgstr "숨기기"
    3636
    37 #: modules/setup.php:35
     37#: modules/setup.php:37
    3838msgid "Done"
    3939msgstr "완료"
    4040
    41 #: modules/settings.php:249
     41#: modules/settings.php:308
    4242msgid "Enable Standard Tracking"
    4343msgstr "Tracking 활성화"
    4444
    45 #: modules/admin.php:72
     45#: modules/admin.php:73
    4646msgid "General"
    4747msgstr "일반"
    4848
    49 #: modules/setup.php:76
     49#: modules/setup.php:83
    5050msgid "Go Back"
    51 msgstr "뒤로가기"
    52 
    53 #: modules/settings.php:219
     51msgstr "뒤로"
     52
     53#: modules/settings.php:264
    5454msgid "Google Account Service Key"
    55 msgstr "구글 계정 비스 키"
    56 
    57 #: modules/settings.php:114
     55msgstr "구글 계정 비스 키"
     56
     57#: modules/settings.php:121
    5858msgid "Google Account Setting"
    5959msgstr "구글 계정 설정"
    6060
    61 #: modules/settings.php:356
     61#: modules/settings.php:239 modules/setup.php:168
     62msgid "Google Authentication Type"
     63msgstr "구글 인증 방법"
     64
     65#. The same with google account
     66#: modules/settings.php:277
     67msgid "Google OAuth Code"
     68msgstr "구글 OAuth 코드"
     69
     70#: modules/setup.php:188
     71msgid "Google OAuth Setting"
     72msgstr "구글 OAuth 설정"
     73
     74#: modules/settings.php:420
    6275msgid "Google Profile Error!"
    63 msgstr "구글 프로파일 에러"
    64 
    65 #: modules/setup.php:168
     76msgstr "구글 프로 에러"
     77
     78#: modules/setup.php:232
    6679msgid "Google Profile Setting"
    67 msgstr "구글 프로파일 설정"
    68 
    69 #: modules/setup.php:157
     80msgstr "구글 프로 설정"
     81
     82#: modules/setup.php:196
    7083msgid "Google Service Account Setting"
    71 msgstr "구글 서비스 계정 정보 설정"
    72 
    73 #: modules/setup.php:287
    74 msgid "Google Service Account key information is not appropriate."
    75 msgstr "구글 서비스 계정 키 정보가 올바르지 않습니다."
    76 
    77 #: modules/settings.php:136
     84msgstr "구글 서비스 계정 설정"
     85
     86#: modules/setup.php:351
     87msgid "Google Setting information is not appropriate."
     88msgstr "구글 설정 정보가 올바르지 않습니다."
     89
     90#: modules/settings.php:143
    7891msgid "Goolge Tracking Options"
    7992msgstr "구글 Tracking 옵션"
    8093
    81 #: modules/settings.php:124
     94#: modules/settings.php:131
    8295msgid "Goolge View Setting"
    8396msgstr "구글 뷰 설정"
    8497
    85 #: modules/settings.php:100
     98#: modules/settings.php:107
    8699msgid ""
    87100"In order to use Nepirity Analysis Service, please enter your account "
     
    89102msgstr "네피리티 분석 서비스를 이용하기 위해서는 아래 계정 정보를 입력하시기 바랍니다."
    90103
    91 #: modules/settings.php:125
     104#: modules/settings.php:132
    92105msgid ""
    93106"In order to use Nepirity Analysis Service, please select your Goolge view "
     
    99112msgstr "네피리티"
    100113
    101 #. Description of the plugin
    102 msgid ""
    103 "Nepirity Analytics is a plugin that provides web traffic data analysis "
    104 "feature with data gathered from Google Analytics."
    105 msgstr ""
    106 "Nepirity Analytics 플러그인은 Google Analytics 으로부터 수집된 데이터를 분석"
    107 "하여 정보를 제공합니다."
    108 
    109 
    110 #: modules/settings.php:210
     114#: modules/settings.php:217
    111115msgid "Nepirity KEY"
    112116msgstr "네피리티 키"
    113117
    114 #: modules/setup.php:136
     118#: modules/setup.php:143
    115119msgid "Nepirity Plugin Setting"
    116120msgstr "네피리티 플러그인 설정"
    117121
    118 #: modules/setup.php:129
     122#: modules/setup.php:136
    119123msgid "Nepirity Plugin Setup Wizard"
    120124msgstr "네피리티 플러그인 설치 마법사"
    121125
    122 #: modules/settings.php:99
     126#: modules/settings.php:106
    123127msgid "Nepirity Settings"
    124128msgstr "네피리티 설정"
    125129
    126 #: modules/setup.php:257
     130#: modules/setup.php:148
    127131msgid "Nepirity key information is not appropriate."
    128132msgstr "네피리티 키 정보가 올바르지 않습니다."
    129133
    130 #: modules/setup.php:28
     134#: modules/setup.php:30
    131135msgid "Next"
    132136msgstr "다음"
    133137
    134 #: modules/setup.php:152
     138#: modules/setup.php:204
    135139msgid "Please save it again."
    136140msgstr "다시 저장해 주시기 바랍니다."
    137141
    138 #: modules/setup.php:146
     142#: modules/setup.php:166
     143msgid "Please select a Google authentication method."
     144msgstr "구글 인증 방법을 선택해 주시기 바랍니다."
     145
     146#: modules/setup.php:353
     147msgid "Please set up your account information correctly."
     148msgstr "계정 정보를 올바르게 설정해 주시기 바랍니다."
     149
     150#: modules/setup.php:189
     151msgid "Please, enter Google OAuth code."
     152msgstr "구글 OAuth 코드를 입력해 주시기 바랍니다."
     153
     154#: modules/setup.php:198
    139155msgid "Please, enter your Google Service account information."
    140156msgstr "구글 서비스 계정 정보를 입력해 주시기 바랍니다."
    141157
    142 #: modules/setup.php:137
     158#: modules/setup.php:144
    143159msgid "Please, enter your Nepirity plugin key."
    144160msgstr "네피리티 플러그인 키 정보를 입력해 주시기 바랍니다."
    145161
    146 #: modules/setup.php:289
    147 msgid "Please, input appropriate Google Service Account key information."
    148 msgstr "올바른 구글 서비스 키 정보를 입력해 주시기 바랍니다."
    149 
    150 #: modules/setup.php:258
     162#: modules/setup.php:149
    151163msgid ""
    152164"Please, input appropriate Nepirity key information and check that the key "
     
    154166msgstr "올바른 네피리티 키 정보를 입력해 주시기 바랍니다."
    155167
    156 #: modules/setup.php:169
     168#: modules/setup.php:233
    157169msgid "Please, select your Google View information."
    158 msgstr "구글 뷰를 선택해 주시기 바랍니다."
    159 
    160 #: nepirity.php:127 modules/views.php:113 modules/admin.php:61
     170msgstr "구글 뷰 정보를 선택해 주시기 바랍니다."
     171
     172#: nepirity-analytics.php:125 modules/views.php:113 modules/admin.php:61
    161173msgid "Settings"
    162174msgstr "설정"
    163175
    164 #: modules/settings.php:45
     176#: modules/settings.php:52
    165177msgid "Settings saved."
    166 msgstr "변경된 내용이 저장되었습니다."
    167 
    168 #: modules/setup.php:31
     178msgstr "설정이 저장되었습니다."
     179
     180#: modules/setup.php:33
    169181msgid "Start"
    170182msgstr "시작"
    171183
    172 #: modules/setup.php:130
     184#: modules/setup.php:137
    173185msgid "Start Nepirity plugin setup wizard"
    174 msgstr "네피리티 설정 마법사를 시작합니다."
    175 
    176 #: modules/admin.php:67
     186msgstr "네피리티 플러그인 설치 마법사를 시작합니다."
     187
     188#: modules/admin.php:68
    177189msgid "Summary"
    178190msgstr "개요"
    179191
    180 #: modules/settings.php:249
     192#: modules/settings.php:308
    181193msgid "Tracking Option"
    182194msgstr "Tracking 옵션"
    183195
    184 #: modules/settings.php:148
     196#: modules/settings.php:155
    185197msgid "Update"
    186198msgstr "수정"
    187199
    188 #: modules/setup.php:154
     200#: modules/setup.php:206
    189201msgid "When you leave this page, the previously saved values are retained."
    190202msgstr "이 페이지를 나가면, 이전에 저장된 값은 유지됩니다."
    191203
    192 #: modules/setup.php:149
     204#: modules/settings.php:271
     205msgid "You can check Google OAuth code"
     206msgstr "구글 OAuth 코드를 확인 하실 수 있습니다."
     207
     208#: modules/setup.php:201
    193209msgid "You can not modify the encrypted key."
    194 msgstr "암호화되어 저장된 내용은 수정 할 수 없습니다."
    195 
    196 #: modules/settings.php:116
     210msgstr "암호화된 키는 수정 하실 수 없습니다."
     211
     212#: modules/settings.php:123
    197213msgid "You cannot edit saved Google account information."
    198 msgstr "암호화 되어 저장된 구글 계정 정보는 수정 하실 수 없습니다."
    199 
    200 #: modules/settings.php:250
     214msgstr "저장된 구글 계정 정보는 수정 하실 수 없습니다."
     215
     216#: modules/settings.php:309
    201217msgid "You don't need to enable this if already inserted Google tracking code."
    202218msgstr "이미 Tracking 코드가 삽입되었으면, 이 옵션을 활성화 할 필요가 없습니다."
    203219
    204 #: modules/setup.php:263
     220#: modules/setup.php:154
    205221msgid "Your current site address is:"
    206 msgstr "여러분의 현재 사이트 주소는 다음과 같습니다."
    207 
    208 #: modules/settings.php:120
     222msgstr "여러분의 사이트 주소는 다음과 같습니다."
     223
     224#: modules/settings.php:127
    209225msgid "[Here]"
    210226msgstr "[이곳]"
    211227
    212 #: modules/settings.php:229
     228#: modules/settings.php:288
    213229msgid "account"
    214230msgstr "계정"
    215231
    216 #: modules/settings.php:234
     232#: modules/settings.php:293
    217233msgid "property"
    218234msgstr "속성"
    219235
    220 #: modules/settings.php:239
     236#: modules/settings.php:298
    221237msgid "view"
    222238msgstr "뷰"
     239
     240#. Description of the plugin
     241msgid ""
     242"Nepirity Analytics is a plugin that provides web traffic data analysis "
     243"feature with data gathered from Google Analytics."
     244msgstr "Nepirity Analytics 플러그인은 Google Analytics 으로부터 수집된 데이터를 분석하여 정보를 제공합니다."
  • nepirity-analytics/trunk/languages/nepirity-services.pot

    r1666843 r1669213  
    99"Project-Id-Version: nepirity-services\n"
    1010"Report-Msgid-Bugs-To: \n"
    11 "POT-Creation-Date: 2017-05-28 11:47+0000\n"
     11"POT-Creation-Date: 2017-06-02 04:11+0000\n"
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    2222msgstr ""
    2323
    24 #: modules/settings.php:119
     24#: modules/settings.php:126
    2525msgid "Click, if you want to bring up the Nepirity Setup Wizard."
    2626msgstr ""
    2727
    28 #: modules/admin.php:58 modules/admin.php:58
     28#: modules/admin.php:58
    2929msgid "Dashboard"
    3030msgstr ""
    3131
    32 #: modules/settings.php:47
     32#: modules/settings.php:54
    3333msgid "Dismiss this notice."
    3434msgstr ""
    3535
    36 #: modules/setup.php:35 modules/setup.php:35
     36#: modules/setup.php:37
    3737msgid "Done"
    3838msgstr ""
    3939
    40 #: modules/settings.php:249
     40#: modules/settings.php:308
    4141msgid "Enable Standard Tracking"
    4242msgstr ""
    4343
    44 #: modules/admin.php:72 modules/admin.php:72
     44#: modules/admin.php:73
    4545msgid "General"
    4646msgstr ""
    4747
    48 #: modules/setup.php:76 modules/setup.php:76
     48#: modules/setup.php:83
    4949msgid "Go Back"
    5050msgstr ""
    5151
    52 #: modules/settings.php:219
     52#: modules/settings.php:264
    5353msgid "Google Account Service Key"
    5454msgstr ""
    5555
    56 #: modules/settings.php:114
     56#: modules/settings.php:121
    5757msgid "Google Account Setting"
    5858msgstr ""
    5959
    60 #: modules/settings.php:356
     60#: modules/settings.php:239 modules/setup.php:168
     61msgid "Google Authentication Type"
     62msgstr ""
     63
     64#. The same with google account
     65#: modules/settings.php:277
     66msgid "Google OAuth Code"
     67msgstr ""
     68
     69#: modules/setup.php:188
     70msgid "Google OAuth Setting"
     71msgstr ""
     72
     73#: modules/settings.php:420
    6174msgid "Google Profile Error!"
    6275msgstr ""
    6376
    64 #: modules/setup.php:168 modules/setup.php:168
     77#: modules/setup.php:232
    6578msgid "Google Profile Setting"
    6679msgstr ""
    6780
    68 #: modules/setup.php:157 modules/setup.php:157
     81#: modules/setup.php:196
    6982msgid "Google Service Account Setting"
    7083msgstr ""
    7184
    72 #: modules/setup.php:287 modules/setup.php:287
    73 msgid "Google Service Account key information is not appropriate."
    74 msgstr ""
    75 
    76 #: modules/settings.php:136
     85#: modules/setup.php:351
     86msgid "Google Setting information is not appropriate."
     87msgstr ""
     88
     89#: modules/settings.php:143
    7790msgid "Goolge Tracking Options"
    7891msgstr ""
    7992
    80 #: modules/settings.php:124
     93#: modules/settings.php:131
    8194msgid "Goolge View Setting"
    8295msgstr ""
    8396
    84 #: modules/settings.php:100
     97#: modules/settings.php:107
    8598msgid ""
    8699"In order to use Nepirity Analysis Service, please enter your account "
     
    88101msgstr ""
    89102
    90 #: modules/settings.php:125
     103#: modules/settings.php:132
    91104msgid ""
    92105"In order to use Nepirity Analysis Service, please select your Goolge view "
     
    94107msgstr ""
    95108
    96 #: modules/admin.php:54 modules/admin.php:54
     109#: modules/admin.php:54
    97110msgid "Nepirity"
    98111msgstr ""
    99112
    100 #. Description of the plugin
    101 msgid ""
    102 "Nepirity Analytics is a plugin that provides web traffic data analysis "
    103 "feature with data gathered from Google Analytics."
    104 msgstr ""
    105 
    106 #: modules/settings.php:210
     113#: modules/settings.php:217
    107114msgid "Nepirity KEY"
    108115msgstr ""
    109116
    110 #: modules/setup.php:136 modules/setup.php:136
     117#: modules/setup.php:143
    111118msgid "Nepirity Plugin Setting"
    112119msgstr ""
    113120
    114 #: modules/setup.php:129 modules/setup.php:129
     121#: modules/setup.php:136
    115122msgid "Nepirity Plugin Setup Wizard"
    116123msgstr ""
    117124
    118 #: modules/settings.php:99
     125#: modules/settings.php:106
    119126msgid "Nepirity Settings"
    120127msgstr ""
    121128
    122 #: modules/setup.php:257 modules/setup.php:257
     129#: modules/setup.php:148
    123130msgid "Nepirity key information is not appropriate."
    124131msgstr ""
    125132
    126 #: modules/setup.php:28 modules/setup.php:28
     133#: modules/setup.php:30
    127134msgid "Next"
    128135msgstr ""
    129136
    130 #: modules/setup.php:152 modules/setup.php:152
     137#: modules/setup.php:204
    131138msgid "Please save it again."
    132139msgstr ""
    133140
    134 #: modules/setup.php:146 modules/setup.php:146
     141#: modules/setup.php:166
     142msgid "Please select a Google authentication method."
     143msgstr ""
     144
     145#: modules/setup.php:353
     146msgid "Please set up your account information correctly."
     147msgstr ""
     148
     149#: modules/setup.php:189
     150msgid "Please, enter Google OAuth code."
     151msgstr ""
     152
     153#: modules/setup.php:198
    135154msgid "Please, enter your Google Service account information."
    136155msgstr ""
    137156
    138 #: modules/setup.php:137 modules/setup.php:137
     157#: modules/setup.php:144
    139158msgid "Please, enter your Nepirity plugin key."
    140159msgstr ""
    141160
    142 #: modules/setup.php:289 modules/setup.php:289
    143 msgid "Please, input appropriate Google Service Account key information."
    144 msgstr ""
    145 
    146 #: modules/setup.php:258 modules/setup.php:258
     161#: modules/setup.php:149
    147162msgid ""
    148163"Please, input appropriate Nepirity key information and check that the key "
     
    150165msgstr ""
    151166
    152 #: modules/setup.php:169 modules/setup.php:169
     167#: modules/setup.php:233
    153168msgid "Please, select your Google View information."
    154169msgstr ""
    155170
    156 #: nepirity.php:127 modules/views.php:113 modules/admin.php:61
    157 #: modules/views.php:113 modules/admin.php:61
     171#: nepirity-analytics.php:125 modules/views.php:113 modules/admin.php:61
    158172msgid "Settings"
    159173msgstr ""
    160174
    161 #: modules/settings.php:45
     175#: modules/settings.php:52
    162176msgid "Settings saved."
    163177msgstr ""
    164178
    165 #: modules/setup.php:31 modules/setup.php:31
     179#: modules/setup.php:33
    166180msgid "Start"
    167181msgstr ""
    168182
    169 #: modules/setup.php:130 modules/setup.php:130
     183#: modules/setup.php:137
    170184msgid "Start Nepirity plugin setup wizard"
    171185msgstr ""
    172186
    173 #: modules/admin.php:67 modules/admin.php:67
     187#: modules/admin.php:68
    174188msgid "Summary"
    175189msgstr ""
    176190
    177 #: modules/settings.php:249
     191#: modules/settings.php:308
    178192msgid "Tracking Option"
    179193msgstr ""
    180194
    181 #: modules/settings.php:148
     195#: modules/settings.php:155
    182196msgid "Update"
    183197msgstr ""
    184198
    185 #: modules/setup.php:154 modules/setup.php:154
     199#: modules/setup.php:206
    186200msgid "When you leave this page, the previously saved values are retained."
    187201msgstr ""
    188202
    189 #: modules/setup.php:149 modules/setup.php:149
     203#: modules/settings.php:271
     204msgid "You can check Google OAuth code"
     205msgstr ""
     206
     207#: modules/setup.php:201
    190208msgid "You can not modify the encrypted key."
    191209msgstr ""
    192210
    193 #: modules/settings.php:116
     211#: modules/settings.php:123
    194212msgid "You cannot edit saved Google account information."
    195213msgstr ""
    196214
    197 #: modules/settings.php:250
     215#: modules/settings.php:309
    198216msgid "You don't need to enable this if already inserted Google tracking code."
    199217msgstr ""
    200218
    201 #: modules/setup.php:263 modules/setup.php:263
     219#: modules/setup.php:154
    202220msgid "Your current site address is:"
    203221msgstr ""
    204222
    205 #: modules/settings.php:120
     223#: modules/settings.php:127
    206224msgid "[Here]"
    207225msgstr ""
    208226
    209 #: modules/settings.php:229
     227#: modules/settings.php:288
    210228msgid "account"
    211229msgstr ""
    212230
    213 #: modules/settings.php:234
     231#: modules/settings.php:293
    214232msgid "property"
    215233msgstr ""
    216234
    217 #: modules/settings.php:239
     235#: modules/settings.php:298
    218236msgid "view"
    219237msgstr ""
     238
     239#. Description of the plugin
     240msgid "Nepirity Analytics is a plugin that provides web traffic data analysis feature with data gathered from Google Analytics."
     241msgstr ""
  • nepirity-analytics/trunk/modules/analytics.php

    r1666843 r1669213  
    77    }
    88
    9     public function get_google_access_token() {
     9    public function get_google_auth_link() {
     10        return NP()->jsonrpc()->google()->get_auth_link();
     11    }
     12
     13    protected function get_googleauth_server_access_token() {
    1014        $google = NP()->jsonrpc()->google();
    1115        $token = NP()->settings()->get_saved_google_token();
     
    2125    }
    2226
    23     public function get_google_profiles() {
     27    protected function get_googleauth_oauth_access_token($key) {
     28        $npkey = NP()->settings()->get_nepirity_key();
     29        $google = NP()->jsonrpc()->google();
     30        $token = $google->get_access_token_using_authkey($npkey, $key);
     31
     32        return $token;
     33    }
     34
     35    public function get_google_access_token($key=null) {
     36        $auth_type = NP()->settings()->get_google_authtype();
     37
     38        switch ($auth_type) {
     39            case Setting::GOOGLE_AUTHTYPE_OAUTH: {
     40                if ($key == null) {
     41                    return  NP()->settings()->get_saved_google_token();
     42                }
     43
     44                return $this->get_googleauth_oauth_access_token($key);
     45            }
     46            case Setting::GOOGLE_AUTHTYPE_SERVER: {
     47                return $this->get_googleauth_server_access_token();
     48            }
     49        }
     50
     51        return "";
     52    }
     53
     54    protected function get_googleauth_server_profiles() {
    2455        $google = NP()->jsonrpc()->google();
    2556        $encrypted_google_key = NP()->settings()->get_google_account_auth_config();
     
    2758
    2859        return $google->get_profiles($npkey, $encrypted_google_key);
     60    }
     61
     62    protected function get_googleauth_oauth_profiles() {
     63        $google = NP()->jsonrpc()->google();
     64
     65        $encoded_token = base64_encode(json_encode(NP()->settings()->get_saved_google_token()));
     66        return $google->get_profiles_using_token($encoded_token);
     67    }
     68
     69    public function get_google_profiles() {
     70        $auth_type = NP()->settings()->get_google_authtype();
     71
     72        switch ($auth_type) {
     73            case Setting::GOOGLE_AUTHTYPE_OAUTH: {
     74                return $this->get_googleauth_oauth_profiles();
     75            }
     76            case Setting::GOOGLE_AUTHTYPE_SERVER: {
     77                return $this->get_googleauth_server_profiles();
     78            }
     79        }
     80
     81        return array();
    2982    }
    3083
  • nepirity-analytics/trunk/modules/settings.php

    r1666843 r1669213  
    55class Setting {
    66    const FIELD_NEPIRITY_KEY = 'np_nepirity_key';
     7    const FIELD_GOOGLE_AUTHTYPE = 'np_google_auth_type';
    78    const FIELD_GOOGLE_ACCOUNT_AUTH_CONFIG = 'np_google_auth_config';
    89    const FIELD_GOOGLE_PROFILE_ACCOUNT_ID = 'np_google_profile_account_id';
     
    1011    const FIELD_GOOGLE_PROFILE_VIEW_ID = 'np_google_profile_view_id';
    1112    const FIELD_GOOGLE_TRACKING_ENABLED = 'np_google_tracking_enabled';
     13
     14    const FIELD_NEPIRITY_VERSION = 'np_nepirity_version';
    1215    const FIELD_NEPIRITY_SERVER = 'np_nepirity_server';
    1316
    1417    const FIELD_GOOGLE_ACCESS_TOKEN = 'np_google_access_token';
     18
     19    const GOOGLE_AUTHTYPE_OAUTH = 1;
     20    const GOOGLE_AUTHTYPE_SERVER = 2;
    1521
    1622    function __construct() {
     
    2127
    2228        $options = array_merge($options, $this->get_nepirity_option_fields());
     29        $options = array_merge($options, $this->get_google_authtype_option_fields());
    2330        $options = array_merge($options, $this->get_google_account_option_fields());
    2431        $options = array_merge($options, $this->get_google_profile_option_fields());
     
    213220    }
    214221
     222    public function get_google_authtype() {
     223        return $this->get_option_value(self::FIELD_GOOGLE_AUTHTYPE);
     224    }
     225
     226    public function is_google_oauth_type() {
     227        if (intval($this->get_option_value(self::FIELD_GOOGLE_AUTHTYPE))
     228                == self::GOOGLE_AUTHTYPE_OAUTH) {
     229            return true;
     230        }
     231
     232        return false;
     233    }
     234
     235    public function get_google_authtype_option_fields() {
     236        $option = array(
     237            array(
     238                "name"=>self::FIELD_GOOGLE_AUTHTYPE,
     239                "type"=>"radio", "desc" => np_translate("Google Authentication Type"),
     240                "options" => array(
     241                    array("desc"=>"OAuth Authentication (Recommeded)", "value"=>self::GOOGLE_AUTHTYPE_OAUTH, "checked"=>true),
     242                    array("desc"=>"Server to Server Authentication", "value"=>self::GOOGLE_AUTHTYPE_SERVER, "checked"=>false)
     243                )
     244            )
     245        );
     246
     247        $checked_value = intval($this->get_google_authtype());
     248
     249        if ($checked_value > 0 && count($option[0]['options']) <= $checked_value) {
     250            for ($i=0; $i<count($option[0]['options']); $i++) {
     251                $option[0]['options'][$i]['checked'] = false;
     252            }
     253
     254            $option[0]['options'][$checked_value -1]['checked'] = true;
     255        }
     256
     257        return $option;
     258    }
     259
    215260    public function get_google_account_option_fields() {
    216261        return array(
     
    218263                "name"=>self::FIELD_GOOGLE_ACCOUNT_AUTH_CONFIG,
    219264                "type"=>"textarea", "desc" => np_translate("Google Account Service Key")
     265            )
     266        );
     267    }
     268
     269    public function get_google_oauth_option_fields() {
     270        $link = NP()->analytics()->get_google_auth_link();
     271        $memo = np_translate("You can check Google OAuth code");
     272        $memo .= " [<a href='".$link."' target='_blank'>here</a>]";
     273
     274        return array(
     275            array(
     276                "name"=>self::FIELD_GOOGLE_ACCOUNT_AUTH_CONFIG, /* The same with google account*/
     277                "type"=>"text", "desc" => np_translate("Google OAuth Code"),
     278                "memo"=>$memo
    220279            )
    221280        );
     
    258317    }
    259318
     319    public function get_nepirity_version_option_name() {
     320        return self::FIELD_NEPIRITY_VERSION;
     321    }
     322
    260323    public function get_all_option_fields() {
    261324        $options = array();
    262325
    263326        $options = array_merge($options, $this->get_nepirity_option_fields());
     327        $options = array_merge($options, $this->get_google_authtype_option_fields());
    264328        $options = array_merge($options, $this->get_google_account_option_fields());
    265329        $options = array_merge($options, $this->get_google_profile_option_fields());
     
    407471        }
    408472
    409         $options = array(self::FIELD_GOOGLE_ACCESS_TOKEN, self::FIELD_NEPIRITY_SERVER);
     473        $options = array(self::FIELD_GOOGLE_ACCESS_TOKEN, self::FIELD_NEPIRITY_SERVER, self::FIELD_NEPIRITY_VERSION);
    410474        for ($i=0; $i<sizeof($options); $i++) {
    411             delete_option($options[$i]['name']);
     475            delete_option($options[$i]);
    412476        }
    413477    }
     
    415479    public function get_saved_google_token() {
    416480        $token = json_decode($this->get_option_value(self::FIELD_GOOGLE_ACCESS_TOKEN), true);
     481
     482        if ($this->is_google_oauth_type()) {
     483            return $token;
     484        }
    417485
    418486        if (sizeof($token) && isset($token['created']) && isset($token['expires_in'])) {
  • nepirity-analytics/trunk/modules/setup.php

    r1666843 r1669213  
    66    const STEP_DEFAULT = 'default';
    77    const STEP_NEPIRITY = 'nepirity';
     8    const STEP_GOOGLE_AUTHTYPE = 'google_authtype';
    89    const STEP_GOOGLE_ACCOUNT = 'google_account';
    910    const STEP_GOOGLE_PROFILE = 'google_profile';
     
    1112    private static $STEP = array(
    1213        self::STEP_DEFAULT, self::STEP_NEPIRITY,
     14        self::STEP_GOOGLE_AUTHTYPE,
    1315        self::STEP_GOOGLE_ACCOUNT, self::STEP_GOOGLE_PROFILE);
    1416
     
    6567                    echo '<td>'. NP()->settings()->get_google_view_selector_tag($data) .'</td>';
    6668                }
     69
     70                if ($data['type'] == "radio") {
     71                    echo '<th scope="row">'.NP()->settings()->get_option_label_tag($data).'</th>';
     72                    echo '<td>'. NP()->views()->get_html_from_option($data) .'</td>';
     73                }
    6774                echo "                  </tr>";
    6875            }
     
    138145    }
    139146
     147    private static function print_wizard_nepirity_error() {
     148        $title = np_translate("Nepirity key information is not appropriate.");
     149        $msg = np_translate("Please, input appropriate Nepirity key information and check that the key settings are correct.");
     150
     151        $msg .= "<br />";
     152        $msg .= "<br />";
     153
     154        $msg .= np_translate("Your current site address is:");
     155        $msg .= "<br />".get_site_url();
     156
     157        self::print_wizard_pannel($title, $msg, array(), 'nepirity_error');
     158    }
     159
    140160    private static function update_nepirity_setting() {
    141161        self::update_settings(NP()->settings()->get_nepirity_option_fields());
    142162    }
    143163
     164    private static function print_wizard_google_authtype_step() {
     165        $fields = NP()->settings()->get_google_authtype_option_fields();
     166        $msg = np_translate("Please select a Google authentication method.");
     167
     168        self::print_wizard_pannel(self::get_wizard_title(np_translate("Google Authentication Type")),
     169            $msg, $fields);
     170    }
     171
     172    private static function update_google_authtype_setting() {
     173        self::update_settings(NP()->settings()->get_google_authtype_option_fields());
     174    }
     175
    144176    private static function print_wizard_google_account_step() {
    145         $fields = NP()->settings()->get_google_account_option_fields();
    146         $msg = np_translate("Please, enter your Google Service account information.");
    147 
    148         if (strlen(NP()->settings()->get_google_account_auth_config())) {
    149             $msg = np_translate("You can not modify the encrypted key.");
    150             $msg .= " ";
    151 
    152             $msg .= np_translate("Please save it again.");
    153             $msg .= "<br />";
    154             $msg .= np_translate("When you leave this page, the previously saved values are retained.");
    155         }
    156 
    157         self::print_wizard_pannel(self::get_wizard_title(np_translate("Google Service Account Setting")),
    158             $msg, $fields, 'google_setup');
     177        $msg = "";
     178        $title = "";
     179        $module = "";
     180        $fields = array();
     181
     182        $auth_type = NP()->settings()->get_google_authtype();
     183
     184        switch ($auth_type) {
     185            case Setting::GOOGLE_AUTHTYPE_OAUTH: {
     186                $module = "google_auth_oauth";
     187                $fields = NP()->settings()->get_google_oauth_option_fields();
     188                $title = self::get_wizard_title(np_translate("Google OAuth Setting"));
     189                $msg = np_translate("Please, enter Google OAuth code.");
     190                break;
     191            }
     192
     193            case Setting::GOOGLE_AUTHTYPE_SERVER: {
     194                $module = "google_setup";
     195                $fields = NP()->settings()->get_google_account_option_fields();
     196                $title = self::get_wizard_title(np_translate("Google Service Account Setting"));
     197
     198                $msg = np_translate("Please, enter your Google Service account information.");
     199
     200                if (strlen(NP()->settings()->get_google_account_auth_config())) {
     201                    $msg = np_translate("You can not modify the encrypted key.");
     202                    $msg .= " ";
     203
     204                    $msg .= np_translate("Please save it again.");
     205                    $msg .= "<br />";
     206                    $msg .= np_translate("When you leave this page, the previously saved values are retained.");
     207                }
     208
     209                break;
     210            }
     211        }
     212
     213        self::print_wizard_pannel($title, $msg, $fields, $module);
    159214    }
    160215    private static function update_google_account_setting() {
    161216        self::update_settings(NP()->settings()->get_google_account_option_fields());
     217
     218        $auth_type = NP()->settings()->get_google_authtype();
     219        if ($auth_type == Setting::GOOGLE_AUTHTYPE_OAUTH) {
     220            $oauth_code = NP()->settings()->get_google_account_auth_config();
     221
     222            $analytics = NP()->analytics();
     223            $token = $analytics->get_google_access_token($oauth_code);
     224            NP()->settings()->save_google_token($token);
     225        }
    162226    }
    163227
     
    192256        $values[$option_name] = NP()->jsonrpc()->support()->get_fast_server();
    193257
     258        $option_name = NP()->settings()->get_nepirity_version_option_name();
     259        $options[] = array("name" => $option_name);
     260        $values[$option_name] = NP()->get_plugin_version();
     261
    194262        self::update_setting_values($options, $values);
    195263    }
     
    248316                break;
    249317            }
     318            case self::STEP_GOOGLE_AUTHTYPE: {
     319                self::update_nepirity_setting(); // update and check it
     320                $key = NP()->settings()->get_nepirity_key();
     321
     322                if (NP()->settings()->is_validated_nepirity_key($key)) {
     323                    self::print_wizard_google_authtype_step();
     324                } else {
     325                    self::print_wizard_nepirity_error();
     326                }
     327                break;
     328            }
    250329            case self::STEP_GOOGLE_ACCOUNT: {
    251                 self::update_nepirity_setting();
    252                 $key = NP()->settings()->get_nepirity_key();
    253 
    254                 if (NP()->settings()->is_validated_nepirity_key($key)) {
    255                     self::print_wizard_google_account_step();
    256                 } else {
    257                     $title = np_translate("Nepirity key information is not appropriate.");
    258                     $msg = np_translate("Please, input appropriate Nepirity key information and check that the key settings are correct.");
    259 
    260                     $msg .= "<br />";
    261                     $msg .= "<br />";
    262 
    263                     $msg .= np_translate("Your current site address is:");
    264                     $msg .= "<br />".get_site_url();
    265 
    266                     self::print_wizard_pannel($title, $msg, array(), 'nepirity_error');
    267                 }
     330                self::update_google_authtype_setting();
     331                self::print_wizard_google_account_step();
    268332                break;
    269333            }
     
    285349                } else {
    286350                    $msg = "";
    287                     $title = np_translate("Google Service Account key information is not appropriate.");
    288 
    289                     $msg .= np_translate("Please, input appropriate Google Service Account key information.")."<br />";
     351                    $title = np_translate("Google Setting information is not appropriate.");
     352
     353                    $msg .= np_translate("Please set up your account information correctly.")."<br />";
    290354                    $msg .= "<br />". self::get_google_error($error_msg);
    291355
  • nepirity-analytics/trunk/modules/views.php

    r1666843 r1669213  
    115115        echo $html;
    116116    }
     117
     118    public function get_html_from_option($option) {
     119        $html = "";
     120
     121        if ($option['type'] == 'radio') {
     122            $name = $option['name'];
     123
     124            foreach ($option['options'] as $data) {
     125                $checked = "";
     126                if ($data['checked']) $checked = ' checked="checked"';
     127
     128                $html .= '<input type="radio" name="'.$name.'" value="'.$data['value'].'" '.$checked.'>';
     129                $html .= $data['desc']. '<br />';
     130            }
     131        }
     132
     133        return $html;
     134    }
    117135}
    118136
  • nepirity-analytics/trunk/nepirity-analytics.php

    r1666843 r1669213  
    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.0
     5Version:     1.0.1
    66Author:      Nepirity Corp.
    77Author URI:  https://www.nepirity.com/
  • nepirity-analytics/trunk/readme.txt

    r1666843 r1669213  
    55Requires at least: 4.6.5
    66Tested up to: 4.7.5
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6262
    6363== Changelog ==
     64= 1.0.1 =
     65Added Google authentication method.
     66
    6467= 1.0.0 =
    6568first version.
    6669
    6770== Upgrade Notice ==
    68 = 1.0.0 =
    69 Nepirity Analytics Official Version.
     71= 1.0.1 =
     72New Google authentication method has been added. You can install the plugin a little easier and more convenient.
  • nepirity-analytics/trunk/sdk/classes/google.php

    r1666843 r1669213  
    99}
    1010
     11abstract 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
     22class 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
     36class 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
    1148}
    1249
Note: See TracChangeset for help on using the changeset viewer.