You are here

function simplenews_statistics_count_clicks in Simplenews Statistics 7

Same name and namespace in other branches
  1. 7.2 simplenews_statistics.module \simplenews_statistics_count_clicks()

Counts the number of subscribers who have opened a link.

2 calls to simplenews_statistics_count_clicks()
simplenews_statistics_cron in ./simplenews_statistics.module
Implements hook_cron().
simplenews_statistics_handler_clicks::render in includes/views/handlers/simplenews_statistics_handler_clicks.inc
Renders the field handler.

File

./simplenews_statistics.module, line 435
Main simplenews statistics file.

Code

function simplenews_statistics_count_clicks($nid, $distinct = FALSE) {

  // @todo: Archived check.
  $query = db_select('simplenews_statistics_click', 'ssc')
    ->condition('ssu.nid', $nid);
  $query
    ->join('simplenews_statistics_url', 'ssu', 'ssu.urlid = ssc.urlid');
  if ($distinct) {
    $query
      ->fields('ssc', array(
      'snid',
    ))
      ->distinct();
  }
  return $query
    ->countQuery()
    ->execute()
    ->fetchField();
}