You are here

function shurly_save_url in ShURLy 6

Same name and namespace in other branches
  1. 8 shurly.module \shurly_save_url()
  2. 7 shurly.module \shurly_save_url()

API function to save a URL @arg $custom is a TRUE/FALSE

2 calls to shurly_save_url()
shurly_create_form_submit in ./shurly.module
shurly_shorten in ./shurly.module
API function to shorten a URL @arg $long_url - the long URL to shorten @arg $custom - optional custom short URL, user_access('enter custom URLs') should be checked prior to calling shurly_shorten()

File

./shurly.module, line 524
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_save_url($long_url, $short_path, $account = NULL, $custom = NULL) {
  if (is_null($account)) {
    $account = $GLOBALS['user'];
  }
  $record = array();
  $record['destination'] = $long_url;
  $record['hash'] = md5($long_url);
  $record['custom'] = $custom ? 1 : 0;
  $record['created'] = time();
  $record['source'] = $short_path;
  $record['uid'] = $account->uid;
  $record['count'] = $record['last_used'] = 0;
  $record['active'] = 1;
  return drupal_write_record('shurly', $record);
}