add capacity to modify user

This commit is contained in:
osaajani 2021-06-12 23:23:15 +02:00
parent f9e0312c89
commit 4a39865903
12 changed files with 687 additions and 143 deletions

View file

@ -13,6 +13,18 @@ namespace models;
class Quota extends StandardModel
{
/**
* Return the quota for a user if it exists.
*
* @param int $id_user : user id
*
* @return array : quota if found, else empty array
*/
public function get_user_quota(int $id_user)
{
return $this->_select_one($this->get_table_name(), ['id_user' => $id_user]);
}
/**
* Get remaining credit for a date
* if no quota for this user return max int
@ -168,7 +180,6 @@ namespace models;
{
$at = $at->format('Y-m-d H:i:s');
$where = [
'!=expiration_date' => null,
'<=expiration_date' => $at,
'auto_renew' => true,
];

View file

@ -31,6 +31,32 @@ namespace models;
return $this->_select_one('user', ['id' => $id]);
}
/**
* Find user by ids
* @param array $ids : users ids
*
* @return array
*/
public function gets_in_by_id($ids)
{
if (!$ids)
{
return [];
}
$query = '
SELECT * FROM `user`
WHERE id ';
$params = [];
$generated_in = $this->_generate_in_from_array($ids);
$query .= $generated_in['QUERY'];
$params = $generated_in['PARAMS'];
return $this->_run_query($query, $params);
}
/**
* Find a user using his email.
*