From de71b6f44afd93d5888ee3873542b64c6d561aba Mon Sep 17 00:00:00 2001 From: God Mod Date: Fri, 3 Apr 2015 23:53:25 +0200 Subject: [PATCH] #1091 --- admin/settings.php | 3 +- includes/rli_raid.class.php | 82 +++++++++++++++++-- .../update_raidlogimport_0703.class.php | 65 +++++++++++++++ language/english/lang_main.php | 3 +- language/german/lang_main.php | 2 + raidlogimport_plugin_class.php | 4 +- 6 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 includes/updates/update_raidlogimport_0703.class.php diff --git a/admin/settings.php b/admin/settings.php index 6cfd4a0..13ea257 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -34,7 +34,7 @@ class RLI_Settings extends page_generic { 'standby' => array('standby_raid') ), 'yes_no' => array( - 'general' => array('deactivate_adj', 'itempool_save', 'no_del_warn'), + 'general' => array('deactivate_adj', 'itempool_save', 'no_del_warn', 'autocreate_zones', 'autocreate_bosses'), 'difficulty' => array('dep_match'), 'att' => array('attendance_raid'), #'am' => array('auto_minus', 'am_value_raids', 'am_allxraids'), @@ -88,6 +88,7 @@ public function update() { } else { $data[$old_name] = $this->in->get($old_name, ''); } + if(isset($data[$old_name]) AND $data[$old_name] != $old_value) { //Update $this->config->set($old_name, $data[$old_name], 'raidlogimport'); $this->rli->reload_config(); diff --git a/includes/rli_raid.class.php b/includes/rli_raid.class.php index 8e25cb6..4a92187 100644 --- a/includes/rli_raid.class.php +++ b/includes/rli_raid.class.php @@ -248,9 +248,11 @@ public function display($with_form=false) { $this->bk_list = $this->pdh->aget('rli_boss', 'html_note', 0, array($this->pdh->get('rli_boss', 'id_list'), false)); asort($this->bk_list); } + $last_key = 0; ksort($this->raids); $this->tpl->add_js("var boss_keys = new Array();", 'docready'); + foreach($this->raids as $ky => $rai) { if(isset($this->data['add']) && $ky == $this->data['add']['standby_raid'] && $this->config('standby_raid') == 0) { continue; @@ -300,12 +302,29 @@ public function display($with_form=false) { if(is_numeric($bk['id'])) { $name_field = new hdropdown('raids['.$ky.'][bosskills]['.$xy.'][id]', array('options' => $this->bk_list, 'value' => $bk['id'], 'id' => 'a'.unique_id())); } else { - $name_field = $bk['id']; - $params = "&string=' + $('#id_".$html_id."').val() + '&bonus=' + $('#bonus_".$html_id."').val() + '&timebonus=' + $('#timebonus_".$html_id."').val() + '&diff=' + $('#diff_".$html_id."').val()"; - $params .= " + '¬e=' + $('#id_".$html_id."').val()"; - $onclosejs = "$('#onclose_submit').removeAttr('disabled'); $('#form_rli_bz').submit();"; - $this->jquery->Dialog($html_id, $this->user->lang('bz_import_boss'), array('url' => "bz.php".$this->SID."&simple_head=simple&upd=true".$params." + '&", 'width' => 1200, 'onclosejs' => $onclosejs)); - $import = true; + $intBossID = $this->pdh->get('rli_boss', 'id_string', array($bk['id'], $bk['diff'])); + if(!$intBossID && (int)$this->config('autocreate_bosses')){ + //Auto generate Boss + $zoneID = $this->pdh->get('rli_zone', 'id_string', array($rai['zone'], $rai['diff'])); + + if($zoneID){ + $intBossID = $this->pdh->put('rli_boss', 'add', array($bk['id'], $bk['id'], $bk['bonus'], $bk['timebonus'], $bk['diff'], $zoneID)); + $this->pdh->process_hook_queue(); + + $this->bk_list = $this->pdh->aget('rli_boss', 'html_note', 0, array($this->pdh->get('rli_boss', 'id_list'), false)); + asort($this->bk_list); + } + } + if($intBossID){ + $name_field = new hdropdown('raids['.$ky.'][bosskills]['.$xy.'][id]', array('options' => $this->bk_list, 'value' => $intBossID, 'id' => 'a'.unique_id())); + } else { + $name_field = $bk['id']; + $params = "&string=' + $('#id_".$html_id."').val() + '&bonus=' + $('#bonus_".$html_id."').val() + '&timebonus=' + $('#timebonus_".$html_id."').val() + '&diff=' + $('#diff_".$html_id."').val()"; + $params .= " + '¬e=' + $('#id_".$html_id."').val()"; + $onclosejs = "$('#onclose_submit').removeAttr('disabled'); $('#form_rli_bz').submit();"; + $this->jquery->Dialog($html_id, $this->user->lang('bz_import_boss'), array('url' => "bz.php".$this->SID."&simple_head=simple&upd=true".$params." + '&", 'width' => 1200, 'onclosejs' => $onclosejs)); + $import = true; + } } $this->tpl->assign_block_vars('raids.bosskills', array( 'BK_SELECT' => $name_field, @@ -722,7 +741,7 @@ private function get_bosskills($begin, $end) { $bosskills[$b]['id'] = $id; $bosskills[$b]['bonus'] = $this->pdh->get('rli_boss', 'bonus', array($id)); $bosskills[$b]['timebonus'] = $this->pdh->get('rli_boss', 'timebonus', array($id)); - } else { + } else { $bosskills[$b]['id'] = $bosskill['name']; $bosskills[$b]['bonus'] = 0; $bosskills[$b]['timebonus'] = 0; @@ -760,6 +779,7 @@ private function get_bosskill_raidtime($begin, $end, $bosskill, $bosskill_before } private function get_event($key) { + if($this->config('event_boss') & 1 AND count($this->raids[$key]['bosskills']) == 1 AND $this->config('raidcount') & 2) { $id = 0; $bosskill = $this->raids[$key]['bosskills'][0]; @@ -768,7 +788,35 @@ private function get_event($key) { $bosskills[$b]['diff'] = $this->diff; } if(!$id) $id = $this->pdh->get('rli_boss', 'id_string', array($bosskill['name'], $bosskill['diff'])); + $event = $this->pdh->get('rli_boss', 'note', array($id)); + if(!is_numeric($event)){ + //Try to get event + $events = $this->pdh->aget('event', 'name', 0, array($this->pdh->get('event', 'id_list'))); + $eventID = 0; + foreach($events as $zid => $zone) { + if($zone === $event) { + $eventID = $zid; + break; + } + } + //Auto create Event + if(!$eventID && (int)$this->config('autocreate_bosses')){ + $eventID = $this->pdh->put('event', 'add_event', array($bosskill['name'], 0, '')); + $event = $eventID; + } + $event = $eventID; + //Auto create Boss + $zoneid = $this->pdh->get('rli_zone', 'id_string', array(trim($this->raids[$key]['zone']), $this->raids[$key]['diff'])); + //Auto create Zone + if(!$zoneid && (int)$this->config('autocreate_zones')){ + $zoneid = $this->pdh->put('rli_zone', 'add', array(trim($this->raids[$key]['zone']), 1, 0.0, $this->raids[$key]['diff'])); + } + if($zoneid){ + $this->pdh->put('rli_boss', 'add', array($bosskill['name'], $event, 0.0, 0.0, $bosskill['diff'], $zoneid)); + $this->pdh->process_hook_queue(); + } + } $this->raids[$key]['eventval'] = $this->pdh->get('event', 'value', array($event)); if($this->config('raidcount') & 1) { $this->raids[$key]['timebonus'] = 0; @@ -777,6 +825,25 @@ private function get_event($key) { } } else { $id = $this->pdh->get('rli_zone', 'id_string', array(trim($this->raids[$key]['zone']), $this->raids[$key]['diff'])); + //Auto create Zone + if(!$id && (int)$this->config('autocreate_zones')){ + //Try to get event + $zones = $this->pdh->aget('event', 'name', 0, array($this->pdh->get('event', 'id_list'))); + $eventID = 0; + foreach($zones as $zid => $zone) { + if(strpos($zone, trim($this->raids[$key]['zone'])) !== false) { + $eventID = $zid; + break; + } + } + //Create new Event for this Zone + if(!$eventID) $eventID = $this->pdh->put('event', 'add_event', array(trim($this->raids[$key]['zone']), 0, '')); + if($eventID){ + $id = $this->pdh->put('rli_zone', 'add', array(trim($this->raids[$key]['zone']), $eventID, 0.0, $this->raids[$key]['diff'])); + $this->pdh->process_hook_queue(); + } + } + if(($this->config('raidcount') & 1 AND $this->config('raidcount') & 2 AND count($this->raids[$key]['bosskills']) == 1) OR !$id) { $this->raids[$key]['timebonus'] = 0; } else { @@ -786,6 +853,7 @@ private function get_event($key) { $event = $this->pdh->get('rli_zone', 'event', array($id)); $this->raids[$key]['eventval'] = $this->pdh->get('event', 'value', array($event)); } + return $event; } diff --git a/includes/updates/update_raidlogimport_0703.class.php b/includes/updates/update_raidlogimport_0703.class.php new file mode 100644 index 0000000..bafdbd8 --- /dev/null +++ b/includes/updates/update_raidlogimport_0703.class.php @@ -0,0 +1,65 @@ +. + */ + +if(!defined('EQDKP_INC')) { + header('HTTP/1.0 Not Found'); + exit; +} + +include_once(registry::get_const('root_path').'maintenance/includes/sql_update_task.class.php'); +if (!class_exists('update_raidlogimport_0703')) { +class update_raidlogimport_0703 extends sql_update_task { + public $author = 'Hoofy'; + public $version = '0.7.0.3'; + public $name = 'Raidlogimport 0.7.0.3 Update'; + public $type = 'plugin_update'; + public $plugin_path = 'raidlogimport'; + + private $data = array(); + + public static function __shortcuts() { + $shortcuts = array('config'); + return array_merge(parent::__shortcuts(), $shortcuts); + } + + // init language + public $langs = array( + 'english' => array( + 'update_raidlogimport_0703' => 'Raidlogimport 0.7.0.3 Update Package', + 'update_function' => 'Added configs', + ), + 'german' => array( + 'update_raidlogimport_0703' => 'Raidlogimport 0.7.0.3 Update Package', + 'update_function' => 'Configs hinzugefügt', + ), + ); + + public function update_function() { + $cfgs = array('autocreate_bosses', 'autocreate_zones'); + foreach($cfgs as $cfg) { + $this->config->set($cfg, 1, 'raidlogimport'); + } + return true; + } +} +} + +?> \ No newline at end of file diff --git a/language/english/lang_main.php b/language/english/lang_main.php index 5e2056d..456cd8d 100644 --- a/language/english/lang_main.php +++ b/language/english/lang_main.php @@ -264,7 +264,8 @@ "no_del_warn" => 'Dont show warnings on deletion?', "p_rli_zone_display" => 'Which zones shall be displayed?', "dkpvals" => 'DKP-Values', - + 'autocreate_zones' => 'Create zones automatically, if they don\'t exist', + 'autocreate_bosses' =>'Create bosses automatically, if they don\'t exist', ); ?> \ No newline at end of file diff --git a/language/german/lang_main.php b/language/german/lang_main.php index 9f9e350..1fdc7b3 100644 --- a/language/german/lang_main.php +++ b/language/german/lang_main.php @@ -265,6 +265,8 @@ $lang['autocomplete_1'] = 'Mitgliedsname'; $lang['autocomplete_2'] = 'Itemname'; $lang['no_del_warn'] = 'Keine Warnung beim Löschen anzeigen'; + $lang['autocreate_zones'] = 'Zonen automatisch Erstellen, sofern noch nicht vorhanden'; + $lang['autocreate_bosses'] = 'Bosse automatisch Erstellen, sofern noch nicht vorhanden'; //portal $lang['p_rli_zone_display'] = 'Welche Zonen sollen angezeigt werden?'; diff --git a/raidlogimport_plugin_class.php b/raidlogimport_plugin_class.php index c691152..5db838e 100644 --- a/raidlogimport_plugin_class.php +++ b/raidlogimport_plugin_class.php @@ -30,7 +30,7 @@ public static function __shortcuts() { } public $vstatus = 'Beta'; - public $version = '0.7.0.2'; + public $version = '0.7.0.3'; protected static $apiLevel = 20; @@ -131,6 +131,8 @@ private function create_default_configs() { 'itempool_save' => '1', //save itempool per item & event 'del_dbl_times' => '0', //delete double leave/joins 'autocomplete' => '0', //auto-complete fields (1 member, 2 items) + 'autocreate_zones' => 0, + 'autocreate_bosses' => 0, ); if(strtolower($this->config->get('default_game')) == 'wow') { $config_data = array_merge($config_data, array(