function google_analytics_api_admin_submit in Google Analytics Reports 7
Same name and namespace in other branches
- 6 google_analytics_api.pages.inc \google_analytics_api_admin_submit()
Submit handler. Steps throuh the OAuth process, revokes tokens, saves profiles.
File
- ./
google_analytics_api.pages.inc, line 115 - Admin and OAuth callbacks.
Code
function google_analytics_api_admin_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
cache_clear_all('GAFeed', 'cache', '*');
switch ($op) {
case t('Start setup and authorize account'):
variable_set('google_analytics_reports_hd', $form_state['values']['google_analytics_reports_hd']);
/* Anonymous keys are a Google default */
$key = variable_get('google_analytics_reports_consumer_key', 'anonymous');
$secret = variable_get('google_analytics_reports_consumer_secret', 'anonymous');
module_load_include('inc', 'google_analytics_api', 'GAFeed.lib');
$GAFeed = new GAFeed($key, $secret);
/* Step #1 of OAuth */
$token = $GAFeed
->getRequestToken();
$_SESSION['google_analytics_reports_oauth']['token'] = $token;
$_SESSION['google_analytics_reports_oauth']['destination'] = $_GET['q'];
/* Step #2 of OAuth */
$GAFeed
->obtainAuthorization($token);
break;
case t('Save settings'):
variable_set('google_analytics_reports_profile_id', $form_state['values']['google_analytics_reports_profile_id']);
variable_set('google_analytics_reports_cache_length', $form_state['values']['google_analytics_reports_cache_length']);
drupal_set_message(t('Settings have been saved successfully.'));
break;
case t('Revoke access token'):
google_analytics_api_revoke();
drupal_set_message(t('Access token has been successfully revoked.'));
break;
}
}