1: <?php
2:
3: function bright_menu_settings() {
4: if (!current_user_can('manage_options')) {
5: wp_die(bright_message('You do not have sufficient permissions to access this page.'));
6: }
7:
8: $hidden_field_name = 'bright_submit_hidden';
9:
10:
11:
12:
13:
14:
15: $opt_name = 'bright_api_url';
16: $data_field_name = 'bright_api_url';
17:
18:
19: $opt_val = get_option( $opt_name );
20:
21: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
22:
23: $opt_val = $_POST[ $data_field_name ];
24:
25:
26: update_option( $opt_name, $opt_val );
27: }
28:
29:
30:
31: $opt_name = 'bright_scorm_cloud_app_id';
32: $data_field_name = 'bright_scorm_cloud_app_id';
33:
34:
35: $opt_val = get_option( $opt_name );
36:
37: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
38:
39: $opt_val = $_POST[ $data_field_name ];
40:
41:
42: update_option( $opt_name, $opt_val );
43: }
44:
45:
46:
47: $opt_name = 'bright_scorm_cloud_secret_key';
48: $data_field_name = 'bright_scorm_cloud_secret_key';
49:
50:
51: $opt_val = get_option( $opt_name );
52:
53: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
54:
55: $opt_val = $_POST[ $data_field_name ];
56:
57:
58: update_option( $opt_name, $opt_val );
59: }
60:
61:
62:
63: $opt_name = 'bright_realm_guid';
64: $data_field_name = 'bright_realm_guid';
65:
66:
67: $opt_val = get_option( $opt_name );
68:
69: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
70:
71: $opt_val = $_POST[ $data_field_name ];
72:
73:
74: update_option( $opt_name, $opt_val );
75: }
76:
77:
78:
79: $opt_name = 'bright_secret_key';
80: $data_field_name = 'bright_secret_key';
81:
82:
83: $opt_val = get_option( $opt_name );
84:
85: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
86:
87: $opt_val = $_POST[ $data_field_name ];
88:
89:
90: update_option( $opt_name, $opt_val );
91: }
92:
93:
94:
95: $opt_name = 'bright_usermeta_export';
96: $data_field_name = 'bright_usermeta_export';
97:
98:
99: $opt_val = get_option( $opt_name );
100:
101: if(isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y') {
102:
103: $opt_val = $_POST[ $data_field_name ];
104:
105:
106: update_option( $opt_name, $opt_val );
107: }
108:
109:
110: if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
111: bright_reset_token();
112: $api_key = bright_get_authentication_code_for_user(wp_get_current_user());
113: ?>
114: <div class="updated"><p><strong>API KEY: <?php echo ($api_key) ?></strong></p></div>
115: <div class="<?php echo empty($api_key) ? 'error' : 'updated'; ?>"><p><strong><?php echo('Settings checked and <strong>' . (empty($api_key) ? 'failed' : 'succeeded') . '</strong>.') ?></strong></p></div>
116: <div class="updated"><p><strong><?php _e('settings saved.', 'bright-menu' ); ?></strong></p></div>
117: <?php
118:
119: if (empty($api_key)) {
120: ?>
121: <div class="error"><p><?php echo bright_curl_error(); ?></p></div>
122: <?php
123: }
124: } ?>
125: <img src="http://www.aura-software.com/wp-content/uploads/2012/04/just-bulb-01.png"/>
126: <div class="wrap">
127: <h2><?php bright_echo_message('Bright Settings'); ?></h2>
128: <form name="form1" method="post" action="">
129: <div class="bright-compat">
130: <?php echo bright_check_compat(); ?>
131: </div>
132: <table>
133:
134:
135: <?php
136: $opt_name = 'bright_api_url';
137: $opt_val = get_option( $opt_name );
138: ?>
139: <div title="<?php _e("") ?>">
140: <tr title="<?php _e("") ?>">
141: <td><div title="<?php _e("") ?>"><?php _e("Bright API URL:", 'bright-menu' ); ?></div></td>
142: <td><input type="text" name="bright_api_url" value="<?php echo $opt_val; ?>" size="50"></td>
143: </tr>
144: </div>
145:
146: <tr>
147: <td colspan="2"><hr/></td>
148: </tr>
149:
150: <?php
151: $opt_name = 'bright_scorm_cloud_app_id';
152: $opt_val = get_option( $opt_name );
153: ?>
154: <div title="<?php _e("") ?>">
155: <tr title="<?php _e("") ?>">
156: <td><div title="<?php _e("") ?>"><?php _e("SCORM Cloud Application ID:", 'bright-menu' ); ?></div></td>
157: <td><input type="text" name="bright_scorm_cloud_app_id" value="<?php echo $opt_val; ?>" size="10"></td>
158: </tr>
159: </div>
160:
161: <?php
162: $opt_name = 'bright_scorm_cloud_secret_key';
163: $opt_val = get_option( $opt_name );
164: ?>
165: <div title="<?php _e("") ?>">
166: <tr title="<?php _e("") ?>">
167: <td><div title="<?php _e("") ?>"><?php _e("SCORM Cloud Secret Key:", 'bright-menu' ); ?></div></td>
168: <td><input type="text" name="bright_scorm_cloud_secret_key" value="<?php echo $opt_val; ?>" size="50"></td>
169: </tr>
170: </div>
171:
172: <tr>
173: <td colspan="2"><hr/></td>
174: </tr>
175:
176: <?php
177: $opt_name = 'bright_realm_guid';
178: $opt_val = get_option( $opt_name );
179: ?>
180: <div title="<?php _e("") ?>">
181: <tr title="<?php _e("") ?>">
182: <td><div title="<?php _e("") ?>"><?php _e("Bright Realm GUID:", 'bright-menu' ); ?></div></td>
183: <td><input type="text" name="bright_realm_guid" value="<?php echo $opt_val; ?>" size="20"></td>
184: </tr>
185: </div>
186:
187: <?php
188: $opt_name = 'bright_secret_key';
189: $opt_val = get_option( $opt_name );
190: ?>
191: <div title="<?php _e("") ?>">
192: <tr title="<?php _e("") ?>">
193: <td><div title="<?php _e("") ?>"><?php _e("Bright Realm Secret Key:", 'bright-menu' ); ?></div></td>
194: <td><input type="text" name="bright_secret_key" value="<?php echo $opt_val; ?>" size="50"></td>
195: </tr>
196: </div>
197:
198: <tr>
199: <td colspan="2"><hr/></td>
200: </tr>
201:
202: <?php
203: $opt_name = 'bright_usermeta_export';
204: $opt_val = get_option( $opt_name );
205: ?>
206: <div title="<?php _e("This is a list of 'usermeta' keys that will by synced to bright's realm user table") ?>">
207: <tr title="<?php _e("This is a list of 'usermeta' keys that will by synced to bright's realm user table") ?>">
208: <td><div title="<?php _e("This is a list of 'usermeta' keys that will by synced to bright's realm user table") ?>"><?php _e("UserMeta Sync:", 'bright-menu' ); ?></div></td>
209: <td><input type="text" name="bright_usermeta_export" value="<?php echo $opt_val; ?>" size="80"></td>
210: </tr>
211: </div>
212:
213: <hr/>
214: <tr>
215: <td>
216: <p class="submit"><input type="submit" name="Test Settings" class="button-primary" value="<?php esc_attr_e('Test Settings') ?>"/></p>
217: </td>
218: <td>
219: <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>"/></p>
220: </td>
221: <td>
222: <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
223: </td>
224: </tr>
225: </form>
226: </div>
227:
228: <?php } ?>
229: