From 19d4554ca41310dd70ed9d5399cf7a11ca439e87 Mon Sep 17 00:00:00 2001 From: Balfear Date: Wed, 29 Jun 2022 15:23:01 +0300 Subject: [PATCH 1/3] Added inventory action --- config/access.php | 4 +- config/application.php | 8 + lang/en_us.php | 8 + lib/Flux/Template.php | 20 ++ modules/item/inventory.php | 136 ++++++++++++ themes/default/account/view.php | 4 +- themes/default/character/view.php | 20 +- themes/default/guild/view.php | 10 +- themes/default/item/inventory.php | 331 ++++++++++++++++++++++++++++++ 9 files changed, 536 insertions(+), 5 deletions(-) create mode 100644 modules/item/inventory.php create mode 100644 themes/default/item/inventory.php diff --git a/config/access.php b/config/access.php index 54598d711..75da0dfb1 100644 --- a/config/access.php +++ b/config/access.php @@ -98,7 +98,8 @@ 'item' => array( 'index' => AccountLevel::ANYONE, 'view' => AccountLevel::ANYONE, - 'iteminfo' => AccountLevel::ADMIN + 'iteminfo' => AccountLevel::ADMIN, + 'inventory' => AccountLevel::ANYONE ), 'monster' => array( 'index' => AccountLevel::ANYONE, @@ -250,6 +251,7 @@ 'SeeAccountID' => AccountLevel::LOWGM, // Minimum group level required to see Account ID on account view and character view pages. 'SeeUnknownItems' => AccountLevel::LOWGM, // Minimum group level required to see unidentified items as identified. 'AvoidSexChangeCost' => AccountLevel::LOWGM, // Avoid paying cost (if any) for sex changes. + 'SeeItemUniqueID' => AccountLevel::LOWGM, // Ability to see item unique ID. 'EditHigherPower' => AccountLevel::NOONE, 'BanHigherPower' => AccountLevel::NOONE diff --git a/config/application.php b/config/application.php index d7978f36a..24eeb8d54 100644 --- a/config/application.php +++ b/config/application.php @@ -515,6 +515,14 @@ // Item random options. 'RandomOptions' => include('item_randoptions.php'), + // List of storages. + 'StorageTables' => array( + 'inventory', + 'cart_inventory', + 'storage', + 'guild_storage', + ), + // DON'T TOUCH. THIS IS FOR DEVELOPERS. 'FluxTables' => array( 'CreditsTable' => 'cp_credits', diff --git a/lang/en_us.php b/lang/en_us.php index 2ad69071a..f793a4780 100755 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -56,6 +56,7 @@ 'ItemCard2Label' => 'Slot 3', 'ItemCard3Label' => 'Slot 4', 'ItemRandOptionsLabel' => 'Random options', + 'EnchantGradeClass' => array( "D", "C", "B", "A"), //SIDEBAR //FluxCP Menu Items @@ -837,5 +838,12 @@ // Module: webcommands 'WCTitleLabel' => 'Web Commands', + //Storage names + 'StorageGroup' => array( + 'Inventory', + 'Cart Inventory', + 'Storage', + 'Guild Storage' + ), ); ?> diff --git a/lib/Flux/Template.php b/lib/Flux/Template.php index 490b5550c..cc403341e 100644 --- a/lib/Flux/Template.php +++ b/lib/Flux/Template.php @@ -958,6 +958,26 @@ public function linkToCharacter($charID, $text, $server = null) } } + /** + * $table: 0 - inventory table / 1 - cart inventory / 2 - storage table / 3 - guild storage + * It can be changed in application.php + */ + public function linkToInventoryItem($index, $text, $table = 0, $server = null) + { + if ($index) { + $params = array('type' => (int)$table, 'index' => $index); + if ($server) { + $params['preferred_server'] = $server; + } + + $url = $this->url('item', 'inventory', $params); + return sprintf('%s', $url, htmlspecialchars($text)); + } + else { + return false; + } + } + /** * Deny entry to a page if called. This method should be used from a module * script, and no where else. diff --git a/modules/item/inventory.php b/modules/item/inventory.php new file mode 100644 index 000000000..c6f6a4ac8 --- /dev/null +++ b/modules/item/inventory.php @@ -0,0 +1,136 @@ +get('type'); +$index = $params->get('index'); +$storageTable = Flux::config('StorageTables.'.$type); + +$title = 'Viewing '.htmlspecialchars(Flux::message('StorageGroup.'.$type)).' Item'; + +require_once 'Flux/TemporaryTable.php'; + +if($server->isRenewal) { + $fromTables = array("{$server->charMapDatabase}.item_db_re", "{$server->charMapDatabase}.item_db2_re"); +} else { + $fromTables = array("{$server->charMapDatabase}.item_db", "{$server->charMapDatabase}.item_db2"); +} +$tableName = "{$server->charMapDatabase}.items"; +$tempTable = new Flux_TemporaryTable($server->connection, $tableName, $fromTables); +$shopTable = Flux::config('FluxTables.ItemShopTable'); +$itemDescTable = Flux::config('FluxTables.ItemDescTable'); + +// Get item id from storage +$col = "nameid, refine, attribute, bound, unique_id, enchantgrade, "; +$col .= "card0, card1, card2, card3, "; +$col .= "option_id0, option_val0, option_id1, option_val1, option_id2, option_val2, option_id3, option_val3, option_id4, option_val4"; +$sql = "SELECT $col FROM {$server->charMapDatabase}.$storageTable WHERE id = ?"; +$sth = $server->connection->getStatement($sql); +$sth->execute(array($index)); +$itemData = $sth->fetch(); + +if($server->isRenewal) { + $temp = array(); + if ($itemData->option_id0) array_push($temp, array($itemData->option_id0, $itemData->option_val0)); + if ($itemData->option_id1) array_push($temp, array($itemData->option_id1, $itemData->option_val1)); + if ($itemData->option_id2) array_push($temp, array($itemData->option_id2, $itemData->option_val2)); + if ($itemData->option_id3) array_push($temp, array($itemData->option_id3, $itemData->option_val3)); + if ($itemData->option_id4) array_push($temp, array($itemData->option_id4, $itemData->option_val4)); + $itemData->rndopt = $temp; +} + +$itemID = $itemData->nameid; + +$job_list = array_keys($this->GetJobsList($server->isRenewal)); +$class_list = array_keys($this->GetClassList($server->isRenewal)); +$equip_list = array_keys(Flux::config('EquipLocations')->toArray()); +$trade_list = array_keys(Flux::config('TradeRestriction')->toArray()); + +$col = 'items.id AS item_id, name_aegis AS identifier, '; +$col .= 'name_english AS name, type, subtype, '; +$col .= 'price_buy, price_sell, weight/10 AS weight, attack, defense, `range`, slots, gender, '; +$col .= 'weapon_level, equip_level_min, equip_level_max, refineable, view, alias_name, '; +$col .= 'script, equip_script, unequip_script, origin_table, '; +$col .= implode(', ', $job_list).', '; // Job list +$col .= implode(', ', $class_list).', '; // Class list +$col .= implode(', ', $equip_list).', '; +$col .= implode(', ', $trade_list).', '; // Trade restriction list + +$col .= "$shopTable.cost, $shopTable.id AS shop_item_id, "; +if(Flux::config('ShowItemDesc')){ + $col .= 'itemdesc, '; +} +if($server->isRenewal) $col .= 'magic_attack, '; +$col .= 'origin_table'; + +$sql = "SELECT $col FROM {$server->charMapDatabase}.items "; +$sql .= "LEFT OUTER JOIN {$server->charMapDatabase}.$shopTable ON $shopTable.nameid = items.id "; +if(Flux::config('ShowItemDesc')){ + $sql .= "LEFT OUTER JOIN {$server->charMapDatabase}.$itemDescTable ON $itemDescTable.itemid = items.id "; +} +$sql .= "WHERE items.id = ? LIMIT 1"; + +$sth = $server->connection->getStatement($sql); +$sth->execute(array($itemID)); + +$item = $sth->fetch(); +$isCustom = null; + +if ($item) { + $title = "Viewing Item ($item->name)"; + $isCustom = (bool)preg_match('/item_db2$/', $item->origin_table); + + // Jobs + $jobs = array(); + foreach($job_list as $job) if($item->$job) $jobs[] = $job; + // Classes + $upper = array(); + foreach($class_list as $class) if($item->$class) $upper[] = $class; + // Equip location + $equip_locs = array(); + foreach($equip_list as $eq_loc) if($item->$eq_loc) $equip_locs[] = $eq_loc; + // Trade restrictions + $restrictions = array(); + foreach($trade_list as $trade) if($item->$trade) $restrictions[] = $trade; + + $cardIDs = array(); + $item_cards = array(); + + $itemData->cardsOver = -$item->slots; + + if ($itemData->card0) { + $cardIDs[] = $itemData->card0; + $itemData->cardsOver++; + } + if ($itemData->card1) { + $cardIDs[] = $itemData->card1; + $itemData->cardsOver++; + } + if ($itemData->card2) { + $cardIDs[] = $itemData->card2; + $itemData->cardsOver++; + } + if ($itemData->card3) { + $cardIDs[] = $itemData->card3; + $itemData->cardsOver++; + } + + if ($itemData->card0 == 254 || $itemData->card0 == 255 || $itemData->card0 == -256 || $itemData->cardsOver < 0) { + $itemData->cardsOver = 0; + } + + if ($cardIDs) { + $ids = implode(',', array_fill(0, count($cardIDs), '?')); + $sql = "SELECT id, name_english FROM {$server->charMapDatabase}.items WHERE id IN ($ids)"; + $sth = $server->connection->getStatement($sql); + + $sth->execute($cardIDs); + $temp = $sth->fetchAll(); + + if ($temp) { + foreach ($temp as $card) { + $item_cards[$card->id] = $card->name_english; + } + } + } +} +?> diff --git a/themes/default/account/view.php b/themes/default/account/view.php index 68e3f27ba..be449c3c2 100644 --- a/themes/default/account/view.php +++ b/themes/default/account/view.php @@ -276,7 +276,9 @@ class="block-link"> iconImage($item->nameid) ?> - actionAllowed('item', 'view')): ?> + actionAllowed('item', 'inventory')): ?> + linkToInventoryItem($item->id, $item->nameid, 2) ?> + actionAllowed('item', 'view')): ?> linkToItem($item->nameid, $item->nameid) ?> nameid) ?> diff --git a/themes/default/character/view.php b/themes/default/character/view.php index df8a73c1b..734e3fdf4 100644 --- a/themes/default/character/view.php +++ b/themes/default/character/view.php @@ -372,7 +372,15 @@ iconImage($item->nameid) ?> equip) echo ' class="equipped"' ?>> - linkToItem($item->nameid, $item->nameid) ?> + + actionAllowed('item', 'inventory')): ?> + linkToInventoryItem($item->id, $item->nameid, 0) ?> + actionAllowed('item', 'view')): ?> + linkToItem($item->nameid, $item->nameid) ?> + + nameid) ?> + + @@ -523,7 +531,15 @@ iconImage($cart_item->nameid) ?> - linkToItem($cart_item->nameid, $cart_item->nameid) ?> + + actionAllowed('item', 'inventory')): ?> + linkToInventoryItem($cart_item->id, $cart_item->nameid, 1) ?> + actionAllowed('item', 'view')): ?> + linkToItem($cart_item->nameid, $cart_item->nameid) ?> + + nameid) ?> + + diff --git a/themes/default/guild/view.php b/themes/default/guild/view.php index 1c234bea9..1d646d170 100644 --- a/themes/default/guild/view.php +++ b/themes/default/guild/view.php @@ -228,7 +228,15 @@ iconImage($item->nameid) ?> - linkToItem($item->nameid, $item->nameid) ?> + + actionAllowed('item', 'inventory')): ?> + linkToInventoryItem($item->id, $item->nameid, 0) ?> + actionAllowed('item', 'view')): ?> + linkToItem($item->nameid, $item->nameid) ?> + + nameid) ?> + + diff --git a/themes/default/item/inventory.php b/themes/default/item/inventory.php new file mode 100644 index 000000000..aa1df40a2 --- /dev/null +++ b/themes/default/item/inventory.php @@ -0,0 +1,331 @@ + +

Viewing Item

+ +iconImage($item->item_id); ?> +

+ + #item_id) ?>: name) ?> +

+ + + + + itemImage($item->item_id)): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + isRenewal): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + isRenewal): ?> + + + + + + allowedToSeeItemUniqueID): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + allowedToSeeItemDb2Scripts) || (!$isCustom && $auth->allowedToSeeItemDbScripts)): ?> + + + + + + + + + + + + + + + + + + + + +
Item IDitem_id) ?> + + For Sale + cost): ?> + + Yes + + + + No + + +
Identifieridentifier) ?>Credit Price + cost): ?> + cost) ?> + + Not For Sale + +
Namename) ?>TypeitemTypeText($item->type) ?>subtype) echo ' - '.$this->itemSubTypeText($item->type, $item->subtype) ?>
NPC Buyprice_buy) ?>Weightweight, 1) ?>
NPC Sell + price_sell) && $item->price_buy): ?> + price_buy / 2)) ?> + + price_sell) ?> + + Weapon Levelweapon_level) ?>
Rangerange) ?>Defensedefense) ?>
Slotsslots) ?>Refineable + refineable): ?> + Yes + + No + +
Attackattack) ?>Min Equip Level + equip_level_min == 0): ?> + None + + equip_level_min) ?> + +
MATKmagic_attack) ?>Max Equip Level + equip_level_max == 0): ?> + None + + equip_level_max) ?> + +
Slot 1 + card0 && ($itemData->type == $type_list['armor'] || $itemData->type == $type_list['weapon']) && $itemData->card0 != 254 && $itemData->card0 != 255 && $itemData->card0 != -256): ?> + card0])): ?> + linkToItem($itemData->card0, $item_cards[$itemData->card0]) ?> + + linkToItem($itemData->card0, $itemData->card0) ?> + + + None + + Slot 2 + card1 && ($itemData->type == $type_list['armor'] || $itemData->type == $type_list['weapon']) && $itemData->card0 != 255 && $itemData->card0 != -256): ?> + card1])): ?> + linkToItem($itemData->card1, $item_cards[$itemData->card1]) ?> + + linkToItem($itemData->card1, $itemData->card1) ?> + + + None + +
Slot 3 + card2 && ($itemData->type == $type_list['armor'] || $itemData->type == $type_list['weapon']) && $itemData->card0 != 254 && $itemData->card0 != 255 && $itemData->card0 != -256): ?> + card2])): ?> + linkToItem($itemData->card2, $item_cards[$itemData->card2]) ?> + + linkToItem($itemData->card2, $itemData->card2) ?> + + + None + + Slot 4 + card3 && ($itemData->type == $type_list['armor'] || $itemData->type == $type_list['weapon']) && $itemData->card0 != 254 && $itemData->card0 != 255 && $itemData->card0 != -256): ?> + card3])): ?> + linkToItem($itemData->card3, $item_cards[$itemData->card3]) ?> + + linkToItem($itemData->card3, $itemData->card3) ?> + + + None + +
Refine + refine ? "+".$itemData->refine : 0; ?> + Broken + attribute): ?> + Yes + + No + +
Enchant grade + enchantgrade): ?> + enchantgrade)); ?> + + None + +
Bound + bound == 1):?> + Account Bound + bound == 2):?> + Guild Bound + bound == 3):?> + Party Bound + bound == 4):?> + Character Bound + + None + +
Random options + rndopt): ?> +
    + rndopt as $rndopt) echo "
  • ".$this->itemRandOption($rndopt[0], $rndopt[1])."
  • "; ?> +
