mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Created BaseUserModel
This commit is contained in:
parent
2dbedc1303
commit
2bd38270a1
31
classes/models/BaseUserModel.php
Normal file
31
classes/models/BaseUserModel.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Base user model that contains identification information
|
||||||
|
* about the user
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BaseUserModel {
|
||||||
|
|
||||||
|
//Private fields
|
||||||
|
private $userID = 0;
|
||||||
|
|
||||||
|
//Set and get user ID
|
||||||
|
public function set_id(int $id){
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_id() : int {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check wether this object is valid or not
|
||||||
|
*
|
||||||
|
* @return bool TRUE if this object is valid / FALSE else
|
||||||
|
*/
|
||||||
|
public function isValid() : bool {
|
||||||
|
return $this->id > 0;
|
||||||
|
}
|
||||||
|
}
|
@ -5,10 +5,9 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class GeneralSettings {
|
class GeneralSettings extends BaseUserModel {
|
||||||
|
|
||||||
//Private fields
|
//Private fields
|
||||||
private $id;
|
|
||||||
private $email;
|
private $email;
|
||||||
private $firstName;
|
private $firstName;
|
||||||
private $lastName;
|
private $lastName;
|
||||||
@ -21,15 +20,6 @@ class GeneralSettings {
|
|||||||
private $virtualDirectory;
|
private $virtualDirectory;
|
||||||
private $personnalWebsite;
|
private $personnalWebsite;
|
||||||
|
|
||||||
//Set and get user ID
|
|
||||||
public function set_id(int $id){
|
|
||||||
$this->id = $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_id() : int {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set and get the email address of the user
|
//Set and get the email address of the user
|
||||||
public function set_email(string $email){
|
public function set_email(string $email){
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
@ -150,13 +140,4 @@ class GeneralSettings {
|
|||||||
public function get_personnalWebsite() : string {
|
public function get_personnalWebsite() : string {
|
||||||
return $this->personnalWebsite != null ? $this->personnalWebsite : "null";
|
return $this->personnalWebsite != null ? $this->personnalWebsite : "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,7 +5,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SecuritySettings {
|
class SecuritySettings extends BaseUserModel {
|
||||||
|
|
||||||
//Private fields
|
//Private fields
|
||||||
private $security_question_1;
|
private $security_question_1;
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class User {
|
//This model requires the BaseUserModel to be loaded
|
||||||
|
require_once __DIR__."/BaseUserModel.php";
|
||||||
|
|
||||||
|
class User extends BaseUserModel {
|
||||||
|
|
||||||
//Private fields
|
//Private fields
|
||||||
private $id;
|
|
||||||
private $firstName;
|
private $firstName;
|
||||||
private $lastName;
|
private $lastName;
|
||||||
private $publicPage;
|
private $publicPage;
|
||||||
@ -16,26 +18,6 @@ class User {
|
|||||||
private $virtualDirectory;
|
private $virtualDirectory;
|
||||||
private $accountImageURL;
|
private $accountImageURL;
|
||||||
|
|
||||||
/**
|
|
||||||
* Public constructor of this object
|
|
||||||
*/
|
|
||||||
public function __construct(){
|
|
||||||
|
|
||||||
//Set the user ID to 0 by default (invalid user)
|
|
||||||
$this->set_id(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set and get user ID
|
|
||||||
public function set_id(int $id){
|
|
||||||
$this->id = $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_id() : int {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Set and get the first name of the user
|
//Set and get the first name of the user
|
||||||
public function set_firstName(string $firstName){
|
public function set_firstName(string $firstName){
|
||||||
$this->firstName = $firstName;
|
$this->firstName = $firstName;
|
||||||
@ -96,13 +78,4 @@ class User {
|
|||||||
public function get_accountImageURL() : string {
|
public function get_accountImageURL() : string {
|
||||||
return $this->accountImageURL;
|
return $this->accountImageURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user