Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\user;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Entity\EntityChangedInterface;
|
Chris@0
|
6 use Drupal\Core\Entity\ContentEntityInterface;
|
Chris@0
|
7 use Drupal\Core\Session\AccountInterface;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Provides an interface defining a user entity.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @ingroup user_api
|
Chris@0
|
13 */
|
Chris@0
|
14 interface UserInterface extends ContentEntityInterface, EntityChangedInterface, AccountInterface {
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * Maximum length of username text field.
|
Chris@0
|
18 *
|
Chris@0
|
19 * Keep this under 191 characters so we can use a unique constraint in MySQL.
|
Chris@0
|
20 */
|
Chris@0
|
21 const USERNAME_MAX_LENGTH = 60;
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Only administrators can create user accounts.
|
Chris@0
|
25 */
|
Chris@0
|
26 const REGISTER_ADMINISTRATORS_ONLY = 'admin_only';
|
Chris@0
|
27
|
Chris@0
|
28 /**
|
Chris@0
|
29 * Visitors can create their own accounts.
|
Chris@0
|
30 */
|
Chris@0
|
31 const REGISTER_VISITORS = 'visitors';
|
Chris@0
|
32
|
Chris@0
|
33 /**
|
Chris@0
|
34 * Visitors can create accounts that only become active with admin approval.
|
Chris@0
|
35 */
|
Chris@0
|
36 const REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 'visitors_admin_approval';
|
Chris@0
|
37
|
Chris@0
|
38 /**
|
Chris@0
|
39 * New users will be set to the default time zone at registration.
|
Chris@0
|
40 */
|
Chris@0
|
41 const TIMEZONE_DEFAULT = 0;
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * New users will get an empty time zone at registration.
|
Chris@0
|
45 */
|
Chris@0
|
46 const TIMEZONE_EMPTY = 1;
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * New users will select their own timezone at registration.
|
Chris@0
|
50 */
|
Chris@0
|
51 const TIMEZONE_SELECT = 2;
|
Chris@0
|
52
|
Chris@0
|
53 /**
|
Chris@0
|
54 * Whether a user has a certain role.
|
Chris@0
|
55 *
|
Chris@0
|
56 * @param string $rid
|
Chris@0
|
57 * The role ID to check.
|
Chris@0
|
58 *
|
Chris@0
|
59 * @return bool
|
Chris@0
|
60 * Returns TRUE if the user has the role, otherwise FALSE.
|
Chris@0
|
61 */
|
Chris@0
|
62 public function hasRole($rid);
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * Add a role to a user.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @param string $rid
|
Chris@0
|
68 * The role ID to add.
|
Chris@0
|
69 */
|
Chris@0
|
70 public function addRole($rid);
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Remove a role from a user.
|
Chris@0
|
74 *
|
Chris@0
|
75 * @param string $rid
|
Chris@0
|
76 * The role ID to remove.
|
Chris@0
|
77 */
|
Chris@0
|
78 public function removeRole($rid);
|
Chris@0
|
79
|
Chris@0
|
80 /**
|
Chris@0
|
81 * Sets the username of this account.
|
Chris@0
|
82 *
|
Chris@0
|
83 * @param string $username
|
Chris@0
|
84 * The new user name.
|
Chris@0
|
85 *
|
Chris@0
|
86 * @return \Drupal\user\UserInterface
|
Chris@0
|
87 * The called user entity.
|
Chris@0
|
88 */
|
Chris@0
|
89 public function setUsername($username);
|
Chris@0
|
90
|
Chris@0
|
91 /**
|
Chris@0
|
92 * Returns the hashed password.
|
Chris@0
|
93 *
|
Chris@0
|
94 * @return string
|
Chris@0
|
95 * The hashed password.
|
Chris@0
|
96 */
|
Chris@0
|
97 public function getPassword();
|
Chris@0
|
98
|
Chris@0
|
99 /**
|
Chris@0
|
100 * Sets the user password.
|
Chris@0
|
101 *
|
Chris@0
|
102 * @param string $password
|
Chris@0
|
103 * The new unhashed password.
|
Chris@0
|
104 *
|
Chris@0
|
105 * @return \Drupal\user\UserInterface
|
Chris@0
|
106 * The called user entity.
|
Chris@0
|
107 */
|
Chris@0
|
108 public function setPassword($password);
|
Chris@0
|
109
|
Chris@0
|
110 /**
|
Chris@0
|
111 * Sets the email address of the user.
|
Chris@0
|
112 *
|
Chris@0
|
113 * @param string $mail
|
Chris@0
|
114 * The new email address of the user.
|
Chris@0
|
115 *
|
Chris@0
|
116 * @return \Drupal\user\UserInterface
|
Chris@0
|
117 * The called user entity.
|
Chris@0
|
118 */
|
Chris@0
|
119 public function setEmail($mail);
|
Chris@0
|
120
|
Chris@0
|
121 /**
|
Chris@0
|
122 * Returns the creation time of the user as a UNIX timestamp.
|
Chris@0
|
123 *
|
Chris@0
|
124 * @return int
|
Chris@0
|
125 * Timestamp of the creation date.
|
Chris@0
|
126 */
|
Chris@0
|
127 public function getCreatedTime();
|
Chris@0
|
128
|
Chris@0
|
129 /**
|
Chris@0
|
130 * Sets the UNIX timestamp when the user last accessed the site..
|
Chris@0
|
131 *
|
Chris@0
|
132 * @param int $timestamp
|
Chris@0
|
133 * Timestamp of the last access.
|
Chris@0
|
134 *
|
Chris@0
|
135 * @return \Drupal\user\UserInterface
|
Chris@0
|
136 * The called user entity.
|
Chris@0
|
137 */
|
Chris@0
|
138 public function setLastAccessTime($timestamp);
|
Chris@0
|
139
|
Chris@0
|
140 /**
|
Chris@0
|
141 * Returns the UNIX timestamp when the user last logged in.
|
Chris@0
|
142 *
|
Chris@0
|
143 * @return int
|
Chris@0
|
144 * Timestamp of the last login time.
|
Chris@0
|
145 */
|
Chris@0
|
146 public function getLastLoginTime();
|
Chris@0
|
147
|
Chris@0
|
148 /**
|
Chris@0
|
149 * Sets the UNIX timestamp when the user last logged in.
|
Chris@0
|
150 *
|
Chris@0
|
151 * @param int $timestamp
|
Chris@0
|
152 * Timestamp of the last login time.
|
Chris@0
|
153 *
|
Chris@0
|
154 * @return \Drupal\user\UserInterface
|
Chris@0
|
155 * The called user entity.
|
Chris@0
|
156 */
|
Chris@0
|
157 public function setLastLoginTime($timestamp);
|
Chris@0
|
158
|
Chris@0
|
159 /**
|
Chris@0
|
160 * Returns TRUE if the user is active.
|
Chris@0
|
161 *
|
Chris@0
|
162 * @return bool
|
Chris@0
|
163 * TRUE if the user is active, false otherwise.
|
Chris@0
|
164 */
|
Chris@0
|
165 public function isActive();
|
Chris@0
|
166
|
Chris@0
|
167 /**
|
Chris@0
|
168 * Returns TRUE if the user is blocked.
|
Chris@0
|
169 *
|
Chris@0
|
170 * @return bool
|
Chris@0
|
171 * TRUE if the user is blocked, false otherwise.
|
Chris@0
|
172 */
|
Chris@0
|
173 public function isBlocked();
|
Chris@0
|
174
|
Chris@0
|
175 /**
|
Chris@0
|
176 * Activates the user.
|
Chris@0
|
177 *
|
Chris@0
|
178 * @return \Drupal\user\UserInterface
|
Chris@0
|
179 * The called user entity.
|
Chris@0
|
180 */
|
Chris@0
|
181 public function activate();
|
Chris@0
|
182
|
Chris@0
|
183 /**
|
Chris@0
|
184 * Blocks the user.
|
Chris@0
|
185 *
|
Chris@0
|
186 * @return \Drupal\user\UserInterface
|
Chris@0
|
187 * The called user entity.
|
Chris@0
|
188 */
|
Chris@0
|
189 public function block();
|
Chris@0
|
190
|
Chris@0
|
191 /**
|
Chris@0
|
192 * Returns the email that was used when the user was registered.
|
Chris@0
|
193 *
|
Chris@0
|
194 * @return string
|
Chris@0
|
195 * Initial email address of the user.
|
Chris@0
|
196 */
|
Chris@0
|
197 public function getInitialEmail();
|
Chris@0
|
198
|
Chris@0
|
199 /**
|
Chris@0
|
200 * Sets the existing plain text password.
|
Chris@0
|
201 *
|
Chris@0
|
202 * Required for validation when changing the password, name or email fields.
|
Chris@0
|
203 *
|
Chris@0
|
204 * @param string $password
|
Chris@0
|
205 * The existing plain text password of the user.
|
Chris@0
|
206 *
|
Chris@0
|
207 * @return $this
|
Chris@0
|
208 */
|
Chris@0
|
209 public function setExistingPassword($password);
|
Chris@0
|
210
|
Chris@0
|
211 /**
|
Chris@0
|
212 * Checks the existing password if set.
|
Chris@0
|
213 *
|
Chris@0
|
214 * @param \Drupal\user\UserInterface $account_unchanged
|
Chris@0
|
215 * The unchanged user entity to compare against.
|
Chris@0
|
216 *
|
Chris@0
|
217 * @return bool
|
Chris@0
|
218 * TRUE if the correct existing password was provided.
|
Chris@0
|
219 *
|
Chris@0
|
220 * @see UserInterface::setExistingPassword()
|
Chris@0
|
221 */
|
Chris@0
|
222 public function checkExistingPassword(UserInterface $account_unchanged);
|
Chris@0
|
223
|
Chris@0
|
224 }
|