This class is an implementation of the active record pattern and has been created in order to simplify the
access to the table "user".
Each User has many Article(s).
Accessible methods:
public static function findById($id):
return an User querying the database.
public static function findByName():
return an array of all User contained in the database.
public static function findByUsernameAndEmail($username, $email):
return the User matching the
username and email.
public static function findAll():
return an array containing all User(s) in the database.
public static function findAllToShow():
return an array User(s) having the flag "toShow" setted
to true.
public function checkUsrPsw($usr, $psw):
check if the username $usr and the password $psw
have a match in the database.
public function articles():
return an array of
Article(s) that belong to the User istance.
public function articlesComments():
return an array of
Comment(s) that belong to all
Article(s) that belong to the User istance.
public function getMaxId():
return an Integer value containing the bigger
id field in the table "User".
public function save():
save the courrent istance.
public function delete():
delete from the database the courrent istance and reset all the
istance fields.
protected function insert():
insert a new istance in the database.
protected function update():
update the courrent istance in the corresponding database record
protected function updatePassword($NewPsw, $OldPsw):
update the password saved in the database.
In order to do that the old password ($OldPsw) MUSTS match with the old password saved in the database.
In the database password are saved using MD5 hash algorhythm.
protected function setNewRandomPassword():
create a new random password, save the MD5 of the password
in the database and return it in order to be sended by email.
public function getId():
return the id of the User istance.
public function getName():
return the Name of the User istance.
public function setName($name):
set the Name of the User istance.
public function getUsername():
return the Username of the User istance.
public function setUsername($username):
set the Username of the User istance.
public function getBody():
return the Body of the User istance, filtered by the filters
definited in the plugins activated.
public function getUnfilteredBody():
return the Body of the User istance, unfiltered.
public function setBody($body):
set the Body of the istance of the User.
public function getRole():
return the Role of the User istance.
public function setRole($role):
set the Role of the User istance.
public function getToshow():
return the "ToShow" flag of the User istance. User having a
"ToShow" setted to True are listed in the website.