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