You are here

function services_admin_keys_save in Services 5

Same name and namespace in other branches
  1. 6 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 87
The file contains code which is used to create the keys interface

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_num_rows(db_query("SELECT * FROM {services_keys} WHERE kid = '%s'", $key['kid']));
  if (!$is_existing) {
    db_query("INSERT INTO {services_keys} (kid, title, domain) VALUES ('%s', '%s', '%s')", $key['kid'], $key['title'], $key['domain']);
    return SAVED_NEW;
  }
  else {
    db_query("UPDATE {services_keys} SET title = '%s', domain = '%s' WHERE kid = '%s'", $key['title'], $key['domain'], $key['kid']);
    return SAVED_UPDATED;
  }
}