|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace producer\controllers; |
|
|
namespace producer\controllers; |
|
|
|
|
|
|
|
|
|
|
|
use yii\filters\AccessControl; |
|
|
|
|
|
|
|
|
class NewsletterController extends ProducerBaseController |
|
|
class NewsletterController extends ProducerBaseController |
|
|
{ |
|
|
{ |
|
|
public function behaviors() |
|
|
public function behaviors() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function actionSubscribe() |
|
|
public function actionSubscribe() |
|
|
{ |
|
|
{ |
|
|
|
|
|
if(!$this->getUserCurrent()) { |
|
|
|
|
|
return $this->redirectProducerLoginFrontend('subscribe'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$userManager = $this->getUserManager(); |
|
|
$userManager = $this->getUserManager(); |
|
|
$userCurrent = $this->getUserCurrent(); |
|
|
$userCurrent = $this->getUserCurrent(); |
|
|
$userManager->subscribeUserNewsletter($userCurrent); |
|
|
$userManager->subscribeUserNewsletter($userCurrent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function actionUnsubscribe() |
|
|
public function actionUnsubscribe() |
|
|
{ |
|
|
{ |
|
|
|
|
|
if(!$this->getUserCurrent()) { |
|
|
|
|
|
return $this->redirectProducerLoginFrontend('unsubscribe'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$userManager = $this->getUserManager(); |
|
|
$userManager = $this->getUserManager(); |
|
|
$userCurrent = $this->getUserCurrent(); |
|
|
$userCurrent = $this->getUserCurrent(); |
|
|
$userManager->unsubscribeUserNewsletter($userCurrent); |
|
|
$userManager->unsubscribeUserNewsletter($userCurrent); |
|
|
$this->setFlash('success', "À partir de maintenant, vous ne recevrez plus d'email de la part de ce producteur."); |
|
|
$this->setFlash('success', "À partir de maintenant, vous ne recevrez plus d'email de la part de ce producteur."); |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function redirectProducerLoginFrontend(string $actionNewsletter) |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['newsletter/'.$actionNewsletter, 'slug_producer' => $this->getProducerCurrent()->slug])])); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
?> |
|
|
?> |