function antispam_get_total_counter in AntiSpam 7
Same name and namespace in other branches
- 6 antispam.module \antispam_get_total_counter()
Get total counter value for the specified counter type.
4 calls to antispam_get_total_counter()
- antispam_block_view in ./
antispam.module - Implements hook_block_view().
- antispam_callback_queue in ./
antispam.admin.inc - Menu callback; Moderation queue.
- antispam_generate_statistics_graph in ./
antispam.admin.inc - Generate a graph of service statistics using Google Chart API
- antispam_help in ./
antispam.module - Implements hook_help().
File
- ./
antispam.module, line 231 - Primary hook implementations for the Antispam module.
Code
function antispam_get_total_counter($counter_type = '') {
$rec = db_query("SELECT SUM(spam_detected) AS total_spam, SUM(ham_detected) AS total_ham, SUM(false_negative) AS total_fnegative, SUM(false_positive) AS total_fpositive FROM {antispam_counter}")
->fetchObject();
if ($rec->total_spam == '') {
$rec->total_spam = 0;
}
if ($rec->total_ham == '') {
$rec->total_ham = 0;
}
if ($rec->total_fnegative == '') {
$rec->total_fnegative = 0;
}
if ($rec->total_fpositive == '') {
$rec->total_fpositive = 0;
}
// Returns an array of all totals.
if (empty($counter_type)) {
return array(
'total_spam' => $rec->total_spam,
'total_ham' => $rec->total_ham,
'total_fnegative' => $rec->total_fnegative,
'total_fpositive' => $rec->total_fpositive,
);
}
switch ($counter_type) {
case ANTISPAM_COUNT_ALL:
return $rec->total_spam + $rec->total_ham;
case ANTISPAM_COUNT_SPAM_DETECTED:
return $rec->total_spam;
case ANTISPAM_COUNT_HAM_DETECTED:
return $rec->total_ham;
case ANTISPAM_COUNT_FALSE_NEGATIVE:
return $rec->total_fnegative;
case ANTISPAM_COUNT_FALSE_POSITIVE:
return $rec->total_fpositive;
// Just in case.
default:
return 0;
}
}