+ + None + +
Unique ID + unique_id == 0): ?> + None + + unique_id ?> + +
Equip Locations + equipLocations($equip_locs)): ?> + + + None + +
Equip Upper + equipUpper($upper)): ?> + equipUpper($upper))) ?> + + None + +
Equippable Jobs + equippableJobs($jobs)): ?> + equippableJobs($jobs))) ?> + + None + +
Equip Gender + gender == 'Female'): ?> + Female + gender == 'Male'): ?> + Male + gender == 'Both' || $item->gender == NULL): ?> + Both (Male and Female) + + None + +
Trade restriction + tradeRestrictions($restrictions)): ?> + tradeRestrictions($restrictions))) ?> + + None + +
Item Use Script + displayScript($item->script)): ?> + + + None + +
Equip Script + displayScript($item->equip_script)): ?> + + + None + +
Unequip Script + displayScript($item->unequip_script)): ?> + + + None + +
Description + itemdesc): ?> + itemdesc ?> + + None + +
+ +

No such item was found. Go back.

+ From 850090a66014fb07ea36c84061eb9416d05be8d6 Mon Sep 17 00:00:00 2001 From: Balfear Date: Wed, 29 Jun 2022 15:26:46 +0300 Subject: [PATCH 2/3] Update en_us.php --- lang/en_us.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en_us.php b/lang/en_us.php index f793a4780..f6400921f 100755 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -56,7 +56,7 @@ 'ItemCard2Label' => 'Slot 3', 'ItemCard3Label' => 'Slot 4', 'ItemRandOptionsLabel' => 'Random options', - 'EnchantGradeClass' => array( "D", "C", "B", "A"), + 'EnchantGradeClass' => array( "None", "D", "C", "B", "A"), //SIDEBAR //FluxCP Menu Items From 6af408032be935d530cf5c16363fbcbd361f47c3 Mon Sep 17 00:00:00 2001 From: Balfear Date: Wed, 29 Jun 2022 15:43:11 +0300 Subject: [PATCH 3/3] Removed Enchant grade info from Pre-Re mode --- themes/default/item/inventory.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/themes/default/item/inventory.php b/themes/default/item/inventory.php index aa1df40a2..f653cf9f3 100644 --- a/themes/default/item/inventory.php +++ b/themes/default/item/inventory.php @@ -174,16 +174,18 @@ - - Enchant grade - - enchantgrade): ?> - enchantgrade)); ?> - - None - - - + isRenewal): ?> + + Enchant grade + + enchantgrade): ?> + enchantgrade)); ?> + + None + + + + Bound