Skip to content

Feat: fix minor bugs with trades & add tradelistings, trade proposals #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 75 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
9fc1f1e
Add handling and display for a proof of terms link for trades.
itinerare Aug 4, 2020
1675295
Creation and partial display of trade listings.
itinerare Aug 5, 2020
b910e94
Merge branch 'inventory_stacks' of https://github.com/Draginraptor/lo…
itinerare Aug 5, 2020
6b427ab
Display and manual expiry of trade listings.
itinerare Aug 5, 2020
ca8f5bb
Tooltip oversight
itinerare Aug 5, 2020
c01a6be
Tidying up formatting.
itinerare Aug 5, 2020
b1f3d74
Edit listing creation notes for clarity
itinerare Aug 5, 2020
ccb7793
Listing index text clarification
itinerare Aug 5, 2020
33ac7b0
Additional text edits.
itinerare Aug 5, 2020
033ee25
Fix for undefined index bug when creating trade
itinerare Aug 5, 2020
48550ef
Fix for bug with asset arrays not being properly processed and encode…
itinerare Aug 5, 2020
3914e31
Remove dd..
itinerare Aug 5, 2020
7d812a7
Fix display issue, streamline slightly.
itinerare Aug 6, 2020
f8b69e7
Tidying formatting on listing summary display
itinerare Aug 6, 2020
2bf7cda
- Fix bug with validation effectively requiring selecting at least on…
itinerare Aug 6, 2020
22992b9
Merge branch 'inventory_stacks' into trade-listings
itinerare Aug 9, 2020
e6bd4a8
Merge branch 'main' into trade-listings
itinerare Aug 9, 2020
6ab9f63
Fix for undefined index bug
itinerare Aug 16, 2020
f2620d1
Different fix for undefined index bug
itinerare Aug 16, 2020
dd27a28
Remove that if again
itinerare Aug 16, 2020
8306073
Added issets
itinerare Aug 16, 2020
2fc3128
Put back that other if
itinerare Aug 16, 2020
d3f1248
Merge branch 'inv-stacks' into trade-listings
itinerare Aug 18, 2020
6453189
Update for compatability with new inv stacks update (thanks https://g…
itinerare Aug 18, 2020
7347eb8
Compat fixes for JS on create trade listing page
itinerare Aug 18, 2020
4993198
Add display name attribute (thanks Uri!)
itinerare Sep 12, 2020
e01b57d
Merge branch 'modified-main' into trade-listings, enable comments on …
itinerare Oct 21, 2020
4350ffd
Merge branch 'modified-main' into trade-listings
itinerare Nov 1, 2020
4b17c14
Merge branch 'modified-main' into trade-listings
itinerare Nov 6, 2020
0e209b8
Add report button to trade listings.
itinerare Nov 6, 2020
4824123
Add report button to listings in trade listing index as well
itinerare Nov 6, 2020
98806cd
Adjust display of report button on trade listings slightly
itinerare Nov 6, 2020
737c170
Merge branch 'modified-main' into trade-listings
itinerare Nov 8, 2020
745c093
Merge branch 'modified-main' into extension/trade-listings
itinerare Nov 15, 2020
923cc15
- Add Title to trade listings extension
preimpression Jan 19, 2021
652cdf5
Merge pull request #1 from preimpression/extension/trade-listings
itinerare Jan 19, 2021
bebbb50
Merge branch 'release/release-2.0.0'
itinerare Aug 29, 2021
0157ab7
chore: add ext tracker info
itinerare Aug 29, 2021
ff970fe
chore: fix ext tracker info
itinerare Sep 23, 2021
246625f
fix(trades): error adding offered items to listing
itinerare Dec 28, 2021
46c0054
Merge branch 'extension/trade-listings' of https://github.com/itinera…
ScuffedNewt Jan 1, 2025
0956523
feat: update trade seeking additions, fix custom selectize rendering
ScuffedNewt Jan 3, 2025
efc9d2f
refactor: fix PHP styling
ScuffedNewt Jan 3, 2025
edd1d33
refactor: fix blade formatting
ScuffedNewt Jan 3, 2025
28a66e9
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Jan 10, 2025
100e269
stash
ScuffedNewt Jan 15, 2025
fae78c6
refactor: fix PHP styling
ScuffedNewt Jan 15, 2025
2185e4d
feat: trade proposals
ScuffedNewt Jan 20, 2025
dad247e
refactor: fix blade formatting
ScuffedNewt Jan 20, 2025
92c1c02
refactor: fix PHP styling
ScuffedNewt Jan 20, 2025
f964753
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Jan 20, 2025
d8f61bc
feat: add trade approval queue and sort options
ScuffedNewt Jan 20, 2025
2db4ab8
fix: header
ScuffedNewt Jan 20, 2025
15a6dbe
fix: make mobile view more user friendly
ScuffedNewt Jan 20, 2025
cea9c07
refactor: fix PHP styling
ScuffedNewt Jan 20, 2025
5dbb26a
refactor: fix blade formatting
ScuffedNewt Jan 20, 2025
4770fa0
feat(listings): allow users to edit listings + bugfixes
ScuffedNewt Jan 22, 2025
e9c13ed
fix: edit vs create
ScuffedNewt Jan 22, 2025
565064a
refactor: fix blade formatting
ScuffedNewt Jan 22, 2025
ba85fbd
refactor: fix PHP styling
ScuffedNewt Jan 22, 2025
a2a5bc2
fix: bool logic for trade queues
ScuffedNewt Jan 22, 2025
6eb9f0e
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Jan 28, 2025
110dd9a
fix: remove tracker
ScuffedNewt Jan 28, 2025
9f0d79f
refactor: fix blade formatting
ScuffedNewt Jan 28, 2025
c7db2fe
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt Apr 4, 2025
e3d1f1a
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
ScuffedNewt May 26, 2025
8152a43
refactor: fix blade formatting
ScuffedNewt May 26, 2025
19b32d9
feat: proposals now auto select info from a listing
ScuffedNewt May 29, 2025
7c5d3d4
fix: prevent negative offerings on listings
ScuffedNewt May 29, 2025
1c75a84
feat: proposals no longer reserve items / characters / currencies bef…
ScuffedNewt May 29, 2025
d5177f2
fix: correctly allows recipient to edit trades
ScuffedNewt May 29, 2025
c39f99a
refactor: fix PHP styling
ScuffedNewt May 29, 2025
4e5218e
refactor: fix blade formatting
ScuffedNewt May 29, 2025
25b6bf4
fix: misc fixes
ScuffedNewt May 29, 2025
788e310
refactor: fix blade formatting
ScuffedNewt May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/Console/Commands/AddSiteSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function handle() {

$this->addSiteSetting('open_transfers_queue', 0, '0: Character transfers do not need mod approval, 1: Transfers must be approved by a mod.');

$this->addSiteSetting('open_trades_queue', 0, '0: Trades do not need mod approval, 1: Trades must be approved by a mod.');

$this->addSiteSetting('trade_listing_duration', 14, 'Number of days a trade listing is displayed for.');

$this->addSiteSetting('trade_listing_limit', 3, 'Number of trade listings a user can have at once.');

$this->addSiteSetting('is_prompts_open', 1, '0: New prompt submissions cannot be made (mods can work on the queue still), 1: Prompts are submittable.');

$this->addSiteSetting('is_claims_open', 1, '0: New claims cannot be made (mods can work on the queue still), 1: Claims are submittable.');
Expand Down
25 changes: 25 additions & 0 deletions app/Helpers/AssetHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,31 @@ function countAssets($array) {
return $count;
}

/**
* Returns whether or not an asset can be traded based on its type.
*
* @param mixed $type
* @param mixed $asset
*
* @return bool
*/
function canTradeAsset($type, $asset) {
switch ($type) {
case 'Item':
return $asset->allow_transfer;
break;
case 'Currency':
// we don't have to worry about character->user or user->character transfers here
// technically you can loophole by transferring to a character and then transferring to a user
// but that is a process issue, not a code issue
return $asset->is_user_owned && $asset->allow_user_to_user;
break;
default:
return false;
break;
}
}

/**
* Distributes the assets in an assets array to the given recipient (character).
* Loot tables will be rolled before distribution.
Expand Down
83 changes: 1 addition & 82 deletions app/Http/Controllers/Admin/Characters/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
use App\Models\Rarity;
use App\Models\Species\Species;
use App\Models\Species\Subtype;
use App\Models\Trade;
use App\Models\Trade\Trade;
use App\Models\User\User;
use App\Services\CharacterManager;
use App\Services\TradeManager;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

Expand Down Expand Up @@ -649,86 +648,6 @@ public function postTransferQueue(Request $request, CharacterManager $service, $
return redirect()->back();
}

/**
* Shows the character trade queue.
*
* @param string $type
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getTradeQueue($type) {
$trades = Trade::query();
$user = Auth::user();

if ($type == 'completed') {
$trades->completed();
} elseif ($type == 'incoming') {
$trades->where('status', 'Pending');
} else {
abort(404);
}

$openTransfersQueue = Settings::get('open_transfers_queue');

return view('admin.masterlist.character_trades', [
'trades' => $trades->orderBy('id', 'DESC')->paginate(20),
'tradesQueue' => Settings::get('open_transfers_queue'),
'openTransfersQueue' => $openTransfersQueue,
'transferCount' => $openTransfersQueue ? CharacterTransfer::active()->where('is_approved', 0)->count() : 0,
'tradeCount' => $openTransfersQueue ? Trade::where('status', 'Pending')->count() : 0,
]);
}

/**
* Shows the character trade action modal.
*
* @param int $id
* @param string $action
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getTradeModal($id, $action) {
if ($action != 'approve' && $action != 'reject') {
abort(404);
}
$trade = Trade::where('id', $id)->first();
if (!$trade) {
abort(404);
}

return view('admin.masterlist._'.$action.'_trade_modal', [
'trade' => $trade,
'cooldown' => Settings::get('transfer_cooldown'),
]);
}

/**
* Acts on a trade in the trade queue.
*
* @param App\Services\CharacterManager $service
* @param int $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postTradeQueue(Request $request, TradeManager $service, $id) {
if (!Auth::check()) {
abort(404);
}

$action = strtolower($request->get('action'));
if ($action == 'approve' && $service->approveTrade($request->only(['action', 'cooldowns']) + ['id' => $id], Auth::user())) {
flash('Trade approved.')->success();
} elseif ($action == 'reject' && $service->rejectTrade($request->only(['action', 'reason']) + ['id' => $id], Auth::user())) {
flash('Trade rejected.')->success();
} else {
foreach ($service->errors()->getMessages()['error'] as $error) {
flash($error)->error();
}
}

return redirect()->back();
}

/**
* Shows a list of all existing MYO slots.
*
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Admin/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Models\Gallery\GallerySubmission;
use App\Models\Report\Report;
use App\Models\Submission\Submission;
use App\Models\Trade;
use App\Models\Trade\Trade;
use App\Models\User\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand All @@ -25,6 +25,7 @@ class HomeController extends Controller {
*/
public function getIndex() {
$openTransfersQueue = Settings::get('open_transfers_queue');
$openTradesQueue = Settings::get('open_trades_queue');
$galleryRequireApproval = Settings::get('gallery_submissions_require_approval');
$galleryCurrencyAwards = Settings::get('gallery_submissions_reward_currency');

Expand All @@ -36,6 +37,7 @@ public function getIndex() {
'reportCount' => Report::where('status', 'Pending')->count(),
'assignedReportCount' => Report::assignedToMe(Auth::user())->count(),
'openTransfersQueue' => $openTransfersQueue,
'openTradesQueue' => $openTradesQueue,
'transferCount' => $openTransfersQueue ? CharacterTransfer::active()->where('is_approved', 0)->count() : 0,
'tradeCount' => $openTransfersQueue ? Trade::where('status', 'Pending')->count() : 0,
'galleryRequireApproval' => $galleryRequireApproval,
Expand Down
103 changes: 103 additions & 0 deletions app/Http/Controllers/Admin/TradeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Facades\Settings;
use App\Http\Controllers\Controller;
use App\Models\Trade\Trade;
use App\Services\TradeManager;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class TradeController extends Controller {
/**
* Shows the character trade queue.
*
* @param string $type
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getTradeQueue(Request $request, $type) {
$trades = Trade::query();
$user = Auth::user();
$data = $request->only(['sort']);
if (isset($data['sort'])) {
switch ($data['sort']) {
case 'newest':
$trades->sortNewest();
break;
case 'oldest':
$trades->sortOldest();
break;
}
} else {
$trades->sortOldest();
}

if ($type == 'completed') {
$trades->completed();
} elseif ($type == 'incoming') {
$trades->where('status', 'Pending');
} else {
abort(404);
}

$openTransfersQueue = Settings::get('open_trades_queue');

return view('admin.trades.trades', [
'trades' => $trades->orderBy('id', 'DESC')->paginate(20),
'tradesQueue' => Settings::get('open_trades_queue'),
'tradeCount' => $openTransfersQueue ? Trade::where('status', 'Pending')->count() : 0,
]);
}

/**
* Shows the character trade action modal.
*
* @param int $id
* @param string $action
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getTradeModal($id, $action) {
if ($action != 'approve' && $action != 'reject') {
abort(404);
}
$trade = Trade::where('id', $id)->first();
if (!$trade) {
abort(404);
}

return view('admin.trades._'.$action.'_trade_modal', [
'trade' => $trade,
'cooldown' => Settings::get('transfer_cooldown'),
]);
}

/**
* Acts on a trade in the trade queue.
*
* @param App\Services\CharacterManager $service
* @param int $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postTradeQueue(Request $request, TradeManager $service, $id) {
if (!Auth::check()) {
abort(404);
}

$action = strtolower($request->get('action'));
if ($action == 'approve' && $service->approveTrade($request->only(['action', 'cooldowns']) + ['id' => $id], Auth::user())) {
flash('Trade approved.')->success();
} elseif ($action == 'reject' && $service->rejectTrade($request->only(['action', 'reason']) + ['id' => $id], Auth::user())) {
flash('Trade rejected.')->success();
} else {
foreach ($service->errors()->getMessages()['error'] as $error) {
flash($error)->error();
}
}

return redirect()->back();
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/Users/GrantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\Models\Currency\Currency;
use App\Models\Item\Item;
use App\Models\Submission\Submission;
use App\Models\Trade;
use App\Models\Trade\Trade;
use App\Models\User\User;
use App\Models\User\UserItem;
use App\Services\CurrencyManager;
Expand Down
11 changes: 10 additions & 1 deletion app/Http/Controllers/Characters/DesignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,21 @@ public function getAddons($id) {
$inventory = isset($r->data['user']) ? parseAssetData($r->data['user']) : null;
}

$item_filter = Item::orderBy('name')->get()->mapWithKeys(function ($item) {
return [
$item->id => json_encode([
'name' => $item->name,
'image_url' => $item->image_url,
]),
];
});

return view('character.design.addons', [
'request' => $r,
'categories' => ItemCategory::visible(Auth::user() ?? null)->orderBy('sort', 'DESC')->get(),
'inventory' => $inventory,
'items' => Item::all()->keyBy('id'),
'item_filter' => Item::orderBy('name')->get()->keyBy('id'),
'item_filter' => $item_filter,
'page' => 'update',
]);
}
Expand Down
7 changes: 7 additions & 0 deletions app/Http/Controllers/Comments/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Report\Report;
use App\Models\Sales\Sales;
use App\Models\SitePage;
use App\Models\Trade\TradeListing;
use App\Models\User\User;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand Down Expand Up @@ -130,6 +131,12 @@ public function store(Request $request, $model, $id) {
$post = 'your site page';
$link = $page->url.'/#comment-'.$comment->getKey();
break;
case 'App\Models\Trade\TradeListing':
$listing = TradeListing::find($comment->commentable_id);
$recipient = $listing->user;
$post = 'your trade listing';
$link = $listing->url.'/#comment-'.$comment->getKey();
break;
case 'App\Models\Gallery\GallerySubmission':
$submission = GallerySubmission::find($comment->commentable_id);
if ($type == 'Staff-Staff') {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Users/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Models\Item\ItemCategory;
use App\Models\Rarity;
use App\Models\Submission\Submission;
use App\Models\Trade;
use App\Models\Trade\Trade;
use App\Models\User\User;
use App\Models\User\UserItem;
use App\Services\InventoryManager;
Expand Down
Loading