function drush_better_statistics_stats_dis in Better Statistics 7
Drush command callback for stats-dis.
File
- ./
better_statistics.drush.inc, line 159 - Drush integration of Better Statistics.
Code
function drush_better_statistics_stats_dis($fields) {
module_load_include('inc', 'better_statistics', 'better_statistics.admin');
$fields = func_get_args();
$active = variable_get('better_statistics_fields', better_statistics_get_default_fields());
$available = _better_statistics_get_custom_fields_by_module();
foreach ($fields as $index => $field) {
if (!_better_statistics_field_exists($field)) {
unset($fields[$index]);
drush_print(dt("The @field field doesn't exist. Use drush stats-ls to view a full list of available fields.", array(
'@field' => $field,
)));
}
elseif (!isset($active[$field])) {
unset($fields[$index]);
drush_print(dt("The @field field isn't enabled.", array(
'@field' => $field,
)));
}
}
if (empty($fields)) {
return drush_log(dt('There were no fields that could be disabled.'), 'ok');
}
else {
// Inform the user which fields will be disabled.
drush_print(dt('The following statistics fields will be disabled: !fields. All data collected for the specified field(s) will be permanently deleted.', array(
'!fields' => implode(', ', $fields),
)));
if (!drush_confirm(dt('Do you really want to continue?'))) {
return drush_user_abort();
}
// Disable the fields here.
$disabled = better_statistics_disable_fields($fields);
// Print confirmation of field disablement.
drush_print(dt("The following fields were successfully disabled: @fields", array(
'@fields' => implode(', ', $disabled),
)));
}
}