|
|
@@ -58,9 +58,15 @@ class ProducerBaseController extends CommonController |
|
|
|
|
|
|
|
public function beforeAction($event) |
|
|
|
{ |
|
|
|
|
|
|
|
$producer = $this->getProducer() ; |
|
|
|
|
|
|
|
$userProducer = UserProducer::find() |
|
|
|
->where([ |
|
|
|
'id_user' => User::getCurrentId(), |
|
|
|
'id_producer' => $producer->id |
|
|
|
]) |
|
|
|
->one() ; |
|
|
|
|
|
|
|
/* |
|
|
|
* Producteur protègé par un code |
|
|
|
*/ |
|
|
@@ -73,18 +79,12 @@ class ProducerBaseController extends CommonController |
|
|
|
} |
|
|
|
// si l'utilisateur est connecté et qu'il n'a pas encore saisi de code |
|
|
|
else { |
|
|
|
$userProducer = UserProducer::find() |
|
|
|
->where([ |
|
|
|
'id_user' => User::getCurrentId(), |
|
|
|
'id_producer' => $producer->id |
|
|
|
]) |
|
|
|
->one() ; |
|
|
|
|
|
|
|
if(!$userProducer || ($userProducer && !$userProducer->active)) { |
|
|
|
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-code','id' => $producer->id])) ; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Producteur hors ligne |
|
|
|
*/ |
|
|
@@ -92,6 +92,10 @@ class ProducerBaseController extends CommonController |
|
|
|
$this->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer-offline','id' => $producer->id])) ; |
|
|
|
} |
|
|
|
|
|
|
|
if(!$userProducer) { |
|
|
|
Producer::addUser(User::getCurrentId(), $producer->id, 0) ; |
|
|
|
} |
|
|
|
|
|
|
|
return parent::beforeAction($event); |
|
|
|
} |
|
|
|
|