function google_analytics_counter_auth_admin_submit in Google Analytics Counter 7.3
Same name and namespace in other branches
- 7.2 google_analytics_counter_auth.inc \google_analytics_counter_auth_admin_submit()
Submit handler.
Steps through the OAuth process, revokes tokens and saves profiles.
File
- ./
google_analytics_counter_auth.inc, line 232 - Provides the GAFeed object type and associated methods.
Code
function google_analytics_counter_auth_admin_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
cache_clear_all('GoogleAnalyticsCounterFeed', 'cache', '*');
switch ($op) {
case t('Start setup and authorize account'):
$client_id = $form_state['values']['client_id'];
$client_secret = $form_state['values']['client_secret'];
$redirect_uri = GoogleAnalyticsCounterFeed::currentUrl();
if (!empty($form_state['values']['redirect_host'])) {
variable_set('google_analytics_counter_redirect_host', $form_state['values']['redirect_host']);
$redirect_uri = $form_state['values']['redirect_host'] . $_SERVER['REQUEST_URI'];
}
variable_set('google_analytics_counter_client_id', $client_id);
variable_set('google_analytics_counter_client_secret', $client_secret);
variable_set('google_analytics_counter_redirect_uri', $redirect_uri);
$gafeed = new GoogleAnalyticsCounterFeed();
$gafeed
->beginAuthentication($client_id, $redirect_uri);
break;
case t('Save settings'):
variable_set('google_analytics_counter_profile_id', $form_state['values']['google_analytics_counter_profile_id']);
drupal_set_message(t('Settings have been saved successfully.'));
break;
case t('Revoke access token'):
google_analytics_counter_revoke();
drupal_set_message(t('Access token has been successfully revoked.'));
break;
}
}