From 5a705f15b0a9a83d6718f3b81de57edac3403120 Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Thu, 1 Dec 2022 20:51:11 +0100 Subject: [PATCH] add card type : review --- common/models/Card.php | 2 ++ mobileapi/components/ActivatedFilter.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/common/models/Card.php b/common/models/Card.php index 16c95a9..332545a 100644 --- a/common/models/Card.php +++ b/common/models/Card.php @@ -34,6 +34,7 @@ class Card extends \common\models\BaseFitnessActiveRecord const TYPE_BARCODE = 30; const TYPE_OLD = 40; const TYPE_EMPLOYEE = 50; + const TYPE_REVIEW = 60; public static $FLAG_TICKET = 0; //has valid ticket @@ -164,6 +165,7 @@ class Card extends \common\models\BaseFitnessActiveRecord self::TYPE_BARCODE => Yii::t('common/card', 'BARCODE'), self::TYPE_OLD => Yii::t('common/card', 'OLD'), self::TYPE_EMPLOYEE => Yii::t('common/card', 'Munkatárs'), + self::TYPE_REVIEW => Yii::t('common/card', 'Review'), ]; } diff --git a/mobileapi/components/ActivatedFilter.php b/mobileapi/components/ActivatedFilter.php index 2a8afb5..8e085d7 100644 --- a/mobileapi/components/ActivatedFilter.php +++ b/mobileapi/components/ActivatedFilter.php @@ -3,6 +3,7 @@ namespace mobileapi\components; use common\components\HttpStatus; +use common\models\Card; use common\models\MobileDevice; use Yii; @@ -35,8 +36,16 @@ class ActivatedFilter extends ActionFilter if (isset($mobileDevice)) { $deviceId = $mobileDevice->id; $idCard = $mobileDevice->id_card; + // find out if the device is activated $activated = $mobileDevice->status === MobileDevice::STATUS_ACTIVE; + // override activated to true, if it is a reviewer card + $card = Card::findOne($idCard); + if ( isset($card) ){ + if ( isset($card->type) ){ + $activated = true; + } + } } // if device is not activated, throw exception with http status 412 if ($activated === false) {