Beispiel #1
0
    /**
     * transfer dkp to other member
     * @param int $dkpsys_id
     */
    function transfer_dkp($dkpsys_id)
    {
        global $user, $db;
        if (confirm_box(true)) {
            //fetch hidden variables
            $member_from = request_var('hidden_idfrom', 0);
            $member_to = request_var('hidden_idto', 0);
            $dkpsys_id = request_var('hidden_dkpid', 0);
            $this->PointsController->transfer_points($member_from, $member_to, $dkpsys_id, $this->link);
        } else {
            // first check if user tries to transfer from one to the same
            $member_from = request_var('transfer_from', 0);
            $member_to = request_var('transfer_to', 0);
            if ($member_from == $member_to) {
                trigger_error($user->lang['ERROR_TRFSAME'], E_USER_WARNING);
            }
            if ($member_from == 0 || $member_to == 0) {
                trigger_error($user->lang['ERROR_NOSELECT'], E_USER_WARNING);
            }
            // prepare some logging information
            $sql = 'SELECT member_name FROM ' . MEMBER_LIST_TABLE . '
					WHERE member_id =  ' . $member_from;
            $result = $db->sql_query($sql, 0);
            $member_from_name = (string) $db->sql_fetchfield('member_name');
            $db->sql_freeresult($result);
            $sql = 'SELECT member_name FROM ' . MEMBER_LIST_TABLE . '
					WHERE member_id =  ' . $member_to;
            $result = $db->sql_query($sql, 0);
            $member_to_name = (string) $db->sql_fetchfield('member_name');
            $db->sql_freeresult($result);
            $s_hidden_fields = build_hidden_fields(array('transfer' => true, 'hidden_name_from' => $member_from_name, 'hidden_name_to' => $member_to_name, 'hidden_idfrom' => $member_from, 'hidden_idto' => $member_to, 'hidden_dkpid' => $dkpsys_id));
            confirm_box(false, sprintf($user->lang['CONFIRM_TRANSFER_MEMBERDKP'], $member_from_name, $member_to_name), $s_hidden_fields);
        }
    }
Beispiel #2
0
 /**
  *
  * this function deletes 1 attendee from a raid
  * dkp account is then updated
  *
  * @param int $raid_id
  * @param int $attendee_id
  * @return boolean
  */
 private function deleteraider($raid_id, $attendee_id)
 {
     global $user, $config, $template, $phpbb_admin_path, $phpEx;
     $link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_raid&amp;mode=editraid&amp;" . URI_RAID . "=" . $raid_id) . '"><h3>' . $user->lang['RETURN_RAID'] . '</h3></a>';
     if (confirm_box(true)) {
         //recall vars
         $raid_id = request_var('raid_idx', 0);
         $member_id = request_var('attendee', 0);
         $this->PointsController->removeraid_delete_dkprecord($raid_id, $member_id);
         //carry on with fact tables
         $this->RaidController->deleteraider($raid_id, $member_id);
         trigger_error(sprintf($user->lang['ADMIN_RAID_ATTENDEE_DELETED_SUCCESS'], utf8_normalize_nfc(request_var('attendeename', '', true)), $raid_id) . $link, E_USER_WARNING);
         //update fact tables
         // do accounting
     } else {
         if ($this->LootController->Countloot($raid_id, $attendee_id) > 0) {
             trigger_error(sprintf($user->lang['ADMIN_RAID_ATTENDEE_DELETED_FAILED'], utf8_normalize_nfc(request_var('attendeename', '', true)), $raid_id) . $link, E_USER_WARNING);
         }
         $attendee = new \bbdkp\controller\members\Members($attendee_id);
         $s_hidden_fields = build_hidden_fields(array('deleteraider' => true, 'raid_idx' => $raid_id, 'attendee' => $attendee_id, 'attendeename' => $attendee->member_name));
         $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
         confirm_box(false, sprintf($user->lang['CONFIRM_DELETE_ATTENDEE'], $attendee->member_name, $raid_id), $s_hidden_fields);
     }
     return true;
 }
