/** * prepares objects to create new raid */ public function init_newraid() { global $user; $events = new \bbdkp\controller\raids\Events(); $events->countevents($this->dkpid); if ($events->total_events == 0) { trigger_error($user->lang['ERROR_NOEVENTSDEFINED'], E_USER_WARNING); } $events->listevents(0, 'event_name', $this->dkpid, 1, false); $this->eventinfo = $events->events; $members = new \bbdkp\controller\members\Members(); $members->listallmembers($this->guildid); $this->memberlist = $members->guildmemberlist; if (count($this->memberlist) == 0) { trigger_error($user->lang['ERROR_NOGUILDMEMBERSDEFINED'], E_USER_WARNING); } }
/** * registers a bbDKP character * * @param \bbdkp\controller\guilds\Guilds $Guild * @return number */ public function register_bbdkp(\bbdkp\controller\guilds\Guilds $Guild) { global $user, $phpbb_root_path, $phpEx; // Include the member class if (!class_exists('\\bbdkp\\controller\\members\\Members')) { require "{$phpbb_root_path}includes/bbdkp/controller/members/Members.{$phpEx}"; } $newmember = new \bbdkp\controller\members\Members(); // check if user exceeded allowed character count, to prevent alt spamming if ($newmember->has_reached_maxbbdkpaccounts()) { return false; } $newmember->game_id = $this->game; // get member name $newmember->member_achiev = $this->achievementPoints; $newmember->member_region = $Guild->region; $newmember->member_realm = $this->realm; $newmember->member_name = $this->name; $newmember->member_title = ' '; $newmember->member_guild_id = $Guild->guildid; $newmember->member_rank_id = $this->guildrank; $newmember->member_level = $this->level; $newmember->member_race_id = $this->raceid; $newmember->member_class_id = $this->classid; $newmember->member_role = ''; $newmember->member_gender_id = $this->genderid; $newmember->member_comment = $user->lang['MEMBER_COMMENT']; $boardtime = getdate(time() + $user->timezone + $user->dst - date('Z')); $jointime = $boardtime[0]; $newmember->member_joindate = $jointime; $newmember->member_outdate = mktime(0, 0, 0, 12, 31, 2030); $newmember->member_achiev = $this->achievementPoints; $newmember->member_armory_url = $this->url; $newmember->phpbb_user_id = $user->data['user_id']; $newmember->member_status = 1; $newmember->Armory_getmember(); $member_id = $newmember->Makemember(); unset($newmember); return $member_id; }
/** * Call the Character API * */ private function CallCharacterAPI() { global $db; $Guild = new \bbdkp\controller\guilds\Guilds(); $Guild->guildid = request_var('hidden_guildid', 0); $Guild->Getguild(); $minlevel = request_var('hidden_minlevel', 0); $maxlevel = request_var('hidden_maxlevel', 200); $selectactive = request_var('hidden_active', 0); $selectnonactive = request_var('hidden_nonactive', 0); $member_filter = utf8_normalize_nfc(request_var('hidden_member_name', '', true)); $members_result = $Guild->listmembers('member_id', 0, 0, $minlevel, $maxlevel, $selectactive, $selectnonactive, $member_filter, true); $log = ''; $i = 0; $j = 0; while ($row = $db->sql_fetchrow($members_result)) { if ($j > 100) { break; } $member = new \bbdkp\controller\members\Members($row['member_id']); $last_update = $member->last_update; $diff = \round(\abs(\time() - $last_update) / 86400, 2); // 1 days ago ? call armory if ($diff > 1) { $i += 1; if ($log != '') { $log .= ', '; } $old_member = new \bbdkp\controller\members\Members($row['member_id']); if (isset($member)) { if ($member->member_rank_id < 90) { $member->Armory_getmember(); } $member->Updatemember($old_member); } unset($old_member); $log .= $row['member_name']; } unset($member); $j++; } $db->sql_freeresult($members_result); unset($members_result); return array($i, $log); }
/** * lists all my characters * */ private function listmychars() { global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx; $members = new \bbdkp\controller\members\Members(); $mycharacters = $members->getmemberlist(0, 0, false, false, '', '', 0, 0, 0, 0, 200, true, '', 1); $lines = 0; foreach ($mycharacters[0] as $char) { $template->assign_block_vars('members_row', array('U_EDIT' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=dkp&mode=characteradd&" . URI_NAMEID . '=' . $char['member_id']), 'GAME' => $char['game_id'], 'COLORCODE' => $char['colorcode'], 'CLASS' => $char['class_name'], 'NAME' => $char['member_name'], 'RACE' => $char['race_name'], 'GUILD' => $char['guildname'], 'REALM' => $char['realm'], 'REGION' => $char['region'], 'RANK' => $char['member_rank'], 'LEVEL' => $char['member_level'], 'ARMORY' => $char['member_armory_url'], 'PHPBBUID' => $char['username'], 'PORTRAIT' => $char['member_portrait_url'], 'ACHIEVPTS' => $char['member_achiev'], 'CLASS_IMAGE' => $char['class_image'], 'RACE_IMAGE' => $char['race_image'])); $sql_array2 = array('SELECT' => ' d.dkpsys_id, d.dkpsys_name, SUM(m.member_earned + m.member_adjustment) AS ep, SUM(m.member_spent - m.member_item_decay + ( ' . max(0, $config['bbdkp_basegp']) . ')) AS gp, SUM(m.member_earned + m.member_adjustment - m.member_spent + m.member_item_decay - ( ' . max(0, $config['bbdkp_basegp']) . ') ) AS member_current, CASE WHEN SUM(m.member_spent - m.member_item_decay) <= 0 THEN SUM(m.member_earned + m.member_adjustment) ELSE ROUND( SUM(m.member_earned + m.member_adjustment) / SUM(' . max(0, $config['bbdkp_basegp']) . ' + m.member_spent - m.member_item_decay) ,2) END AS pr', 'FROM' => array(MEMBER_DKP_TABLE => 'm', DKPSYS_TABLE => 'd', MEMBER_LIST_TABLE => 'l'), 'WHERE' => "l.member_id = m.member_id and l.member_status = 1 and m.member_dkpid = d.dkpsys_id and d.dkpsys_status='Y' and m.member_id = " . $char['member_id'], 'GROUP_BY' => " d.dkpsys_id, d.dkpsys_name ", 'ORDER_BY' => " d.dkpsys_name "); $sql2 = $db->sql_build_query('SELECT', $sql_array2); $dkp_result = $db->sql_query($sql2); while ($row2 = $db->sql_fetchrow($dkp_result)) { $template->assign_block_vars('members_row.dkp_row', array('DKPSYS' => $row2['dkpsys_name'], 'U_VIEW_MEMBER' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=member&" . URI_NAMEID . '=' . $char['member_id'] . '&' . URI_DKPSYS . '= ' . $row2['dkpsys_id']), 'EARNED' => $row2['ep'], 'SPENT' => $row2['gp'], 'PR' => $row2['pr'], 'CURRENT' => $row2['member_current'])); } $db->sql_freeresult($dkp_result); } $template->assign_vars(array('S_SHOWEPGP' => $config['bbdkp_epgp'] == '1' ? true : false)); }
/** * * adds new members to listmembers table, adds dkp */ private function handle_new_members() { global $db, $user, $config, $phpbb_root_path, $phpEx; $membersadded = 0; $attendee = new \bbdkp\controller\members\Members(0, $this->guildlist); foreach ($this->allplayerinfo as $playerid => $player) { $member_id = $attendee->get_member_id($player['playername'], 'wow', $player['realm']); if ($member_id != 0) { // existing bbdkp member $attendee->member_id = $member; $attendee->Getmember(); $this->allplayerinfo[$playerid]['member_id'] = $attendee->member_id; $this->allplayerinfo[$playerid]['rank_id'] = $attendee->member_rank_id; $this->allplayerinfo[$playerid]['guild_id'] = $attendee->member_guild_id; } else { // player in dkp string is unknown $attendee = new \bbdkp\controller\members\Members(0, $this->guildlist); $attendee->game_id = 'wow'; $attendee->member_name = $player['playername']; $attendee->member_realm = $player['realm'] == '' ? $config['bbdkp_default_region'] : $player['realm']; $attendee->member_region = $config['bbdkp_default_region']; $attendee->member_guild_id = $this->guild->guildid; $attendee->member_rank_id = $this->defaultrank_id; $attendee->member_level = $player['level']; if (!in_array($attendee->member_region, $attendee->regionlist)) { $attendee->member_region = ''; } $attendee->member_race_id = $player['race']; $attendee->member_class_id = $player['class']; $attendee->member_gender_id = $player['sex']; $attendee->member_comment = "Member inserted " . $user->format_date($this->time) . ' by RaidTracker'; // take two days ago from raid start (3600*24*-2 = -172800) $attendee->member_joindate = $this->raidbegin - 172800; $attendee->member_outdate = 0; $attendee->member_achiev = 0; if ($attendee->Armory_getmember() == -1) { //no armory response //do checks on guild name from dkp string $found = false; foreach ($this->guildlist as $guild) { // has dkpstringguild a match in guildlist ? if ($guild['name'] == $player['guild']) { $found = true; //is the form guild different from the dkpstring guild ? then override guild ! if ($this->guild->guildid != $guild['id']) { $attendee->member_guild_id = $guild['id']; $attendee->member_guild_name = $player['guild']; $attendee->member_rank_id = $guild['joinrank']; } break; } } if ($found == false) { // if dkpstring guild not in database then assign to noguild $attendee->member_guild_id = 0; $attendee->member_rank_id = 99; } } switch ($config['bbdkp_rt_noguild']) { case 0: //RT_NOGUILD_IGNORE // if we ignore no guild then skip this member if he's got no guild if ($attendee->member_guild_id != 0) { $this->allplayerinfo[$playerid]['member_id'] = $attendee->Makemember(); if ($this->allplayerinfo[$playerid]['member_id'] > 0) { $membersadded += 1; } } break; case 1: //RT_NOGUILD_ADDNONE $this->allplayerinfo[$playerid]['member_id'] = $attendee->Makemember(); if ($this->allplayerinfo[$playerid]['member_id'] > 0) { $membersadded += 1; } break; } } if ($attendee->member_id == 0) { //skipped $this->allplayerinfo[$playerid]['skipped'] = true; } else { $this->acceptedraiders += 1; $this->allplayerinfo[$playerid]['skipped'] = false; $Points = new \bbdkp\controller\points\Points($attendee->member_id, $this->dkp); // check if player has dkp record for pool if (!$Points->has_account($attendee->member_id, $this->dkp)) { $Points->member_id = $attendee->member_id; $Points->dkpid = $this->dkp; $Points->raid_value = 0.0; $Points->time_bonus = 0.0; $Points->zerosum_bonus = 0.0; $Points->earned_decay = 0.0; $Points->spent = 0.0; $Points->item_decay = 0.0; $Points->adjustment = 0.0; $Points->adj_decay = 0.0; $Points->firstraid = $this->raidbegin; $Points->lastraid = $this->raidbegin; $Points->raidcount = 1; $Points->status = 1; $Points->open_account(); unset($Points); //add starting adjustment that can never decay $newadjust = new \bbdkp\controller\adjustments\Adjust($this->dkp); $newadjust->member_id = $attendee->member_id; $newadjust->adjustment_dkpid = $this->dkp; $newadjust->adjustment_value = floatval($config['bbdkp_starting_dkp']); $newadjust->adjustment_reason = $user->lang['RT_STARTING_DKP']; $newadjust->can_decay = 0; $newadjust->adj_decay = 0; $newadjust->decay_time = 0; $newadjust->adjustment_date = $this->raidbegin; $newadjust->adjustment_groupkey = $this->gen_group_key($this->raidbegin, $newadjust->adjustment_reason, $newadjust->adjustment_value); $newadjust->adjustment_added_by = $user->data['username']; $newadjust->add(); unset($newadjust); } } } $a = "debug"; }
* used by ucp_dkp.html * * @package bbdkp * @copyright (c) 2013 bbDkp <https://github.com/bbDKP> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ define('IN_PHPBB', true); define('ADMIN_START', true); $phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './../../../../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include $phpbb_root_path . 'common.' . $phpEx; $guild_id = request_var('guild_id', 0); if (!class_exists('\\bbdkp\\controller\\members\\Members')) { require "{$phpbb_root_path}includes/bbdkp/controller/members/Members.{$phpEx}"; } $members = new \bbdkp\controller\members\Members(); $members->listallmembers($guild_id, true); header('Content-type: text/xml'); // preparing xml $xml = '<?xml version="1.0" encoding="UTF-8"?> <memberlist>'; foreach ((array) $members->guildmemberlist as $member) { $xml .= '<member>'; $xml .= "<member_id>" . $member['member_id'] . "</member_id>"; $xml .= "<member_name>" . $member['rank_name'] . ' ' . $member['member_name'] . "</member_name>"; $xml .= '</member>'; } $xml .= '</memberlist>'; //return xml to ajax echo $xml;
/** * main dkp_adj acp function * @param integer $id * @param string $mode */ public function main($id, $mode) { global $db, $user, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $this->adjustment = new \bbdkp\controller\adjustments\Adjust(); //always late binding in php $this->link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=listiadj") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; $this->tpl_name = 'dkp/acp_' . $mode; switch ($mode) { case 'listiadj': if (count($this->games) == 0) { trigger_error($user->lang['ERROR_NOGAMES'], E_USER_WARNING); } $showadd = isset($_POST['addiadj']) ? true : false; if ($showadd) { redirect(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=addiadj")); break; } // guild dropdown $submit = isset($_POST['member_guild_id']) ? true : false; $Guild = new \bbdkp\controller\guilds\Guilds(); $guildlist = $Guild->guildlist(1); if ($submit) { $Guild->guildid = request_var('member_guild_id', 0); } else { foreach ($guildlist as $g) { $Guild->guildid = $g['id']; $Guild->name = $g['name']; if ($Guild->guildid == 0 && $Guild->name == 'Guildless') { trigger_error('ERROR_NOGUILD', E_USER_WARNING); } break; } } foreach ($guildlist as $g) { $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['id'] == $Guild->guildid ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)')); } $this->adjustment->setAdjustmentDkpid(0); if (isset($_GET[URI_DKPSYS]) or isset($_POST[URI_DKPSYS])) { $this->adjustment->setAdjustmentDkpid(request_var(URI_DKPSYS, 0)); } if ($this->adjustment->getAdjustmentDkpid() == 0) { if (count((array) $this->adjustment->getDkpsys()) == 0) { trigger_error('ERROR_NOPOOLS', E_USER_WARNING); } //get default dkp pool foreach ($this->adjustment->getDkpsys() as $pool) { if ($pool['default'] == 'Y') { $this->adjustment->setAdjustmentDkpid($pool['id']); break; } } //if still 0 then get first one if ($this->adjustment->getAdjustmentDkpid() == 0) { foreach ($this->adjustment->getDkpsys() as $pool) { $this->adjustment->setAdjustmentDkpid($pool['id']); break; } } } foreach ($this->adjustment->getDkpsys() as $pool) { $template->assign_block_vars('dkpsys_row', array('VALUE' => $pool['id'], 'SELECTED' => $pool['id'] == $this->adjustment->getAdjustmentDkpid() ? ' selected="selected"' : '', 'OPTION' => !empty($pool['name']) ? $pool['name'] : '(None)')); } /*** end DKPSYS drop-down ***/ $sort_order = array(0 => array('adjustment_id desc', 'adjustment_id asc'), 1 => array('adjustment_date desc, member_name asc', 'adjustment_date asc, member_name asc'), 2 => array('adjustment_dkpid', 'adjustment_dkpid desc'), 3 => array('dkpsys_name', 'dkpsys_name desc'), 4 => array('member_name', 'member_name desc'), 5 => array('adjustment_reason', 'adjustment_reason desc'), 6 => array('adjustment_value desc', 'adjustment_value'), 7 => array('adjustment_added_by', 'adjustment_added_by desc')); $member_filter = utf8_normalize_nfc(request_var('member_name', '', true)); $result2 = $this->adjustment->countadjust(0, $member_filter, $Guild->guildid); $total_adjustments = (int) $db->sql_fetchfield('total_adjustments'); $db->sql_freeresult($result2); $start = request_var('start', 0); if ($member_filter != '') { $u_list_adjustments = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=listiadj&" . URI_DKPSYS . "=" . $this->adjustment->getAdjustmentDkpid()) . '&member_name=' . $member_filter; } else { $u_list_adjustments = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=listiadj&" . URI_DKPSYS . "=" . $this->adjustment->getAdjustmentDkpid()); } $current_order = $this->switch_order($sort_order); $result = $this->adjustment->ListAdjustments($current_order['sql'], 0, $start, $Guild->guildid, $member_filter); while ($adj = $db->sql_fetchrow($result)) { $template->assign_block_vars('adjustments_row', array('U_ADD_ADJUSTMENT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=addiadj") . '&' . URI_ADJUSTMENT . '=' . $adj['adjustment_id'] . '&' . URI_DKPSYS . '=' . $adj['adjustment_dkpid'], 'DATE' => date($config['bbdkp_date_format'], $adj['adjustment_date']), 'ADJID' => $adj['adjustment_id'], 'DKPID' => $adj['adjustment_dkpid'], 'DKPPOOL' => $adj['dkpsys_name'], 'COLORCODE' => $adj['colorcode'] == '' ? '#254689' : $adj['colorcode'], 'CLASS_IMAGE' => strlen($adj['imagename']) > 1 ? $phpbb_root_path . "images/bbdkp/class_images/" . $adj['imagename'] . ".png" : '', 'S_CLASS_IMAGE_EXISTS' => strlen($adj['imagename']) > 1 ? true : false, 'U_VIEW_MEMBER' => isset($adj['member_name']) ? append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=member&" . URI_NAMEID . '=' . $adj['member_id'] . '&' . URI_DKPSYS . '=' . $adj['adjustment_dkpid']) : '', 'U_VIEW_MEMBER_ACP' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_mdkp&mode=mm_editmemberdkp") . '&member_id=' . $adj['member_id'] . '&' . URI_DKPSYS . '=' . $adj['adjustment_dkpid'], 'MEMBER' => isset($adj['member_name']) ? $adj['member_name'] : '', 'REASON' => isset($adj['adjustment_reason']) ? $adj['adjustment_reason'] : '', 'CAN_DECAY' => $adj['can_decay'], 'ADJUSTMENT' => $adj['adjustment_value'] == 0 ? '' : number_format($adj['adjustment_value'], 2), 'ADJ_DECAY' => -1 * $adj['adj_decay'] == 0 ? '' : -1 * $adj['adj_decay'], 'ADJUSTMENT_NET' => $adj['adjustment_value'] - $adj['adj_decay'] == 0 ? '' : number_format($adj['adjustment_value'] - $adj['adj_decay'], 2), 'DECAY_TIME' => $adj['decay_time'] != 0 ? date($config['bbdkp_date_format'], $adj['decay_time']) : '', 'ADDED_BY' => $adj['adjustment_added_by'], 'MEMBER_NAME' => $member_filter)); } $db->sql_freeresult($result); $listadj_footcount = sprintf($user->lang['LISTADJ_FOOTCOUNT'], $total_adjustments, $config['bbdkp_user_alimit']); $pagination = generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=listiadj&dkpsys_id=" . $this->adjustment->getAdjustmentDkpid()), $total_adjustments, $config['bbdkp_user_alimit'], $start, true); $template->assign_vars(array('L_TITLE' => $user->lang['ACP_LISTIADJ'], 'L_EXPLAIN' => $user->lang['ACP_LISTIADJ_EXPLAIN'], 'S_SHOW' => $total_adjustments > 0 ? true : false, 'O_ADJID' => $current_order['uri'][0], 'O_DATE' => $current_order['uri'][1], 'O_DKPID' => $current_order['uri'][2], 'O_DKPPOOL' => $current_order['uri'][3], 'O_MEMBER' => $current_order['uri'][4], 'O_REASON' => $current_order['uri'][5], 'O_ADJUSTMENT' => $current_order['uri'][6], 'O_ADDED_BY' => $current_order['uri'][7], 'U_LIST_ADJUSTMENTS' => $u_list_adjustments, 'MEMBER_NAME' => $member_filter, 'START' => $start, 'S_GROUP_ADJ' => false, 'LISTADJ_FOOTCOUNT' => $listadj_footcount, 'ADJUSTMENT_PAGINATION' => $pagination, 'TOTAL_ADJUSTMENTS' => 'Total Adjustments', 'PAGE_NUMBER' => on_page($total_adjustments, $config['bbdkp_user_alimit'], $start))); $this->page_title = 'ACP_LISTIADJ'; break; case 'addiadj': $form_key = 'acp_dkp_adj'; add_form_key($form_key); // begin DKPSYS drop-down $dkpsys_id = 1; $sql = 'SELECT dkpsys_id, dkpsys_name, dkpsys_default FROM ' . DKPSYS_TABLE . "\n\t\t WHERE dkpsys_status = 'Y'\n ORDER BY dkpsys_name"; $resultdkpsys = $db->sql_query($sql); $showadj = new \bbdkp\controller\adjustments\Adjust(); $adjust_id = request_var(URI_ADJUSTMENT, 0); $dkpsys_id = request_var(URI_DKPSYS, 0); if ($adjust_id != 0 && $dkpsys_id != 0) { $showadj->get($adjust_id); while ($row2 = $db->sql_fetchrow($resultdkpsys)) { $template->assign_block_vars('adj_dkpid_row', array('VALUE' => $row2['dkpsys_id'], 'SELECTED' => $row2['dkpsys_id'] == $showadj->getAdjustmentDkpid() ? ' selected="selected"' : '', 'OPTION' => !empty($row2['dkpsys_name']) ? $row2['dkpsys_name'] : '(None)')); } } else { // we dont have a GET so put default dkp pool in pulldown while ($row2 = $db->sql_fetchrow($resultdkpsys)) { //dkpsys_default $template->assign_block_vars('adj_dkpid_row', array('VALUE' => $row2['dkpsys_id'], 'SELECTED' => $row2['dkpsys_default'] == 'Y' ? ' selected="selected"' : '', 'OPTION' => !empty($row2['dkpsys_name']) ? $row2['dkpsys_name'] : '(None)')); if ($row2['dkpsys_default'] == 'Y') { $dkpsys_id = $row2['dkpsys_id']; } } } // end DKPSYS drop-down $submit = isset($_POST['add']) ? true : false; $update = isset($_POST['update']) ? true : false; $delete = isset($_POST['delete']) ? true : false; if ($submit || $update) { if (!check_form_key('acp_dkp_adj')) { trigger_error('FORM_INVALID'); } } $now = getdate(); $s_day_options = ''; $day = $showadj->getAdjustmentDate() > 0 ? date('j', $showadj->getAdjustmentDate()) : $now['mday']; for ($i = 1; $i < 32; $i++) { $selected = $i == $day ? ' selected="selected"' : ''; $s_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $s_month_options = ''; $month = $showadj->getAdjustmentDate() > 0 ? date('n', $showadj->getAdjustmentDate()) : $now['mon']; for ($i = 1; $i < 13; $i++) { $selected = $i == $month ? ' selected="selected"' : ''; $s_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $s_year_options = ''; $yr = $showadj->getAdjustmentDate() > 0 ? date('Y', $showadj->getAdjustmentDate()) : $now['year']; for ($i = $now['year'] - 10; $i <= $now['year']; $i++) { $selected = $i == $yr ? ' selected="selected"' : ''; $s_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } if ($submit) { global $user; $this->error_check(); $newadjust = new \bbdkp\controller\adjustments\Adjust(); $temp = str_replace(".", "", request_var('adjustment_value', 0.0)); $temp2 = (double) str_replace(",", ".", $temp); $newadjust->setAdjustmentValue($temp2); $newadjust->setAdjustmentReason(utf8_normalize_nfc(request_var('adjustment_reason', '', true))); $newadjust->setCanDecay(request_var('adj_decayable', 1)); $newadjust->setAdjDecay(0); $newadjust->setDecayTime(0); $newadjust->setAdjustmentDate(mktime(12, 0, 0, request_var('adjustment_month', 0), request_var('adjustment_day', 0), request_var('adjustment_year', 0))); $newadjust->setAdjustmentDkpid(request_var('adj_dkpid', 0)); $newadjust->setAdjustmentGroupkey($this->gen_group_key($this->time, $newadjust->getAdjustmentReason(), $newadjust->getAdjustmentValue())); $newadjust->setAdjustmentAddedBy($user->data['username']); $members = request_var('member_names', array(0 => 0), true); $member_names = array(); foreach ($members as $member_id) { $member = new \bbdkp\controller\members\Members(); $member->member_id = $member_id; $member->Getmember(); $newadjust->setMemberId($member_id); $newadjust->setMemberName($member->member_name); $member_names[] = $member->member_name; $newadjust->add(); } // // Logging // $log_action = array('header' => 'L_ACTION_INDIVADJ_ADDED', 'L_ADJUSTMENT' => $newadjust->getAdjustmentValue(), 'L_REASON' => $newadjust->getAdjustmentReason(), 'L_MEMBERS' => implode(', ', $member_names), 'L_ADDED_BY' => $newadjust->getAdjustmentAddedBy()); $this->log_insert(array('log_type' => 'L_ACTION_INDIVADJ_ADDED', 'log_action' => $log_action)); $success_message = sprintf($user->lang['ADMIN_ADD_IADJ_SUCCESS'], $config['bbdkp_dkp_name'], $newadjust->getAdjustmentValue(), implode(', ', $member_names)); trigger_error($success_message . $this->link); } if ($update) { $this->error_check(); $oldadjust = new \bbdkp\controller\adjustments\Adjust(); $oldadjust->adjustment_id = request_var('hidden_id', 0); $oldadjust->get($oldadjust->adjustment_id); foreach ($oldadjust->getMembersSamegroupkey() as $member_id) { $oldmembers = new \bbdkp\controller\members\Members(); $oldmembers->member_id = $member_id; $oldmembers->Getmember(); $oldmember_names[] = $oldmembers->member_name; unset($oldmembers); // remove old adjustment $oldadjust->delete(); } $updadjust = new \bbdkp\controller\adjustments\Adjust(); $temp = str_replace(".", "", request_var('adjustment_value', 0.0)); $temp2 = (double) str_replace(",", ".", $temp); $updadjust->setAdjustmentValue($temp2); $updadjust->setAdjustmentReason(utf8_normalize_nfc(request_var('adjustment_reason', '', true))); $updadjust->setCanDecay(request_var('adj_decayable', 1)); $updadjust->setAdjDecay(request_var('adjustment_decay', 0.0)); $updadjust->setDecayTime($oldadjust->getDecayTime()); $updadjust->setAdjustmentDate(mktime(12, 0, 0, request_var('adjustment_month', 0), request_var('adjustment_day', 0), request_var('adjustment_year', 0))); $updadjust->setAdjustmentDkpid(request_var('adj_dkpid', 0)); $updadjust->setAdjustmentAddedBy($user->data['username']); $updadjust->setAdjustmentGroupkey($updadjust->gen_group_key($this->time, $updadjust->getAdjustmentReason(), $updadjust->getAdjustmentValue())); $members = request_var('member_names', array(0 => 0), true); foreach ($members as $member_id) { $member = new \bbdkp\controller\members\Members(); $member->member_id = $member_id; $updadjust->setMembersSamegroupkey($member_id); $member->Getmember(); $updadjust->setMemberId($member_id); $updadjust->setMemberName($member->member_name); $member_names[] = $member->member_name; $updadjust->add(); unset($member); } // // Logging // $log_action = array('header' => 'L_ACTION_INDIVADJ_UPDATED', 'id' => $adjust_id, 'L_ADJUSTMENT_BEFORE' => $oldadjust->getAdjustmentValue(), 'L_REASON_BEFORE' => $oldadjust->getAdjustmentReason(), 'L_MEMBERS_BEFORE' => implode(', ', $oldmember_names), 'L_ADJUSTMENT_AFTER' => $updadjust->getAdjustmentValue(), 'L_REASON_AFTER' => $updadjust->getAdjustmentReason(), 'L_MEMBERS_AFTER' => implode(', ', $member_names), 'L_UPDATED_BY' => $user->data['username']); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action)); $success_message = sprintf($user->lang['ADMIN_UPDATE_IADJ_SUCCESS'], $config['bbdkp_dkp_name'], $updadjust->getAdjustmentValue(), implode(', ', $member_names)); trigger_error($success_message . $this->link); } if ($delete) { if (confirm_box(true)) { // get form vars $adjust_id = request_var('xhidden_id', 0); $deleteadj = new \bbdkp\controller\adjustments\Adjust(); $deleteadj->get($adjust_id); $deleteadj->delete(); // Logging $log_action = array('header' => 'L_ACTION_INDIVADJ_DELETED', 'id' => $adjust_id, 'L_ADJUSTMENT' => $deleteadj->getAdjustmentValue(), 'L_REASON' => $deleteadj->getAdjustmentReason(), 'L_MEMBERS' => $deleteadj->getMemberName()); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action)); // // Success messages $success_message = sprintf($user->lang['ADMIN_DELETE_IADJ_SUCCESS'], $config['bbdkp_dkp_name'], $deleteadj->getAdjustmentValue(), $deleteadj->getMemberName()); trigger_error($success_message . $this->link); } else { $s_hidden_fields = build_hidden_fields(array('delete' => true, 'xhidden_id' => request_var('hidden_id', 0))); $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields)); confirm_box(false, $user->lang['CONFIRM_DELETE_IADJ'], $s_hidden_fields); } } //guild dropdown $guildid = request_var('member_guild_id', 0); $Guild = new \bbdkp\controller\guilds\Guilds(); $guildlist = $Guild->guildlist(1); foreach ((array) $guildlist as $g) { if ($guildid == 0) { $guildid = $g['id']; } if ($g['guilddefault'] == 1) { $guildid = $g['id']; } $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $guildid == $g['id'] ? ' selected="selected"' : '', 'OPTION' => $g['name'])); } /* mark members as selected */ $sql = 'SELECT member_id, member_name FROM ' . MEMBER_LIST_TABLE . ' WHERE member_guild_id = ' . $guildid . ' ORDER BY member_name '; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($adjust_id) { //editmode $selected = @in_array($row['member_id'], $showadj->getMembersSamegroupkey()) ? ' selected="selected"' : ''; } else { //newmode $selected = @in_array($row['member_id'], utf8_normalize_nfc(request_var('member_names', array(0 => 0)))) ? ' selected="selected"' : ''; } $template->assign_block_vars('members_row', array('VALUE' => $row['member_id'], 'SELECTED' => $selected, 'OPTION' => $row['member_name'])); } $db->sql_freeresult($result); $template->assign_vars(array('L_TITLE' => $showadj->adjustment_id == 0 ? $user->lang['ADD_IADJ_TITLE'] : $user->lang['EDIT_IADJ_TITLE'], 'L_EXPLAIN' => $user->lang['ACP_ADDIADJ_EXPLAIN'], 'F_ADD_ADJUSTMENT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_adj&mode=addiadj"), 'ADJUSTMENT_ID' => $showadj->adjustment_id, 'DKP_ID' => $showadj->getAdjustmentDkpid(), 'ADJUSTMENT_VALUE' => number_format($showadj->getAdjustmentValue(), 2), 'ADJUSTMENT_REASON' => $showadj->getAdjustmentReason(), 'ADJUSTMENT_DECAY' => number_format($showadj->getAdjDecay(), 2), 'S_DAY_OPTIONS' => $s_day_options, 'S_MONTH_OPTIONS' => $s_month_options, 'S_YEAR_OPTIONS' => $s_year_options, 'CAN_DECAY_NO_CHECKED' => $showadj->getCanDecay() == 0 ? ' checked="checked"' : '', 'CAN_DECAY_YES_CHECKED' => $showadj->getCanDecay() == 1 ? ' checked="checked"' : '', 'MSG_VALUE_EMPTY' => $user->lang['FV_REQUIRED_ADJUSTMENT'], 'UA_FINDMEMBERS' => append_sid($phpbb_admin_path . "style/dkp/findmembers.{$phpEx}"), 'S_ADD' => !$showadj->adjustment_id ? true : false)); $this->page_title = 'ACP_ADDIADJ'; break; } }
/** * fetch Guild API information * @param $data */ private function ApiUpdateBattleNet($data, $params) { global $db, $phpbb_root_path, $phpEx; if ($this->armoryresult = 'KO') { return; } $this->achievementpoints = isset($data['achievementPoints']) ? $data['achievementPoints'] : 0; $this->level = isset($data['level']) ? $data['level'] : 0; $this->battlegroup = isset($data['battlegroup']) ? $data['battlegroup'] : ''; $this->side = isset($data['side']) ? $data['side'] : ''; if (isset($data['name'])) { $this->guildarmoryurl = sprintf('http://%s.battle.net/wow/en/', $this->region) . 'guild/' . $this->realm . '/' . $data['name'] . '/'; } else { $this->guildarmoryurl = ''; } $this->emblem = isset($data['emblem']) ? $data['emblem'] : ''; $this->emblempath = isset($data['emblem']) ? $this->createEmblem(false) : ''; $this->memberdata = isset($data['members']) ? $data['members'] : ''; $query = $db->sql_build_array('UPDATE', array('achievementpoints' => $this->achievementpoints, 'level' => $this->level, 'guildarmoryurl' => $this->guildarmoryurl, 'emblemurl' => $this->emblempath, 'battlegroup' => $this->battlegroup, 'armoryresult' => $this->armoryresult)); $db->sql_query('UPDATE ' . GUILD_TABLE . ' SET ' . $query . ' WHERE id= ' . $this->guildid); if (in_array("members", $params)) { // update ranks table if (!class_exists('\\bbdkp\\controller\\guilds\\Ranks')) { require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Ranks.{$phpEx}"; } $rank = new \bbdkp\controller\guilds\Ranks($this->guildid); $rank->WoWArmoryUpdate($this->memberdata, $this->guildid, $this->region); //update member table if (!class_exists('\\bbdkp\\controller\\members\\Members')) { require "{$phpbb_root_path}includes/bbdkp/controller/members/Members.{$phpEx}"; } $mb = new \bbdkp\controller\members\Members(); $mb->WoWArmoryUpdate($this->memberdata, $this->guildid, $this->region, $this->min_armory); } }
/** * returns raid count, or attendance percentage for a range member/pool * used by listmembers.php and viewmember.php * * @param number $dkpsys_id * @param number $days * @param int|number $member_id * @param int|number $mode indiv raidcount, 1 -> total rc, 2 -> attendancepct * @param bool|string $all if true then get count forever, otherwise since x days * @param int|number $guild_id * @return number */ public function raidcount($dkpsys_id, $days, $member_id = 0, $mode = 1, $all = false, $guild_id = 0) { $end_date = time(); // member joined in the last $days ? if ($member_id > 0) { $start_date = mktime(0, 0, 0, date('m'), date('d') - $days, date('Y')); $attendee = new \bbdkp\controller\members\Members($member_id); $joindate = $attendee->get_joindate($member_id); if ($all == true || $joindate > $start_date) { // then count from join date $start_date = $joindate; } switch ($mode) { case 0: // get member or guild raidcount in pool return $this->getraidcount($start_date, $end_date, $dkpsys_id, $all, $attendee->member_id, $attendee->member_guild_id); break; case 1: // get guild raidcount in pool return $this->getraidcount($start_date, $end_date, $dkpsys_id, $all, 0, $attendee->member_guild_id); break; case 2: //get percentage $memberraidcount = $this->getraidcount($start_date, $end_date, $dkpsys_id, $all, $attendee->member_id, $attendee->member_guild_id); $raid_count = $this->getraidcount($start_date, $end_date, $dkpsys_id, $all, 0, $attendee->member_guild_id); $percent_of_raids = $raid_count > 0 ? round($memberraidcount / $raid_count * 100, 2) : 0; return (double) $percent_of_raids; break; } unset($attendee); } else { $start_date = mktime(0, 0, 0, 1, 1, 2000); return $this->getraidcount($start_date, $end_date, $dkpsys_id, true, 0, $guild_id); } return 0; }
* returns memberlist xml based on ajax call used by acp_addraid.html * * @package acp\ajax * @copyright (c) 2013 bbDkp <https://github.com/bbDKP> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ define('IN_PHPBB', true); define('ADMIN_START', true); $phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './../../../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include $phpbb_root_path . 'common.' . $phpEx; $guild_id = request_var('guild', 0); if (!class_exists('\\bbdkp\\controller\\members\\Members')) { require "{$phpbb_root_path}includes/bbdkp/controller/members/Members.{$phpEx}"; } $members = new \bbdkp\controller\members\Members(); $members->listallmembers($guild_id); header('Content-type: text/xml'); // preparing xml $xml = '<?xml version="1.0" encoding="UTF-8"?> <memberlist>'; foreach ((array) $members->guildmemberlist as $member) { $xml .= '<member>'; $xml .= "<member_id>" . $member['member_id'] . "</member_id>"; $xml .= "<member_name>" . $member['rank_name'] . ' ' . $member['member_name'] . "</member_name>"; $xml .= '</member>'; } $xml .= '</memberlist>'; //return xml to ajax echo $xml;
public function buildpage(viewNavigation $Navigation) { global $config, $phpbb_root_path, $phpEx, $user, $template; $classes = array(); $members = new \bbdkp\controller\members\Members(); $members->game_id = $Navigation->getGameId(); $start = request_var('start', 0); $mode = request_var('rosterlayout', 0); $member_filter = utf8_normalize_nfc(request_var('member_name', '', true)); $url = append_sid("{$phpbb_root_path}dkp.{$phpEx}", 'page=roster&rosterlayout=' . $mode . '&guild_id=' . $Navigation->getGuildId()); $characters = $members->getmemberlist($start, $mode, $Navigation->getQueryByArmor(), $Navigation->getQueryByClass(), $Navigation->getFilter(), $Navigation->getGameId(), $Navigation->getGuildId(), $Navigation->getClassId(), $Navigation->getRaceId(), $Navigation->getLevel1(), $Navigation->getLevel2(), false, $member_filter, 0); $rosterlayoutlist = array(0 => $user->lang['ARM_STAND'], 1 => $user->lang['ARM_CLASS']); foreach ($rosterlayoutlist as $lid => $lname) { $template->assign_block_vars('rosterlayout_row', array('VALUE' => $lid, 'SELECTED' => $lid == $mode ? ' selected="selected"' : '', 'OPTION' => $lname)); } if ($mode == 0) { /* * Displays the listing */ // use pagination foreach ($characters[0] as $char) { $template->assign_block_vars('members_row', array('MEMBER_ID' => $char['member_id'], 'U_VIEW_MEMBER' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", 'page=member&' . URI_NAMEID . '=' . $char['member_id'] . '&' . URI_DKPSYS . '=' . 0), 'GAME' => $char['game_id'], 'COLORCODE' => $char['colorcode'], 'CLASS' => $char['class_name'], 'NAME' => $char['member_name'], 'RACE' => $char['race_name'], 'RANK' => $char['member_rank'], 'LVL' => $char['member_level'], 'ARMORY' => $char['member_armory_url'], 'PHPBBUID' => $char['username'], 'PORTRAIT' => $char['member_portrait_url'], 'ACHIEVPTS' => $char['member_achiev'], 'CLASS_IMAGE' => $char['class_image'], 'RACE_IMAGE' => $char['race_image'])); } $rosterpagination = $Navigation->generate_pagination2($url . '&o=' . $characters[1]['uri']['current'], $characters[2], $config['bbdkp_user_llimit'], $start, true, 'start'); // add navigationlinks $navlinks_array = array(array('DKPPAGE' => $user->lang['MENU_ROSTER'], 'U_DKPPAGE' => $url)); foreach ($navlinks_array as $name) { $template->assign_block_vars('dkpnavlinks', array('DKPPAGE' => $name['DKPPAGE'], 'U_DKPPAGE' => $name['U_DKPPAGE'])); } $template->assign_vars(array('ROSTERPAGINATION' => $rosterpagination, 'O_NAME' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][0], 'O_CLASS' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][2], 'O_RANK' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][3], 'O_LEVEL' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][4], 'O_PHPBB' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][5], 'O_ACHI' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][6])); // add template constants $template->assign_vars(array('S_RSTYLE' => '0', 'S_SHOWACH' => $config['bbdkp_show_achiev'], 'LISTMEMBERS_FOOTCOUNT' => 'Total members : ' . $characters[2], 'S_DISPLAY_ROSTERLISTING' => true)); } elseif ($mode == 1) { //display grid $classgroup = $members->get_classes($Navigation->getFilter(), $Navigation->getQueryByArmor(), $Navigation->getClassId(), $Navigation->getGameId(), $Navigation->getGuildId(), $Navigation->getRaceId(), $Navigation->getLevel1(), $Navigation->getLevel2()); if (count($classgroup) > 0) { foreach ($classgroup as $row1) { $classes[$row1['class_id']]['name'] = $row1['class_name']; $classes[$row1['class_id']]['imagename'] = $row1['imagename']; $classes[$row1['class_id']]['colorcode'] = $row1['colorcode']; } foreach ($classes as $classid => $class) { $classimgurl = $phpbb_root_path . "images/bbdkp/roster_classes/" . $class['imagename'] . '.png'; $classcolor = $class['colorcode']; $template->assign_block_vars('class', array('CLASSNAME' => $class['name'], 'CLASSIMG' => $classimgurl, 'COLORCODE' => $classcolor)); $classmembers = 1; foreach ($characters[0] as $row2) { if ($row2['member_class_id'] == $classid) { $template->assign_block_vars('class.members_row', array('MEMBER_ID' => $row2['member_id'], 'GAME' => $row2['game_id'], 'COLORCODE' => $row2['colorcode'], 'CLASS' => $row2['class_name'], 'NAME' => $row2['member_name'], 'RACE' => $row2['race_name'], 'RANK' => $row2['member_rank'], 'LVL' => $row2['member_level'], 'ARMORY' => $row2['member_armory_url'], 'PHPBBUID' => $row2['username'], 'PORTRAIT' => $row2['member_portrait_url'], 'ACHIEVPTS' => $row2['member_achiev'], 'CLASS_IMAGE' => $row2['class_image'], 'RACE_IMAGE' => $row2['race_image'])); $classmembers++; } } } $rosterpagination = $Navigation->generate_pagination2($url . '&o=' . $characters[1]['uri']['current'], count($characters[0]), $config['bbdkp_user_llimit'], $start, true, 'start'); if (isset($characters[1]) && sizeof($characters[1]) > 0) { $template->assign_vars(array('ROSTERPAGINATION' => $rosterpagination, 'U_LIST_MEMBERS0' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][0], 'U_LIST_MEMBERS1' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][1], 'U_LIST_MEMBERS2' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][2], 'U_LIST_MEMBERS3' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][3], 'U_LIST_MEMBERS4' => $url . '&' . URI_ORDER . '=' . $characters[1]['uri'][4])); } // add template constants $template->assign_vars(array('S_SHOWACH' => $config['bbdkp_show_achiev'], 'LISTMEMBERS_FOOTCOUNT' => 'Total members : ' . count($characters[0]), 'S_DISPLAY_ROSTERGRID' => true)); } // add menu navigationlinks $navlinks_array = array(array('DKPPAGE' => $user->lang['MENU_ROSTER'], 'U_DKPPAGE' => $url)); foreach ($navlinks_array as $name) { $template->assign_block_vars('dkpnavlinks', array('DKPPAGE' => $name['DKPPAGE'], 'U_DKPPAGE' => $name['U_DKPPAGE'])); } $template->assign_vars(array('S_RSTYLE' => '1')); } $template->assign_vars(array('MEMBER_NAME' => $member_filter, 'S_MULTIGAME' => sizeof($Navigation->games) > 1 ? true : false, 'S_DISPLAY_ROSTER' => true, 'F_ROSTER' => $url, 'S_GAME' => $members->game_id)); $header = $user->lang['GUILDROSTER']; page_header($header); }