Ejemplo n.º 1
0
 function getFullNoteObject($noteId, $playerId = 0)
 {
     $query = "SELECT * FROM notes WHERE note_id = '{$noteId}'";
     $result = Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     if ($note = mysql_fetch_object($result)) {
         $query = "SELECT user_name, display_name FROM players WHERE player_id = '{$note->owner_id}'";
         $player = Module::query($query);
         $playerObj = mysql_fetch_object($player);
         $type = MODULE::kSHARE_FACEBOOK;
         $note->facebook_shares = Notes::getNoteShares($noteId, $type);
         $type = MODULE::kSHARE_TWITTER;
         $note->twitter_shares = Notes::getNoteShares($noteId, $type);
         $type = MODULE::kSHARE_PINTEREST;
         $note->pinterest_shares = Notes::getNoteShares($noteId, $type);
         $type = MODULE::kSHARE_EMAIL;
         $note->email_shares = Notes::getNoteShares($noteId, $type);
         $note->username = $playerObj->user_name;
         $note->displayname = $playerObj->display_name;
         $note->contents = Notes::getNoteContents($noteId, $note->game_id);
         $note->comments = Notes::getNoteComments($noteId, $playerId);
         $note->tags = Notes::getNoteTags($noteId, $note->game_id);
         $note->likes = Notes::getNoteLikes($noteId);
         $note->player_liked = $playerId == 0 ? 0 : Notes::playerLiked($playerId, $noteId);
         $note->player_flagged = $playerId == 0 ? 0 : Notes::playerFlagged($playerId, $noteId);
         $note->icon_media_id = 5;
         if ($note->dropped = Notes::noteDropped($noteId, $note->game_id)) {
             $location = Notes::getNoteLocation($noteId, $note->game_id);
         } else {
             $location = new stdClass();
             $location->lat = $location->lon = 0;
         }
         $note->lat = $location->lat;
         $note->lon = $location->lon;
         return $note;
     }
     return;
 }
