Esempio n. 1
0
 /**
  * main acp function
  * @param integer $id
  * @param string $mode
  */
 public function main($id, $mode)
 {
     global $user, $config, $template, $db, $phpbb_admin_path, $phpEx;
     $this->tpl_name = 'dkp/acp_' . $mode;
     $this->link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_recruit&amp;mode=listrecruit") . '"><h3>' . $user->lang['RETURN_RECLIST'] . '</h3></a>';
     $this->apply_installed = false;
     $plugin_versioninfo = (array) parent::get_plugin_info(request_var('versioncheck_force', false));
     if (isset($plugin_versioninfo['apply'])) {
         $this->apply_installed = true;
     }
     $guild_id = request_var(URI_GUILD, 1);
     $Guild = new \bbdkp\controller\guilds\Guilds();
     $guildlist = $Guild->guildlist(1);
     foreach ($guildlist as $g) {
         $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $guild_id == $g['id'] ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
     }
     $Guild->guildid = $guild_id;
     $Guild->Getguild();
     $template->assign_vars(array('APPLY_INSTALLED' => $this->apply_installed ? 1 : 0, 'GUILD_EMBLEM' => $Guild->emblempath, 'U_VIEW_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&amp;mode=editguild&amp;" . URI_GUILD . '=' . $Guild->guildid), 'U_ADDRECRUIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_recruit&amp;mode=addrecruit&amp;" . URI_GUILD . '=' . $Guild->guildid), 'U_RECRUITLIST' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_recruit&amp;mode=listrecruit&amp;" . URI_GUILD . '=' . $Guild->guildid), 'U_EDITRECRUIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_recruit&amp;mode=editrecruit"), 'U_LIST_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&amp;mode=listguilds")));
     switch ($mode) {
         /***************************************
          * List recruitments
          ***************************************/
         case 'listrecruit':
             $this->BuildTemplateListRecruits($guild_id);
             break;
             /*************************************
              *  Add recruit
              *************************************/
         /*************************************
          *  Add recruit
          *************************************/
         case 'addrecruit':
             $recruit = new \bbdkp\controller\guilds\Recruitment();
             $recruit->setGuildId($Guild->guildid);
             $recruit->setLastUpdate($this->time);
             $add = isset($_POST['add']) ? true : false;
             $update = isset($_POST['update']) ? true : false;
             $action = request_var('action', '');
             if ($this->apply_installed) {
                 //if apply is installed then fetch list of templates
                 $result = $db->sql_query('SELECT * FROM ' . APPTEMPLATELIST_TABLE);
                 $templates = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     $templates[$row['template_id']] = $row['template_name'];
                 }
                 $db->sql_freeresult($result);
             }
             if ($action == 'delete') {
                 $recruit->id = request_var('id', 0);
                 $recruit->get($recruit->id);
                 $recruit->delete();
                 $success_message = sprintf($user->lang['ADMIN_DELETE_RECRUITMENT_SUCCESS'], $recruit->id);
                 trigger_error($success_message . $this->link, E_USER_WARNING);
             } elseif ($action == 'edit') {
                 $recruit->id = request_var('id', 0);
                 $recruit->get($recruit->id);
                 $template->assign_vars(array('S_UPDATE' => true, 'RECRUIT_ID' => $recruit->id, 'RECSTATUS' => $recruit->getStatus() == '1' ? 'checked="checked"' : '', 'RECRUIT_STATUS' => $recruit->getStatus() == '1' ? $user->lang['RECRUIT_OPEN'] : $user->lang['RECRUIT_CLOSED'], 'NUMPOSITIONS' => $recruit->getPositions(), 'APPLICANTS' => $recruit->getApplicants(), 'RECRUIT_LEVEL' => $recruit->getLevel(), 'APPLICANTS' => $recruit->getApplicants(), 'NOTE' => $recruit->getNote()));
             } else {
                 //add
                 $template->assign_vars(array('RECSTATUS' => 'checked="checked"', 'S_ADD' => true, 'NUMPOSITIONS' => '1', 'RECRUIT_LEVEL' => $Guild->min_armory));
             }
             if ($this->apply_installed) {
                 foreach ($templates as $template_id => $value) {
                     $template->assign_block_vars('applytemplates_row', array('VALUE' => $template_id, 'SELECTED' => $template_id == $recruit->getApplytemplateid() ? ' selected="selected"' : '', 'OPTION' => $value));
                 }
             }
             if ($add || $update) {
                 if (!check_form_key('addrecruit')) {
                     trigger_error('FORM_INVALID');
                 }
                 $recruit->id = request_var('hidden_recruit_id', 0);
                 $recruit->role_id = request_var('role', 0);
                 $recruit->setClassId(request_var('class_id', 0));
                 $recruit->setPositions(request_var('numpositions', 0));
                 $recruit->setApplicants(request_var('applicants', 0));
                 $recruit->setStatus(request_var('recruitstatus', '') == 'on' ? 1 : 0);
                 $recruit->setLevel(request_var('recruit_level', 0));
                 $recruit->setNote(utf8_normalize_nfc(request_var('note', '', true)));
                 $recruit->setApplytemplateid(request_var('applytemplateid', 1));
             }
             if ($add) {
                 $recruit->Make();
                 $success_message = sprintf($user->lang['ADMIN_ADD_RECRUITMENT_SUCCESS'], $recruit->id);
                 trigger_error($success_message . $this->link, E_USER_NOTICE);
             } elseif ($update) {
                 $recruit->update();
                 $success_message = sprintf($user->lang['ADMIN_UPDATE_RECRUITMENT_SUCCESS'], $recruit->id);
                 trigger_error($success_message . $this->link, E_USER_NOTICE);
             } else {
                 $this->BuildDropDowns($Guild, $recruit);
             }
             $form_key = 'addrecruit';
             add_form_key($form_key);
             $this->page_title = $user->lang['ACP_ADDRECRUITS'];
             break;
         default:
             $this->page_title = 'ACP_DKP_MAINPAGE';
             $success_message = 'Error';
             trigger_error($success_message . $this->link, E_USER_WARNING);
     }
 }
