You are here

function simplenews_statistics_encoder_simplenews_statistics_encode in Simplenews Statistics 7

Same name and namespace in other branches
  1. 7.2 simplenews_statistics_encoder/simplenews_statistics_encoder.module \simplenews_statistics_encoder_simplenews_statistics_encode()

Implements hook_simplenews_statistics_encode().

File

simplenews_statistics_encoder/simplenews_statistics_encoder.module, line 48
Main simplenews statistics encoder file.

Code

function simplenews_statistics_encoder_simplenews_statistics_encode($id, $key) {

  // The IDs should always be numeric, but check to be sure.
  if (!is_numeric($id)) {
    return $id;
  }

  // Encode based on type selected.
  $type = variable_get('simplenews_statistics_encoder_type', 'md5');
  module_load_include('inc', 'simplenews_statistics_encoder', 'encoder');
  if ($type == 'md5') {
    return simplenews_statistics_encoder_generate_hash($id, $key);
  }
  elseif ($type == 'shorturl') {
    $salt = variable_get('simplenews_statistics_encoder_salt', 0);
    $salted = $id + $salt;
    return simplenews_statistics_encoder_encode($salted);
  }
  else {
    return $id;
  }
}