Beispiel #3
0
 /**
  * @return bool
  */
 private function dkplisting(viewNavigation $Navigation)
 {
     global $user, $config, $template;
     if ($config['bbdkp_epgp'] == '1') {
         $this->memberlist = $this->PointsController->listEPGPaccounts($this->start, true);
     } else {
         $this->memberlist = $this->PointsController->listdkpaccounts($this->start, true);
     }
     if (count($this->memberlist[0]) == 0) {
         $output = array('S_DISPLAY_STANDINGS' => true);
         $template->assign_vars($output);
         return;
     }
     //all time guild raidcount
     $Guild_raidcount = $this->Raids->raidcount($this->PointsController->dkpsys_id, 0, 0, 1, true, $this->PointsController->guild_id);
     $current_order = $this->memberlist[1];
     $lines = $this->memberlist[2];
     // all accounts
     $membersids = array();
     if ($lines > 0) {
         foreach ($this->memberlist[0] as $member_id => $dkp) {
             $dkp['ATTENDANCE'] = $Guild_raidcount > 0 ? number_format($dkp['RAIDCOUNT'] / $Guild_raidcount, 4) * 100 : 0;
             $template->assign_block_vars('members_row', $dkp);
             $membersids[$member_id] = 1;
         }
         if ($this->PointsController->member_filter != '') {
             $pagination = generate_pagination(append_sid($this->u_listmemberdkp, "i=dkp_mdkp&mode=mm_listmemberdkp&amp;member_name=" . $this->PointsController->member_filter . "&amp;o=" . $current_order['uri']['current']), $lines, $config['bbdkp_user_llimit'], $this->start, true, 'start');
         } else {
             $pagination = generate_pagination(append_sid($this->u_listmemberdkp, "i=dkp_mdkp&mode=mm_listmemberdkp&amp;o=" . $current_order['uri']['current']), $lines, $config['bbdkp_user_llimit'], $this->start, true, 'start');
         }
     }
     $output = array('IDLIST' => implode(",", $membersids), 'BUTTON_NAME' => $user->lang['DELETE'], 'BUTTON_VALUE' => $user->lang['DELETE_SELECTED_MEMBERS'], 'O_NAME' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][1], 'O_RANK' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][2], 'O_LEVEL' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][3], 'O_CLASS' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][4], 'O_RAIDVALUE' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][5], 'O_ADJUSTMENT' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][10], 'O_SPENT' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][12], 'O_LASTRAID' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][17], 'O_RAIDCOUNT' => $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][18], 'S_SHOWZS' => $config['bbdkp_zerosum'] == '1' ? true : false, 'S_SHOWDECAY' => $config['bbdkp_decay'] == '1' ? true : false, 'S_SHOWEPGP' => $config['bbdkp_epgp'] == '1' ? true : false, 'S_SHOWTIME' => $config['bbdkp_timebased'] == '1' ? true : false, 'U_LIST_MEMBERDKP' => $this->u_listmemberdkp, 'S_NOTMM' => false, 'S_DISPLAY_STANDINGS' => true, 'LISTMEMBERS_FOOTCOUNT' => sprintf($user->lang['LISTMEMBERS_FOOTCOUNT'], $lines), 'DKPSYS' => $Navigation->getDkpsysId(), 'DKPSYSNAME' => $Navigation->getDkpsysName(), 'DKPPAGINATION' => $pagination, 'MEMBER_NAME' => $this->PointsController->member_filter);
     if ($config['bbdkp_timebased'] == 1) {
         $output['O_TIMEBONUS'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][6];
     }
     if ($config['bbdkp_zerosum'] == 1) {
         $output['O_ZSBONUS'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][7];
     }
     if ($config['bbdkp_decay'] == 1) {
         $output['O_RDECAY'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][9];
         $output['O_IDECAY'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][13];
     }
     if ($config['bbdkp_epgp'] == 1) {
         $output['O_EP'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][11];
         $output['O_GP'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][14];
         $output['O_PR'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][15];
     } else {
         $output['O_EARNED'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][8];
         $output['O_CURRENT'] = $this->u_listmemberdkp . "&amp;o=" . $current_order['uri'][16];
     }
     $template->assign_vars($output);
 }