Esempio n. 2
0
 /**
  *
  * list the guilds
  */
 private function BuildTemplateListGuilds()
 {
     global $user, $template, $phpbb_admin_path, $phpEx, $db;
     if (count($this->games) == 0) {
         trigger_error($user->lang['ERROR_NOGAMES'], E_USER_WARNING);
     }
     $updateguild = new \bbdkp\controller\guilds\Guilds();
     $guildlist = $updateguild->guildlist(1);
     foreach ($guildlist as $g) {
         $template->assign_block_vars('defaultguild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['guilddefault'] == '1' ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
     }
     $guilddefaultupdate = isset($_POST['upddefaultguild']) ? true : false;
     if ($guilddefaultupdate) {
         $this->UpdateDefaultGuild($updateguild);
     }
     $guildadd = isset($_POST['addguild']) ? true : false;
     if ($guildadd) {
         redirect(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&amp;mode=addguild"));
     }
     $sort_order = array(0 => array('id', 'id desc'), 1 => array('name', 'name desc'), 2 => array('realm desc', 'realm desc'), 3 => array('region', 'region desc'), 4 => array('roster', 'roster desc'));
     $current_order = $this->switch_order($sort_order);
     $guild_count = 0;
     $previous_data = '';
     $sort_index = explode('.', $current_order['uri']['current']);
     $previous_source = preg_replace('/( (asc|desc))?/i', '', $sort_order[$sort_index[0]][$sort_index[1]]);
     $show_all = isset($_GET['show']) && request_var('show', '') == 'all' ? true : false;
     $sql = 'SELECT id, name, realm, region, roster, game_id FROM ' . GUILD_TABLE . ' WHERE id > 0 ORDER BY ' . $current_order['sql'];
     if (!($guild_result = $db->sql_query($sql))) {
         trigger_error($user->lang['ERROR_GUILDNOTFOUND'], E_USER_WARNING);
     }
     $lines = 0;
     while ($row = $db->sql_fetchrow($guild_result)) {
         $guild_count++;
         $listguild = new \bbdkp\controller\guilds\Guilds($row['id']);
         $template->assign_block_vars('guild_row', array('ID' => $listguild->guildid, 'NAME' => $listguild->name, 'REALM' => $listguild->realm, 'REGION' => $listguild->region, 'GAME' => $listguild->game_id, 'MEMBERCOUNT' => $listguild->membercount, 'SHOW_ROSTER' => $listguild->showroster == 1 ? 'yes' : 'no', 'U_VIEW_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&amp;mode=editguild&amp;" . URI_GUILD . '=' . $listguild->guildid)));
         $previous_data = $row[$previous_source];
     }
     $form_key = 'listguilds';
     add_form_key($form_key);
     $template->assign_vars(array('U_GUILDLIST' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild") . '&amp;mode=listguilds', 'U_ADDGUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild") . '&amp;mode=addguild', 'U_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild") . '&amp;mode=editguild', 'L_TITLE' => $user->lang['ACP_LISTGUILDS'], 'L_EXPLAIN' => $user->lang['ACP_LISTGUILDS_EXPLAIN'], 'BUTTON_VALUE' => $user->lang['DELETE_SELECTED_GUILDS'], 'O_ID' => $current_order['uri'][0], 'O_NAME' => $current_order['uri'][1], 'O_REALM' => $current_order['uri'][2], 'O_REGION' => $current_order['uri'][3], 'O_ROSTER' => $current_order['uri'][4], 'U_LIST_GUILD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_guild&amp;mode=listguilds"), 'GUILDMEMBERS_FOOTCOUNT' => sprintf($user->lang['GUILD_FOOTCOUNT'], $guild_count)));
     $this->page_title = 'ACP_LISTGUILDS';
 }
Esempio n. 3
0
$db->sql_query($sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
    $text = $row['welcome_msg'];
    $bbcode_uid = $row['bbcode_uid'];
    $bbcode_bitfield = $row['bbcode_bitfield'];
    $bbcode_options = $row['bbcode_options'];
}
$db->sql_freeresult($result);
$message = generate_text_for_display($text, $bbcode_uid, $bbcode_bitfield, $bbcode_options);
$message = smiley_text($message);
// Include the abstract base
if (!class_exists('\\bbdkp\\controller\\guilds\\Guilds')) {
    require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Guilds.{$phpEx}";
}
$guild = new Guilds(1);
$data = $guild->GetApiInfo(array('news'));
$guild->GetGuildNews($data);
$newsarr = $guild->guildnews;
$i = 0;
if (isset($newsarr)) {
    foreach ($newsarr as $id => $news) {
        $i++;
        switch ($news['type']) {
            case 'itemCraft':
            case 'itemLoot':
                $template->assign_block_vars('activityfeed', array('TYPE' => 'ITEM', 'ID' => $id, 'VERB' => $user->lang('LOOTED'), 'CHARACTER' => $news['character'], 'TIMESTAMP' => !empty($news['timestamp']) ? dateDiff($news['timestamp']) . '&nbsp;' : '&nbsp;', 'ITEM' => isset($news['itemId']) ? $news['itemId'] : '', 'CONTEXT' => $news['context']));
                break;
            case 'playerAchievement':
                $template->assign_block_vars('activityfeed', array('TYPE' => 'ACHI', 'ID' => $id, 'VERB' => $user->lang('ACHIEVED'), 'CHARACTER' => $news['character'], 'TIMESTAMP' => !empty($news['timestamp']) ? dateDiff($news['timestamp']) . '&nbsp;' : '&nbsp;', 'ACHIEVEMENT' => $news['achievement']['id'], 'TITLE' => $news['achievement']['title'], 'POINTS' => sprintf($user->lang['FORNPOINTS'], $news['achievement']['points'])));
                break;
Esempio n. 4
0
 /**
  * @param $updateguild
  * @param $updateArmory
  * @return void
  */
 private function UpdateGuild(\bbdkp\controller\guilds\Guilds $updateguild, $updateArmory)
 {
     global $user;
     $updateguild->guildid = $this->url_id;
     $updateguild->Getguild();
     $old_guild = new \bbdkp\controller\guilds\Guilds($this->url_id);
     $old_guild->Getguild();
     $updateguild->game_id = request_var('game_id', '');
     $updateguild->name = utf8_normalize_nfc(request_var('guild_name', '', true));
     $updateguild->realm = utf8_normalize_nfc(request_var('realm', '', true));
     $updateguild->region = request_var('region_id', ' ');
     $updateguild->showroster = request_var('showroster', 0);
     $updateguild->min_armory = request_var('min_armorylevel', 0);
     $updateguild->recstatus = request_var('switchon_recruitment', 0);
     $updateguild->armory_enabled = request_var('armory_enabled', 0);
     $updateguild->recruitforum = request_var('recruitforum', 0);
     //in the request we expect the file name here including extension, no path
     $updateguild->emblempath = "images/bbdkp/guildemblem/" . utf8_normalize_nfc(request_var('guild_emblem', '', true));
     $updateguild->aionlegionid = 0;
     $updateguild->aionserverid = 0;
     $GuildAPIParameters = array();
     if ($updateArmory) {
         $GuildAPIParameters = array('members');
     }
     if ($updateguild->Guildupdate($old_guild, $GuildAPIParameters)) {
         $success_message = sprintf($user->lang['ADMIN_UPDATE_GUILD_SUCCESS'], $this->url_id);
         trigger_error($success_message . $this->link, E_USER_NOTICE);
     } else {
         $success_message = sprintf($user->lang['ADMIN_UPDATE_GUILD_FAILED'], $this->url_id);
         trigger_error($success_message . $this->link, E_USER_WARNING);
     }
 }