1 | <?php |
---|
2 | // for easier patching |
---|
3 | |
---|
4 | // Note: DO UPDATES ALWAYS OVER THE ITEM NAMES, SO NO KB's |
---|
5 | // DATABASES GET SCREWED UP. |
---|
6 | // |
---|
7 | // |
---|
8 | if (!config::get("DBUpdate")) |
---|
9 | config::set("DBUpdate","000"); |
---|
10 | |
---|
11 | // Current update version of Database |
---|
12 | define(CURRENT_DB_UPDATE,config::get("DBUpdate")); |
---|
13 | //Update version of this autoupgrade.php |
---|
14 | define(LASTEST_DB_UPDATE,"002"); |
---|
15 | |
---|
16 | function updateDB(){ |
---|
17 | // if update nesseary run updates |
---|
18 | if (CURRENT_DB_UPDATE < LASTEST_DB_UPDATE ){ |
---|
19 | update001(); |
---|
20 | update002(); |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | function update001(){ |
---|
25 | //Checking if this Update already done |
---|
26 | if (CURRENT_DB_UPDATE < "001" ) |
---|
27 | { |
---|
28 | require_once("common/includes/class.item.php"); |
---|
29 | // Changing ShieldBooster Slot from None to Mid Slot |
---|
30 | $ShieldBoosterGroup = item::get_group_id("Small Shield Booster I"); |
---|
31 | update_slot_of_group($ShieldBoosterGroup,0,2); |
---|
32 | |
---|
33 | // Changing Tracking Scripts Slot from None to Mid Slot |
---|
34 | $ScriptGroupID1 = item::get_group_id("Optimal Range"); |
---|
35 | update_slot_of_group($ScriptGroupID1,0,2); |
---|
36 | |
---|
37 | // Changing Warp Disruption Scripts Slot from None to Mid Slot |
---|
38 | $ScriptGroupID2 = item::get_group_id("Focused Warp Disruption"); |
---|
39 | update_slot_of_group($ScriptGroupID2,0,2); |
---|
40 | |
---|
41 | // Changing Tracking Disruption Scripts Slot from None to Mid Slot |
---|
42 | $ScriptGroupID3 = item::get_group_id("Optimal Range Disruption"); |
---|
43 | update_slot_of_group($ScriptGroupID3,0,2); |
---|
44 | |
---|
45 | // Changing Sensor Booster Scripts Slot from None to Mid Slot |
---|
46 | $ScriptGroupID4 = item::get_group_id("Targeting Range"); |
---|
47 | update_slot_of_group($ScriptGroupID4,0,2); |
---|
48 | |
---|
49 | // Changing Sensor Dampener Scripts Slot from None to Mid Slot |
---|
50 | $ScriptGroupID5 = item::get_group_id("Scan Resolution Dampening"); |
---|
51 | update_slot_of_group($ScriptGroupID5,0,2); |
---|
52 | |
---|
53 | // Changing Energy Weapon Slot from None to High Slot |
---|
54 | $EnergyWeaponGroup = item::get_group_id("Gatling Pulse Laser I"); |
---|
55 | update_slot_of_group($EnergyWeaponGroup,0,1); |
---|
56 | |
---|
57 | // Changing Group of Salvager I to same as Small Tractor Beam I |
---|
58 | $item = new Item(); |
---|
59 | $item->lookup("Salvager I"); |
---|
60 | $SalvagerTypeId = $item->getId(); |
---|
61 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
62 | $TractorBeam = item::get_group_id("Small Tractor Beam I"); |
---|
63 | move_item_to_group($SalvagerTypeId,$SalvagerGroup ,$TractorBeam); |
---|
64 | |
---|
65 | //writing Update Status into ConfigDB |
---|
66 | config::set("DBUpdate","001"); |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | function update002(){ |
---|
71 | // to correct the already existing Salvager in med slots. |
---|
72 | // missed it in update001 |
---|
73 | if (CURRENT_DB_UPDATE < "002" ) |
---|
74 | { |
---|
75 | require_once("common/includes/class.item.php"); |
---|
76 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
77 | update_slot_of_group($SalvagerGroup,2,1); |
---|
78 | config::set("DBUpdate","002"); |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | function update_slot_of_group($id,$oldSlot = 0 ,$newSlot){ |
---|
83 | $qry = new DBQuery(); |
---|
84 | $query = "UPDATE kb3_item_types |
---|
85 | SET itt_slot = $newSlot WHERE itt_id = $id and itt_slot = $oldSlot;"; |
---|
86 | $qry->execute($query); |
---|
87 | $query = "UPDATE kb3_items_destroyed |
---|
88 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
89 | SET itd_itl_id = $newSlot |
---|
90 | WHERE itd_itl_id = $oldSlot;"; |
---|
91 | $qry->execute($query); |
---|
92 | |
---|
93 | $query = "UPDATE kb3_items_dropped |
---|
94 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
95 | SET itd_itl_id = $newSlot |
---|
96 | WHERE itd_itl_id = $oldSlot;"; |
---|
97 | $qry->execute($query); |
---|
98 | } |
---|
99 | |
---|
100 | function move_item_to_group($id,$oldGroup ,$newGroup){ |
---|
101 | $qry = new DBQuery(); |
---|
102 | $query = "UPDATE kb3_invtypes |
---|
103 | SET groupID = $newGroup |
---|
104 | WHERE typeID = $id AND groupID = $oldGroup;"; |
---|
105 | $qry->execute($query); |
---|
106 | } |
---|
107 | |
---|
108 | ?> |
---|