You are here

function services_admin_keys_save in Services 6

Same name and namespace in other branches
  1. 5 services_admin_keys.inc \services_admin_keys_save()
1 call to services_admin_keys_save()
services_admin_keys_form_submit in ./services_admin_keys.inc

File

./services_admin_keys.inc, line 88
@author Services Dev Team

Code

function services_admin_keys_save(&$key) {
  $is_existing = FALSE;
  $key['kid'] = !empty($key['kid']) ? $key['kid'] : md5(uniqid(mt_rand(), TRUE));
  $is_existing = db_result(db_query("SELECT count(*) FROM {services_keys}\n    WHERE kid = '%s'", $key['kid']));
  if ($is_existing) {
    db_query("UPDATE {services_keys} SET title = '%s', domain = '%s'\n      WHERE kid = '%s'", $key['title'], $key['domain'], $key['kid']);
    return SAVED_UPDATED;
  }
  else {
    db_query("INSERT INTO {services_keys} (kid, title, domain)\n      VALUES ('%s', '%s', '%s')", $key['kid'], $key['title'], $key['domain']);
    return SAVED_NEW;
  }
}