-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgad-admin-options-ui.php
311 lines (256 loc) · 11.2 KB
/
gad-admin-options-ui.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
/* Copyright 2009 Carson McDonald ([email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once( dirname( __FILE__ ) . '/ga-lib.php' );
require_once( dirname( __FILE__ ) . '/gauth-lib.php' );
require_once( dirname( __FILE__ ) . '/simplefilecache.php' );
class GADAdminOptionsUI {
var $info_message;
var $error_message;
function GADAdminOptionsUI() {
$this->__construct();
}
function __construct() {
$this->info_message = '';
$this->error_message = '';
}
/**
* @todo get rid of inline styles
*/
function display_admin_halting_error() {
?>
<div class="wrap" style="padding-top: 50px;">
<?php $this->display_messages(); ?>
Please try again later.
</div>
<?php
}
/**
* @todo get rid of inline styles
*/
function display_admin_handle_other_options( $account_hash ) {
?>
<div class="wrap" style="padding-top: 50px;">
<?php
$this->display_messages();
if ( sizeof( $account_hash ) != 0 ) {
$current_account_id = isset( $_POST['ga_account_id'] ) ? $_POST['ga_account_id'] : get_option( 'gad_account_id' ) !== false ? get_option( 'gad_account_id' ) : '';
}
if ( ! isset( $current_account_id ) || $current_account_id == '' ) {
?>
<div class="updated">
<p><?php _e( '<b>Note:</b> You will need to select an account and <b>click "Save Changes"</b> before the analytics dashboard will work.', 'google-analytics-dashboard' ); ?></p>
</div>
<?php
}
?>
<form action="" method="post">
<?php
wp_nonce_field( 'update_ga_dashboard_' . get_current_user_id() );
?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="ga_account_id"><?php _e( 'Available Accounts', 'google-analytics-dashboard' ); ?></label></th>
<td>
<?php
if ( sizeof( $account_hash ) == 0 ) {
echo '<span id="ga_account_id">' . __( 'No accounts available.', 'google-analytics-dashboard' ) . '</span>';
} else {
echo '<select id="ga_account_id" name="ga_account_id">';
foreach ( $account_hash as $account_id => $account_name ) {
echo '<option value="' . esc_attr( $account_id ) . '" ' . ( $current_account_id == $account_id ? 'selected' : '' ) . '>' . esc_attr( $account_name ) . '</option>';
}
echo '</select>';
}
?>
</td>
</tr>
<?php if ( get_option( 'gad_login_pass' ) !== false ) : ?>
<tr valign="top">
<th scope="row">
<label for="ga_forget_pass"><?php _e( 'Forget Password', 'google-analytics-dashboard' ); ?></label></th>
<td><input name="ga_forget_pass" type="checkbox" id="ga_forget_pass" value="ga_forget_pass" /></td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row">
<label for="ga_forget_auth"><?php _e( 'Forget Authentication', 'google-analytics-dashboard' ); ?></label>
</th>
<td><input name="ga_forget_auth" type="checkbox" id="ga_forget_auth" value="ga_forget_auth" /></td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_forget_all"><?php _e( 'Forget Everything', 'google-analytics-dashboard' ); ?></label></th>
<td><input name="ga_forget_all" type="checkbox" id="ga_forget_all" value="ga_forget_all" /></td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_display_level"><?php _e( 'Dashboard Level', 'google-analytics-dashboard' ); ?></label></th>
<td>
<?php
$ga_display_level = get_option( 'gad_display_level' );
?>
<select name="ga_display_level" id="ga_display_level">
<option value="">None - Admin only</option>
<option value="level_7" <?php echo ( $ga_display_level == 'level_7' ) ? 'selected' : ''; ?>><?php _e( 'Editor', 'google-analytics-dashboard' ); ?></option>
<option value="level_2" <?php echo ( $ga_display_level == 'level_2' ) ? 'selected' : ''; ?>><?php _e( 'Author', 'google-analytics-dashboard' ); ?></option>
<option value="level_1" <?php echo ( $ga_display_level == 'level_1' ) ? 'selected' : ''; ?>><?php _e( 'Contributor', 'google-analytics-dashboard' ); ?></option>
<option value="level_0" <?php echo ( $ga_display_level == 'level_0' ) ? 'selected' : ''; ?>><?php _e( 'Subscriber', 'google-analytics-dashboard' ); ?></option>
</select>
</td>
</tr>
<?php
if ( SimpleFileCache::canCache() ) {
?>
<tr valign="top">
<th scope="row">
<label for="ga_cache_timeout"><?php _e( 'Cache Timeout (seconds)', 'google-analytics-dashboard' ); ?></label>
</th>
<td>
<input value="<?php echo esc_attr( get_option( 'gad_cache_timeout' ) !== false ? get_option( 'gad_cache_timeout' ) : '60' ); ?>" name="ga_cache_timeout" id="ga_cache_timeout" />
</td>
</tr>
<?php
} else {
?>
<tr valign="top">
<th colspan="2">
<span style="padding: 10px;" class="error"><?php _e( 'The configuration of your server will prevent response caching.', 'google-analytics-dashboard' ); ?></span>
</th>
</tr>
<?php
}
?>
<tr valign="top">
<th scope="row"> </th>
<td> </td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_goal_one"><?php _e( 'Goal #1 Label', 'google-analytics-dashboard' ); ?></label></th>
<td><input value="<?php echo esc_attr( get_option( 'gad_goal_one' ) ); ?>" name="ga_goal_one" id="ga_goal_one" /></td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_goal_two"><?php _e( 'Goal #2 Label', 'google-analytics-dashboard' ); ?></label></th>
<td><input value="<?php echo esc_attr( get_option( 'gad_goal_two' ) ); ?>" name="ga_goal_two" id="ga_goal_two" /></td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_goal_three"><?php _e( 'Goal #3 Label', 'google-analytics-dashboard' ); ?></label></th>
<td><input value="<?php echo esc_attr( get_option( 'gad_goal_three' ) ); ?>" name="ga_goal_three" id="ga_goal_three" />
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_goal_four"><?php _e( 'Goal #4 Label', 'google-analytics-dashboard' ); ?></label></th>
<td><input value="<?php echo esc_attr( get_option( 'gad_goal_four' ) ); ?>" name="ga_goal_four" id="ga_goal_four" />
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_disable_post_stats"><?php _e( 'Disable Post Stats Display', 'google-analytics-dashboard' ); ?></label>
</th>
<td>
<input name="ga_disable_post_stats" type="checkbox" id="ga_disable_post_stats" value="ga_disable_post_stats" <?php echo ( get_option( 'gad_disable_post_stats' ) == 'true' ) ? 'checked' : ''; ?> />
</td>
</tr>
</table>
<p class="submit">
<input type="submit" name="SubmitOptions" class="button-primary" value="<?php _e( 'Save Changes', 'google-analytics-dashboard' ); ?>" />
</p>
</form>
</div>
<?php
}
function display_admin_handle_login_options( $gauth ) {
?>
<div class="wrap" style="padding-top: 50px;">
<?php $this->display_messages(); ?>
<form action="" method="post">
<input type="hidden" name="gad_login_type" value="oauth" />
<table class="form-table">
<tr valign="top">
<th><?php _e( 'Login using Google\'s OAuth system.', 'google-analytics-dashboard' ); ?></th>
</tr>
<tr valign="top">
<th><?php _e( 'This is the prefered method of attaching your Google account.<br/>
Clicking the "Start the Login Process" button will redirect you to a login page at google.com.<br/>
After accepting the login there you will be returned here.', 'google-analytics-dashboard' ); ?></th>
</tr>
<tr valign="top">
<td><p class="submit">
<input type="submit" name="SubmitLogin" class="button-primary" value="<?php _e( 'Start the Login Process »', 'google-analytics-dashboard' ); ?>" />
</p></td>
</tr>
</table>
</form>
<p style="padding-top: 20px;" />
<form action="" method="post">
<input type="hidden" name="gad_login_type" value="client" />
<table class="form-table">
<tr valign="top" style="border-top: 1px solid;">
<th scope="row" colspan="2"><?php _e( 'You can still use the older authentication system but it is not recommended.', 'google-analytics-dashboard' ); ?></th>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_email"><?php _e( 'Google Analytics Email', 'google-analytics-dashboard' ); ?></label></th>
<td>
<input name="ga_email" type="text" size="15" id="ga_email" class="regular-text" value="<?php echo isset( $_POST['ga_email'] ) ? $_POST['ga_email'] : get_option( 'gad_login_email' ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="ga_pass"><?php _e( 'Google Analytics Password', 'google-analytics-dashboard' ); ?></label>
</th>
<td><input name="ga_pass" type="password" size="15" id="ga_pass" class="regular-text" value="" /></td>
</tr>
<?php if ( isset( $gauth ) && $gauth->requiresCaptcha() ) : ?>
<tr valign="top">
<th scope="row">
<label for="ga_captcha"><?php _e( 'Google CAPTCHA', 'google-analytics-dashboard' ); ?></label></th>
<td>
<img src="<?php echo $gauth->getCaptchaImageURL(); ?>" /><br /><br />
<input name="ga_captcha" type="text" size="10" id="ga_captcha" class="regular-text" value="" />
<input type="hidden" name="ga_captcha_token" value="<?php echo $gauth->getCaptchaToken(); ?>" />
</td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row">
<label for="ga_save_pass"><?php _e( 'Save Password', 'google-analytics-dashboard' ); ?></label></th>
<td>
<input name="ga_save_pass" type="checkbox" id="ga_save_pass" value="ga_save_pass" <?php if ( isset( $_POST['ga_save_pass'] ) || get_option( 'gad_login_pass' ) !== false ) {
echo 'checked';
} ?> />
</td>
</tr>
</table>
<p class="submit">
<input type="submit" name="SubmitLogin" class="button-primary" value="<?php _e( 'Login »' ); ?>" />
</p>
</form>
</div>
<?php
}
function display_messages() {
if ( isset( $this->info_message ) && trim( $this->info_message ) != '' ) {
echo '<div id="message" class="updated fade"><p><strong>' . $this->info_message . '</strong></p></div>';
}
if ( isset( $this->error_message ) && trim( $this->error_message ) != '' ) {
echo '<div id="message" class="error fade"><p><strong>' . $this->error_message . '</strong></p></div>';
}
}
}