Ejemplo n.º 2
0
 private static function getPlayerArrayDataBP($gameId, $playerArray, $getItems = true, $getAttributes = true, $getNotes = true)
 {
     //preload data into memory for quick re-use
     $mediaA = Media::getMedia($gameId)->data;
     $mediaMap = array();
     $numMedia = count($mediaA);
     for ($i = 0; $i < $numMedia; $i++) {
         $mediaMap[$mediaA[$i]->media_id] = $mediaA[$i];
     }
     if ($getItems) {
         $itemsMap = array();
         $itemsA = Module::queryArray("SELECT * FROM items WHERE game_id = '{$gameId}' AND (is_attribute = '0' OR is_attribute = '')");
         $numItems = count($itemsA);
         for ($i = 0; $i < $numItems; $i++) {
             $itemsA[$i]->media_url = $mediaMap[$itemsA[$i]->media_id]->url;
             $itemsA[$i]->media_thumb_url = $mediaMap[$itemsA[$i]->media_id]->thumb_url;
             $itemsA[$i]->icon_url = $mediaMap[$itemsA[$i]->icon_media_id]->url;
             $itemsA[$i]->icon_thumb_url = $mediaMap[$itemsA[$i]->icon_media_id]->thumb_url;
             $itemsMap[$itemsA[$i]->item_id] = $itemsA[$i];
         }
     }
     if ($getAttributes) {
         $attributesMap = array();
         $attributesA = Module::queryArray("SELECT * FROM items WHERE game_id = '{$gameId}' AND is_attribute = '1'");
         $numAttributes = count($attributesA);
         for ($i = 0; $i < $numAttributes; $i++) {
             $attributesA[$i]->media_url = $mediaMap[$attributesA[$i]->media_id]->url;
             $attributesA[$i]->media_thumb_url = $mediaMap[$attributesA[$i]->media_id]->thumb_url;
             $attributesA[$i]->icon_url = $mediaMap[$attributesA[$i]->icon_media_id]->url;
             $attributesA[$i]->icon_thumb_url = $mediaMap[$attributesA[$i]->icon_media_id]->thumb_url;
             $attributesMap[$attributesA[$i]->media_id] = $attributesA[$i];
         }
     }
     if ($getNotes) {
         $gameTagsMap = array();
         $gameTagsA = Module::queryArray("SELECT * FROM game_tags WHERE game_id = '{$gameId}'");
         $numGameTags = count($gameTagsA);
         for ($i = 0; $i < $numGameTags; $i++) {
             $gameTagsMap[$gameTagsA[$i]->tag_id] = $gameTagsA[$i];
         }
     }
     $backpacks = array();
     $numPlayers = count($playerArray);
     for ($i = 0; $i < $numPlayers; $i++) {
         $backpack = new stdClass();
         $backpack->owner = Module::queryObject("SELECT player_id, user_name, display_name, group_name, media_id FROM players WHERE player_id = '{$playerArray[$i]}'");
         if (!$backpack->owner) {
             continue;
         }
         $playerPic = Media::getMediaObject('player', $backpack->owner->media_id)->data;
         $backpack->owner->player_pic_url = $playerPic->url;
         $backpack->owner->player_pic_thumb_url = $playerPic->thumb_url;
         $media->thumb_file_path = substr($media->file_path, 0, strrpos($media->file_path, '.')) . '_128' . substr($media->file_path, strrpos($media->file_path, '.'));
         $media->url_path = Config::gamedataWWWPath . "/";
         if ($getItems || $getAttributes) {
             if ($getItems) {
                 $backpack->items = array();
             }
             if ($getAttributes) {
                 $backpack->attributes = array();
             }
             $playerItemData = Module::queryArray("SELECT item_id, qty FROM player_items WHERE game_id = '{$gameId}' AND player_id = '{$playerArray[$i]}'");
             $numItems = count($playerItemData);
             for ($j = 0; $j < $numItems; $j++) {
                 if ($getItems && isset($itemsMap[$playerItemData[$j]->item_id])) {
                     $item = clone $itemsMap[$playerItemData[$j]->item_id];
                     $item->qty = $playerItemData[$j]->qty;
                     $backpack->items[] = $item;
                 } else {
                     if ($getAttributes && isset($attributesMap[$playerItemData[$j]->item_id])) {
                         $attribute = clone $attributesMap[$playerItemData[$j]->item_id];
                         $attribute->qty = $playerItemData[$j]->qty;
                         $backpack->attributes[] = $attribute;
                     }
                 }
             }
         }
         if ($getNotes) {
             $rawNotes = Module::query("SELECT * FROM notes WHERE owner_id = '{$playerArray[$i]}' AND game_id = '{$gameId}' AND parent_note_id = 0 ORDER BY sort_index ASC");
             $backpack->notes = array();
             while ($note = mysql_fetch_object($rawNotes)) {
                 $note->username = $backpack->owner->user_name;
                 if ($backpack->owner->display_name && $backpack->owner->display_name != "") {
                     $note->username = $backpack->owner->display_name;
                 }
                 $rawContent = Module::query("SELECT * FROM note_content WHERE note_id = '{$note->note_id}'");
                 $note->contents = array();
                 while ($content = mysql_fetch_object($rawContent)) {
                     $content->media_url = $mediaMap[$content->media_id]->url;
                     $content->media_thumb_url = $mediaMap[$content->media_id]->thumb_url;
                     $note->contents[] = $content;
                 }
                 $note->likes = Notes::getNoteLikes($note->note_id);
                 $note->player_liked = Notes::playerLiked($playerId, $note->note_id);
                 $result = Module::query("SELECT * FROM note_tags WHERE note_id = '{$note->note_id}'");
                 $note->tags = array();
                 while ($tag = mysql_fetch_object($result)) {
                     $note->tags[] = $gameTagsMap[$tag->tag_id];
                 }
                 $note->dropped = 0;
                 if ($location = Notes::noteDropped($note->note_id, $note->game_id)) {
                     $note->dropped = 1;
                 }
                 $note->lat = $location ? $location->latitude : 0;
                 $note->lon = $location ? $location->longitude : 0;
                 $rawComments = Module::query("SELECT * FROM notes WHERE game_id = '{$gameId}' AND parent_note_id = {$note->note_id} ORDER BY sort_index ASC");
                 $note->comments = array();
                 while ($comment = mysql_fetch_object($rawComments)) {
                     $player = Module::queryObject("SELECT user_name, display_name FROM players WHERE player_id = '{$comment->owner_id}' LIMIT 1");
                     $comment->username = $player->user_name;
                     $comment->displayname = $player->display_name;
                     $rawContent = Module::query("SELECT * FROM note_content WHERE note_id = '{$comment->note_id}'");
                     $comment->contents = array();
                     while ($content = mysql_fetch_object($rawContent)) {
                         $content->media_url = $mediaMap[$content->media_id]->url;
                         $content->media_thumb_url = $mediaMap[$content->media_id]->thumb_url;
                         $comment->contents[] = $content;
                     }
                     $comment->likes = Notes::getNoteLikes($comment->note_id);
                     $comment->player_liked = Notes::playerLiked($playerId, $comment->note_id);
                     $note->comments[] = $comment;
                 }
                 $backpack->notes[] = $note;
             }
         }
         $backpacks[] = $backpack;
     }
     return $backpacks;
 }
Ejemplo n.º 3
0
 function getFullNoteObject($noteId, $playerId = 0)
 {
     $query = "SELECT * FROM notes WHERE note_id = '{$noteId}'";
     $result = Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     if ($note = mysql_fetch_object($result)) {
         $query = "SELECT user_name FROM players WHERE player_id = '{$note->owner_id}'";
         $player = Module::query($query);
         $playerObj = mysql_fetch_object($player);
         $note->username = $playerObj->user_name;
         $note->displayname = $playerObj->display_name;
         $note->contents = Notes::getNoteContents($noteId, $note->game_id);
         $note->comments = Notes::getNoteComments($noteId, $playerId);
         $note->tags = Notes::getNoteTags($noteId, $note->game_id);
         $note->likes = Notes::getNoteLikes($noteId);
         $note->player_liked = $playerId == 0 ? 0 : Notes::playerLiked($playerId, $noteId);
         $note->icon_media_id = 5;
         if ($note->dropped = Notes::noteDropped($noteId, $note->game_id)) {
             $location = Notes::getNoteLocation($noteId, $note->game_id);
         } else {
             $location = new stdClass();
             $location->lat = $location->lon = 0;
         }
         $note->lat = $location->lat;
         $note->lon = $location->lon;
         return $note;
     }
     return;
 }