$t('Firestats'),
'description' => $t("Statistics are not being collected! You must install Firestats from http://firestats.cc/ to enable collection of statistics for your Drupal website.
- Install FireStats as a !standalone on the webserver.
- Put the FireStats file system location in the module's !settings.
", array('!standalone' => l(t('Standalone'), 'http://firestats.cc/wiki/Standalone'), '!settings' => l(t('settings'), 'admin/settings/firestats'))),
'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
'value' => $t('!firestats installation missing', array('!firestats' => l('Firestats', 'http://firestats.cc/'))),
);
}
else {
$requirements['firestats'] = array(
'title' => $t('Firestats'),
'severity' => REQUIREMENT_OK,
'value' => $t('!firestats integrated successfully', array('!firestats' => l('Firestats', 'http://firestats.cc/'))),
);
}
}
return $requirements;
}
/**
* Implementation of hook_help().
*/
function firestats_help($path, $arg) {
switch ($path) {
case 'admin/help#firestats':
return t("You must install Firestats from http://firestats.cc/ to enable collection of statistics for your Drupal website.
- Install FireStats as a !standalone on the webserver.
- Put the FireStats file system location in the module's !settings.
Further, if !visibility_api module is installed, Firestats integration module allows you to collect statistics for specified parts of your Drupal site.", array('!standalone' => l(t('Standalone'), 'http://firestats.cc/wiki/Standalone'), '!settings' => l(t('settings'), 'admin/settings/firestats'), '!visibility_api' => l(t('Visibility API'), 'http://drupal.org/project/visibility_api')));
break;
}
}
/**
* Implementation of hook_menu().
*/
function firestats_menu() {
$items['admin/settings/firestats'] = array(
'title' => t('Firestats'),
'description' => t('Configure Firestats installation path; role and path based access.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('firestats_settings'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Firestats settings form.
*/
function firestats_settings() {
$form = array();
$fs_setup = file_exists(FS_INSTALL_PATH);
if ($fs_setup) {
$fs_test = t('
Firestats was found at: '. FS_SERVER_PATH . '');
}
else {
$fs_test = t('
Firestats path is not correct. Check the status report for more info.', array('@status' => url('admin/reports/status')));
}
$form['firestats_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Firestats configuration'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['firestats_settings']['firestats_test'] = array(
'#type' => 'markup',
'#value' => $fs_test,
);
$form['firestats_settings']['firestats_path'] = array(
'#type' => 'textfield',
'#title' => t('Firestats path'),
'#default_value' => variable_get('firestats_path', ''),
'#description' => t('Path to the Firestats installation(without trailing slash), relative to server root.
Examples: /var/www/html/firestats, C:\WebServer\www\firestats.'),
);
$form['firestats_settings']['firestats_site_id'] = array(
'#type' => 'textfield',
'#title' => t('"!site" Site ID', array('!site' => variable_get('site_name', 'Drupal'))),
'#size' => 5,
'#default_value' => variable_get('firestats_site_id', 1),
'#description' => t("Specify the Site ID which you have created in your Firestats's sites settings."),
);
if (module_exists('visibility_api')) {
visibility_api_form_configuration('firestats', $form);
$form['visibility_api_role_settings']['#title'] = t('Role specific Firestats settings');
$form['visibility_api_role_settings']['visibility_api_roles']['#title'] = t('Collect stats for specific roles');
$form['visibility_api_role_settings']['visibility_api_roles']['#description'] = t('Collects stats only for the selected role(s). If you select no roles, it will be collected from all users.');
$form['visibility_api_path_settings']['#title'] = t('Path specific Firestats settings');
$form['visibility_api_path_settings']['visibility_api_visibility']['#title'] = t('Collect stats on specific paths');
$form['visibility_api_path_settings']['visibility_api_visibility']['#options'] = array(
t('Collect stats on every page except the listed pages.'),
t('Collect stats on only the listed pages.'),
);
}
else {
$form['firestats_visibility'] = array(
'#type' => 'fieldset',
);
$form['firestats_visibility']['firestats_visibility_instructions'] = array(
'#type' => 'markup',
'#value' => t('Install !visibility_api module to collect statistics for only the specified parts of your Drupal website.', array('!visibility_api' => l(t('Visibility API'), 'http://drupal.org/project/visibility_api'))),
);
}
return system_settings_form($form);
}
/**
* Implementation of hook_boot().
*/
function firestats_boot() {
define('FS_FULL_INSTALLATION', '0');
define('FS_SERVER_PATH', variable_get('firestats_path', ''));
$fs_collect = module_exists('visibility_api') ? visibility_api_access('firestats') : TRUE;
define('FS_COLLECT_STATS', $fs_collect);
if (FS_SERVER_PATH != NULL) {
define('FS_INSTALL_PATH', FS_SERVER_PATH . '/php/db-hit.php');
}
}
/**
* Implementation of hook_exit().
*/
function firestats_exit() {
if ($file_exists = file_exists(FS_INSTALL_PATH) && FS_COLLECT_STATS) {
require_once (FS_INSTALL_PATH);
fs_add_site_hit(variable_get('firestats_site_id', 1), true);
}
}
/**
* Count the hit in FireStats.
*/
function firestats_add_hit() {
if (function_exists('ver_comp')) {
if (ver_comp('1.5', FS_VERSION, TRUE) < 0) {
// Complies with FireStats 1.6 onwards API.
fs_add_site_hit(variable_get('firestats_site_id', 1), TRUE);
}
else {
// Complies with FireStats 1.5 API.
fs_add_hit(NULL, TRUE, variable_get('firestats_site_id', 1));
}
}
}