2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* User.php
|
|
|
|
* Contains key class User, as well as the Guest and Member class derived
|
|
|
|
* from it.
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User model; contains attributes and methods shared by both members and guests.
|
|
|
|
*/
|
|
|
|
abstract class User
|
|
|
|
{
|
2022-12-25 13:50:33 +01:00
|
|
|
protected int $id_user;
|
|
|
|
protected string $first_name;
|
|
|
|
protected string $surname;
|
|
|
|
protected string $slug;
|
|
|
|
protected string $emailaddress;
|
|
|
|
protected string $password_hash;
|
2016-09-01 23:13:23 +02:00
|
|
|
protected $creation_time;
|
|
|
|
protected $last_action_time;
|
|
|
|
protected $ip_address;
|
|
|
|
protected $is_admin;
|
2023-03-14 21:15:20 +01:00
|
|
|
protected $reset_key;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2022-12-25 13:50:33 +01:00
|
|
|
protected bool $is_logged;
|
|
|
|
protected bool $is_guest;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns user id.
|
|
|
|
*/
|
|
|
|
public function getUserId()
|
|
|
|
{
|
|
|
|
return $this->id_user;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns first name.
|
|
|
|
*/
|
|
|
|
public function getFirstName()
|
|
|
|
{
|
|
|
|
return $this->first_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns surname.
|
|
|
|
*/
|
|
|
|
public function getSurname()
|
|
|
|
{
|
|
|
|
return $this->surname;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns full name.
|
|
|
|
*/
|
|
|
|
public function getFullName()
|
|
|
|
{
|
|
|
|
return trim($this->first_name . ' ' . $this->surname);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns email address.
|
|
|
|
*/
|
|
|
|
public function getEmailAddress()
|
|
|
|
{
|
|
|
|
return $this->emailaddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Have a guess!
|
|
|
|
*/
|
|
|
|
public function getIPAddress()
|
|
|
|
{
|
|
|
|
return $this->ip_address;
|
|
|
|
}
|
|
|
|
|
2024-01-15 11:33:43 +01:00
|
|
|
public function getSlug()
|
|
|
|
{
|
|
|
|
return $this->slug;
|
|
|
|
}
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
/**
|
|
|
|
* Returns whether user is logged in.
|
|
|
|
*/
|
|
|
|
public function isLoggedIn()
|
|
|
|
{
|
|
|
|
return $this->is_logged;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether user is a guest.
|
|
|
|
*/
|
|
|
|
public function isGuest()
|
|
|
|
{
|
|
|
|
return $this->is_guest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether user is an administrator.
|
|
|
|
*/
|
|
|
|
public function isAdmin()
|
|
|
|
{
|
|
|
|
return $this->is_admin;
|
|
|
|
}
|
|
|
|
}
|