93 lines
No EOL
1.7 KiB
PHP
93 lines
No EOL
1.7 KiB
PHP
<?php
|
|
/**
|
|
* User
|
|
*
|
|
*/
|
|
class User
|
|
{
|
|
|
|
protected $_email;
|
|
protected $_firstName;
|
|
protected $_lastName;
|
|
protected $_regDate;
|
|
protected $_isDeleted = false;
|
|
|
|
|
|
public function __construct(array $data = array()) {
|
|
|
|
|
|
if (isset($data['table']) && $data['table'] instanceof Users) {
|
|
|
|
$this->setFirstName($data['data']['firstName']);
|
|
$this->setLastName($data['data']['lastName']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Set user lastname
|
|
*
|
|
* @param string $name
|
|
* @return boolean
|
|
*/
|
|
public function setLastName($name)
|
|
{
|
|
if (is_string($name) && preg_match('/^[A-ö\ \.\-]{0,20}$/', $name)) {
|
|
$this->_lastName = $name;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/**
|
|
* Set user firstname
|
|
*
|
|
* @param string $name
|
|
* @return boolean
|
|
*/
|
|
public function setFirstName($name)
|
|
{
|
|
if (is_string($name) && preg_match('/^[A-ö\-]{0,10}$/', $name)) {
|
|
$this->_firstName = $name;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the user registration date
|
|
*
|
|
* @return string $_regDate
|
|
*/
|
|
public function userSince()
|
|
{
|
|
return (!empty($_regDate)) ?: null;
|
|
}
|
|
|
|
|
|
/**
|
|
* Controll wheter the user is currently active on the
|
|
* site.
|
|
* TODO: Make sure we have a way to see if the user is logged in.
|
|
* @return boolean
|
|
*/
|
|
public function isActive()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* String representation of the object
|
|
* @return string
|
|
*/
|
|
public function __toString()
|
|
{
|
|
return '{' . $this->_firstName . ' ' . $this->_lastName . '}';
|
|
}
|
|
} |