Beispiel #4
0
 /**
  * private subroutine for raidplan_push
  *
  * @param array $raid
  * @return int|null|number
  */
 private function exec_pushraid($raid)
 {
     global $db, $cache, $phpbb_root_path, $phpEx;
     $cache->destroy('sql', RP_RAIDS_TABLE);
     if (!class_exists('\\bbdkp\\controller\\raids\\RaidController')) {
         require "{$phpbb_root_path}includes/bbdkp/controller/raids/RaidController.{$phpEx}";
     }
     if (!class_exists('\\bbdkp\\controller\\points\\PointsController')) {
         require "{$phpbb_root_path}includes/bbdkp/controller/points/PointsController.{$phpEx}";
     }
     $RaidController = new RaidController($raid['dkpid']);
     $RaidController->init_newraid();
     $event = $RaidController->eventinfo[$raid['event_id']];
     $raidinfo = array('raid_note' => (string) $raid['raid_note'], 'event_id' => $raid['event_id'], 'raid_start' => (int) $raid['raid_start'], 'raid_end' => (int) $raid['raid_end']);
     $raid_detail = array();
     foreach ($raid['raid_attendees'] as $member_id) {
         $raid_detail[] = array('member_id' => (int) $member_id, 'raid_value' => (double) $raid['raid_value'], 'zerosum_bonus' => (double) $raid['zerosum_bonus'], 'time_bonus' => (double) $raid['raid_timebonus'], 'raid_decay' => (double) $raid['raid_decay']);
     }
     $raid_id = $RaidController->add_raid($raidinfo, $raid_detail);
     $PointsController = new PointsController();
     $PointsController->add_points($raid_id);
     //store raid_id
     $sql = 'UPDATE ' . RP_RAIDS_TABLE . ' SET raid_id = ' . $raid_id . ' WHERE raidplan_id = ' . $this->id;
     $db->sql_query($sql);
     unset($RaidController);
     unset($PointsController);
     return $raid_id;
 }
