Skip to content

Commit

Permalink
#1091
Browse files Browse the repository at this point in the history
  • Loading branch information
God Mod committed Apr 3, 2015
1 parent 17c7345 commit de71b6f
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 10 deletions.
3 changes: 2 additions & 1 deletion admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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();
Expand Down
82 changes: 75 additions & 7 deletions includes/rli_raid.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 .= " + '&note=' + $('#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 .= " + '&note=' + $('#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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
}

Expand Down
65 changes: 65 additions & 0 deletions includes/updates/update_raidlogimport_0703.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/* Project: EQdkp-Plus
* Package: RaidLogImport Plugin
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2015 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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;
}
}
}

?>
3 changes: 2 additions & 1 deletion language/english/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

?>
2 changes: 2 additions & 0 deletions language/german/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?';
Expand Down
4 changes: 3 additions & 1 deletion raidlogimport_plugin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit de71b6f

Please sign in to comment.