4828b892
Mihail
after merge with ...
|
1
2
3
4
5
|
<?php
namespace common\models;
use Yii;
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
6
7
8
|
use yii\web\IdentityInterface;
use yii\base\NotSupportedException;
use yii\db\ActiveRecord;
|
4828b892
Mihail
after merge with ...
|
9
10
11
|
/**
* This is the model class for table "w_accounts".
*
|
c5a7a79e
Administrator
upload project
|
12
|
*
|
4828b892
Mihail
after merge with ...
|
13
14
15
|
* @property integer $id
* @property integer $if_manager
* @property string $email
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
16
|
* @property string $auth_key
|
4828b892
Mihail
after merge with ...
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
* @property string $pass
* @property integer $margin_id
* @property string $name
* @property string $phones
* @property integer $country
* @property integer $city
* @property string $address
* @property string $comment
* @property integer $rating
* @property string $dt
* @property integer $is_active
* @property integer $is_firm
* @property string $last_loginin
* @property string $firm_inn
* @property string $firm_bank
* @property double $balance
* @property integer $office_id
* @property integer $is_scribe
* @property integer $set_manager_id
* @property string $phones2
* @property string $phones3
* @property integer $car
* @property integer $mod
* @property string $snumb
* @property integer $deliveries
* @property integer $scode
* @property string $firm_ur_adr
* @property string $firm_fiz_adr
* @property string $firm_code_eg
* @property string $firm_rs
* @property string $firm_mfo
* @property string $firm_site
* @property string $company
*/
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
51
|
class Accounts extends ActiveRecord implements IdentityInterface
|
4828b892
Mihail
after merge with ...
|
52
|
{
|
7b407169
Administrator
upload project
|
53
|
|
2fd0fce6
Administrator
VItaliy 04.12.2015
|
54
55
56
|
/**
* @var
*/
|
a8808843
Administrator
access in admin
|
57
58
|
public $re_pass;
public $surname;
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
59
|
public $country_region;
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
60
61
62
63
64
|
public $verifyCode;
public $auth_key;
public $password_hash;
public $password_reset_token;
|
a8808843
Administrator
access in admin
|
65
|
|
4828b892
Mihail
after merge with ...
|
66
67
68
69
70
71
72
73
74
|
/**
* @inheritdoc
*/
public static function tableName()
{
return 'w_accounts';
}
|
2fd0fce6
Administrator
VItaliy 04.12.2015
|
75
76
77
|
/**
* @return bool
*/
|
4828b892
Mihail
after merge with ...
|
78
79
|
public function beforeSave()
{
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
80
|
$this->dt = time();
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
81
|
$this->name = $this->surname.' '.$this->name;
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
82
|
return true;
|
85b72093
Administrator
first commit from...
|
83
|
|
4828b892
Mihail
after merge with ...
|
84
85
86
87
88
89
90
91
92
|
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['if_manager', 'margin_id', 'country', 'city', 'rating', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'],
|
2fd0fce6
Administrator
VItaliy 04.12.2015
|
93
|
[['company','email', 'pass', 'name', 'phones',], 'required'],
|
4828b892
Mihail
after merge with ...
|
94
95
|
[['comment'], 'string'],
[['balance'], 'number'],
|
a8808843
Administrator
access in admin
|
96
97
|
[['email', 'name','surname', 'firm_site'], 'string', 'max' => 150],
[['pass','re_pass'], 'string', 'max' => 30],
|
4828b892
Mihail
after merge with ...
|
98
99
100
101
|
[['phones', 'phones2', 'phones3'], 'string', 'max' => 50],
[['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254],
[['last_loginin'], 'string', 'max' => 15],
[['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255],
|
a8808843
Administrator
access in admin
|
102
103
|
[['email'], 'unique'],
[['email'], 'email'],
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
104
105
106
|
[['rating','if_manager','set_manager_id','balance'], 'default', 'value' => '0'],
[['is_active','margin_id','office_id','is_scribe'], 'default', 'value' => '1'],
[['comment'], 'default', 'value' => 'Новый пользователь'],
|
4828b892
Mihail
after merge with ...
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'if_manager' => 'Статус менеджера',
'email' => 'E-mail (Логин)',
'pass' => 'Пароль',
'margin_id' => 'Тип цены',
'name' => 'Имя',
'phones' => 'Телефоны',
'country' => Yii::t('app', 'Country'),
'city' =>'Город',
'address' => 'Адрес',
'comment' => 'Комментарий',
'rating' => Yii::t('app', 'Rating'),
'dt' =>'Дата регистрации',
'is_active' => 'Активный',
'is_firm' => 'Юридическое лицо',
'last_loginin' => Yii::t('app', 'Last Loginin'),
'firm_inn' => 'ИНН',
'firm_bank' => 'Банк',
'balance' => Yii::t('app', 'Balance'),
'office_id' => Yii::t('app', 'Office ID'),
'is_scribe' => 'Подписка',
'set_manager_id' => 'Персональный менеджер',
'phones2' => 'Телефоны 2',
'phones3' => 'Телефоны 3',
'car' => Yii::t('app', 'Car'),
'mod' => Yii::t('app', 'Mod'),
'snumb' => 'snumb',
'deliveries' => Yii::t('app', 'Deliveries'),
'scode' => 'Код в 1С',
'firm_ur_adr' => 'Юридический адрес',
'firm_fiz_adr' => 'Физический адрес',
'firm_code_eg' => 'Код ЭГ',
'firm_rs' => 'Расчётный счёт',
'firm_mfo' => 'МФО',
'firm_site' => 'Сайт',
'company' => 'Название фирмы',
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
152
|
'country_region' => 'Регион'
|
4828b892
Mihail
after merge with ...
|
153
154
|
];
}
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
155
156
157
158
159
160
161
162
163
164
165
|
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
166
|
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
if ($this->save()) {
return $this;
}
}
return null;
}
/**
* @inheritdoc
*/
public static function findIdentity($id)
{
return static::findOne(['id' => $id]);
}
/**
* @inheritdoc
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
192
|
* Finds user by email
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
193
|
*
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
194
|
* @param string $email
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
195
196
|
* @return static|null
*/
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
197
|
public static function findByEmail($email)
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
198
|
{
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
199
|
return static::findOne(['email' => $email]);
|
89d4b5ac
Administrator
VItaliy 25.11.2015
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
}
/**
* @inheritdoc
*/
public function getId()
{
return $this->getPrimaryKey();
}
/**
* @inheritdoc
*/
public function getAuthKey()
{
return $this->auth_key;
}
/**
* @inheritdoc
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* Generates "remember me" authentication key
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
/**
* Generates new password reset token
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
}
/**
* Removes password reset token
*/
public function removePasswordResetToken()
{
$this->password_reset_token = null;
}
|
27b0cb06
Administrator
VItaliy 02.12.2015
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/**
* Finds out if password reset token is valid
*
* @param string $token password reset token
* @return boolean
*/
public static function isPasswordResetTokenValid($token)
{
if (empty($token)) {
return false;
}
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token);
$timestamp = (int) end($parts);
return $timestamp + $expire >= time();
}
|
4828b892
Mihail
after merge with ...
|
274
|
}
|