Beispiel #5
0
 /**
  * Main points acp function
  * @param int $id
  * @param string $mode
  */
 function main($id, $mode)
 {
     global $user, $template, $cache, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     $link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_point&amp;mode=pointconfig") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>';
     $this->PointsController = new \bbdkp\controller\points\PointsController();
     switch ($mode) {
         case 'pointconfig':
             $submit = isset($_POST['update']) ? true : false;
             if ($submit) {
                 if (!check_form_key('acp_dkp')) {
                     trigger_error($user->lang['FV_FORMVALIDATION'], E_USER_WARNING);
                 }
                 //decay
                 set_config('bbdkp_decay', request_var('decay_activate', 0), true);
                 set_config('bbdkp_itemdecaypct', request_var('itemdecaypct', 0), true);
                 set_config('bbdkp_raiddecaypct', request_var('raiddecaypct', 0), true);
                 set_config('bbdkp_decayfrequency', request_var('decayfreq', 0), true);
                 set_config('bbdkp_decayfreqtype', request_var('decayfreqtype', 0), true);
                 set_config('bbdkp_adjdecaypct', request_var('adjdecaypct', 0), true);
                 //time
                 set_config('bbdkp_timebased', request_var('timebonus_activate', 0.0), true);
                 set_config('bbdkp_dkptimeunit', request_var('dkptimeunit', 0.0), true);
                 set_config('bbdkp_timeunit', request_var('timeunit', 0.0), true);
                 set_config('bbdkp_standardduration', request_var('standardduration', 0.0), true);
                 //zerosum
                 if (request_var('zerosum_activate', 0) == 0) {
                     set_config('bbdkp_zerosum', 0, true);
                 }
                 if (request_var('zerosum_activate', 0) == 1 && request_var('epgp_activate', 0) == 1) {
                     set_config('bbdkp_zerosum', 1, true);
                     //epgp and zerosum are mutually exclusive, zerosum will prevail if selected
                     set_config('bbdkp_epgp', 0, true);
                 }
                 if (request_var('zerosum_activate', 0) == 0 && request_var('epgp_activate', 0) == 1) {
                     set_config('bbdkp_zerosum', 0, true);
                     set_config('bbdkp_epgp', 1, true);
                 }
                 if (request_var('zerosum_activate', 0) == 1 && request_var('epgp_activate', 0) == 0) {
                     set_config('bbdkp_zerosum', 1, true);
                     set_config('bbdkp_epgp', 0, true);
                 }
                 if (request_var('zerosum_activate', 0) == 0 && request_var('epgp_activate', 0) == 0) {
                     set_config('bbdkp_zerosum', 0, true);
                     set_config('bbdkp_epgp', 0, true);
                 }
                 set_config('bbdkp_bankerid', request_var('zerosumbanker', 0), true);
                 set_config('bbdkp_zerosumdistother', request_var('zerosumdistother', 0), true);
                 set_config('bbdkp_basegp', request_var('basegp', 0.0), true);
                 set_config('bbdkp_minep', request_var('minep', 0.0), true);
                 set_config('bbdkp_decaycron', request_var('decay_scheduler', 0), true);
                 $cache->destroy('config');
                 trigger_error('Settings saved.' . $link, E_USER_NOTICE);
             }
             $zerosum_synchronise = isset($_POST['zerosum_synchronise']) ? true : false;
             $decay_synchronise = isset($_POST['decay_synchronise']) ? true : false;
             $dkp_synchronise = isset($_POST['syncdkp']) ? true : false;
             // resynchronise DKP
             if ($dkp_synchronise) {
                 if (confirm_box(true)) {
                     $message = sprintf($user->lang['ADMIN_DKPPOOLSYNC_SUCCESS'], $this->PointsController->syncdkpsys());
                     trigger_error($message . $link, E_USER_NOTICE);
                 } else {
                     $s_hidden_fields = build_hidden_fields(array('syncdkp' => true));
                     $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
                     confirm_box(false, sprintf($user->lang['RESYNC_DKP_CONFIRM']), $s_hidden_fields);
                 }
             }
             // recalculate zerosum
             if ($zerosum_synchronise) {
                 if (confirm_box(true)) {
                     $this->PointsController->sync_zerosum($config['bbdkp_zerosum']);
                 } else {
                     $s_hidden_fields = build_hidden_fields(array('zerosum_synchronise' => true));
                     $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
                     confirm_box(false, sprintf($user->lang['RESYNC_ZEROSUM_CONFIRM']), $s_hidden_fields);
                 }
             }
             if ($decay_synchronise) {
                 if (confirm_box(true)) {
                     $count = $this->PointsController->sync_decay($config['bbdkp_decay']);
                     $count1 = $this->PointsController->sync_adjdecay($config['bbdkp_decay']);
                     trigger_error(sprintf($user->lang['RESYNC_DECAY_SUCCESS'], $count, $count1) . $link, E_USER_NOTICE);
                 } else {
                     $s_hidden_fields = build_hidden_fields(array('decay_synchronise' => true));
                     $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
                     confirm_box(false, sprintf($user->lang['RESYNC_DECAY_CONFIRM']), $s_hidden_fields);
                 }
             }
             $freqtypes = array(0 => $user->lang['FREQ0'], 1 => $user->lang['FREQ1'], 2 => $user->lang['FREQ2']);
             $s_freqtype_options = '';
             foreach ($freqtypes as $key => $type) {
                 $selected = $config['bbdkp_decayfreqtype'] == $key ? ' selected="selected"' : '';
                 $s_freqtype_options .= '<option value="' . $key . '" ' . $selected . '> ' . $type . '</option>';
             }
             $s_bankerlist_options = '';
             global $db;
             $sql = 'SELECT member_id, member_name FROM ' . MEMBER_LIST_TABLE . " WHERE member_status = '1' order by member_name asc";
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 $selected = $config['bbdkp_bankerid'] == $row['member_id'] ? ' selected="selected"' : '';
                 $s_bankerlist_options .= '<option value="' . $row['member_id'] . '" ' . $selected . '> ' . $row['member_name'] . '</option>';
             }
             $db->sql_freeresult($result);
             unset($db, $result);
             add_form_key('acp_dkp');
             $template->assign_vars(array('DKP_NAME' => $config['bbdkp_dkp_name'], 'F_EPGPACTIVATE' => $config['bbdkp_epgp'], 'BASEGP' => $config['bbdkp_basegp'], 'MINEP' => $config['bbdkp_minep'], 'F_DECAYACTIVATE' => $config['bbdkp_decay'], 'ITEMDECAYPCT' => $config['bbdkp_itemdecaypct'], 'RAIDDECAYPCT' => $config['bbdkp_raiddecaypct'], 'ADJDECAYPCT' => $config['bbdkp_adjdecaypct'], 'DECAYFREQ' => $config['bbdkp_decayfrequency'], 'S_FREQTYPE_OPTIONS' => $s_freqtype_options, 'F_DECAYSCHEDULER' => $config['bbdkp_decaycron'], 'F_TIMEBONUSACTIVATE' => $config['bbdkp_timebased'], 'DKPTIMEUNIT' => $config['bbdkp_dkptimeunit'], 'TIMEUNIT' => $config['bbdkp_timeunit'], 'STANDARDDURATION' => $config['bbdkp_standardduration'], 'F_ZEROSUMACTIVATE' => $config['bbdkp_zerosum'], 'S_BANKER_OPTIONS' => $s_bankerlist_options, 'F_ZEROSUM_DISTOTHER' => $config['bbdkp_zerosumdistother'], 'DECAYIMGEXAMPLE' => $phpbb_root_path . "adm/style/dkp/decayexample.png"));
             $this->page_title = 'ACP_DKP_POINT_CONFIG';
             $this->tpl_name = 'dkp/acp_dkp_' . $mode;
             break;
     }
 }