add unsibscribe newsletter

This commit is contained in:
2016-05-23 08:16:44 +02:00
parent e51f4a5934
commit 85047ec900
8 changed files with 133 additions and 13 deletions

View File

@@ -218,10 +218,6 @@ class CustomerController extends Controller
// s
/**

View File

@@ -15,6 +15,8 @@ use yii\filters\AccessControl;
use common\models\User;
use common\components\Helper;
use common\models\Log;
use common\models\Customer;
use yii\web\NotFoundHttpException;
/**
* Site controller
@@ -176,6 +178,26 @@ class SiteController extends Controller
{
return $this->render('about');
}
public function actionNewsletterUnsubscribe($id,$token)
{
$customer = Customer::find()
->andWhere(['id_customer' => $id ])
->andWhere(['newsletter_token' => $token])
->one();
if ( !isset($customer)){
throw new NotFoundHttpException("Az oldal nem található");
}
$customer->newsletter = 0;
$customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time();
$customer->save();
return $this->render("unsubscribe");
}
/**
* Signs user up.