[CLEANUP] The correct case must be used for standard PHP types in phpdoc
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Domain / Model / BackendUser.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * This model represents a back-end user.
19 *
20 * @api
21 */
22 class BackendUser extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
23 {
24 /**
25 * @var string
26 * @validate notEmpty
27 */
28 protected $userName = '';
29
30 /**
31 * @var string
32 */
33 protected $description = '';
34
35 /**
36 * @var bool
37 */
38 protected $isAdministrator = false;
39
40 /**
41 * @var bool
42 */
43 protected $isDisabled = false;
44
45 /**
46 * @var \DateTime|null
47 */
48 protected $startDateAndTime = null;
49
50 /**
51 * @var \DateTime|null
52 */
53 protected $endDateAndTime = null;
54
55 /**
56 * @var string
57 */
58 protected $email = '';
59
60 /**
61 * @var string
62 */
63 protected $realName = '';
64
65 /**
66 * @var \DateTime|null
67 */
68 protected $lastLoginDateAndTime;
69
70 /**
71 * @var bool
72 */
73 protected $ipLockIsDisabled = false;
74
75 /**
76 * Gets the user name.
77 *
78 * @return string the user name, will not be empty
79 */
80 public function getUserName()
81 {
82 return $this->userName;
83 }
84
85 /**
86 * Sets the user name.
87 *
88 * @param string $userName the user name to set, must not be empty
89 */
90 public function setUserName($userName)
91 {
92 $this->userName = $userName;
93 }
94
95 /**
96 * @return string
97 */
98 public function getDescription()
99 {
100 return $this->description;
101 }
102
103 /**
104 * @param string $description
105 */
106 public function setDescription($description)
107 {
108 $this->description = $description;
109 }
110
111 /**
112 * Checks whether this user is an administrator.
113 *
114 * @return bool whether this user is an administrator
115 */
116 public function getIsAdministrator()
117 {
118 return $this->isAdministrator;
119 }
120
121 /**
122 * Sets whether this user should be an administrator.
123 *
124 * @param bool $isAdministrator whether this user should be an administrator
125 */
126 public function setIsAdministrator($isAdministrator)
127 {
128 $this->isAdministrator = $isAdministrator;
129 }
130
131 /**
132 * Checks whether this user is disabled.
133 *
134 * @return bool whether this user is disabled
135 */
136 public function getIsDisabled()
137 {
138 return $this->isDisabled;
139 }
140
141 /**
142 * Sets whether this user is disabled.
143 *
144 * @param bool $isDisabled whether this user is disabled
145 */
146 public function setIsDisabled($isDisabled)
147 {
148 $this->isDisabled = $isDisabled;
149 }
150
151 /**
152 * Returns the point in time from which this user is enabled.
153 *
154 * @return \DateTime|null the start date and time
155 */
156 public function getStartDateAndTime()
157 {
158 return $this->startDateAndTime;
159 }
160
161 /**
162 * Sets the point in time from which this user is enabled.
163 *
164 * @param \DateTime|null $dateAndTime the start date and time
165 */
166 public function setStartDateAndTime(\DateTime $dateAndTime = null)
167 {
168 $this->startDateAndTime = $dateAndTime;
169 }
170
171 /**
172 * Returns the point in time before which this user is enabled.
173 *
174 * @return \DateTime|null the end date and time
175 */
176 public function getEndDateAndTime()
177 {
178 return $this->endDateAndTime;
179 }
180
181 /**
182 * Sets the point in time before which this user is enabled.
183 *
184 * @param \DateTime|null $dateAndTime the end date and time
185 */
186 public function setEndDateAndTime(\DateTime $dateAndTime = null)
187 {
188 $this->endDateAndTime = $dateAndTime;
189 }
190
191 /**
192 * Gets the e-mail address of this user.
193 *
194 * @return string the e-mail address, might be empty
195 */
196 public function getEmail()
197 {
198 return $this->email;
199 }
200
201 /**
202 * Sets the e-mail address of this user.
203 *
204 * @param string $email the e-mail address, may be empty
205 */
206 public function setEmail($email)
207 {
208 $this->email = $email;
209 }
210
211 /**
212 * Returns this user's real name.
213 *
214 * @return string the real name. might be empty
215 */
216 public function getRealName()
217 {
218 return $this->realName;
219 }
220
221 /**
222 * Sets this user's real name.
223 *
224 * @param string $name the user's real name, may be empty.
225 */
226 public function setRealName($name)
227 {
228 $this->realName = $name;
229 }
230
231 /**
232 * Checks whether this user is currently activated.
233 *
234 * This function takes the "disabled" flag, the start date/time and the end date/time into account.
235 *
236 * @return bool whether this user is currently activated
237 */
238 public function isActivated()
239 {
240 return !$this->getIsDisabled() && $this->isActivatedViaStartDateAndTime() && $this->isActivatedViaEndDateAndTime();
241 }
242
243 /**
244 * Checks whether this user is activated as far as the start date and time is concerned.
245 *
246 * @return bool whether this user is activated as far as the start date and time is concerned
247 */
248 protected function isActivatedViaStartDateAndTime()
249 {
250 if ($this->getStartDateAndTime() === null) {
251 return true;
252 }
253 $now = new \DateTime('now');
254 return $this->getStartDateAndTime() <= $now;
255 }
256
257 /**
258 * Checks whether this user is activated as far as the end date and time is concerned.
259 *
260 * @return bool whether this user is activated as far as the end date and time is concerned
261 */
262 protected function isActivatedViaEndDateAndTime()
263 {
264 if ($this->getEndDateAndTime() === null) {
265 return true;
266 }
267 $now = new \DateTime('now');
268 return $now <= $this->getEndDateAndTime();
269 }
270
271 /**
272 * Sets whether the IP lock for this user is disabled.
273 *
274 * @param bool $disableIpLock whether the IP lock for this user is disabled
275 */
276 public function setIpLockIsDisabled($disableIpLock)
277 {
278 $this->ipLockIsDisabled = $disableIpLock;
279 }
280
281 /**
282 * Checks whether the IP lock for this user is disabled.
283 *
284 * @return bool whether the IP lock for this user is disabled
285 */
286 public function getIpLockIsDisabled()
287 {
288 return $this->ipLockIsDisabled;
289 }
290
291 /**
292 * Gets this user's last login date and time.
293 *
294 * @return \DateTime|null this user's last login date and time, will be NULL if this user has never logged in before
295 */
296 public function getLastLoginDateAndTime()
297 {
298 return $this->lastLoginDateAndTime;
299 }
300
301 /**
302 * Sets this user's last login date and time.
303 *
304 * @param \DateTime|null $dateAndTime this user's last login date and time
305 */
306 public function setLastLoginDateAndTime(\DateTime $dateAndTime = null)
307 {
308 $this->lastLoginDateAndTime = $dateAndTime;
309 }
310 }