public function __construct(Remote $remote, $id = false, $data = array()) { $this->remote = $remote; $this->data = $data; if ($id === false) { // Generate a UUID for the transaction. \module_load_include('inc', 'uuid'); $this->id = \uuid_generate(); } else { $this->id = $id; } // Set the timeout to a higher number. drupal_set_time_limit(0); }
private function populate() { $json = $this->notation; $json_array = drupal_json_decode($json); dsm($json_array); //object_type if (isset($json_array['objectType']) && $json_array['objectType'] == 'SubStatement') { $this->object_type = 'SubStatement'; if (isset($json_array['version'])) { unset($json_array['version']); } if (isset($json_array['id'])) { unset($json_array['id']); } if (isset($json_array['stored'])) { unset($json_array['version']); } if (isset($json_array['authority'])) { unset($json_array['version']); } } else { $this->object_type = 'Statement'; } //version if (isset($json_array['version'])) { $this->version = $json_array['version']; } else { if ($this->object_type != 'SubStatement') { $this->version = '1.0.0'; } } //id if (isset($json_array['id'])) { $this->statement_id = $json_array['id']; } else { // generate uuid for the statement if ($this->object_type != 'SubStatement' && $this->statement_id == '') { $this->statement_id = uuid_generate(); } } //timestamp // need to do something about saving the datetime values tincan api expects into mysql.... if (isset($json_array['timestamp'])) { $this->timestamp = $json_array['timestamp']; } // stored if (isset($json_array['stored'])) { $this->stored = $json_array['stored']; } else { if ($this->object_type != 'SubStatement') { $this->stored = date('c'); //must be in iso 8601 format; } } // Actor if (isset($json_array['actor'])) { $this->tincan_actor = array(); $this->populateActor($json_array['actor']); } // Verb if (isset($json_array['verb'])) { $this->tincan_verb = array(); $this->populateVerb($json_array['verb']); } // Object if (isset($json_array['object'])) { $this->tincan_object = array(); $this->populateObject($json_array['object']); } // Result if (isset($json_array['result'])) { $this->tincan_result = array(); $this->populateResult($json_array['result']); } // Authority if (isset($json_array['authority'])) { $this->tincan_authority = array(); $this->populateAuthority($json_array['authority']); } else { //figure out authorize default if ($this->object_type != 'SubStatement') { } } if (isset($json_array['context'])) { $this->tincan_context = array(); $this->populateContext($json_array['context']); } }
public static function generate($form, &$form_state) { module_load_include('inc', 'uuid'); $form_state['values']['api_key'] = uuid_generate(); self::submit($form, $form_state); }
if (isset($_SESSION['user'])) { $GLOBALS['user'] = new User($_SESSION['user']); } } $stmt = $pdo->prepare(' REPLACE INTO `sessions` ( `uuid`, `ip`, `last_active` ) VALUES ( :uuid, INET_ATON(:ip), now() ) '); $stmt->bindParam(':uuid', $_SESSION['uuid']); $stmt->bindParam(':ip', $_SERVER['REMOTE_ADDR']); $stmt->execute(); // And that should finish up for when a session is already made } else { $uuid = uuid_generate(); $stmt = $pdo->prepare(' INSERT INTO `sessions` ( `uuid`, `ip`, `last_active` ) VALUES ( :uuid, INET_ATON(:ip), now() ) '); $stmt->bindParam(':ip', $_SERVER['REMOTE_ADDR']); $stmt->bindParam(':uuid', $uuid); $stmt->execute(); $_SESSION['uuid'] = $uuid; }