2018-04-15 10:35:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* User model
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
class User {
|
|
|
|
|
|
|
|
//Private fields
|
|
|
|
private $id;
|
|
|
|
private $firstName;
|
|
|
|
private $lastName;
|
|
|
|
private $publicPage;
|
|
|
|
private $openPage;
|
|
|
|
private $virtualDirectory;
|
|
|
|
private $accountImageURL;
|
|
|
|
|
2018-04-15 10:36:59 +00:00
|
|
|
/**
|
|
|
|
* Public constructor of this object
|
|
|
|
*/
|
|
|
|
public function __construct(){
|
|
|
|
|
|
|
|
//Set the user ID to 0 by default (invalid user)
|
|
|
|
$this->set_id(0);
|
|
|
|
|
|
|
|
}
|
2018-04-15 10:35:00 +00:00
|
|
|
|
|
|
|
//Set and get user ID
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_id(int $id){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->id = $id;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function get_id() : int {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Set and get the first name of the user
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_firstName(string $firstName){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->firstName = $firstName;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function get_firstName() : string {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->firstName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Set and get the last name of the user
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_lastName(string $lastName){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->lastName = $lastName;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function get_lastName() : string {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->lastName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Set and get the public status of the user page
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_publicPage(bool $publicPage){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->publicPage = $publicPage;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function is_publicPage() : bool {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->publicPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Set and get the open status of the user page
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_openPage(bool $openPage){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->openPage = $openPage;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function is_openPage() : bool {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->openPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Set and get the virtual directory of the user
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_virtualDirectory(string $virtualDirectory){
|
|
|
|
$this->virtualDirectory = $virtualDirectory == "" ? null : $virtualDirectory;
|
2018-04-15 10:35:00 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function get_virtualDirectory() : string {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->virtualDirectory != null ? $this->virtualDirectory : "null";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Set and get the URL pointing of the user account image
|
2018-04-15 11:55:51 +00:00
|
|
|
public function set_accountImageURL(string $accountImageURL){
|
2018-04-15 10:35:00 +00:00
|
|
|
$this->accountImageURL = $accountImageURL;
|
|
|
|
}
|
|
|
|
|
2018-04-15 11:55:51 +00:00
|
|
|
public function get_accountImageURL() : string {
|
2018-04-15 10:35:00 +00:00
|
|
|
return $this->accountImageURL;
|
|
|
|
}
|
2018-04-15 10:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check wether is object is valid or not
|
|
|
|
*
|
|
|
|
* @return bool TRUE if this object is valid / FALSE else
|
|
|
|
*/
|
|
|
|
public function isValid() : bool {
|
|
|
|
return $this->id > 0;
|
|
|
|
}
|
2018-04-15 10:35:00 +00:00
|
|
|
}
|