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

@@ -108,6 +108,10 @@ class TicketController extends Controller {
public function actionDaily(){
set_time_limit(0);
$this->actionWarnExpire();
}
public function actionWeekly(){
set_time_limit(0);
$this->actionNewsletter();
}

View File

@@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160523_053901_alter_customer_set_default_newsletter_false extends Migration
{
public function up()
{
$this->execute("update customer set newsletter = 0");
}
public function down()
{
echo "m160523_053901_alter_customer_set_default_newsletter_false cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@@ -0,0 +1,39 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
use common\models\Customer;
class m160523_055217_add_customer_newsletter_token extends Migration
{
public function up()
{
$this->addColumn("customer", "newsletter_token", "string" );
$customers = Customer::find()->all();
foreach ($customers as $customer ){
$customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time();
$customer->save();
}
}
public function down()
{
echo "m160523_055217_add_customer_newsletter_token cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}