You are here

function simplenews_statistics_set_url in Simplenews Statistics 7

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

Creates an url record in the database.

Parameters

string $url: The URL.

int $nid: The Simplenews nid this link belongs to.

Return value

object || FALSE Object representing the url record or FALSE.

1 call to simplenews_statistics_set_url()
_simplenews_statistics_replace_url in ./simplenews_statistics.module
Alter link to go through statistics.

File

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

Code

function simplenews_statistics_set_url($url, $nid) {
  $record = new stdClass();
  $record->nid = $nid;
  $record->url = $url;
  $result = drupal_write_record('simplenews_statistics_url', $record);
  if ($result !== FALSE) {

    // Immediately cache the record for later use.
    $cached_urls =& drupal_static('simplenews_statistics_url');
    $cached_urls[$url] = $record;
    return $record;
  }
  return FALSE;
}