mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-06-06 06:46:25 +02:00
Update all models to use StandardModel basis
This commit is contained in:
parent
0e22f3d02c
commit
155a048834
17 changed files with 580 additions and 1478 deletions
|
@ -11,30 +11,33 @@
|
|||
|
||||
namespace models;
|
||||
|
||||
/**
|
||||
* Class for user table administration. Not a standard model because has absolutly no user based restrictions
|
||||
*/
|
||||
class User extends \descartes\Model
|
||||
{
|
||||
/**
|
||||
* Retourne un user par son email.
|
||||
*
|
||||
* @param string $email : L'email du user
|
||||
*
|
||||
* @return mixed array | false : false si pas de user pour ce mail, sinon le user associé sous forme de tableau
|
||||
* Find a user using his email
|
||||
* @param string $email : User email
|
||||
* @return mixed array
|
||||
*/
|
||||
public function get_by_email($email)
|
||||
{
|
||||
return $this->_select_one('user', ['email' => $email]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return users by transfer status.
|
||||
*
|
||||
* Return users by their transfer status.
|
||||
* @param bool $transfer : transfer status
|
||||
* @return array
|
||||
*/
|
||||
public function gets_by_transfer($transfer)
|
||||
{
|
||||
return $this->_select('transfer', ['transfer' => $transfer]);
|
||||
return $this->_select('user', ['transfer' => $transfer]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return list of user.
|
||||
*
|
||||
|
@ -46,6 +49,7 @@ namespace models;
|
|||
return $this->_select('user', [], null, false, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne une liste de useres sous forme d'un tableau.
|
||||
*
|
||||
|
@ -59,44 +63,35 @@ namespace models;
|
|||
return $this->_delete('user', ['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert un user.
|
||||
*
|
||||
* @param array $user : La user à insérer avec les champs name, script, admin & admin
|
||||
*
|
||||
* @return mixed bool|int : false si echec, sinon l'id de la nouvelle lignée insérée
|
||||
* Insert a new user
|
||||
* @param array $user : User to insert
|
||||
* @return mixed bool|int : false if fail, new user id else
|
||||
*/
|
||||
public function insert($user)
|
||||
{
|
||||
$result = $this->_insert('user', $user);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_last_id();
|
||||
$success = $this->_insert('user', $user);
|
||||
return ($success ? $this->_last_id() : false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Met à jour un user par son id.
|
||||
*
|
||||
* @param int $id : L'id de la user à modifier
|
||||
* @param array $user : Les données à mettre à jour pour la user
|
||||
*
|
||||
* @return int : le nombre de ligne modifiées
|
||||
* Update a user using his is
|
||||
* @param int $id : User id
|
||||
* @param array $datas : Datas to update
|
||||
* @return int : number of modified rows
|
||||
*/
|
||||
public function update($id, $user)
|
||||
public function update($id, $datas)
|
||||
{
|
||||
return $this->_update('user', $user, ['id' => $id]);
|
||||
return $this->_update('user', $datas, ['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a user password by his id.
|
||||
*
|
||||
* @param int $id : User id
|
||||
* @param array $password : The new password of the user
|
||||
*
|
||||
* @return int : Number of modified lines
|
||||
*/
|
||||
public function update_password($id, $password)
|
||||
|
@ -104,12 +99,11 @@ namespace models;
|
|||
return $this->_update('user', ['password' => $password], ['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a user transfer property value by his id.
|
||||
*
|
||||
* @param int $id : User id
|
||||
* @param array $transfer : The new transfer property value
|
||||
*
|
||||
* @return int : Number of modified lines
|
||||
*/
|
||||
public function update_transfer($id, $transfer)
|
||||
|
@ -117,12 +111,11 @@ namespace models;
|
|||
return $this->_update('user', ['transfer' => $transfer], ['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a user email by his id.
|
||||
*
|
||||
* @param int $id : User id
|
||||
* @param array $email : The new email
|
||||
*
|
||||
* @return int : Number of modified lines
|
||||
*/
|
||||
public function update_email($id, $email)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue