function piwik_reports_admin_settings_form in Piwik Reports 7.4
Same name and namespace in other branches
- 7.3 piwik_reports.module \piwik_reports_admin_settings_form()
Return the $form that handles piwik reports config page.
Parameters
array $form_state: See form API.
Return value
array Piwik form fields.
1 string reference to 'piwik_reports_admin_settings_form'
- piwik_reports_menu in ./
piwik_reports.module - Implements hook_menu().
File
- ./
piwik_reports.module, line 418 - Defines features and functions common to Piwik Reports.
Code
function piwik_reports_admin_settings_form($form_state) {
drupal_set_title(t('Piwik reports'));
$piwik_installed = module_exists('piwik');
$form['piwik_reports_server'] = array(
'#type' => 'fieldset',
'#title' => t('Piwik report server'),
'#weight' => 1,
'#collapsible' => TRUE,
'#collapsed' => $piwik_installed,
);
if ($piwik_installed) {
$form['piwik_reports_server']['#description'] = t('Leave blank to use the same URL set in Piwik tracking.');
}
$form['piwik_reports_server']['piwik_reports_url_http'] = array(
'#type' => 'textfield',
'#title' => t('Piwik Server URL'),
'#default_value' => variable_get('piwik_reports_url_http', ''),
'#size' => 80,
'#maxlength' => 255,
'#required' => !$piwik_installed,
'#weight' => 1,
'#description' => t('The URL to your Piwik base directory. Example: "http://www.example.com/piwik/".'),
);
$form['piwik_reports_token'] = array(
'#type' => 'fieldset',
'#title' => t('Token auth'),
'#weight' => 5,
'#description' => t('To see piwik reports in Drupal you need a <strong>token_auth</strong> value. You can find it in the <strong>Users</strong> tab under the <strong>Settings</strong> link in your Piwik account or ask your Piwik server administrator.'),
);
$form['piwik_reports_token']['piwik_reports_token_auth'] = array(
'#type' => 'textfield',
'#title' => t('Piwik authentication string'),
'#default_value' => check_plain(variable_get('piwik_reports_token_auth', '')),
'#size' => 40,
'#maxlength' => 40,
'#description' => t('Leave blank if you prefer each user setting his own, or paste it here to have a global <strong>token_auth</strong>. If anonymous users have view permissions in Piwik you can set this value to <strong>anonymous</strong>. Users still need "Access Piwik reports" permission to see the reports in Drupal.'),
);
$form['piwik_reports_sites'] = array(
'#type' => 'fieldset',
'#title' => t('Allowed sites'),
'#weight' => 10,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('List sites you want restrict your users access to.'),
);
$sites = piwik_reports_get_sites(check_plain(variable_get('piwik_reports_token_auth', '')));
$form['piwik_reports_sites']['piwik_reports_allowed_sites'] = array(
'#type' => 'textfield',
'#weight' => 10,
'#collapsible' => TRUE,
'#default_value' => variable_get('piwik_reports_allowed_sites', ''),
'#collapsed' => TRUE,
'#description' => t('List accessible sites id separated by a comma. Example: "1,4,12". Leave blank to let users see all sites accessible on piwik server with current token auth (highly recommended in case of per user token auth).'),
);
if (is_array($sites) && count($sites)) {
if (variable_get('piwik_reports_token_auth', '') != '') {
$form['piwik_reports_sites']['piwik_reports_allowed_sites']['#description'] .= ' ' . t('Sites currently accessible with global token_auth are:');
}
else {
$form['piwik_reports_sites']['piwik_reports_allowed_sites']['#description'] .= ' ' . t('Sites currently accessible as anonymous are:');
}
foreach ($sites as $site) {
$form['piwik_reports_sites']['piwik_reports_allowed_sites']['#description'] .= '<br />' . (int) $site['idsite'] . ' - ' . check_plain($site['name']);
}
}
else {
$form['piwik_reports_sites']['piwik_reports_allowed_sites']['#description'] .= ' ' . t('No accessible sites are available with current global token auth. Please check your token auth is correct and that it has view permission on Piwik server.');
}
return system_settings_form($form);
}