function statspro_drush_run in Statistics Pro 6.2
Same name and namespace in other branches
- 6 statspro.drush.inc \statspro_drush_run()
Run drush command for specified mode
1 string reference to 'statspro_drush_run'
- statspro_drush_command in ./
statspro.drush.inc - Implementation of hook_drush_command().
File
- ./
statspro.drush.inc, line 56 - Drush include file for statuspro
Code
function statspro_drush_run() {
$modes = func_get_args();
if (empty($modes)) {
drush_die('Missing mode: use drush help statspro for more information');
}
drush_print(t('Statistics Pro information'));
if ($modes[0] == 'path_aggregated') {
require_once drupal_get_path('module', 'statspro') . '/statspro_path_aggregated.inc';
$period = isset($modes[1]) ? $modes[1] : variable_get('statspro_period', 'today');
$number_of_days = isset($modes[2]) ? (int) $modes[2] : variable_get('statspro_custom_number_days', 30);
$period_info = statspro_get_period_info($period, $number_of_days);
if ($period_info['period'] === NULL) {
drush_print(t('Unknown period %period.', array(
'%period' => $period,
)));
return;
}
$table_data = statspro_path_aggregated_get_data_for_configurable_period_report($period_info['period']);
if (!is_array($table_data) || !isset($table_data['rows']) || count($table_data['rows']) == 0) {
drush_print(t('No path aggregated data available for period %period_name.', array(
'%period_name' => $period_info['period_name'],
)));
return;
}
drush_print(t('Path aggregated report for period %period_name.', array(
'%period_name' => $period_info['period_name'],
)));
$lines = statspro_get_array_as_fixed_space_fields($table_data['headers'], $table_data['rows']);
drush_print(implode("\n", $lines));
}
else {
require_once drupal_get_path('module', 'statspro') . '/statspro.inc';
$statspro = new StatsPro();
$rc = $statspro
->get_aggregate_stat($modes[0]);
if (is_array($rc)) {
drush_print($rc['subject'] . ': ' . $rc['amount']);
}
else {
drush_die('Unknown mode');
}
}
}