|
|
@@ -63,12 +63,14 @@ use dosamigos\leaflet\widgets\Map; |
|
|
|
/** |
|
|
|
* Site controller |
|
|
|
*/ |
|
|
|
class SiteController extends FrontendController { |
|
|
|
class SiteController extends FrontendController |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
public function behaviors() { |
|
|
|
public function behaviors() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
'access' => [ |
|
|
|
'class' => AccessControl::className(), |
|
|
@@ -98,7 +100,8 @@ class SiteController extends FrontendController { |
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
public function actions() { |
|
|
|
public function actions() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
'captcha' => [ |
|
|
|
'class' => 'yii\captcha\CaptchaAction', |
|
|
@@ -107,6 +110,11 @@ class SiteController extends FrontendController { |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Affiche la page d'erreur. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionError() |
|
|
|
{ |
|
|
|
$exception = Yii::$app->errorHandler->exception; |
|
|
@@ -120,13 +128,23 @@ class SiteController extends FrontendController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function actionIndex() { |
|
|
|
|
|
|
|
/** |
|
|
|
* Affiche la page d'accueil. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionIndex() |
|
|
|
{ |
|
|
|
return $this->render('index'); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionProducers() { |
|
|
|
|
|
|
|
/** |
|
|
|
* Liste les producteurs utilisant la plateforme. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionProducers() |
|
|
|
{ |
|
|
|
$data_provider_producers = new ActiveDataProvider([ |
|
|
|
'query' => Etablissement::find() |
|
|
|
->where([ |
|
|
@@ -143,11 +161,23 @@ class SiteController extends FrontendController { |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionMentions() { |
|
|
|
/** |
|
|
|
* Affiche les mentions légales. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionMentions() |
|
|
|
{ |
|
|
|
return $this->render('mentions'); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionLogin() { |
|
|
|
/** |
|
|
|
* Affiche la page de connexion et traite le formulaire de connexion. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionLogin() |
|
|
|
{ |
|
|
|
if (!\Yii::$app->user->isGuest) { |
|
|
|
return Yii::$app->getResponse()->redirect(['commande/index']); |
|
|
|
} |
|
|
@@ -168,12 +198,24 @@ class SiteController extends FrontendController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function actionLogout() { |
|
|
|
/** |
|
|
|
* Déconnecte l'utilisateur. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionLogout() |
|
|
|
{ |
|
|
|
Yii::$app->user->logout(); |
|
|
|
return $this->goHome(); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionContact() { |
|
|
|
/** |
|
|
|
* Affiche la page de contact et traite le formulaire s'il est soumis. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionContact() |
|
|
|
{ |
|
|
|
$model = new ContactForm(); |
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
|
if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
|
@@ -190,12 +232,17 @@ class SiteController extends FrontendController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function actionSignup() { |
|
|
|
/** |
|
|
|
* Affiche la page d'inscription et traite son formulaire. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionSignup() |
|
|
|
{ |
|
|
|
$model = new SignupForm(); |
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
if ($user = $model->signup()) { |
|
|
|
if (Yii::$app->getUser()->login($user)) { |
|
|
|
|
|
|
|
$this->redirect(['commande/index']); |
|
|
|
} |
|
|
|
} |
|
|
@@ -213,7 +260,14 @@ class SiteController extends FrontendController { |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionRequestPasswordReset() { |
|
|
|
/** |
|
|
|
* Affiche la page de demande de nouveau mot de passe. |
|
|
|
* Traitement du formulaire. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionRequestPasswordReset() |
|
|
|
{ |
|
|
|
$model = new PasswordResetRequestForm(); |
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
|
if ($model->sendEmail()) { |
|
|
@@ -226,10 +280,17 @@ class SiteController extends FrontendController { |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render('requestPasswordResetToken', [ |
|
|
|
'model' => $model, |
|
|
|
'model' => $model, |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Met à jour le mot de passe de l'utilisateur. |
|
|
|
* |
|
|
|
* @param string $token |
|
|
|
* @return mixed |
|
|
|
* @throws BadRequestHttpException |
|
|
|
*/ |
|
|
|
public function actionResetPassword($token) { |
|
|
|
try { |
|
|
|
$model = new ResetPasswordForm($token); |
|
|
@@ -244,19 +305,39 @@ class SiteController extends FrontendController { |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render('resetPassword', [ |
|
|
|
'model' => $model, |
|
|
|
'model' => $model, |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionCgv() { |
|
|
|
/** |
|
|
|
* Affiche les conditions générale de service. |
|
|
|
* |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionCgv() |
|
|
|
{ |
|
|
|
return $this->render('cgv'); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionCreditpain() { |
|
|
|
/** |
|
|
|
* Affiche les précisions concernant l'utilisation du crédit pain. |
|
|
|
* @return type |
|
|
|
*/ |
|
|
|
public function actionCreditpain() |
|
|
|
{ |
|
|
|
return $this->render('creditpain'); |
|
|
|
} |
|
|
|
|
|
|
|
public function actionProducerCode($id) { |
|
|
|
/** |
|
|
|
* Affiche le formulaire de demande de code pour accéder à certains |
|
|
|
* producteurs. |
|
|
|
* |
|
|
|
* @param integer $id |
|
|
|
* @return mixed |
|
|
|
* @throws \yii\web\HttpException |
|
|
|
*/ |
|
|
|
public function actionProducerCode($id) |
|
|
|
{ |
|
|
|
|
|
|
|
$producer = Etablissement::findOne($id); |
|
|
|
if(!$producer) |
|
|
@@ -276,7 +357,15 @@ class SiteController extends FrontendController { |
|
|
|
]) ; |
|
|
|
} |
|
|
|
|
|
|
|
public function actionProducer($id) { |
|
|
|
/** |
|
|
|
* Affiche la page de connexion / inscription pour accéder notamment au |
|
|
|
* formulaire de commande des producteirs. |
|
|
|
* |
|
|
|
* @param integer $id |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function actionProducer($id) |
|
|
|
{ |
|
|
|
$model_login = new LoginForm(); |
|
|
|
$model_signup = new SignupForm(); |
|
|
|
|