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