add subscriber
This commit is contained in:
@@ -397,12 +397,16 @@ class Helper {
|
||||
}
|
||||
|
||||
public static function getWebUrl(){
|
||||
if ( self::isCompanyMovar()){
|
||||
return "https://fitnessadmin.hu/fitness-web";
|
||||
}else if ( self::isCompanyGyor()){
|
||||
return "https://fitnessadmin.hu/cutler";
|
||||
if ( \Yii::$app->params['development'] == true ){
|
||||
return "http://localhost/fitness-web";
|
||||
}else{
|
||||
return "https://localhost/fitness-web";
|
||||
if ( self::isCompanyMovar()){
|
||||
return "https://fitnessadmin.hu/fitness-web";
|
||||
}else if ( self::isCompanyGyor()){
|
||||
return "https://fitnessadmin.hu/cutler";
|
||||
}else{
|
||||
return "https://localhost/fitness-web";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
return [
|
||||
'development' => false,
|
||||
'adminEmail' => 'rocho02@gmail.com',
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
@@ -47,6 +48,7 @@ return [
|
||||
'day' => 5,
|
||||
]
|
||||
],
|
||||
'newsletter_from' => 'noreply@fitnessadmin.hu'
|
||||
'newsletter_from' => 'noreply@fitnessadmin.hu',
|
||||
'newsletter_enabled' => false
|
||||
|
||||
];
|
||||
|
||||
@@ -45,6 +45,10 @@ class Log extends BaseFitnessActiveRecord
|
||||
public static $TYPE_WASTE = 100;
|
||||
public static $TYPE_NEWSLETTER_SUBSCRIBE = 110;
|
||||
public static $TYPE_NEWSLETTER_UNSUBSCRIBE = 120;
|
||||
public static $TYPE_NEWSLETTER_SENT = 130;
|
||||
public static $TYPE_TICKET_EXPIRE_SENT = 140;
|
||||
public static $TYPE_NEWSLETTER_SEND_START = 150;
|
||||
public static $TYPE_NEWSLETTER_SEND_END = 160;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
||||
85
common/models/Subscriber.php
Normal file
85
common/models/Subscriber.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "subscriber".
|
||||
*
|
||||
* @property integer $id_subscriber
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property integer $status
|
||||
* @property string $token
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Subscriber extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'subscriber';
|
||||
}
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
||||
],
|
||||
], parent::behaviors());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['email'], 'email'],
|
||||
[['status','email','name'], 'required'],
|
||||
[['status'], 'integer'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
['status' ,'validateSubscribe' ,'skipOnEmpty' => false, 'skipOnError' => false ,'on' => 'subscribe']
|
||||
];
|
||||
}
|
||||
|
||||
public function validateSubscribe($attr,$param){
|
||||
if ( $this->status != '1'){
|
||||
$this->addError( "status", "Feliratkozáshoz be kell jelölnie ezt a mezőt!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_subscriber' => Yii::t('common/subscriber', 'Id Subscriber'),
|
||||
'name' => Yii::t('common/subscriber', 'Név'),
|
||||
'email' => Yii::t('common/subscriber', 'Email'),
|
||||
'status' => Yii::t('common/subscriber', 'Szeretnék hírlevelet kapni'),
|
||||
'token' => Yii::t('common/subscriber', 'Token'),
|
||||
'created_at' => Yii::t('common/subscriber', 'Created At'),
|
||||
'updated_at' => Yii::t('common/subscriber', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeSave($insert){
|
||||
if ( parent::beforeSave($insert)){
|
||||
$this->token = Yii::$app->security->generateRandomString() . '_' . time();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user