public static function createNote($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } if ($pack->media) { $pack->media->auth = $pack->auth; $pack->media->game_id = $pack->game_id; $pack->media_id = media::createMedia($pack->media)->data->media_id; } $game = games::getGame($pack); $pack->note_id = dbconnection::queryInsert("INSERT INTO notes (" . "game_id," . "user_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->media_id) ? "media_id," : "") . "published," . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . "'" . $pack->auth->user_id . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . ($game->data->moderated ? "'PENDING'" : "'AUTO'") . "," . "CURRENT_TIMESTAMP" . ")"); if ($pack->trigger) { $scene_id = dbconnection::queryObject("SELECT * FROM user_game_scenes WHERE user_id = '{$pack->auth->user_id}' AND game_id = '{$pack->game_id}'")->scene_id; if (!$scene_id) { $scene_id = $game->data->intro_scene_id; } $instance_id = dbconnection::queryInsert("INSERT INTO instances (game_id, object_id, object_type, created) VALUES ('{$pack->game_id}', '{$pack->note_id}', 'NOTE', CURRENT_TIMESTAMP)"); $trigger_id = dbconnection::queryInsert("INSERT INTO triggers (game_id, instance_id, scene_id, type, latitude, longitude, infinite_distance, created) VALUES ( '{$pack->game_id}', '{$instance_id}', '{$scene_id}', 'LOCATION', '{$pack->trigger->latitude}', '{$pack->trigger->longitude}', '1', CURRENT_TIMESTAMP);"); } //allow for 'tag_id' in API, but really just use object_tags if ($pack->tag_id) { dbconnection::queryInsert("INSERT INTO object_tags (game_id, object_type, object_id, tag_id, created) VALUES ('{$pack->game_id}', 'NOTE', '{$pack->note_id}', '{$pack->tag_id}', CURRENT_TIMESTAMP)"); } client::logPlayerCreatedNote($pack); games::bumpGameVersion($pack); return notes::getNote($pack); }