Example #1
0
    /**
     * shows add/edit character form
     *
     * @param int $member_id
     * @param array $guildlist
     */
    private function fill_addmember($member_id, $guildlist)
    {
        global $db, $auth, $user, $template, $config, $phpbb_root_path;
        $members = new \bbdkp\controller\members\Members();
        // Attach the language file
        $user->add_lang('mods/dkp_common');
        $user->add_lang(array('mods/dkp_admin'));
        $show = true;
        if ($member_id == 0) {
            // check if user can add character
            if (!$auth->acl_get('u_dkp_charadd')) {
                trigger_error($user->lang['NOUCPADDCHARS']);
            }
            if (!$auth->acl_get('u_dkpucp')) {
                trigger_error($user->lang['NOUCPADDCHARS']);
            }
            if ($members->has_reached_maxbbdkpaccounts()) {
                $show = false;
                $template->assign_vars(array('MAX_CHARS_EXCEEDED' => sprintf($user->lang['MAX_CHARS_EXCEEDED'], $config['bbdkp_maxchars'])));
            }
            // set add mode
            $S_ADD = true;
        } else {
            $S_ADD = false;
            $members->member_id = $member_id;
            $members->Getmember();
        }
        foreach ($guildlist as $g) {
            //assign guild_id property
            if ($members->member_guild_id == 0) {
                //if there is a default guild
                if ($g['guilddefault'] == 1) {
                    $members->member_guild_id = $g['id'];
                }
                //if member count > 0
                if ($members->member_guild_id == 0 && $g['membercount'] > 1) {
                    $members->member_guild_id = $g['id'];
                }
                //if guild id field > 0
                if ($members->member_guild_id == 0 && $g['id'] > 0) {
                    $members->member_guild_id = $g['id'];
                }
            }
            //populate guild popup
            if ($g['id'] > 0) {
                $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['id'] == $members->member_guild_id ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
            }
            $guilds = new \bbdkp\controller\guilds\Guilds($members->member_guild_id);
            $gamename = $this->games[$guilds->game_id];
        }
        // Rank drop-down -> for initial load
        // reloading is done from ajax to prevent redraw
        $Ranks = new \bbdkp\controller\guilds\Ranks($members->member_guild_id);
        $result = $Ranks->listranks();
        while ($row = $db->sql_fetchrow($result)) {
            $template->assign_block_vars('rank_row', array('VALUE' => $row['rank_id'], 'SELECTED' => $members->member_rank_id == $row['rank_id'] ? ' selected="selected"' : '', 'OPTION' => !empty($row['rank_name']) ? $row['rank_name'] : '(None)'));
        }
        //race dropdown
        $sql_array = array('SELECT' => '  r.race_id, l.name as race_name ', 'FROM' => array(RACE_TABLE => 'r', BB_LANGUAGE => 'l'), 'WHERE' => " r.race_id = l.attribute_id\n\t\t\t\t\t\tAND r.game_id = '" . $guilds->game_id . "'\n\t\t\t\t\t\tAND l.attribute='race'\n\t\t\t\t\t\tAND l.game_id = r.game_id\n\t\t\t\t\t\tAND l.language= '" . $config['bbdkp_lang'] . "'", 'ORDER_BY' => 'l.name asc');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        if ($member_id > 0) {
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('race_row', array('VALUE' => $row['race_id'], 'SELECTED' => $members->member_race_id == $row['race_id'] ? ' selected="selected"' : '', 'OPTION' => !empty($row['race_name']) ? $row['race_name'] : '(None)'));
            }
        } else {
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('race_row', array('VALUE' => $row['race_id'], 'SELECTED' => '', 'OPTION' => !empty($row['race_name']) ? $row['race_name'] : '(None)'));
            }
        }
        // Class dropdown
        // reloading is done from ajax to prevent redraw
        $sql_array = array('SELECT' => ' c.class_id, l.name as class_name, c.class_hide,
							  c.class_min_level, class_max_level, c.class_armor_type , c.imagename ', 'FROM' => array(CLASS_TABLE => 'c', BB_LANGUAGE => 'l'), 'WHERE' => " l.game_id = c.game_id  AND c.game_id = '" . $guilds->game_id . "'\n\t\t\tAND l.attribute_id = c.class_id  AND l.language= '" . $config['bbdkp_lang'] . "' AND l.attribute = 'class' ", 'ORDER_BY' => 'l.name asc');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['class_min_level'] <= 1) {
                $option = !empty($row['class_name']) ? $row['class_name'] . "\n\t\t\t\t Level (" . $row['class_min_level'] . " - " . $row['class_max_level'] . ")" : '(None)';
            } else {
                $option = !empty($row['class_name']) ? $row['class_name'] . "\n\t\t\t\t Level " . $row['class_min_level'] . "+" : '(None)';
            }
            if ($member_id > 0) {
                $template->assign_block_vars('class_row', array('VALUE' => $row['class_id'], 'SELECTED' => $members->member_class_id == $row['class_id'] ? ' selected="selected"' : '', 'OPTION' => $option));
            } else {
                $template->assign_block_vars('class_row', array('VALUE' => $row['class_id'], 'SELECTED' => '', 'OPTION' => $option));
            }
        }
        $db->sql_freeresult($result);
        //Role dropdown
        $Roles = new \bbdkp\controller\games\Roles();
        $Roles->game_id = $guilds->game_id;
        $Roles->guild_id = $members->member_guild_id;
        $listroles = $Roles->listroles();
        foreach ($listroles as $roleid => $Role) {
            $template->assign_block_vars('role_row', array('VALUE' => $Role['role_id'], 'SELECTED' => $members->member_role == $Role['role_id'] ? ' selected="selected"' : '', 'OPTION' => $Role['rolename']));
        }
        // build presets for joindate pulldowns
        $now = getdate();
        $s_memberjoin_day_options = '<option value="0"	>--</option>';
        for ($i = 1; $i < 32; $i++) {
            $day = isset($members->member_joindate_d) ? $members->member_joindate_d : $now['mday'];
            $selected = $i == $day ? ' selected="selected"' : '';
            $s_memberjoin_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberjoin_month_options = '<option value="0">--</option>';
        for ($i = 1; $i < 13; $i++) {
            $month = isset($members->member_joindate_mo) ? $members->member_joindate_mo : $now['mon'];
            $selected = $i == $month ? ' selected="selected"' : '';
            $s_memberjoin_month_options .= " <option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberjoin_year_options = '<option value="0">--</option>';
        for ($i = $now['year'] - 10; $i <= $now['year']; $i++) {
            $yr = isset($members->member_joindate_y) ? $members->member_joindate_y : $now['year'];
            $selected = $i == $yr ? ' selected="selected"' : '';
            $s_memberjoin_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        // build presets for outdate pulldowns
        $s_memberout_day_options = '<option value="0"' . ($members->member_id > 0 ? $members->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = 1; $i < 32; $i++) {
            if ($members->member_id > 0 && $members->member_outdate != 0) {
                $day = $members->member_outdate_d;
                $selected = $i == $day ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberout_month_options = '<option value="0"' . ($members->member_id > 0 ? $members->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = 1; $i < 13; $i++) {
            if ($members->member_id > 0 && $members->member_outdate != 0) {
                $month = $members->member_outdate_mo;
                $selected = $i == $month ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberout_year_options = '<option value="0"' . ($members->member_id > 0 ? $members->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = $now['year'] - 10; $i <= $now['year'] + 10; $i++) {
            if ($members->member_id > 0 && $members->member_outdate != 0) {
                $yr = $members->member_outdate_y;
                $selected = $i == $yr ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        // check if user can add character
        $S_UPDATE = true;
        if (!$auth->acl_get('u_dkp_charupdate')) {
            $S_UPDATE = false;
        }
        $S_DELETE = true;
        if (!$auth->acl_get('u_dkp_chardelete')) {
            $S_DELETE = false;
        }
        foreach ($this->regions as $key => $regionname) {
            $template->assign_block_vars('region_row', array('VALUE' => $key, 'SELECTED' => $members->member_region == $key ? ' selected="selected"' : '', 'OPTION' => !empty($regionname) ? $regionname : '(None)'));
        }
        $form_key = 'characteradd';
        add_form_key($form_key);
        $template->assign_vars(array('GAME_ID' => $guilds->game_id, 'GAME' => $gamename, 'STATUS' => $members->member_status == 1 ? ' checked="checked"' : '', 'MEMBER_NAME' => $members->member_name, 'MEMBER_TITLE' => $members->member_title, 'MEMBER_ID' => $members->member_id, 'MEMBER_LEVEL' => $members->member_level, 'MALE_CHECKED' => $members->member_gender_id == '0' ? ' checked="checked"' : '', 'FEMALE_CHECKED' => $members->member_gender_id == '1' ? ' checked="checked"' : '', 'MEMBER_COMMENT' => $members->member_comment, 'REALM' => $members->member_realm, 'S_CAN_HAVE_ARMORY' => $members->game_id == 'wow' || $members->game_id == 'aion' ? true : false, 'MEMBER_URL' => $members->member_armory_url, 'MEMBER_PORTRAIT' => $members->member_portrait_url, 'S_MEMBER_PORTRAIT_EXISTS' => strlen($members->member_portrait_url) > 1 ? true : false, 'S_CAN_GENERATE_ARMORY' => $members->game_id == 'wow' ? true : false, 'COLORCODE' => $members->colorcode == '' ? '#254689' : $members->colorcode, 'CLASS_IMAGE' => $members->class_image, 'S_CLASS_IMAGE_EXISTS' => strlen($members->class_image) > 1 ? true : false, 'RACE_IMAGE' => $members->race_image, 'S_RACE_IMAGE_EXISTS' => strlen($members->race_image) > 1 ? true : false, 'S_JOINDATE_DAY_OPTIONS' => $s_memberjoin_day_options, 'S_JOINDATE_MONTH_OPTIONS' => $s_memberjoin_month_options, 'S_JOINDATE_YEAR_OPTIONS' => $s_memberjoin_year_options, 'S_OUTDATE_DAY_OPTIONS' => $s_memberout_day_options, 'S_OUTDATE_MONTH_OPTIONS' => $s_memberout_month_options, 'S_OUTDATE_YEAR_OPTIONS' => $s_memberout_year_options, 'S_SHOW' => $show, 'S_ADD' => $S_ADD, 'S_CANDELETE' => $S_DELETE, 'S_CANUPDATE' => $S_UPDATE));
    }
Example #2
0
    /**
     * Build addmember template
     *
     * @param $mode
     */
    private function BuildTemplateAddEditmembers($mode)
    {
        global $template, $db, $config, $user, $phpbb_admin_path, $phpEx;
        $member_id = request_var('hidden_member_id', request_var(URI_NAMEID, 0));
        $editmember = new \bbdkp\controller\members\Members($member_id);
        $S_ADD = $member_id > 0 ? false : true;
        if ($S_ADD) {
            // set defaults
            $editmember->member_guild_id = request_var(URI_GUILD, 0);
        }
        $Guild = new \bbdkp\controller\guilds\Guilds($editmember->member_guild_id);
        $guildlist = $Guild->guildlist();
        if ($S_ADD) {
            $editmember->game_id = $Guild->game_id;
            $editmember->member_rank_id = $Guild->raidtrackerrank;
            $editmember->member_status = 1;
            $editmember->member_gender_id = 0;
        }
        foreach ($guildlist as $g) {
            //populate guild popup
            $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['id'] == $editmember->member_guild_id ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
        }
        // Game dropdown
        if (isset($this->games)) {
            foreach ($this->games as $gameid => $gamename) {
                $template->assign_block_vars('game_row', array('VALUE' => $gameid, 'SELECTED' => $editmember->game_id == $gameid ? ' selected="selected"' : '', 'OPTION' => $gamename));
            }
        } else {
            trigger_error('ERROR_NOGAMES', E_USER_WARNING);
        }
        foreach ($this->regions as $key => $regionname) {
            $template->assign_block_vars('region_row', array('VALUE' => $key, 'SELECTED' => $editmember->member_region == $key ? ' selected="selected"' : '', 'OPTION' => !empty($regionname) ? $regionname : '(None)'));
        }
        // Rank drop-down -> for initial load
        // reloading is done from ajax to prevent redraw
        $Ranks = new \bbdkp\controller\guilds\Ranks($editmember->member_guild_id);
        $result = $Ranks->listranks();
        while ($row = $db->sql_fetchrow($result)) {
            $template->assign_block_vars('rank_row', array('VALUE' => $row['rank_id'], 'SELECTED' => $editmember->member_rank_id == $row['rank_id'] ? ' selected="selected"' : '', 'OPTION' => !empty($row['rank_name']) ? $row['rank_name'] : '(None)'));
        }
        // Race dropdown
        // reloading is done from ajax to prevent redraw
        $sql_array = array('SELECT' => '  r.race_id, l.name as race_name ', 'FROM' => array(RACE_TABLE => 'r', BB_LANGUAGE => 'l'), 'WHERE' => " r.race_id = l.attribute_id\n\t\t\t\t\t\t\t\tAND r.game_id = '" . $editmember->game_id . "'\n\t\t\t\t\t\t\t\tAND l.attribute='race'\n\t\t\t\t\t\t\t\tAND l.game_id = r.game_id\n\t\t\t\t\t\t\t\tAND l.language= '" . $config['bbdkp_lang'] . "'", 'ORDER_BY' => 'l.name asc');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        if ($editmember->member_id > 0) {
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('race_row', array('VALUE' => $row['race_id'], 'SELECTED' => $editmember->member_race_id == $row['race_id'] ? ' selected="selected"' : '', 'OPTION' => !empty($row['race_name']) ? $row['race_name'] : '(None)'));
            }
        } else {
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('race_row', array('VALUE' => $row['race_id'], 'SELECTED' => '', 'OPTION' => !empty($row['race_name']) ? $row['race_name'] : '(None)'));
            }
        }
        $db->sql_freeresult($result);
        //
        // Class dropdown
        // reloading is done from ajax to prevent redraw
        $sql_array = array('SELECT' => ' c.class_id, l.name as class_name, c.class_hide,
									  c.class_min_level, class_max_level, c.class_armor_type , c.imagename ', 'FROM' => array(CLASS_TABLE => 'c', BB_LANGUAGE => 'l'), 'WHERE' => " l.game_id = c.game_id  AND c.game_id = '" . $editmember->game_id . "'\n\t\t\t\t\tAND l.attribute_id = c.class_id  AND l.language= '" . $config['bbdkp_lang'] . "' AND l.attribute = 'class' ", 'ORDER_BY' => 'l.name asc');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['class_min_level'] <= 1) {
                $option = !empty($row['class_name']) ? $row['class_name'] . "\n\t\t\t\t\t\t Level (" . $row['class_min_level'] . " - " . $row['class_max_level'] . ")" : '(None)';
            } else {
                $option = !empty($row['class_name']) ? $row['class_name'] . "\n\t\t\t\t\t\t Level " . $row['class_min_level'] . "+" : '(None)';
            }
            if ($editmember->member_id != 0) {
                $template->assign_block_vars('class_row', array('VALUE' => $row['class_id'], 'SELECTED' => $editmember->member_class_id == $row['class_id'] ? ' selected="selected"' : '', 'OPTION' => $option));
            } else {
                $template->assign_block_vars('class_row', array('VALUE' => $row['class_id'], 'SELECTED' => '', 'OPTION' => $option));
            }
        }
        $db->sql_freeresult($result);
        // get roles
        $Roles = new \bbdkp\controller\games\Roles();
        $Roles->game_id = $Guild->game_id;
        $Roles->guild_id = $editmember->member_guild_id;
        $listroles = $Roles->listroles();
        foreach ($listroles as $roleid => $Role) {
            $template->assign_block_vars('role_row', array('VALUE' => $Role['role_id'], 'SELECTED' => $editmember->member_role == $Role['role_id'] ? ' selected="selected"' : '', 'OPTION' => $Role['rolename']));
        }
        // build presets for joindate pulldowns
        $now = getdate();
        $s_memberjoin_day_options = '<option value="0"	>--</option>';
        for ($i = 1; $i < 32; $i++) {
            $day = $editmember->member_id > 0 ? $editmember->member_joindate_d : $now['mday'];
            $selected = $i == $day ? ' selected="selected"' : '';
            $s_memberjoin_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberjoin_month_options = '<option value="0">--</option>';
        for ($i = 1; $i < 13; $i++) {
            $month = $editmember->member_id > 0 ? $editmember->member_joindate_mo : $now['mon'];
            $selected = $i == $month ? ' selected="selected"' : '';
            $s_memberjoin_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberjoin_year_options = '<option value="0">--</option>';
        for ($i = $now['year'] - 10; $i <= $now['year']; $i++) {
            $yr = $editmember->member_id > 0 ? $editmember->member_joindate_y : $now['year'];
            $selected = $i == $yr ? ' selected="selected"' : '';
            $s_memberjoin_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        // build presets for outdate pulldowns
        $s_memberout_day_options = '<option value="0"' . ($editmember->member_id > 0 ? $editmember->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = 1; $i < 32; $i++) {
            if ($editmember->member_id > 0 && $editmember->member_outdate != 0) {
                $day = $editmember->member_outdate_d;
                $selected = $i == $day ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberout_month_options = '<option value="0"' . ($editmember->member_id > 0 ? $editmember->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = 1; $i < 13; $i++) {
            if ($editmember->member_id > 0 && $editmember->member_outdate != 0) {
                $month = $editmember->member_outdate_mo;
                $selected = $i == $month ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        $s_memberout_year_options = '<option value="0"' . ($editmember->member_id > 0 ? $editmember->member_outdate != 0 ? '' : ' selected="selected"' : ' selected="selected"') . '>--</option>';
        for ($i = $now['year'] - 10; $i <= $now['year'] + 10; $i++) {
            if ($editmember->member_id > 0 && $editmember->member_outdate != 0) {
                $yr = $editmember->member_outdate_y;
                $selected = $i == $yr ? ' selected="selected"' : '';
            } else {
                $selected = '';
            }
            $s_memberout_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>";
        }
        // phpbb User dropdown
        $phpbb_user_id = $editmember->member_id > 0 ? $editmember->phpbb_user_id : 0;
        $sql_array = array('SELECT' => ' u.user_id, u.username ', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => " u.group_id != 6 and u.group_id != 1 ", 'ORDER_BY' => " u.username ASC");
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        $s_phpbb_user = '******' . ($phpbb_user_id == 0 ? ' selected="selected"' : '') . '>--</option>';
        while ($row = $db->sql_fetchrow($result)) {
            $selected = $row['user_id'] == $phpbb_user_id ? ' selected="selected"' : '';
            $s_phpbb_user .= '<option value="' . $row['user_id'] . '"' . $selected . '>' . $row['username'] . '</option>';
        }
        unset($now);
        $form_key = 'mm_addmember';
        add_form_key($form_key);
        $template->assign_vars(array('L_TITLE' => $user->lang['ACP_MM_ADDMEMBER'], 'L_EXPLAIN' => $user->lang['ACP_MM_ADDMEMBER_EXPLAIN'], 'F_ADD_MEMBER' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_mm&amp;mode=mm_addmember&amp;"), 'STATUS' => $editmember->member_status == 1 ? 'checked="checked"' : '', 'MEMBER_NAME' => $editmember->member_name, 'MEMBER_ID' => $editmember->member_id, 'MEMBER_LEVEL' => $editmember->member_level, 'REALM' => $editmember->member_realm, 'DEACTIVATE_REASON' => $editmember->deactivate_reason == '' ? '' : $user->lang[$editmember->deactivate_reason], 'STATUS_LOCK' => $editmember->deactivate_reason == '' ? false : true, 'MEMBER_ACHIEV' => $editmember->member_achiev, 'MEMBER_TITLE' => $editmember->member_title, 'MALE_CHECKED' => $editmember->member_gender_id == '0' ? ' checked="checked"' : '', 'FEMALE_CHECKED' => $editmember->member_gender_id == '1' ? ' checked="checked"' : '', 'MEMBER_COMMENT' => $editmember->member_comment, 'S_CAN_HAVE_ARMORY' => $editmember->game_id == 'wow' || $editmember->game_id == 'aion' ? true : false, 'MEMBER_URL' => $editmember->member_armory_url, 'MEMBER_PORTRAIT' => $editmember->member_portrait_url, 'S_MEMBER_PORTRAIT_EXISTS' => strlen($editmember->member_portrait_url) > 1 ? true : false, 'S_CAN_GENERATE_ARMORY' => $editmember->game_id == 'wow' ? true : false, 'COLORCODE' => $editmember->colorcode == '' ? '#254689' : $editmember->colorcode, 'CLASS_IMAGE' => $editmember->class_image, 'S_CLASS_IMAGE_EXISTS' => strlen($editmember->class_image) > 1 ? true : false, 'RACE_IMAGE' => $editmember->race_image, 'S_RACE_IMAGE_EXISTS' => strlen($editmember->race_image) > 1 ? true : false, 'S_JOINDATE_DAY_OPTIONS' => $s_memberjoin_day_options, 'S_JOINDATE_MONTH_OPTIONS' => $s_memberjoin_month_options, 'S_JOINDATE_YEAR_OPTIONS' => $s_memberjoin_year_options, 'S_OUTDATE_DAY_OPTIONS' => $s_memberout_day_options, 'S_OUTDATE_MONTH_OPTIONS' => $s_memberout_month_options, 'S_OUTDATE_YEAR_OPTIONS' => $s_memberout_year_options, 'S_PHPBBUSER_OPTIONS' => $s_phpbb_user, 'TITLE_NAME' => $editmember->game_id == 'wow' ? sprintf($editmember->member_title, $editmember->member_name) : '', 'LA_ALERT_AJAX' => $user->lang['ALERT_AJAX'], 'LA_ALERT_OLDBROWSER' => $user->lang['ALERT_OLDBROWSER'], 'LA_MSG_NAME_EMPTY' => $user->lang['FV_REQUIRED_NAME'], 'UA_FINDRANK' => append_sid($phpbb_admin_path . "style/dkp/findrank.{$phpEx}"), 'UA_FINDCLASSRACE' => append_sid($phpbb_admin_path . "style/dkp/findclassrace.{$phpEx}"), 'S_ADD' => $S_ADD));
        $this->page_title = 'ACP_MM_ADDMEMBER';
        $this->tpl_name = 'dkp/acp_' . $mode;
    }
 /**
  * Main
  *
  * @param $id
  * @param $mode
  */
 public function main($id, $mode)
 {
     global $db, $user, $auth, $template, $cache;
     global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     $user->add_lang(array('mods/raidplanner', 'mods/dkp_common'));
     if (!$auth->acl_get('a_raid_config')) {
         trigger_error($user->lang['USER_CANNOT_MANAGE_RAIDPLANNER']);
     }
     // main tabs
     $template->assign_vars(array('RAIDPLANNER_VERSION' => $config['bbdkp_raidplanner'], 'U_RP_PLANNER_SETTINGS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_settings"), 'U_RP_CAL_SETTINGS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_cal_settings"), 'U_RP_TEAMS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"), 'U_RP_TEAMSLIST' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"), 'U_RP_TEAMSEDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams_edit"), 'U_RP_COMPOSITION' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=raidplanner&amp;mode=rp_composition")));
     $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode={$mode}") . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
     if (!class_exists('\\bbdkp\\admin\\Admin')) {
         require "{$phpbb_root_path}includes/bbdkp/admin/admin.{$phpEx}";
     }
     $bbdkp = new \bbdkp\admin\Admin();
     switch ($mode) {
         case 'rp_settings':
             $update = isset($_POST['update_rp_settings']) ? true : false;
             // check the form key
             if ($update) {
                 if (!check_form_key('acp_raidplanner')) {
                     trigger_error('FORM_INVALID');
                 }
             }
             // update Raidplan settings
             if ($update) {
                 $invitehour = request_var('event_invite_hh', 0) * 60 + request_var('event_invite_mm', 0);
                 set_config('rp_default_invite_time', $invitehour, 0);
                 $starthour = request_var('event_start_hh', 0) * 60 + request_var('event_start_mm', 0);
                 set_config('rp_default_start_time', $starthour, 0);
                 $endhour = request_var('event_end_hh', 0) * 60 + request_var('event_end_mm', 0);
                 set_config('rp_default_end_time', $endhour, 0);
                 $freezetime = request_var('freeze_time', 0);
                 set_config('rp_default_freezetime', $freezetime, 0);
                 $expire_time = request_var('expire_time', 0);
                 set_config('rp_default_expiretime', $expire_time, 0);
                 $rp_enable_past_raids = request_var('rp_enable_past_raids', 0);
                 set_config('rp_enable_past_raids', $rp_enable_past_raids, 0);
                 $disp_upcoming = request_var('disp_next_raidplans', 0);
                 set_config('rp_display_next_raidplans', $disp_upcoming, 0);
                 $send_pm_rpchange = request_var('send_pm_rpchange', 0);
                 set_config('rp_pm_rpchange', $send_pm_rpchange, 0);
                 $send_email_rpchange = request_var('send_email_rpchange', 0);
                 set_config('rp_email_rpchange', $send_email_rpchange, 0);
                 $send_pm_signup = request_var('send_pm_signup', 0);
                 set_config('rp_pm_signup', $send_pm_signup, 0);
                 $send_email_signup = request_var('send_email_signup', 0);
                 set_config('rp_email_signup', $send_email_signup, 0);
                 $push_mode = request_var('push_mode', 0);
                 set_config('rp_rppushmode', $push_mode, 0);
                 $cache->destroy('config');
                 $message = "";
                 $message .= '<br />' . sprintf($user->lang['RPSETTINGS_UPDATED'], E_USER_NOTICE);
                 meta_refresh(1, $this->u_action);
                 trigger_error($message . $link);
             }
             // build presets for invite hour pulldown
             $invhour = intval($config['rp_default_invite_time'] / 60);
             for ($i = 0; $i <= 23; $i++) {
                 $template->assign_block_vars('event_invite_hh', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $invhour ? ' selected="selected"' : ''));
             }
             // build presets for invite minute pulldown
             $invmin = $config['rp_default_invite_time'] - $invhour * 60;
             for ($i = 0; $i <= 59; $i++) {
                 $template->assign_block_vars('event_invite_mm', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $invmin ? ' selected="selected"' : ''));
             }
             // build presets for start hour pulldown
             $starthour = intval($config['rp_default_start_time'] / 60);
             for ($i = 0; $i <= 23; $i++) {
                 $template->assign_block_vars('event_start_hh', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $starthour ? ' selected="selected"' : ''));
             }
             // build presets for start minute pulldown
             $startmin = $config['rp_default_start_time'] - $starthour * 60;
             for ($i = 0; $i <= 59; $i++) {
                 $template->assign_block_vars('event_start_mm', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $startmin ? ' selected="selected"' : ''));
             }
             // build presets for end hour pulldown
             $endhour = intval($config['rp_default_end_time'] / 60);
             for ($i = 0; $i <= 23; $i++) {
                 $template->assign_block_vars('event_end_hh', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $endhour ? ' selected="selected"' : ''));
             }
             // build presets for end minute pulldown
             $endmin = $config['rp_default_end_time'] - $endhour * 60;
             for ($i = 0; $i <= 59; $i++) {
                 $template->assign_block_vars('event_end_mm', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $endmin ? ' selected="selected"' : ''));
             }
             $template->assign_vars(array('RAIDPLANNER_VERSION' => $config['bbdkp_raidplanner'], 'ENABLEPASTRAIDS_CHECKED' => (int) $config['rp_enable_past_raids'] == 1 ? "checked='checked'" : '', 'FROZEN_TIME' => $config['rp_default_freezetime'], 'EXPIRE_TIME' => $config['rp_default_expiretime'], 'DISP_NEXT_EVENTS_DISABLED' => $config['rp_index_display_week'] == 1 ? "disabled='disabled'" : '', 'DISP_NEXT_EVENTS' => $config['rp_display_next_raidplans'], 'DISP_EVENTS_1_DAY_CHECKED' => $config['rp_disp_raidplans_only_on_start'] == '1' ? "checked='checked'" : '', 'SEL_AUTOPUSHRAIDPLAN' => (int) $config['rp_rppushmode'] == 0 ? "selected='selected'" : '', 'SEL_MANUALPUSHRAIDPLAN' => (int) $config['rp_rppushmode'] == 1 ? "selected='selected'" : '', 'SEL_NOPUSHRAIDPLAN' => (int) $config['rp_rppushmode'] == 2 ? "selected='selected'" : '', 'SENDPMRP_CHECKED' => (int) $config['rp_pm_rpchange'] == 1 ? "checked='checked'" : '', 'SENDEMAILRP_CHECKED' => (int) $config['rp_email_rpchange'] == 1 ? "checked='checked'" : '', 'SENDPMSIGN_CHECKED' => (int) $config['rp_pm_signup'] == 1 ? "checked='checked'" : '', 'SENDEMAILSIGN_CHECKED' => (int) $config['rp_email_signup'] == 1 ? "checked='checked'" : '', 'PRUNE_FREQ' => (int) $config['rp_prune_frequency'] / 86400, 'PRUNE_LIMIT' => (int) $config['rp_prune_limit'] / 86400, 'POPULATE_FREQ' => (int) $config['rp_populate_frequency'] / 86400, 'POPULATE_LIMIT' => (int) $config['rp_populate_limit'] / 86400, 'U_PLUS_HOUR' => $this->u_action . "&amp;calPlusHour=1&amp;plusVal=1", 'U_MINUS_HOUR' => $this->u_action . "&amp;calPlusHour=1&amp;plusVal=0", 'U_ACTION' => $this->u_action));
             $this->tpl_name = 'dkp/acp_' . $mode;
             $form_key = 'acp_raidplanner';
             add_form_key($form_key);
             break;
         case 'rp_cal_settings':
             $updatecal = isset($_POST['update_rp_settings_cal']) ? true : false;
             // check the form key
             if ($updatecal) {
                 if (!check_form_key('acp_raidplanner')) {
                     trigger_error('FORM_INVALID');
                 }
             }
             // update all calendar settings
             if ($updatecal) {
                 set_config('rp_show_welcomemsg', isset($_POST['show_welcome']) ? 1 : 0, 0);
                 $text = utf8_normalize_nfc(request_var('welcome_message', '', true));
                 $uid = $bitfield = $options = '';
                 // will be modified by generate_text_for_storage
                 $allow_bbcode = $allow_urls = $allow_smilies = true;
                 generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
                 $sql = 'UPDATE ' . RP_RAIDPLAN_ANNOUNCEMENT . " SET\n\t\t\t\t\t\t\tannouncement_msg = '" . (string) $db->sql_escape($text) . "' ,\n\t\t\t\t\t\t\tannouncement_timestamp = " . (int) time() . " ,\n\t\t\t\t\t\t\tbbcode_bitfield = \t'" . (string) $bitfield . "' ,\n\t\t\t\t\t\t\tbbcode_uid = \t\t'" . (string) $uid . "'\n\t\t\t\t\t\t\tWHERE announcement_id = 1";
                 $db->sql_query($sql);
                 $disp_week = request_var('disp_week', 0);
                 set_config('rp_index_display_week', $disp_week, 0);
                 $first_day = request_var('first_day', 0);
                 set_config('rp_first_day_of_week', $first_day, 0);
                 $hour_mode = request_var('hour_mode', 12);
                 set_config('rp_hour_mode', $hour_mode, 0);
                 $disp_trunc = request_var('disp_trunc', 0);
                 set_config('rp_display_truncated_name', $disp_trunc, 0);
                 $disp_hidden_groups = request_var('disp_hidden_groups', '');
                 set_config('rp_display_hidden_groups', $disp_hidden_groups, 0);
                 $disp_raidplans_1_day = request_var('disp_raidplans_1_day', 0);
                 set_config('rp_disp_raidplans_only_on_start', $disp_raidplans_1_day, 0);
                 $date_format = request_var('date_format', 'M d, Y');
                 set_config('rp_date_format', $date_format, 0);
                 $show_name = request_var('show_name', 0);
                 set_config('rp_show_name', $show_name, 0);
                 $date_time_format = request_var('date_time_format', 'M d, Y h:i a');
                 set_config('rp_date_time_format', $date_time_format, 0);
                 $time_format = request_var('time_format', 'h:i a');
                 set_config('rp_time_format', $time_format, 0);
                 // prune_freq is entered in days by user, but stored in seconds
                 $prune_freq = request_var('prune_freq', 0);
                 $prune_freq = 86400 * $prune_freq;
                 set_config('rp_prune_frequency', $prune_freq, 0);
                 // prune_limit is entered in days by user, but stored in seconds
                 $prune_limit = request_var('prune_limit', 0);
                 $prune_limit = 86400 * $prune_limit;
                 set_config('rp_prune_limit', $prune_limit, 0);
                 // auto populate recurring raidplan settings
                 // populate_freq is entered in days by user, but stored in seconds
                 $populate_freq = request_var('populate_freq', 0);
                 $populate_freq = 86400 * $populate_freq;
                 set_config('rp_populate_frequency', $populate_freq, 0);
                 // populate_limit is entered in days by user, but stored in seconds
                 $populate_limit = request_var('populate_limit', 0);
                 $populate_limit = 86400 * $populate_limit;
                 set_config('rp_populate_limit', $populate_limit, 0);
                 $cache->destroy('config');
                 $message = '<br />' . sprintf($user->lang['CALSETTINGS_UPDATED'], E_USER_NOTICE);
                 meta_refresh(1, $this->u_action);
                 trigger_error($message . $link);
             }
             $sel_monday = $sel_tuesday = $sel_wednesday = $sel_thursday = $sel_friday = $sel_saturday = $sel_sunday = "";
             switch ($config['rp_first_day_of_week']) {
                 case 0:
                     $sel_monday = "selected='selected'";
                     break;
                 case 1:
                     $sel_tuesday = "selected='selected'";
                     break;
                 case 2:
                     $sel_wednesday = "selected='selected'";
                     break;
                 case 3:
                     $sel_thursday = "selected='selected'";
                     break;
                 case 4:
                     $sel_friday = "selected='selected'";
                     break;
                 case 5:
                     $sel_saturday = "selected='selected'";
                     break;
                 case 6:
                     $sel_sunday = "selected='selected'";
                     break;
             }
             // get welcome msg
             $sql = 'SELECT announcement_msg, bbcode_bitfield, bbcode_uid FROM ' . RP_RAIDPLAN_ANNOUNCEMENT;
             $db->sql_query($sql);
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 $text = $row['announcement_msg'];
                 $bitfield = $row['bbcode_bitfield'];
                 $uid = $row['bbcode_uid'];
             }
             $textarr = generate_text_for_edit($text, $uid, $bitfield, 7);
             $template->assign_vars(array('SHOW_WELCOME' => (int) $config['rp_show_welcomemsg'] == 1 ? 'checked="checked"' : "", 'WELCOME_MESSAGE' => $textarr['text'], 'DISP_WEEK_CHECKED' => $config['rp_index_display_week'] == 1 ? "checked='checked'" : '', 'SEL_MONDAY' => $sel_monday, 'SEL_TUESDAY' => $sel_tuesday, 'SEL_WEDNESDAY' => $sel_wednesday, 'SEL_THURSDAY' => $sel_thursday, 'SEL_FRIDAY' => $sel_friday, 'SEL_SATURDAY' => $sel_saturday, 'SEL_SUNDAY' => $sel_sunday, 'SEL_12_HOURS' => $config['rp_hour_mode'] == 12 ? "selected='selected'" : '', 'SEL_24_HOURS' => $config['rp_hour_mode'] != 12 ? "selected='selected'" : '', 'DISP_TRUNCATED' => $config['rp_display_truncated_name'], 'DISP_HIDDEN_GROUPS_CHECKED' => $config['rp_display_hidden_groups'] == '1' ? "checked='checked'" : '', 'DATE_FORMAT' => $config['rp_date_format'], 'DATE_TIME_FORMAT' => $config['rp_date_time_format'], 'TIME_FORMAT' => $config['rp_time_format'], 'SHOW_NAME' => (int) $config['rp_show_name'] == 1 ? 'checked="checked"' : ""));
             $this->tpl_name = 'dkp/acp_' . $mode;
             $form_key = 'acp_raidplanner';
             add_form_key($form_key);
             break;
         case 'rp_teams':
             $this->listteam($mode);
             break;
         case 'rp_teams_edit':
             //include the guilds class
             if (!class_exists('\\bbdkp\\controller\\guilds\\Guilds')) {
                 require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Guilds.{$phpEx}";
             }
             if (!class_exists('\\bbdkp\\controller\\games\\Game')) {
                 require "{$phpbb_root_path}includes/bbdkp/controller/games/Game.{$phpEx}";
             }
             $action = request_var('action', '');
             $game_id = request_var('game_id', '');
             $guild_id = request_var(URI_GUILD, 1);
             $teams_id = request_var('teams_id', 1);
             $role_id = request_var('role_id', 1);
             $addteam = isset($_POST['addteam']) ? true : false;
             $updateteam = isset($_POST['updateteam']) ? true : false;
             $newroleadd = isset($_POST['newroleadd']) ? true : false;
             if ($action == 'deleteteam') {
                 $this->DeleteTeam($teams_id);
                 $success_message = sprintf($user->lang['TEAM_DELETE_SUCCESS'], $teams_id);
                 $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams") . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
                 meta_refresh(1, append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"));
                 trigger_error($success_message . $link);
             } elseif ($action == 'editteam') {
                 // prepare edit template
                 $team = $this->getteam($teams_id);
                 $template->assign_vars(array('S_UPDATE' => true, 'TEAM_ID' => $teams_id));
                 $listroles = $this->listroles($teams_id);
                 $showaddline = true;
                 if ($this->rolesneeded >= $team['team_size']) {
                     $showaddline = false;
                 }
                 // get guilds
                 $Guild = new \bbdkp\controller\guilds\Guilds();
                 $guildlist = $Guild->guildlist($guild_id);
                 foreach ($guildlist as $g) {
                     $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $team['guild_id'] == $g['id'] ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
                 }
                 //get games
                 if (!class_exists('\\bbdkp\\admin\\Admin')) {
                     require "{$phpbb_root_path}includes/bbdkp/admin/admin.{$phpEx}";
                 }
                 $bbdkp = new \bbdkp\admin\Admin();
                 if (isset($bbdkp->games)) {
                     foreach ($bbdkp->games as $key => $gamename) {
                         $template->assign_block_vars('game_row', array('VALUE' => $key, 'SELECTED' => $team['game_id'] == $key ? ' selected="selected"' : '', 'OPTION' => !empty($gamename) ? $gamename : '(None)'));
                     }
                 } else {
                     trigger_error('ERROR_NOGAMES', E_USER_WARNING);
                 }
                 // get roles
                 $Roles = new \bbdkp\controller\games\Roles();
                 $Roles->game_id = $team['game_id'];
                 $Roles->guild_id = $team['guild_id'];
                 $listroles = $Roles->listroles();
                 foreach ($listroles as $roleid => $Role) {
                     $template->assign_block_vars('allroles', array('VALUE' => $Role['role_id'], 'SELECTED' => '', 'OPTION' => $Role['rolename']));
                 }
                 $template->assign_vars(array('S_ADDNEW_SHOW' => $showaddline));
             } elseif ($updateteam || $addteam) {
                 $template->assign_vars(array('S_ADD' => true));
                 if (!check_form_key('acp_raidplanner')) {
                     trigger_error('FORM_INVALID');
                 }
                 $teamdata = array('team_name' => utf8_normalize_nfc(request_var('teamname', 'New Team', true)), 'team_size' => request_var('teamsize', 0), 'game_id' => request_var('game_id', ''), 'guild_id' => request_var('guild_id', 0));
                 $error = $teamdata['team_name'] == '' ? trigger_error($user->lang['TEAMROLE_NAME_EMPTY'], E_USER_WARNING) : '';
                 $error = $teamdata['team_size'] == '' ? trigger_error($user->lang['TEAMROLE_SIZE_EMPTY'], E_USER_WARNING) : '';
                 if ($addteam) {
                     $sql = 'INSERT INTO ' . RP_TEAMS . $db->sql_build_array('INSERT', $teamdata);
                     $db->sql_query($sql);
                     $teams_id = $db->sql_nextid();
                     $success_message = sprintf($user->lang['TEAM_ADD_SUCCESS'], utf8_normalize_nfc(request_var('newteamname', 'New Team', true)));
                     $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams") . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
                     meta_refresh(1, append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"));
                     trigger_error($success_message . $link);
                 }
                 if ($updateteam) {
                     $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams_edit&amp;action=editteam&amp;teams_id=" . $teams_id) . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
                     $sql = 'UPDATE ' . RP_TEAMS . ' SET ' . $db->sql_build_array('UPDATE', $teamdata) . '
                          WHERE teams_id=' . (int) $teams_id;
                     $db->sql_query($sql);
                     $roledata = request_var('rolesize', array(0 => 0));
                     $sumneeded = 0;
                     foreach ($roledata as $roleid => $Roleneeded) {
                         $sumneeded += $Roleneeded;
                     }
                     if ($sumneeded > $teamdata['team_size']) {
                         $success_message = sprintf($user->lang['TEAMROLE_UPDATE_FAIL'], $teams_id, $teamdata['team_size'], $sumneeded);
                         trigger_error($success_message . $link, E_USER_WARNING);
                     }
                     foreach ($roledata as $roleid => $Roleneeded) {
                         $updroles = array('role_needed' => $Roleneeded);
                         $sql = 'UPDATE ' . RP_TEAMSIZE . ' SET ' . $db->sql_build_array('UPDATE', $updroles) . ' WHERE teams_id=' . (int) $teams_id . ' AND role_id = ' . $roleid;
                         $db->sql_query($sql);
                     }
                     $success_message = sprintf($user->lang['TEAM_UPDATE_SUCCESS'], $teams_id);
                     meta_refresh(1, append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"));
                     trigger_error($success_message . $link);
                 }
             } elseif ($action == 'deleterole') {
                 $this->DeleteOneRole($teams_id, $role_id);
                 $success_message = sprintf($user->lang['ADMIN_DELETE_ROLE_SUCCESS'], $role_id);
                 $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams") . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
                 meta_refresh(1, append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"));
                 trigger_error($success_message . $link);
             } elseif ($newroleadd) {
                 $newrolesize = request_var('newrolesize', 1);
                 $role_id = request_var('newrole_id', 1);
                 $this->AddOneRole($teams_id, $game_id, $role_id, $newrolesize);
                 $success_message = sprintf($user->lang['ADMIN_ADD_ROLE_SUCCESS'], $role_id);
                 $link = '<br /><a href="' . append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams") . '"><p>' . $user->lang['RETURN_RP'] . '</p></a>';
                 meta_refresh(1, append_sid("{$phpbb_root_path}adm/index.{$phpEx}", "i=raidplanner&amp;mode=rp_teams"));
                 trigger_error($success_message . $link);
             } else {
                 // default load add team template
                 $template->assign_vars(array('S_ADD' => true, 'TEAM_ID' => $teams_id));
                 $Guild = new \bbdkp\controller\guilds\Guilds();
                 $guildlist = $Guild->guildlist($guild_id);
                 foreach ($guildlist as $g) {
                     $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
                 }
                 if (isset($bbdkp->games)) {
                     foreach ($bbdkp->games as $key => $gamename) {
                         $template->assign_block_vars('game_row', array('VALUE' => $key, 'SELECTED' => '', 'OPTION' => !empty($gamename) ? $gamename : '(None)'));
                     }
                 } else {
                     trigger_error('ERROR_NOGAMES', E_USER_WARNING);
                 }
             }
             $this->tpl_name = 'dkp/acp_' . $mode;
             $form_key = 'acp_raidplanner';
             add_form_key($form_key);
             break;
     }
 }
Example #4
0
 /**
  * Uninstall a game
  * @param $game_id
  * @param $gamename
  */
 public final function Uninstall($game_id, $gamename)
 {
     global $cache, $db;
     $this->game_id = $game_id;
     $this->gamename = $gamename;
     $db->sql_transaction('begin');
     $factions = new \bbdkp\controller\games\Faction();
     $factions->game_id = $this->game_id;
     $factions->Delete_all_factions();
     $races = new \bbdkp\controller\games\Races();
     $races->game_id = $this->game_id;
     $races->Delete_all_races();
     $classes = new \bbdkp\controller\games\Classes();
     $classes->game_id = $this->game_id;
     $classes->Delete_all_classes();
     $roles = new \bbdkp\controller\games\Roles();
     $roles->game_id = $this->game_id;
     $roles->Delete_all_roles();
     $sql = 'DELETE FROM ' . BBGAMES_TABLE . " WHERE game_id = '" . $this->game_id . "'";
     $db->sql_query($sql);
     $db->sql_transaction('commit');
     $cache->destroy('sql', BBGAMES_TABLE);
     $cache->destroy('sql', CLASS_TABLE);
     $cache->destroy('sql', BB_LANGUAGE);
     $cache->destroy('sql', RACE_TABLE);
     $cache->destroy('sql', DKPSYS_TABLE);
     $cache->destroy('sql', EVENTS_TABLE);
     $cache->destroy('sql', MEMBER_LIST_TABLE);
 }
Example #5
0
    /**
     * @param $Guild
     * @param $recruit
     */
    private function BuildDropDowns($Guild, $recruit)
    {
        global $config, $db, $template;
        // Class dropdown
        // reloading is done from ajax to prevent redraw
        $sql_array = array('SELECT' => ' c.class_id, l.name as class_name, c.class_hide,
									  c.class_min_level, class_max_level, c.class_armor_type, c.imagename ', 'FROM' => array(CLASS_TABLE => 'c', BB_LANGUAGE => 'l'), 'WHERE' => " l.game_id = c.game_id  AND c.game_id = '" . $Guild->game_id . "'\n\t\t\t\t\tAND l.attribute_id = c.class_id  AND l.language= '" . $config['bbdkp_lang'] . "' AND l.attribute = 'class' ", 'ORDER_BY' => 'l.name asc');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $template->assign_block_vars('class_row', array('VALUE' => $row['class_id'], 'SELECTED' => $recruit->getClassId() == $row['class_id'] ? ' selected="selected"' : '', 'OPTION' => $row['class_name']));
        }
        $db->sql_freeresult($result);
        // get roles
        $Roles = new \bbdkp\controller\games\Roles();
        $Roles->game_id = $Guild->game_id;
        $Roles->guild_id = $Guild->guildid;
        $listroles = $Roles->listroles();
        foreach ($listroles as $roleid => $Role) {
            $template->assign_block_vars('role_row', array('VALUE' => $Role['role_id'], 'SELECTED' => $recruit->role_id == $Role['role_id'] ? ' selected="selected"' : '', 'OPTION' => $Role['rolename']));
        }
    }
Example #6
0
 /**
  * lists game parameters
  *
  * @param \bbdkp\controller\games\game $editgame
  */
 private function showgame(\bbdkp\controller\games\game $editgame)
 {
     global $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $config, $template;
     //populate dropdown
     foreach ($this->gamelist as $key => $game) {
         $template->assign_block_vars('gamelistrow', array('VALUE' => $key, 'OPTION' => $game, 'SELECTED' => $editgame->game_id == $key ? ' selected="selected"' : ''));
     }
     // list the factions
     $listfactions = new \bbdkp\controller\games\Faction();
     $listfactions->game_id = $editgame->game_id;
     $fa = $listfactions->getfactions();
     $total_factions = 0;
     foreach ($fa as $faction_id => $faction) {
         $total_factions++;
         $template->assign_block_vars('faction_row', array('ID' => $faction['f_index'], 'FACTIONGAME' => $editgame->game_id, 'FACTIONID' => $faction['faction_id'], 'FACTIONNAME' => $faction['faction_name'], 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;action=deletefaction&amp;id={$faction['f_index']}&amp;" . URI_GAME . '=' . $editgame->game_id), 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;action=editfaction&amp;id={$faction['f_index']}&amp;" . URI_GAME . '=' . $editgame->game_id)));
     }
     // list the races
     $sort_order = array(0 => array('game_id asc, race_id asc', 'game_id desc, race_id asc'), 1 => array('race_id', 'race_id desc'), 2 => array('race_name', 'race_name desc'), 3 => array('faction_name desc', 'faction_name, race_name desc'));
     $current_order = $this->switch_order($sort_order);
     $total_races = 0;
     $listraces = new \bbdkp\controller\games\Races();
     $listraces->game_id = $editgame->game_id;
     $ra = $listraces->listraces($current_order['sql']);
     foreach ($ra as $race_id => $race) {
         $total_races++;
         $template->assign_block_vars('race_row', array('GAME' => $race['game_name'], 'RACEID' => $race['race_id'], 'RACENAME' => $race['race_name'], 'FACTIONNAME' => $race['faction_name'], 'RACE_IMAGE_M' => strlen($race['image_male']) > 1 ? $phpbb_root_path . "images/bbdkp/race_images/" . $race['image_male'] . ".png" : '', 'RACE_IMAGE_F' => strlen($race['image_female']) > 1 ? $phpbb_root_path . "images/bbdkp/race_images/" . $race['image_female'] . ".png" : '', 'S_RACE_IMAGE_M_EXISTS' => strlen($race['image_male']) > 1 ? true : false, 'S_RACE_IMAGE_F_EXISTS' => strlen($race['image_female']) > 1 ? true : false, 'U_VIEW_RACE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=addrace&amp;r=" . $race['race_id'] . "&amp;" . URI_GAME . "={$listraces->game_id}"), 'U_DELETE' => $this->u_action . "&amp;racedelete=1&amp;id={$race['race_id']}&amp;" . URI_GAME . "={$listraces->game_id}", 'U_EDIT' => $this->u_action . "&amp;raceedit=1&amp;id={$race['race_id']}&amp;" . URI_GAME . "={$listraces->game_id}"));
     }
     unset($listraces, $ra);
     // list the roles
     $sort_order = array(0 => array('game_id asc, role_id asc', 'game_id desc, role_id asc'), 1 => array('role_id', 'role_id desc'), 2 => array('rolename', 'rolename desc'));
     $current_order3 = $this->switch_order($sort_order);
     $listroles = new \bbdkp\controller\games\Roles();
     $listroles->game_id = $editgame->game_id;
     $total_roles = 0;
     $roles = $listroles->listroles($current_order3['sql']);
     foreach ($roles as $role_id => $role) {
         $total_roles++;
         $template->assign_block_vars('role_row', array('ROLE_ID' => $role['role_id'], 'ROLE_NAME' => $role['rolename'], 'ROLE_COLOR' => $role['role_color'], 'ROLE_ICON' => $role['role_icon'], 'S_ROLE_ICON_EXISTS' => strlen($role['role_icon']) > 0 ? true : false, 'U_ROLE_ICON' => strlen($role['role_icon']) > 0 ? $phpbb_root_path . "images/bbdkp/role_icons/" . $role['role_icon'] . ".png" : '', 'ROLE_CAT_ICON' => $role['role_cat_icon'], 'S_ROLE_CAT_ICON_EXISTS' => strlen($role['role_cat_icon']) > 0 ? true : false, 'U_ROLE_CAT_ICON' => strlen($role['role_cat_icon']) > 0 ? $phpbb_root_path . "images/bbdkp/role_icons/" . $role['role_cat_icon'] . ".png" : '', 'U_DELETE' => $this->u_action . '&amp;action=deleterole&amp;role_id=' . $role['role_id'] . '&amp;' . URI_GAME . "=" . $editgame->game_id, 'U_EDIT' => $this->u_action . '&amp;action=editrole&amp;role_id=' . $role['role_id'] . '&amp;' . URI_GAME . "=" . $editgame->game_id));
     }
     // list the classes
     $sort_order2 = array(0 => array('c.game_id asc, c.class_id asc', 'c.game_id desc, c.class_id asc'), 1 => array('class_id', 'class_id desc'), 2 => array('class_name', 'class_name desc'), 3 => array('class_armor_type', 'class_armor_type, class_id desc'), 4 => array('class_min_level', 'class_min_level, class_id desc'), 5 => array('class_max_level', 'class_max_level, class_id desc'));
     $current_order2 = $this->switch_order($sort_order2, "o1");
     $total_classes = 0;
     $listclasses = new \bbdkp\controller\games\Classes();
     $listclasses->game_id = $editgame->game_id;
     $cl = $listclasses->listclasses($current_order2['sql'], 1);
     foreach ($cl as $c_index => $class) {
         $total_classes++;
         $template->assign_block_vars('class_row', array('GAME' => $class['game_name'], 'C_INDEX' => $c_index, 'CLASSID' => $class['class_id'], 'CLASSNAME' => $class['class_name'], 'COLORCODE' => $class['colorcode'], 'CLASSARMOR' => isset($user->lang[$class['class_armor_type']]) ? $user->lang[$class['class_armor_type']] : ' ', 'CLASSMIN' => $class['class_min_level'], 'CLASSMAX' => $class['class_max_level'], 'CLASSHIDE' => $class['class_hide'], 'S_CLASS_IMAGE_EXISTS' => strlen($class['imagename']) > 1 ? true : false, 'CLASSIMAGE' => strlen($class['imagename']) > 1 ? $phpbb_root_path . "images/bbdkp/class_images/" . $class['imagename'] . ".png" : '', 'U_VIEW_CLASS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=addclass&amp;r=" . $class['class_id'] . "&amp;game_id={$listclasses->game_id}"), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;classdelete=1&amp;id={$class['class_id']}&amp;game_id={$listclasses->game_id}"), 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;classedit=1&amp;id={$class['class_id']}&amp;game_id={$listclasses->game_id}")));
     }
     unset($listclasses, $cl);
     $imgexists = file_exists($phpbb_root_path . 'images/bbdkp/gameworld/' . $editgame->game_id . '/' . $editgame->getImagename() . '.png');
     //set the other fields
     $template->assign_vars(array('F_ENABLEARMORY' => $editgame->getArmoryEnabled(), 'GAMEIMAGEEXPLAIN' => sprintf($user->lang['GAME_IMAGE_EXPLAIN'], $editgame->game_id), 'GAMEIMAGE' => $editgame->getImagename(), 'GAME_NAME' => $editgame->getName(), 'GAMEPATH' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $editgame->game_id . '/' . $editgame->getImagename() . '.png', 'S_GAMEIMAGE_EXISTS' => strlen($editgame->getImagename()) > 0 && $imgexists ? true : false, 'EDITGAME' => sprintf($user->lang['ACP_EDITGAME'], $editgame->getName()), 'BOSSBASEURL' => $editgame->getBossbaseurl(), 'ZONEBASEURL' => $editgame->getZonebaseurl(), 'ISWOW' => $editgame->game_id == 'wow' ? 1 : 0, 'APIKEY' => $editgame->getApikey(), 'PRIVKEY' => $editgame->getPrivkey(), 'LOCALE' => $editgame->getApilocale(), 'GAME_ID' => $editgame->game_id, 'URI_GAME' => URI_GAME, 'O_RACEGAMEID' => $current_order['uri'][0], 'O_RACEID' => $current_order['uri'][1], 'O_RACENAME' => $current_order['uri'][2], 'O_FACTIONNAME' => $current_order['uri'][3], 'O_CLASSGAMEID' => $current_order2['uri'][0], 'O_CLASSID' => $current_order2['uri'][1], 'O_CLASSNAME' => $current_order2['uri'][2], 'O_CLASSARMOR' => $current_order2['uri'][3], 'O_CLASSMIN' => $current_order2['uri'][4], 'O_CLASSMAX' => $current_order2['uri'][5], 'U_ADD_GAMES' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&amp;mode=editgames&amp;"), 'LISTFACTION_FOOTCOUNT' => sprintf($user->lang['LISTFACTION_FOOTCOUNT'], $total_factions), 'LISTRACE_FOOTCOUNT' => sprintf($user->lang['LISTRACE_FOOTCOUNT'], $total_races), 'LISTCLASS_FOOTCOUNT' => sprintf($user->lang['LISTCLASS_FOOTCOUNT'], $total_classes), 'LISTROLES_FOOTCOUNT' => sprintf($user->lang['LISTROLES_FOOTCOUNT'], $total_roles), 'U_ACTION' => $this->u_action));
 }