|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Root class for users, this will mostly be used to store generic |
|
5
|
|
|
* config, but will probably be extended in future to provide additional |
|
6
|
|
|
* functionality. |
|
7
|
|
|
* |
|
8
|
|
|
* @package Users |
|
9
|
|
|
* @author i-lateral <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class Users extends Object |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Minimum character length of the password required |
|
16
|
|
|
* on registration/account editing |
|
17
|
|
|
* |
|
18
|
|
|
* @var int |
|
19
|
|
|
* @config |
|
20
|
|
|
*/ |
|
21
|
|
|
private static $password_min_length = 6; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Maximum character length of the password required |
|
25
|
|
|
* on registration/account editing |
|
26
|
|
|
* |
|
27
|
|
|
* @var int |
|
28
|
|
|
* @config |
|
29
|
|
|
*/ |
|
30
|
|
|
private static $password_max_length = 16; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Enforces strong password (at least one digit and one alphanumeric |
|
34
|
|
|
* character) on registration/account editing |
|
35
|
|
|
* |
|
36
|
|
|
* @var boolean |
|
37
|
|
|
* @config |
|
38
|
|
|
*/ |
|
39
|
|
|
private static $password_require_strong = false; |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Stipulate if a user requires verification. NOTE this does not |
|
43
|
|
|
* actually deny the user the ability to login, it only alerts them |
|
44
|
|
|
* that they need validiation |
|
45
|
|
|
* |
|
46
|
|
|
* @var boolean |
|
47
|
|
|
* @config |
|
48
|
|
|
*/ |
|
49
|
|
|
private static $require_verification = true; |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Stipulate whether to send a verification email to users after |
|
53
|
|
|
* registration |
|
54
|
|
|
* |
|
55
|
|
|
* @var boolean |
|
56
|
|
|
* @config |
|
57
|
|
|
*/ |
|
58
|
|
|
private static $send_verification_email = false; |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Stipulate the sender address for emails sent from this module. If |
|
62
|
|
|
* not set, use the default @Email.admin_email instead. |
|
63
|
|
|
* |
|
64
|
|
|
* @var string |
|
65
|
|
|
* @config |
|
66
|
|
|
*/ |
|
67
|
|
|
private static $send_email_from; |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Auto login users after registration |
|
71
|
|
|
* |
|
72
|
|
|
* @var boolean |
|
73
|
|
|
* @config |
|
74
|
|
|
*/ |
|
75
|
|
|
private static $login_after_register = true; |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Add new users to the following groups. This is a list of group codes. |
|
79
|
|
|
* Adding a new code will add the user to this group |
|
80
|
|
|
* |
|
81
|
|
|
* @var array |
|
82
|
|
|
* @config |
|
83
|
|
|
*/ |
|
84
|
|
|
private static $new_user_groups = array( |
|
|
|
|
|
|
85
|
|
|
"users-frontend" |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Remove a group from the list of groups a new user is added to on |
|
90
|
|
|
* registering. |
|
91
|
|
|
* |
|
92
|
|
|
* @param string $code Group code that will be used |
|
93
|
|
|
* |
|
94
|
|
|
* @return void |
|
95
|
|
|
*/ |
|
96
|
|
|
public static function removeNewUserGroup($code) |
|
97
|
|
|
{ |
|
98
|
|
|
if (isset(self::config()->new_user_groups[$code])) { |
|
99
|
|
|
unset(self::config()->new_user_groups[$code]); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Groups a user will be added to when verified. This should be an |
|
105
|
|
|
* array of group "codes", NOT names or ID's |
|
106
|
|
|
* |
|
107
|
|
|
* @var array |
|
108
|
|
|
* @config |
|
109
|
|
|
*/ |
|
110
|
|
|
private static $verification_groups = array( |
|
|
|
|
|
|
111
|
|
|
"users-verified" |
|
112
|
|
|
); |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Remove a group from the list of groups a new user is added to on |
|
116
|
|
|
* registering. |
|
117
|
|
|
* |
|
118
|
|
|
* @param string $code Group code that will be used |
|
119
|
|
|
* |
|
120
|
|
|
* @return void |
|
121
|
|
|
*/ |
|
122
|
|
|
public static function removeVerificationGroup($code) |
|
123
|
|
|
{ |
|
124
|
|
|
if (isset(self::config()->verification_groups[$code])) { |
|
125
|
|
|
unset(self::config()->verification_groups[$code]); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.