function brukar_server_admin_applications_form_submit($form, &$form_state) { $val = (object) $form_state['values']; if ($val->id == 0) { $val->consumer_key = brukar_common_uuid(); $val->consumer_secret = brukar_common_uuid(); $val->active = 1; } drupal_write_record('brukar_application', $val, $val->id == 0 ? array() : 'id'); drupal_goto('admin/structure/brukar/application'); }
function new_access_token($token, $consumer, $verifier = null) { // db_query('DELETE FROM {brukar_token} WHERE `id` = :id', array(':id' => $token->id))->execute(); $aTokenD = db_query('SELECT * FROM {brukar_token} WHERE `type` = :type AND uid = :uid AND application_id = :aid', array(':uid' => $token->uid, ':aid' => $consumer->id, ':type' => 'access'))->fetch(); if ($aTokenD === false) { $aToken = new BrukarServerToken(brukar_common_uuid(), brukar_common_uuid()); $record = array('application_id' => $consumer->id, 'uid' => $token->uid, 'type' => 'access', 'token_key' => $aToken->key, 'token_secret' => $aToken->secret, 'created' => time()); db_insert('brukar_token')->fields($record)->execute(); // drupal_write_record('brukar_token', $record); } else { $aToken = new BrukarServerToken($aTokenD->token_key, $aTokenD->token_secret, $aTokenD->id, $aTokenD->uid); } /* $record = array( 'id' => $site->id, 'last' => time(), ); drupal_write_record('auth_user_site', $record, 'id'); */ return $aToken; }