private static function getAllPlayerDataBP($gameId, $getItems = true, $getAttributes = true, $getNotes = true) { $result = Module::query("SELECT DISTINCT player_id FROM player_log WHERE game_id='{$gameId}' AND player_id != 0"); $players = array(); while ($player = mysql_fetch_object($result)) { $players[] = $player->player_id; } return Players::getPlayerArrayDataBP($gameId, $players, $getItems, $getAttributes, $getNotes); }
/** Gets array of JSON encoded 'web backpacks', containing player information relating to items, attributes, and notes gained throughout a game. For an example of its use, see 'getBackPacksFromArray.html'. @param: bpReqObj- a JSON encoded object with two fields: gameId- An integer representing the game_id of the game information desired. playerArray- Either a JSON encoded array of integer player_ids of all the players whose information is desired, a single integer if only one player's information is desired, or nothing if all player information for an entire game is desired. @returns: On success, returns JSON encoded game object with a parameter containing an array of player objects with various parameters describing a player's information. If gameId is empty, returns 'Error- Empty Game' and aborts the function. If game with gameId does not exist, returns 'Error- Invalid Game Id' and aborts the function. If playerArray is anything other than the specified options, returns 'Error- Invalid Player Array' and aborts the function. **/ public static function getPlayerBackpacksFromArray($bpReqObj) { //Module::serverErrorLog('Get Backpacks From Arrays Called: '.date_format(date_create(), 'H:i:s:u')."\n".$bpReqObj); $gameId = $bpReqObj['gameId']; $playerArray = $bpReqObj['playerArray']; $getItems = isset($bpReqObj['items']) ? $bpReqObj['items'] : true; //Default true $getAttributes = isset($bpReqObj['attributes']) ? $bpReqObj['attributes'] : true; //Default true $getNotes = isset($bpReqObj['notes']) ? $bpReqObj['notes'] : true; //Default true if (is_numeric($gameId)) { $gameId = intval($gameId); } else { return new returnData(1, "Error- Empty Game " . $gameId); } if (($game = Games::getDetailedGameInfo($gameId)) == "Invalid Game Id") { return new returnData(1, "Error- Empty Game " . $gameId); } if (is_null($playerArray)) { $game->backpacks = Players::getAllPlayerDataBP($gameId, $getItems, $getAttributes, $getNotes); return new returnData(0, $game); } else { if (is_array($playerArray)) { $game->backpacks = Players::getPlayerArrayDataBP($gameId, $playerArray, $getItems, $getAttributes, $getNotes); return new returnData(0, $game); } else { if (is_numeric($playerArray)) { $game->backpacks = Players::getSinglePlayerDataBP($gameId, intval($playerArray), false, $getItems, $getAttributes, $getNotes); return new returnData(0, $game, true); } else { return new returnData(1, "Error- Invalid Player Array"); } } } }