Browse Source

Merge branch 'hotfix/hotfix_1227'

master
Guillaume Bourgeois 1 year ago
parent
commit
e60f3481b2
3 changed files with 17 additions and 4 deletions
  1. +1
    -1
      frontend/controllers/SiteController.php
  2. +1
    -3
      frontend/views/site/producer.php
  3. +15
    -0
      producer/controllers/NewsletterController.php

+ 1
- 1
frontend/controllers/SiteController.php View File

$loginForm->id_producer = $id; $loginForm->id_producer = $id;
$signupForm->id_producer = $id; $signupForm->id_producer = $id;
$signupForm->option_user_producer = 'user'; $signupForm->option_user_producer = 'user';
$returnUrl = $this->getRequest()->get('returnUrl', $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));
$returnUrl = $this->getRequest()->get('return_url', $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]));


if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) {

+ 1
- 3
frontend/views/site/producer.php View File

?> ?>


<div id="page-producer"> <div id="page-producer">

<div class="alert alert-warning"> <div class="alert alert-warning">
Veuillez vous identifier pour commander vos produits sur l'espace du producteur <strong><?= Html::encode($producer->name); ?></strong>.
Veuillez vous identifier pour accéder à l'espace du producteur <strong><?= Html::encode($producer->name); ?></strong>.
</div> </div>

<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"> <div class="panel-heading">

+ 15
- 0
producer/controllers/NewsletterController.php View File



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])]));
}
} }


?> ?>

Loading…
Cancel
Save