function ga_stats_admin_settings in Google Analytics Statistics 7
Same name and namespace in other branches
- 7.2 ga_stats.admin.inc \ga_stats_admin_settings()
- 7.x ga_stats.module \ga_stats_admin_settings()
Callback for the GA Stats admin form.
1 string reference to 'ga_stats_admin_settings'
- ga_stats_menu in ./
ga_stats.module - Implements hook_menu().
File
- ./
ga_stats.admin.inc, line 49
Code
function ga_stats_admin_settings() {
$form = array();
$form['ga_stats_accounts'] = array(
'#type' => 'fieldset',
'#title' => t('Google Analytics Tracking Accounts'),
'#collapsible' => TRUE,
);
if (!ga_stats_is_ready()) {
drupal_set_message(t('Your Google Analytics account credentials are not set. Visit the !authentication to configure them.', array(
'!authentication' => l(t('authentication tab'), 'admin/config/services/ga_stats/auth'),
)), 'error');
$form['#disabled'] = TRUE;
$accounts = FALSE;
}
else {
require_once 'includes/ga.inc';
// @todo expand on the error cases here.
$accounts = ga_stats_ga_get_accounts(ga_stats_get_client());
}
$options = array();
if (!empty($accounts) && is_array($accounts)) {
foreach ($accounts as $id => $value) {
$acc = $value
->getProperties();
$options[$acc['profileId']] = "{$acc['title']} ({$acc['webPropertyId']})";
}
$form['ga_stats_accounts']['ga_stats_profile'] = array(
'#type' => 'select',
'#title' => t('Google Analytics Profile to Use'),
'#description' => t('The Google Analytics profile from which to retrieve statistics'),
'#options' => $options,
'#default_value' => variable_get('ga_stats_profile', ''),
);
}
else {
$form['ga_stats_accounts']['ga_stats_profile'] = array(
'#type' => 'markup',
'#markup' => '<div class="messages warning">' . t('Cannot select a tracking account until your Google Analytics !configured.', array(
'!configured' => l(t('account is configured'), 'admin/config/services/ga_stats/auth'),
)) . '</div>',
);
}
$form['enabled_stats'] = array(
'#type' => 'fieldset',
'#title' => t('Enabled Statistics'),
'#description' => t('Make sure to clear the Drupal cache after changing this setting in order to inform Views of the new settings. <br/><em><b>WARNING:</b> Do not disable a setting which is currently in use in Views.</em>'),
);
$form['enabled_stats']['ga_stats_enabled_metrics'] = array(
'#type' => 'checkboxes',
'#default_value' => variable_get('ga_stats_enabled_metrics', array(
'pageviews',
)),
'#options' => ga_stats_ga_metrics(TRUE),
'#title' => t('Metrics'),
'#description' => t('The metrics that will be available from Google Analytics in Views.'),
);
$form['enabled_stats']['ga_stats_enabled_timeframes'] = array(
'#type' => 'checkboxes',
'#default_value' => variable_get('ga_stats_enabled_timeframes', array(
'today',
'month',
)),
'#options' => ga_stats_ga_timeframes(TRUE, TRUE),
'#title' => t('Time Frames'),
'#description' => t('The timeframes that will be available from Google Analytics in Views.'),
);
$form['ga_stats_max_results'] = array(
'#type' => 'textfield',
'#title' => t('Max Results per Metric/Timeframe'),
'#description' => t('The max results that a call (a metric/timeframe combination) can return. MUST be a number.'),
'#default_value' => variable_get('ga_stats_max_results', '100'),
);
if (variable_get('ga_stats_profile', FALSE)) {
$form['actions']['ga_stats_update'] = array(
'#type' => 'button',
'#value' => t('Update Counts'),
'#weight' => 20,
'#executes_submit_callback' => TRUE,
'#submit' => array(
'ga_stats_update_counts',
),
);
}
return system_settings_form($form);
}