You are here

function antispam_get_total_counter in AntiSpam 6

Same name and namespace in other branches
  1. 7 antispam.module \antispam_get_total_counter()

Get total counter value for the specified counter type

4 calls to antispam_get_total_counter()
antispam_block in ./antispam.module
Implementation of hook_block().
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
Implementation of hook_help().

File

./antispam.module, line 283

Code

function antispam_get_total_counter($counter_type = '') {
  $rec = db_fetch_object(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}"));
  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;
  }
  if (empty($counter_type)) {

    // returns an array of all totals
    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;
    default:
      return 0;
  }
}