-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Settings.php
99 lines (84 loc) · 2.93 KB
/
Settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php namespace Winter\User\Models;
use Model;
class Settings extends Model
{
/**
* @var array Behaviors implemented by this model.
*/
public $implement = [
\System\Behaviors\SettingsModel::class
];
public $settingsCode = 'user_settings';
public $settingsFields = 'fields.yaml';
const ACTIVATE_AUTO = 'auto';
const ACTIVATE_USER = 'user';
const ACTIVATE_ADMIN = 'admin';
const LOGIN_EMAIL = 'email';
const LOGIN_USERNAME = 'username';
const REMEMBER_ALWAYS = 'always';
const REMEMBER_NEVER = 'never';
const REMEMBER_ASK = 'ask';
public function initSettingsData()
{
$this->require_activation = config('winter.user::requireActivation', true);
$this->activate_mode = config('winter.user::activateMode', self::ACTIVATE_AUTO);
$this->use_throttle = config('winter.user::useThrottle', true);
$this->block_persistence = config('winter.user::blockPersistence', false);
$this->allow_registration = config('winter.user::allowRegistration', true);
$this->login_attribute = config('winter.user::loginAttribute', self::LOGIN_EMAIL);
$this->remember_login = config('winter.user::rememberLogin', self::REMEMBER_ALWAYS);
$this->use_register_throttle = config('winter.user::useRegisterThrottle', true);
}
public function getActivateModeOptions()
{
return [
self::ACTIVATE_AUTO => [
'winter.user::lang.settings.activate_mode_auto',
'winter.user::lang.settings.activate_mode_auto_comment'
],
self::ACTIVATE_USER => [
'winter.user::lang.settings.activate_mode_user',
'winter.user::lang.settings.activate_mode_user_comment'
],
self::ACTIVATE_ADMIN => [
'winter.user::lang.settings.activate_mode_admin',
'winter.user::lang.settings.activate_mode_admin_comment'
]
];
}
public function getActivateModeAttribute($value)
{
if (!$value) {
return self::ACTIVATE_AUTO;
}
return $value;
}
public function getLoginAttributeOptions()
{
return [
self::LOGIN_EMAIL => ['winter.user::lang.login.attribute_email'],
self::LOGIN_USERNAME => ['winter.user::lang.login.attribute_username']
];
}
public function getRememberLoginOptions()
{
return [
self::REMEMBER_ALWAYS => [
'winter.user::lang.settings.remember_always',
],
self::REMEMBER_NEVER => [
'winter.user::lang.settings.remember_never',
],
self::REMEMBER_ASK => [
'winter.user::lang.settings.remember_ask',
]
];
}
public function getRememberLoginAttribute($value)
{
if (!$value) {
return self::REMEMBER_ALWAYS;
}
return $value;
}
}