瀏覽代碼

[Espace producteur] Newsletter : redirection vers la connexion en tant qu'invité #1227

master
Guillaume Bourgeois 1 年之前
父節點
當前提交
0aaade740a
共有 3 個文件被更改,包括 17 次插入4 次删除
  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 查看文件

@@ -460,7 +460,7 @@ class SiteController extends FrontendController
$loginForm->id_producer = $id;
$signupForm->id_producer = $id;
$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 ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) {

+ 1
- 3
frontend/views/site/producer.php 查看文件

@@ -49,11 +49,9 @@ $this->setMeta('description', 'Veuillez vous connecter pour réserver les produi
?>

<div id="page-producer">

<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 class="col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">

+ 15
- 0
producer/controllers/NewsletterController.php 查看文件

@@ -38,6 +38,8 @@

namespace producer\controllers;

use yii\filters\AccessControl;

class NewsletterController extends ProducerBaseController
{
public function behaviors()
@@ -55,6 +57,10 @@ class NewsletterController extends ProducerBaseController

public function actionSubscribe()
{
if(!$this->getUserCurrent()) {
return $this->redirectProducerLoginFrontend('subscribe');
}

$userManager = $this->getUserManager();
$userCurrent = $this->getUserCurrent();
$userManager->subscribeUserNewsletter($userCurrent);
@@ -64,12 +70,21 @@ class NewsletterController extends ProducerBaseController

public function actionUnsubscribe()
{
if(!$this->getUserCurrent()) {
return $this->redirectProducerLoginFrontend('unsubscribe');
}

$userManager = $this->getUserManager();
$userCurrent = $this->getUserCurrent();
$userManager->unsubscribeUserNewsletter($userCurrent);
$this->setFlash('success', "À partir de maintenant, vous ne recevrez plus d'email de la part de ce producteur.");
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…
取消
儲存