public function get_latest_achievements($no_to_fetch) { $achievs = array(); $count = 0; if (!$this->_has_valid_achievement_data()) { return $achievs; } $achiev_data = WoW_Armory_Character_DAL::fetch_achievements($this->region, $this->locale); if (is_wp_error($achiev_data)) { WoW_Armory_Character_DAL::persist_character_note($this, __('The global achievement data is corrupt. Please clear the cache.', 'wow_armory_character')); } else { arsort($this->achievements->achievementsCompletedTimestamp); foreach ($this->achievements->achievementsCompletedTimestamp as $key => $timestamp) { if ($count >= $no_to_fetch) { break; } $ach = $achiev_data->get_achievement_by_id($this->achievements->achievementsCompleted[$key]); // Our achievement data may not contain what we need so we skip achievements that don't get // returned correctly. Come on Blizz... if (!is_null($ach)) { $ach->completed = $timestamp; $achievs[] = $ach; $count++; } else { WoW_Armory_Character_DAL::persist_character_note($this, __('The achievement data does not contain a match for achievement id ' . $this->achievements->achievementsCompleted[$key] . '.', 'wow_armory_character')); } } } return $achievs; }
public function get_item_url_components() { switch ($this->type) { case self::ITEM_ACHIEVEMENT: case self::ITEM_CRITERIA: $achievements = WoW_Armory_Character_DAL::fetch_achievements($this->region, $this->locale); if (is_wp_error($achievements)) { return null; } $achiev = $achievements->get_achievement_by_id($this->achievement->id); $components = array('id' => $achiev->id, 'section' => $achiev->section->id, 'category' => $achiev->category->id); return $components; break; case self::ITEM_LOOT: return array('id' => $this->itemId); break; } }