private static function tagObjectFromSQL($sql_tag) { if (!$sql_tag) { return $sql_tag; } $tag = new stdClass(); $tag->tag_id = $sql_tag->tag_id; $tag->game_id = $sql_tag->game_id; $tag->tag = $sql_tag->tag; $tag->media_id = $sql_tag->media_id; if ($sql_tag->media_id) { $tag->media = media::getMedia($sql_tag); } $tag->visible = $sql_tag->visible; $tag->curated = $sql_tag->curated; $tag->sort_index = $sql_tag->sort_index; return $tag; }
public static function updateMedia($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } //boring, but this is the only immutable property of media dbconnection::query("UPDATE media SET " . (isset($pack->name) ? "name = '" . addslashes($pack->name) . "', " : "") . "last_active = CURRENT_TIMESTAMP " . "WHERE media_id = '{$pack->media_id}'"); games::bumpGameVersion($pack); return media::getMedia($pack); }
public static function getFullGame($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $sql_game = dbconnection::queryObject("SELECT * FROM games WHERE game_id = '{$pack->game_id}' LIMIT 1"); if (!$sql_game) { return new return_package(2, NULL, "The game you've requested does not exist"); } $game = games::getGame($pack)->data; $game->authors = users::getUsersForGame($pack)->data; //pack already has auth and game_id //heres where we just hack the pack for use in other requests without overhead of creating new packs $pack->media_id = $game->media_id; $game->media = media::getMedia($pack)->data; $pack->media_id = $game->icon_media_id; $game->icon_media = media::getMedia($pack)->data; return new return_package(0, $game); }