Beispiel #1
0
 /**
  *
  * delete a guild
  * @param $updateguild
  */
 private function DeleteGuild(\bbdkp\controller\guilds\Guilds $updateguild)
 {
     global $user, $template;
     if (confirm_box(true)) {
         $deleteguild = new \bbdkp\controller\guilds\Guilds(request_var('guildid', 0));
         $deleteguild->Getguild();
         $deleteguild->Guildelete();
         $success_message = sprintf($user->lang['ADMIN_DELETE_GUILD_SUCCESS'], $deleteguild->guildid);
         trigger_error($success_message . $this->link, E_USER_NOTICE);
     } else {
         $s_hidden_fields = build_hidden_fields(array('deleteguild' => true, 'guildid' => $updateguild->guildid));
         $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields));
         confirm_box(false, $user->lang['CONFIRM_DELETE_GUILD'], $s_hidden_fields);
     }
 }
Beispiel #2
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);
     }
 }
Beispiel #3
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);
     }
 }