@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | <p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.6; font-weight: normal; margin: 0 0 10px; padding: 0;"> |
15 | 15 | <?= Yii::t('yuncms', 'Your account on {0} has been created.', Yii::$app->name) ?>. |
16 | - <?php if ($showPassword || Yii::$app->settings->get('enableGeneratingPassword','user')): ?> |
|
16 | + <?php if ($showPassword || Yii::$app->settings->get('enableGeneratingPassword', 'user')): ?> |
|
17 | 17 | <?= Yii::t('yuncms', 'We have generated a password for you') ?>: <strong><?= $user->password ?></strong> |
18 | 18 | <?php endif ?> |
19 | 19 |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | 'emailRequired' => ['email', 'required'], |
92 | 92 | 'emailTrim' => ['email', 'filter', 'filter' => 'trim'], |
93 | 93 | 'emailPattern' => ['email', 'email'], |
94 | - 'emailUsernameUnique' => [['email', 'username'], 'unique', 'when' => function ($model, $attribute) { |
|
94 | + 'emailUsernameUnique' => [['email', 'username'], 'unique', 'when' => function($model, $attribute) { |
|
95 | 95 | return $this->user->$attribute != $model->$attribute; |
96 | 96 | }, 'targetClass' => User::class], |
97 | 97 | 'newPasswordLength' => ['new_password', 'string', 'min' => 6], |
98 | 98 | 'currentPasswordRequired' => ['current_password', 'required'], |
99 | - 'currentPasswordValidate' => ['current_password', function ($attr) { |
|
99 | + 'currentPasswordValidate' => ['current_password', function($attr) { |
|
100 | 100 | if (!PasswordHelper::validate($this->$attr, $this->user->password_hash)) { |
101 | 101 | $this->addError($attr, Yii::t('yuncms', 'Current password is not valid')); |
102 | 102 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if ($this->email == $this->user->email && $this->user->unconfirmed_email != null) { |
141 | 141 | $this->user->unconfirmed_email = null; |
142 | 142 | } elseif ($this->email != $this->user->email) { |
143 | - switch (Yii::$app->settings->get('emailChangeStrategy','user')) { |
|
143 | + switch (Yii::$app->settings->get('emailChangeStrategy', 'user')) { |
|
144 | 144 | case UserSettings::STRATEGY_INSECURE: |
145 | 145 | $this->insecureEmailChange(); |
146 | 146 | break; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'emailRequired' => ['email', 'required'], |
50 | 50 | 'emailPattern' => ['email', 'email'], |
51 | 51 | 'emailExist' => ['email', 'exist', 'targetClass' => User::class], |
52 | - 'emailConfirmed' => ['email', function () { |
|
52 | + 'emailConfirmed' => ['email', function() { |
|
53 | 53 | if ($this->user != null && $this->user->isEmailConfirmed) { |
54 | 54 | $this->addError('email', Yii::t('yuncms', 'This account has already been confirmed')); |
55 | 55 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** @var UserToken $token */ |
89 | 89 | $token = new UserToken(['user_id' => $this->user->id, 'type' => UserToken::TYPE_CONFIRMATION]); |
90 | 90 | $token->save(false); |
91 | - Yii::$app->sendMail($this->user->email,Yii::t('yuncms', 'Confirm account on {0}', Yii::$app->name),'user/confirmation',['user' => $this->user, 'token' => $token]); |
|
91 | + Yii::$app->sendMail($this->user->email, Yii::t('yuncms', 'Confirm account on {0}', Yii::$app->name), 'user/confirmation', ['user' => $this->user, 'token' => $token]); |
|
92 | 92 | Yii::$app->session->setFlash('info', Yii::t('yuncms', 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.')); |
93 | 93 | return true; |
94 | 94 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | 'emailRequired' => ['email', 'required'], |
64 | 64 | 'emailPattern' => ['email', 'email'], |
65 | 65 | 'emailExist' => ['email', 'exist', 'targetClass' => User::class, 'message' => Yii::t('yuncms', 'There is no user with this email address')], |
66 | - 'emailUnconfirmed' => ['email', function ($attribute) { |
|
66 | + 'emailUnconfirmed' => ['email', function($attribute) { |
|
67 | 67 | $this->user = User::findByEmail($this->email); |
68 | - if ($this->user !== null && Yii::$app->settings->get('enableConfirmation','user') && !$this->user->isEmailConfirmed) { |
|
68 | + if ($this->user !== null && Yii::$app->settings->get('enableConfirmation', 'user') && !$this->user->isEmailConfirmed) { |
|
69 | 69 | $this->addError($attribute, Yii::t('yuncms', 'You need to confirm your email address.')); |
70 | 70 | } |
71 | 71 | }], |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | { |
84 | 84 | if ($this->validate()) { |
85 | 85 | /** @var UserToken $token */ |
86 | - $token = new UserToken([ 'user_id' => $this->user->id, 'type' => UserToken::TYPE_RECOVERY]); |
|
86 | + $token = new UserToken(['user_id' => $this->user->id, 'type' => UserToken::TYPE_RECOVERY]); |
|
87 | 87 | $token->save(false); |
88 | - Yii::$app->sendMail($this->user->email,Yii::t('yuncms', 'Complete password reset on {0}', Yii::$app->name),'user/recovery',['user' => $this->user, 'token' => $token]); |
|
88 | + Yii::$app->sendMail($this->user->email, Yii::t('yuncms', 'Complete password reset on {0}', Yii::$app->name), 'user/recovery', ['user' => $this->user, 'token' => $token]); |
|
89 | 89 | Yii::$app->session->setFlash('info', Yii::t('yuncms', 'An email has been sent with instructions for resetting your password')); |
90 | 90 | return true; |
91 | 91 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | 'location' => $this->string()->comment('Location'), |
31 | 31 | 'address' => $this->string()->comment('Address'), |
32 | 32 | 'website' => $this->string()->comment('Website'), |
33 | - 'timezone' => $this->string(100)->comment('Timezone'),//默认格林威治时间 |
|
33 | + 'timezone' => $this->string(100)->comment('Timezone'), //默认格林威治时间 |
|
34 | 34 | 'birthday' => $this->string(15)->comment('Birthday'), |
35 | 35 | 'current' => $this->smallInteger(1)->comment('Current'), |
36 | 36 | 'qq' => $this->string(11)->comment('QQ'), |
@@ -42,7 +42,7 @@ |
||
42 | 42 | { |
43 | 43 | /** @var ActiveRecord $class */ |
44 | 44 | $class = $this->modelClass; |
45 | - $class::create($this->attributes,$this->runValidation); |
|
45 | + $class::create($this->attributes, $this->runValidation); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) { |
31 | 31 | //监听用户活动时间 |
32 | 32 | /** @var \yii\web\UserEvent $event */ |
33 | - $app->on(Application::EVENT_AFTER_REQUEST, function ($event) use ($app) { |
|
33 | + $app->on(Application::EVENT_AFTER_REQUEST, function($event) use ($app) { |
|
34 | 34 | if (!$app->user->isGuest && Yii::$app->has('queue')) { |
35 | 35 | $user = UserExtra::findOne(['user_id' => $app->user->id]); |
36 | 36 | $user->updateAttributesAsync(['last_visit' => time()]); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | //监听用户登录事件 |
41 | 41 | /** @var \yii\web\UserEvent $event */ |
42 | - $app->user->on(User::EVENT_AFTER_LOGIN, function ($event) use ($app) { |
|
42 | + $app->user->on(User::EVENT_AFTER_LOGIN, function($event) use ($app) { |
|
43 | 43 | //记录最后登录时间记录最后登录IP记录登录次数 |
44 | 44 | $user = UserExtra::findOne(['user_id' => $app->user->id]); |
45 | 45 | $user->updateAttributesAsync(['login_at' => time(), 'login_ip' => Yii::$app->request->userIP]); |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | use Yii; |
22 | 22 | use <?= $generator->baseClass?>; |
23 | 23 | use yii\db\Connection; |
24 | -<?php if(isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
24 | +<?php if (isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
25 | 25 | use yii\helpers\Inflector; |
26 | 26 | <?php endif; ?> |
27 | 27 | |
28 | 28 | use yii\caching\DbDependency; |
29 | 29 | use yii\caching\ChainedDependency; |
30 | -<?php if(isset($labels['created_at'])): ?> |
|
30 | +<?php if (isset($labels['created_at'])): ?> |
|
31 | 31 | use yii\behaviors\TimestampBehavior; |
32 | 32 | <?php endif; ?> |
33 | -<?php if(isset($labels['user_id'])): ?> |
|
33 | +<?php if (isset($labels['user_id'])): ?> |
|
34 | 34 | use yii\behaviors\BlameableBehavior; |
35 | 35 | <?php endif; ?> |
36 | -<?php if(isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
36 | +<?php if (isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
37 | 37 | use yii\behaviors\AttributeBehavior; |
38 | 38 | <?php endif; ?> |
39 | 39 | use yuncms\helpers\DateHelper; |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | <?php endif; ?> |
54 | 54 | * |
55 | 55 | * @property-read boolean $isAuthor 是否是作者 |
56 | -<?php if(isset($labels['status'])): ?> |
|
56 | +<?php if (isset($labels['status'])): ?> |
|
57 | 57 | * @property-read boolean $isDraft 是否草稿 |
58 | 58 | * @property-read boolean $isPublished 是否发布 |
59 | 59 | <?php endif; ?> |
60 | 60 | */ |
61 | -class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') ?><?php if(isset($labels['status'])): ?> implements ScanInterface<?php endif; ?> |
|
61 | +class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') ?><?php if (isset($labels['status'])): ?> implements ScanInterface<?php endif; ?> |
|
62 | 62 | { |
63 | 63 | |
64 | 64 | //场景定义 |
65 | 65 | const SCENARIO_CREATE = 'create';//创建 |
66 | 66 | const SCENARIO_UPDATE = 'update';//更新 |
67 | -<?php if(isset($labels['status'])): ?> |
|
67 | +<?php if (isset($labels['status'])): ?> |
|
68 | 68 | //状态定义 |
69 | 69 | const STATUS_DRAFT = 0b0;//草稿 |
70 | 70 | const STATUS_REVIEW = 0b1;//待审核 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $behaviors['timestamp'] = [ |
98 | 98 | 'class' => TimestampBehavior::className() |
99 | 99 | ]; |
100 | -<?php elseif(isset($labels['created_at'])): ?> |
|
100 | +<?php elseif (isset($labels['created_at'])): ?> |
|
101 | 101 | $behaviors['timestamp'] = [ |
102 | 102 | 'class' => TimestampBehavior::className(), |
103 | 103 | 'attributes' => [ |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ], |
106 | 106 | ]; |
107 | 107 | <?php endif; ?> |
108 | -<?php if(isset($labels['user_id'])): ?> |
|
108 | +<?php if (isset($labels['user_id'])): ?> |
|
109 | 109 | $behaviors['user'] = [ |
110 | 110 | 'class' => BlameableBehavior::className(), |
111 | 111 | 'attributes' => [ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ], |
114 | 114 | ]; |
115 | 115 | <?php endif; ?> |
116 | -<?php if(isset($labels['slug'])): ?> |
|
116 | +<?php if (isset($labels['slug'])): ?> |
|
117 | 117 | $behaviors['slug'] = [ |
118 | 118 | 'class' => AttributeBehavior::className(), |
119 | 119 | 'attributes' => [ |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | ]; |
126 | 126 | <?php endif; ?> |
127 | -<?php if(isset($labels['uuid'])): ?> |
|
127 | +<?php if (isset($labels['uuid'])): ?> |
|
128 | 128 | $behaviors['uuid'] = [ |
129 | 129 | 'class' => AttributeBehavior::className(), |
130 | 130 | 'attributes' => [ |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function rules() |
168 | 168 | { |
169 | - return [<?= "\n " . implode(",\n ", $rules) . ",\n " ?> <?php if(isset($labels['status'])): ?>// status rule |
|
169 | + return [<?= "\n " . implode(",\n ", $rules) . ",\n " ?> <?php if (isset($labels['status'])): ?>// status rule |
|
170 | 170 | ['status', 'default', 'value' => self::STATUS_REVIEW], |
171 | 171 | ['status', 'in', 'range' => [self::STATUS_DRAFT, self::STATUS_REVIEW, self::STATUS_REJECTED, self::STATUS_PUBLISHED]],<?php endif; ?> |
172 | 172 | ]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | return $this->user_id == Yii::$app->user->id; |
217 | 217 | } |
218 | -<?php if(isset($labels['status'])): ?> |
|
218 | +<?php if (isset($labels['status'])): ?> |
|
219 | 219 | /** |
220 | 220 | * 是否草稿状态 |
221 | 221 | * @return bool |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | ])); |
397 | 397 | return $total; |
398 | 398 | } |
399 | -<?php if(isset($labels['created_at'])): ?> |
|
399 | +<?php if (isset($labels['created_at'])): ?> |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * 获取模型今日新增总数 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | { |
59 | 59 | return parent::one($db); |
60 | 60 | } |
61 | -<?php if(isset($labels['created_at'])): ?> |
|
61 | +<?php if (isset($labels['created_at'])): ?> |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * 热门模型 |