From 1fd94ea25caf59e277d83142ed1ca7d8516310be Mon Sep 17 00:00:00 2001 From: nekocari Date: Sat, 12 Oct 2024 22:57:39 +0200 Subject: [PATCH] fixed card tradeable check, put keep back in as alias for not tradeable --- app/models/card.php | 5 ++--- app/models/card_flagged.php | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/models/card.php b/app/models/card.php index ed1b048..b567927 100644 --- a/app/models/card.php +++ b/app/models/card.php @@ -285,9 +285,8 @@ public static function getFillerHtml($file_path,$img_width,$img_height){ public function isTradeable() { if(is_null($this->is_tradeable)){ $this->is_tradeable = false; - if($this->getStatus()){ - // TODO: make use of: Trade::getWhere($condition)? - $query = 'SELECT count(*) FROM trades WHERE (offered_card = '.$this->id.' OR requested_card = '.$this->id.') AND status = \'new\' '; + if($this->getStatus()->isTradeable()){ + $query = 'SELECT count(*) FROM '.Trade::getDbTableName().' WHERE (offered_card = '.$this->id.' OR requested_card = '.$this->id.') AND status = \'new\' '; $trades = $this->db->query($query)->fetchColumn(); if($trades == 0){ $this->is_tradeable = true; diff --git a/app/models/card_flagged.php b/app/models/card_flagged.php index 38b6f5f..2fa6774 100644 --- a/app/models/card_flagged.php +++ b/app/models/card_flagged.php @@ -40,12 +40,22 @@ public function missingIn($manager_category_id) { * @return boolean */ public function missingInNotTradeable(){ - if($this->missingInCollect() OR $this->not_tradeable_flag == 0 OR $this->in_not_tradeable_flag == 1){ - return false; - }else{ - return true; - } + if($this->missingInCollect() OR $this->not_tradeable_flag == 0 OR $this->in_not_tradeable_flag == 1){ + return false; + }else{ + return true; + } + } + + /** + * @deprecated + * keep was replaced with not tradeable categories + * @return boolean + */ + public function missingInKeep(){ + return $this->missingInNotTradeable(); } + /** * Is card missing in collection? * @return boolean @@ -82,6 +92,14 @@ public function deckInNotTradeable(){ return true; } } + /** + * @deprecated + * keep was replaced with not tradeable categories + * @return boolean + */ + public function deckInKeep(){ + return $this->deckInNotTradeable(); + } /** * is this deck currently beeing collected? * @return boolean @@ -312,7 +330,7 @@ public function getSortingOptions(){ } // KEEP - UNTRADEABLES // select status is not collections and untradeable and card is missing in this untradeable status - if(!$status->isCollections() AND !$status->isTradeable() AND $this->missingIn($status->getId()) ){ + if(!$status->isCollections() AND !$status->isTradeable() AND $this->missingIn($status->getId()) AND ($this->getStatus()->isNew() OR $this->isTradeable()) ){ $option_selected = true; $option['prop_selected'] = true; }