diff --git a/app/Http/Controllers/BrowseController.php b/app/Http/Controllers/BrowseController.php index c7f752c9da..4449846595 100644 --- a/app/Http/Controllers/BrowseController.php +++ b/app/Http/Controllers/BrowseController.php @@ -144,6 +144,18 @@ public function getCharacters(Request $request) $query->where('is_gift_art_allowed', 1)->orWhere('is_gift_art_allowed', 2); break; } + if($request->get('is_gift_writing_allowed')) switch($request->get('is_gift_writing_allowed')) { + case 1: + $query->where('is_gift_writing_allowed', 1); + break; + case 2: + $query->where('is_gift_writing_allowed', 2); + break; + case 3: + $query->where('is_gift_writing_allowed', 1)->orWhere('is_gift_writing_allowed', 2); + break; + } + if($request->get('is_sellable')) $query->where('is_sellable', 1); if($request->get('is_tradeable')) $query->where('is_tradeable', 1); if($request->get('is_giftable')) $query->where('is_giftable', 1); diff --git a/app/Http/Controllers/Characters/CharacterController.php b/app/Http/Controllers/Characters/CharacterController.php index 4925f19641..cf1ed30fd1 100644 --- a/app/Http/Controllers/Characters/CharacterController.php +++ b/app/Http/Controllers/Characters/CharacterController.php @@ -115,7 +115,7 @@ public function postEditCharacterProfile(Request $request, CharacterManager $ser $isOwner = ($this->character->user_id == Auth::user()->id); if(!$isMod && !$isOwner) abort(404); - if($service->updateCharacterProfile($request->only(['name', 'text', 'is_gift_art_allowed', 'is_trading', 'alert_user']), $this->character, Auth::user(), !$isOwner)) { + if($service->updateCharacterProfile($request->only(['name', 'text', 'is_gift_art_allowed', 'is_gift_writing_allowed', 'is_trading', 'alert_user']), $this->character, Auth::user(), !$isOwner)) { flash('Profile edited successfully.')->success(); } else { diff --git a/app/Http/Controllers/Users/BookmarkController.php b/app/Http/Controllers/Users/BookmarkController.php index 4c8992fe95..e2f556bb19 100644 --- a/app/Http/Controllers/Users/BookmarkController.php +++ b/app/Http/Controllers/Users/BookmarkController.php @@ -73,7 +73,7 @@ public function postCreateEditBookmark(Request $request, BookmarkManager $servic { $id ? $request->validate(CharacterBookmark::$updateRules) : $request->validate(CharacterBookmark::$createRules); $data = $request->only([ - 'character_id', 'notify_on_trade_status', 'notify_on_gift_art_status', 'notify_on_transfer', 'notify_on_image', 'comment' + 'character_id', 'notify_on_trade_status', 'notify_on_gift_art_status', 'notify_on_gift_writing_status', 'notify_on_transfer', 'notify_on_image', 'comment' ]); if($id && $service->updateBookmark($data + ['bookmark_id' => $id], Auth::user())) { flash('Bookmark updated successfully.')->success(); diff --git a/app/Models/Character/Character.php b/app/Models/Character/Character.php index 6cee5414f5..9a9ab1a6d9 100644 --- a/app/Models/Character/Character.php +++ b/app/Models/Character/Character.php @@ -35,7 +35,7 @@ class Character extends Model 'owner_alias', 'number', 'slug', 'description', 'parsed_description', 'is_sellable', 'is_tradeable', 'is_giftable', 'sale_value', 'transferrable_at', 'is_visible', - 'is_gift_art_allowed', 'is_trading', 'sort', + 'is_gift_art_allowed', 'is_gift_writing_allowed', 'is_trading', 'sort', 'is_myo_slot', 'name', 'trade_id' ]; @@ -475,6 +475,9 @@ public function notifyBookmarkers($type) case 'BOOKMARK_GIFTS': $column = 'notify_on_gift_art_status'; break; + case 'BOOKMARK_GIFT_WRITING': + $column = 'notify_on_gift_writing_status'; + break; case 'BOOKMARK_OWNER': $column = 'notify_on_transfer'; break; diff --git a/app/Models/Character/CharacterBookmark.php b/app/Models/Character/CharacterBookmark.php index de458407b9..11eddc19ec 100644 --- a/app/Models/Character/CharacterBookmark.php +++ b/app/Models/Character/CharacterBookmark.php @@ -13,7 +13,7 @@ class CharacterBookmark extends Model * @var array */ protected $fillable = [ - 'user_id', 'character_id', 'notify_on_trade_status', 'notify_on_gift_art_status', 'notify_on_transfer', 'notify_on_image', 'comment' + 'user_id', 'character_id', 'notify_on_trade_status', 'notify_on_gift_art_status', 'notify_on_gift_writing_status', 'notify_on_transfer', 'notify_on_image', 'comment' ]; /** diff --git a/app/Models/Notification.php b/app/Models/Notification.php index 25a8c29790..cca941eeb8 100644 --- a/app/Models/Notification.php +++ b/app/Models/Notification.php @@ -141,4 +141,5 @@ public static function getNotificationId($type) const BOOKMARK_OWNER = 36; const BOOKMARK_IMAGE = 37; const CHARACTER_TRANSFER_ACCEPTABLE = 38; + const BOOKMARK_GIFT_WRITING = 39; } diff --git a/app/Services/BookmarkManager.php b/app/Services/BookmarkManager.php index 0eeb5c5e55..17a2fde9e1 100644 --- a/app/Services/BookmarkManager.php +++ b/app/Services/BookmarkManager.php @@ -41,7 +41,8 @@ public function createBookmark($data, $user) 'user_id' => $user->id, 'sort' => 0, 'notify_on_trade_status' => isset($data['notify_on_trade_status']) ? $data['notify_on_trade_status'] : 0, - 'notify_on_gift_art_status' => isset($data['notify_on_gift_art_status']) ? $data['notify_on_gift_art_status'] : 0, + 'notify_on_gift_art_status' => isset($data['notify_on_gift_art_status']) ? $data['notify_on_gift_art_status'] : 0, + 'notify_on_gift_writing_status' => isset($data['notify_on_gift_writing_status']) ? $data['notify_on_gift_writing_status'] : 0, 'notify_on_transfer' => isset($data['notify_on_transfer']) ? $data['notify_on_transfer'] : 0, 'notify_on_image' => isset($data['notify_on_image']) ? $data['notify_on_image'] : 0, 'comment' => $data['comment'] @@ -72,7 +73,8 @@ public function updateBookmark($data, $user) $bookmark->update([ 'notify_on_trade_status' => isset($data['notify_on_trade_status']) ? $data['notify_on_trade_status'] : 0, - 'notify_on_gift_art_status' => isset($data['notify_on_gift_art_status']) ? $data['notify_on_gift_art_status'] : 0, + 'notify_on_gift_art_status' => isset($data['notify_on_gift_art_status']) ? $data['notify_on_gift_art_status'] : 0, + 'notify_on_gift_writing_status' => isset($data['notify_on_gift_writing_status']) ? $data['notify_on_gift_writing_status'] : 0, 'notify_on_transfer' => isset($data['notify_on_transfer']) ? $data['notify_on_transfer'] : 0, 'notify_on_image' => isset($data['notify_on_image']) ? $data['notify_on_image'] : 0, 'comment' => $data['comment'] diff --git a/app/Services/CharacterManager.php b/app/Services/CharacterManager.php index 5756f800c8..f5c7cdebcd 100644 --- a/app/Services/CharacterManager.php +++ b/app/Services/CharacterManager.php @@ -200,6 +200,7 @@ private function handleCharacter($data, $isMyo = false) $characterData['is_visible'] = isset($data['is_visible']); $characterData['sale_value'] = isset($data['sale_value']) ? $data['sale_value'] : 0; $characterData['is_gift_art_allowed'] = 0; + $characterData['is_gift_writing_allowed'] = 0; $characterData['is_trading'] = 0; $characterData['parsed_description'] = parse($data['description']); if($isMyo) $characterData['is_myo_slot'] = 1; @@ -971,6 +972,7 @@ public function updateCharacterProfile($data, $character, $user, $isAdmin = fals try { $notifyTrading = false; $notifyGiftArt = false; + $notifyGiftWriting = false; // Allow updating the gift art/trading options if the editing // user owns the character @@ -979,9 +981,11 @@ public function updateCharacterProfile($data, $character, $user, $isAdmin = fals if($character->user_id != $user->id) throw new \Exception("You cannot edit this character."); if($character->is_trading != isset($data['is_trading'])) $notifyTrading = true; - if($character->is_gift_art_allowed != isset($data['is_gift_art_allowed'])) $notifyGiftArt = true; + if(isset($data['is_gift_art_allowed']) && $character->is_gift_art_allowed != $data['is_gift_art_allowed']) $notifyGiftArt = true; + if(isset($data['is_gift_writing_allowed']) && $character->is_gift_writing_allowed != $data['is_gift_writing_allowed']) $notifyGiftWriting = true; $character->is_gift_art_allowed = isset($data['is_gift_art_allowed']) && $data['is_gift_art_allowed'] <= 2 ? $data['is_gift_art_allowed'] : 0; + $character->is_gift_writing_allowed = isset($data['is_gift_writing_allowed']) && $data['is_gift_writing_allowed'] <= 2 ? $data['is_gift_writing_allowed'] : 0; $character->is_trading = isset($data['is_trading']); $character->save(); } @@ -1006,6 +1010,7 @@ public function updateCharacterProfile($data, $character, $user, $isAdmin = fals if($notifyTrading) $character->notifyBookmarkers('BOOKMARK_TRADING'); if($notifyGiftArt) $character->notifyBookmarkers('BOOKMARK_GIFTS'); + if($notifyGiftWriting) $character->notifyBookmarkers('BOOKMARK_GIFT_WRITING'); return $this->commitReturn(true); } catch(\Exception $e) { @@ -1397,6 +1402,26 @@ public function moveCharacter($character, $recipient, $data, $cooldown = -1, $lo // Notify bookmarkers $character->notifyBookmarkers('BOOKMARK_OWNER'); + if(Config::get('lorekeeper.settings.reset_character_status_on_transfer')) { + // Reset trading status, gift art status, and writing status + $character->update([ + 'is_gift_art_allowed' => 0, + 'is_gift_writing_allowed' => 0, + 'is_trading' => 0, + ]); + } + + if(Config::get('lorekeeper.settings.reset_character_profile_on_transfer')) { + // Reset name and profile + $character->update(['name' => null]); + + // Reset profile + $character->profile->update([ + 'text' => null, + 'parsed_text' => null + ]); + } + // Add a log for the ownership change $this->createLog( $sender ? $sender->id : null, @@ -1885,8 +1910,10 @@ public function approveRequest($data, $request, $user) $this->createLog($user->id, null, $request->character->user_id, $request->character->user->alias, $request->character->id, $request->update_type == 'MYO' ? 'MYO Design Approved' : 'Character Design Updated', '[#'.$image->id.']', 'user'); // If this is for a MYO, set user's FTO status and the MYO status of the slot + // and clear the character's name if($request->character->is_myo_slot) { + if(Config::get('lorekeeper.settings.clear_myo_name_on_approval')) $request->character->name = null; $request->character->is_myo_slot = 0; $request->user->settings->is_fto = 0; $request->user->settings->save(); diff --git a/config/lorekeeper/notifications.php b/config/lorekeeper/notifications.php index 3f4402399a..724d3b7dba 100644 --- a/config/lorekeeper/notifications.php +++ b/config/lorekeeper/notifications.php @@ -245,4 +245,10 @@ 'message' => 'The transfer for {character_name} was approved by {sender_name}. (View Transfers)', 'url' => 'characters/transfers/incoming' ], + + // BOOKMARK_GIFT_WRITING + 39 => [ + 'message' => 'A character you have bookmarked ({character_name}) has had its Gift Writing Allowed status changed. (View Bookmarks)', + 'url' => 'account/bookmarks' + ], ]; diff --git a/config/lorekeeper/settings.php b/config/lorekeeper/settings.php index 214de62f6b..b15d2ad145 100644 --- a/config/lorekeeper/settings.php +++ b/config/lorekeeper/settings.php @@ -78,11 +78,31 @@ | The next number pulled for STD will be 004. | The next number pulled for MYO will be 003. | + | reset_character_status_on_transfer: + | This determines whether owner-set character status-- + | trading, gift art, and gift writing-- + | should be cleared when the character is transferred to a new owner. + | Default: 0/Disabled, 1 to enable. + | + | reset_character_profile_on_transfer: + | This determines whether character name and profile should be cleared + | when the character is transferred to a new owner. + | Default: 0/Disabled, 1 to enable. + | + | clear_myo_slot_name_on_approval: + | Whether the "name" given to a MYO slot should be cleared when a design update for it is approved/ + | the slot becomes a full character. + | Default: 0/Disabled, 1 to enable. + | */ 'character_codes' => '{category}-{number}', 'character_number_digits' => 3, 'character_pull_number' => 'all', + 'reset_character_status_on_transfer' => 0, + 'reset_character_profile_on_transfer' => 0, + 'clear_myo_slot_name_on_approval' => 0, + /* |-------------------------------------------------------------------------- | Masterlist Thumbnail Dimensions diff --git a/database/migrations/2020_10_30_170108_add_gift_writing_status_to_characters.php b/database/migrations/2020_10_30_170108_add_gift_writing_status_to_characters.php new file mode 100644 index 0000000000..85e4c246f5 --- /dev/null +++ b/database/migrations/2020_10_30_170108_add_gift_writing_status_to_characters.php @@ -0,0 +1,44 @@ +boolean('is_gift_writing_allowed')->default(0); + }); + + Schema::table('character_bookmarks', function (Blueprint $table) { + // + $table->boolean('notify_on_gift_writing_status')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('characters', function (Blueprint $table) { + // + $table->dropColumn('is_gift_writing_allowed'); + }); + + Schema::table('character_bookmarks', function (Blueprint $table) { + // + $table->dropColumn('notify_on_gift_writing_status'); + }); + } +} diff --git a/resources/views/account/bookmarks.blade.php b/resources/views/account/bookmarks.blade.php index b9e536345b..e8ce9dea0e 100644 --- a/resources/views/account/bookmarks.blade.php +++ b/resources/views/account/bookmarks.blade.php @@ -43,6 +43,9 @@ @if($bookmark->character->is_gift_art_allowed && !$bookmark->character->is_myo_slot)