/** * View Bossprogress page * @param viewNavigation $Navigation */ public function buildpage(viewNavigation $Navigation) { global $phpbb_root_path, $phpEx, $user, $template, $config; $igame = new \bbdkp\controller\games\Game(); $igame->game_id = $Navigation->getGameId(); $igame->Get(); $Guild = new \bbdkp\controller\guilds\Guilds($Navigation->getGuildId()); $bp = new \bbdkp\controller\Raids\GuildProgress(); $data = $bp->GetProgress($Guild); $numzones = 0; foreach ($data as $zone_id => $zone) { $numzones += 1; } $start = request_var('start', 0); $template->assign_vars(array('S_STYLE' => $config['bbdkp_zone_style'], 'S_BPSHOW' => true, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $Guild->game_id . '/' . $Guild->game_id . '.png', 'F_BP' => \append_sid("{$phpbb_root_path}dkp.{$phpEx}", 'page=bossprogress&guild_id=' . $Navigation->getGuildId()), 'GAME_ID' => $Navigation->getGameId(), 'GAME_NAME' => $igame->getName(), 'GUILD_ID' => $Guild->guildid, 'PAGE_NUMBER' => \on_page($numzones, 2, $start), 'PAGINATION' => \generate_pagination(append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=bossprogress&guild_id=" . $Guild->guildid), $numzones, 2, $start, true), 'U_BPIMG' => "{$phpbb_root_path}images/bbdkp/gameworld/{$Navigation->getGameId()}/{$Navigation->getGameId()}.png")); $i = 0; $j = 0; //loop the zones foreach ($data as $zone_id => $zone) { $i += 1; if ($i >= $start) { $j += 1; //show max 2 zones per page if ($j <= 2) { $template->assign_block_vars('zone', array('ZONE_NAME' => $zone['zonename'], 'ZONE_ID' => $zone['zoneid'], 'ZONE_PROGRESSIMG' => $zone['zoneimage'], 'ZONE_BACKGROUNDIMG' => $zone['zonebackground'], 'ZONECOMPLETE' => $zone['zonecomplete'], 'ZONESTATS' => $zone['zonestats'])); foreach ($zone['bosses'] as $boss_id => $boss) { $killdate = ''; if ($boss['bosskilldate'] != '') { $killdate = date($config['bbdkp_date_format'], $boss['bosskilldate']); // convert UNIX timestamp to PHP DateTime } if ($boss['bosskilled'] == 0) { $bossimg = "{$phpbb_root_path}images/bbdkp/gameworld/" . $Guild->game_id . '/bosses/' . $boss['imagename'] . '_b.png'; } else { $bossimg = "{$phpbb_root_path}images/bbdkp/gameworld/" . $Guild->game_id . '/bosses/' . $boss['imagename'] . '.png'; } $template->assign_block_vars('zone.boss', array('BOSS_NAME' => $boss['bossname'], 'BOSS_IMAGENAME' => $bossimg, 'BOSS_ID' => $boss['id'], 'BOSS_WEBID' => $boss['webid'], 'BOSS_TYPE' => $boss['type'], 'BOSS_URL' => sprintf($igame->getBossbaseurl(), $boss['webid']), 'BOSS_URLVIEW' => $phpbb_root_path . "images/bbdkp/icons/view.gif", 'BOSS_KILLED' => $boss['bosskilled'] == 1 ? 'checked="checked"' : '', 'BOSS_SHOW' => $boss['bossshow'] == 1 ? "checked=checked" : '', 'BOSS_KILLDATE' => $killdate, 'BOSS_COUNTER' => $boss['bosscounter'], 'S_BOSS_KILLED' => $boss['bosskilled'])); } } } } page_header($user->lang['MENU_BOSS']); }
function display_bpblock($guild_id) { global $config, $user, $phpbb_root_path, $template, $phpEx; //include the guilds class if (!class_exists('\\bbdkp\\controller\\guilds\\Guilds')) { require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Guilds.{$phpEx}"; } $Guild = new \bbdkp\controller\guilds\Guilds($guild_id); if (!class_exists('\\bbdkp\\controller\\raids\\GuildProgress')) { require "{$phpbb_root_path}includes/bbdkp/controller/raids/BossProgress.{$phpEx}"; } $bp = new \bbdkp\controller\Raids\GuildProgress(); $igame = new \bbdkp\controller\games\Game(); $igame->game_id = $Guild->game_id; $igame->Get(); $data = $bp->GetProgress($Guild); //loop the zones foreach ($data as $zone_id => $zone) { if ((int) $zone['zonecomplete'] <= 0) { $cssclass = 'bpprogress00'; } elseif ((int) $zone['zonecomplete'] <= 25) { $cssclass = 'bpprogress25'; } elseif ((int) $zone['zonecomplete'] <= 50) { $cssclass = 'bpprogress50'; } elseif ((int) $zone['zonecomplete'] <= 75) { $cssclass = 'bpprogress75'; } elseif ((int) $zone['zonecomplete'] <= 99) { $cssclass = 'bpprogress99'; } elseif ((int) $zone['zonecomplete'] >= 100) { $cssclass = 'bpprogress100'; } $template->assign_block_vars('zone', array('ZONE_NAME' => $zone['zonename'], 'ZONE_ID' => $zone['zoneid'], 'ZONECOMPLETE' => $zone['zonecomplete'], 'ZONEKILLS' => $zone['zonekills'], 'BOSSCOUNT' => $zone['zonebosses'], 'ZONE_URL' => sprintf($igame->getZonebaseurl(), $zone['webid']), 'CSSCLASS' => $cssclass)); foreach ($zone['bosses'] as $boss_id => $boss) { $template->assign_block_vars('zone.boss', array('BOSS_NAME' => $boss['bossname'], 'BOSS_URL' => sprintf($igame->getBossbaseurl(), $boss['webid']), 'BOSS_KILLED' => $boss['bosskilled'] == "1" ? "1" : "0")); } } }
/** * get api info * * @param $params * @return bool */ public function GetApiInfo($params) { global $user; $data = 0; if ($this->game_id != 'wow') { return false; } if ($this->guildid == "0") { return false; } $game = new \bbdkp\controller\games\Game(); $game->game_id = $this->game_id; $game->Get(); //is both game and guild armory-enabled and has api key and locale ? if ($game->getArmoryEnabled() == 1 && $this->armory_enabled == 1 && trim($game->getApikey()) != '' && trim($game->getApilocale()) != '') { //available extra fields : 'members', 'achievements','news' $api = new \bbdkp\controller\wowapi\BattleNet('guild', $this->region, $game->getApikey(), $game->getApilocale(), $game->getPrivkey()); $data = $api->Guild->getGuild($this->name, $this->realm, $params); $data = $data['response']; unset($api); if (!isset($data)) { $this->armoryresult = 'KO'; $log_action = array('header' => 'L_ERROR_ARMORY_DOWN', 'L_UPDATED_BY' => $user->data['username'], 'L_GUILD' => $this->name . '-' . $this->realm); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action, 'log_result' => 'L_ERROR')); return false; } //if we get error code if (isset($data['code'])) { if ($data['code'] == '403') { // even if we have active API account, it may be that Blizzard account is inactive $this->armoryresult = 'KO'; $log_action = array('header' => 'L_ERROR_BATTLENET_ACCOUNT_INACTIVE', 'L_UPDATED_BY' => $user->data['username'], 'L_GUILD' => $this->name . '-' . $this->realm); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action, 'log_result' => 'L_ERROR')); return false; } } $this->armoryresult = 'OK'; } else { $this->armoryresult = 'KO'; } return $data; }
/** * fetch info from Armory * * @return integer */ public function Armory_getmember() { global $phpEx, $phpbb_root_path, $user; $game = new \bbdkp\controller\games\Game(); $game->game_id = $this->game_id; $game->Get(); if ($this->game_id != 'wow') { $this->member_portrait_url = ''; $this->deactivate_reason = ''; return -1; } if ($game->getArmoryEnabled() == 0) { return -1; } //Initialising the class if (!class_exists('\\bbdkp\\controller\\wowapi\\BattleNet')) { require $phpbb_root_path . 'includes/bbdkp/controller/wowapi/BattleNet.' . $phpEx; } /** * available extra fields : * 'guild','stats','talents','items','reputation','titles','professions','appearance', * 'companions','mounts','pets','achievements','progression','pvp','quests' */ $api = new \bbdkp\controller\wowapi\BattleNet('character', $this->member_region, $game->getApikey(), $game->getApilocale(), $game->getPrivkey()); $params = array('guild', 'titles', 'talents'); $data = $api->Character->getCharacter($this->member_name, $this->member_realm, $params); unset($api); // if $data == false then there is no character data, so if (!isset($data) || !isset($data['response'])) { $this->armoryresult = 'KO'; $log_action = array('header' => 'L_ERROR_ARMORY_DOWN', 'L_UPDATED_BY' => $user->data['username'], 'L_GUILD' => $this->name . '-' . $this->realm); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action, 'log_result' => 'L_ERROR')); return -1; } $data = $data['response']; //if we get error code if (isset($data['code'])) { if ($data['code'] == '403') { // even if we have active API account, it may be that Blizzard account is inactive $this->armoryresult = 'KO'; $log_action = array('header' => 'L_ERROR_BATTLENET_ACCOUNT_INACTIVE', 'L_UPDATED_BY' => $user->data['username'], 'L_GUILD' => $this->name . '-' . $this->realm); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action, 'log_result' => 'L_ERROR')); return -1; } } if (isset($data['reason'])) { //not found in armory $this->member_status = 0; $this->deactivate_reason = 'DEACTIVATED_BY_API'; return -1; } $this->member_level = isset($data['level']) ? $data['level'] : $this->member_level; $this->member_race_id = isset($data['race']) ? $data['race'] : $this->member_race_id; $this->member_class_id = isset($data['class']) ? $data['class'] : $this->member_class_id; /* * select the build */ $buildid = 0; if (isset($data['talents'][0]) && isset($data['talents'][1])) { if (isset($data['talents'][0]['selected'])) { $buildid = 0; } elseif (isset($data['talents'][1]['selected'])) { $buildid = 1; } } elseif (isset($data['talents'][0])) { $buildid = 0; } elseif (isset($data['talents'][1])) { $buildid = 1; } $conversion_array = array('DPS' => 0, 'HEALING' => 1, 'TANK' => 2); $role = isset($data['talents'][$buildid]['spec']['role']) ? $data['talents'][$buildid]['spec']['role'] : 'DPS'; if (isset($role) && in_array($role, $conversion_array)) { $this->member_role = $conversion_array[$role]; } $this->member_gender_id = isset($data['gender']) ? $data['gender'] : $this->member_gender_id; $this->member_achiev = isset($data['achievementPoints']) ? $data['achievementPoints'] : $this->member_achiev; if (isset($data['name'])) { $this->member_armory_url = sprintf('http://%s.battle.net/wow/en/', $this->member_region) . 'character/' . $this->member_realm . '/' . $data['name'] . '/simple'; } if (isset($data['thumbnail'])) { $this->member_portrait_url = sprintf('http://%s.battle.net/static-render/%s/', $this->member_region, $this->member_region) . $data['thumbnail']; } if (isset($data['realm'])) { $this->member_realm = $data['realm']; } if (isset($data['guild'])) { $found = false; foreach ($this->guildlist as $guild) { if (strtolower($guild['name']) == strtolower($data['guild']['name'])) { $this->member_guild_id = $guild['id']; $this->member_guild_name = $guild['name']; $found = true; break; } } if ($found == false) { $this->member_guild_id = 0; $this->member_rank_id = 99; } } else { $this->member_guild_id = 0; $this->member_rank_id = 99; } if (isset($data['titles'])) { foreach ($data['titles'] as $key => $title) { if (isset($title['selected'])) { $this->member_title = $title['name']; break; } } } //if the last logged-in date is > 3 months ago then disable the account if (isset($data['lastModified'])) { $latest = $data['lastModified']; $diff = \round(\abs(\time() - $latest / 1000) / 60 / 60 / 24, 2); if ($diff > 90 && $this->member_status == 1) { $this->member_status = 0; $this->deactivate_reason = 'DEACTIVATED_BY_API'; } if ($diff < 90 && $this->member_status == 0 && $this->deactivate_reason == 'DEACTIVATED_BY_API') { $this->member_status = 1; $this->deactivate_reason = ''; } } return 1; }
/** * Delete Game from bbDKP * @param \bbdkp\controller\games\Game $editgame * */ private function DeleteGame(\bbdkp\controller\games\Game $editgame) { global $user; if (confirm_box(true)) { $deletegame = new \bbdkp\controller\games\Game(); $deletegame->game_id = request_var('hidden_game_id', ''); $deletegame->Get(); $deletegame->Delete(); $log_action = array('header' => 'L_ACTION_GAME_DELETED', 'L_GAME' => $deletegame->game_id); $this->log_insert(array('log_type' => 'L_ACTION_GAME_DELETED', 'log_action' => $log_action)); //meta_refresh(1, append_sid ( "{$phpbb_admin_path}index.$phpEx", "i=dkp_game&mode=listgames") ); trigger_error(sprintf($user->lang['ADMIN_DELETE_GAME_SUCCESS'], $deletegame->getName()), E_USER_WARNING); } else { // get field content $s_hidden_fields = build_hidden_fields(array('gamedelete' => true, 'hidden_game_id' => $editgame->game_id)); confirm_box(false, sprintf($user->lang['CONFIRM_DELETE_GAME'], $editgame->getName()), $s_hidden_fields); } }
/** * list the ranks for this guild * @param $updateguild */ private function BuildTemplateEditGuildRanks($updateguild) { global $phpEx, $template, $db, $phpbb_admin_path, $user; // everything from rank 90 is readonly $listranks = new \bbdkp\controller\guilds\Ranks($updateguild->guildid); $listranks->game_id = $updateguild->game_id; $result = $listranks->listranks(); while ($row = $db->sql_fetchrow($result)) { $prefix = $row['rank_prefix']; $suffix = $row['rank_suffix']; $template->assign_block_vars('ranks_row', array('RANK_ID' => $row['rank_id'], 'RANK_NAME' => $row['rank_name'], 'RANK_PREFIX' => $prefix, 'RANK_SUFFIX' => $suffix, 'HIDE_CHECKED' => $row['rank_hide'] == 1 ? 'checked="checked"' : '', 'S_READONLY' => $row['rank_id'] >= 90 ? true : false, 'U_DELETE_RANK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&mode=editguild&deleterank=1&ranktodelete=" . $row['rank_id'] . "&" . URI_GUILD . "=" . $updateguild->guildid))); } $db->sql_freeresult($result); $game = new \bbdkp\controller\games\Game(); $game->game_id = $updateguild->game_id; $game->Get(); $template->assign_vars(array('S_GUILDLESS' => $updateguild->guildid == 0 ? true : false, 'F_ENABLGAMEEARMORY' => $game->getArmoryEnabled(), 'F_ENABLEARMORY' => $updateguild->armory_enabled, 'GAME_ID' => $updateguild->game_id, 'GUILDID' => $updateguild->guildid, 'GUILD_NAME' => $updateguild->name, 'U_ADD_RANK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&mode=editguild&addrank=1&guild=" . $updateguild->guildid), 'L_TITLE' => $this->url_id < 0 ? $user->lang['ACP_ADDGUILD'] : $user->lang['ACP_EDITGUILD'], 'L_EXPLAIN' => $this->url_id < 0 ? $user->lang['ACP_ADDGUILD_EXPLAIN'] : $user->lang['ACP_EDITGUILD_EXPLAIN'], 'L_ADD_GUILD_TITLE' => $this->url_id < 0 ? $user->lang['ADD_GUILD'] : $user->lang['EDIT_GUILD'], 'MSG_NAME_EMPTY' => $user->lang['FV_REQUIRED_NAME'], 'EMBLEM' => $updateguild->emblempath, 'EMBLEMFILE' => basename($updateguild->emblempath), 'S_ADD' => $this->url_id < 0 ? true : false, 'U_EDIT_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&mode=editguild&action=editguild&" . URI_GUILD . '=' . $updateguild->guildid), 'U_EDIT_GUILDRANKS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&mode=editguild&action=guildranks&" . URI_GUILD . '=' . $updateguild->guildid), 'U_EDIT_GUILDRECRUITMENT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&mode=editguild&action=guildrecruitment&" . URI_GUILD . '=' . $updateguild->guildid))); $form_key = 'editguildranks'; add_form_key($form_key); $this->page_title = $user->lang['ACP_EDITGUILD']; }