Do not take deleted records into concern
This commit is contained in:
parent
74df69b33a
commit
8c91c86508
3 changed files with 21 additions and 18 deletions
|
@ -153,6 +153,7 @@ class Admins_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_ADMIN)
|
||||
->where('users.email', $admin['email'])
|
||||
->where('users.id !=', $admin_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -177,7 +178,7 @@ class Admins_model extends EA_Model {
|
|||
$this->db->where('id_users !=', $admin_id);
|
||||
}
|
||||
|
||||
return $this->db->get_where('user_settings', ['username' => $username])->num_rows() === 0;
|
||||
return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +195,7 @@ class Admins_model extends EA_Model {
|
|||
$admin['id_roles'] = $this->get_admin_role_id();
|
||||
|
||||
$settings = $admin['settings'];
|
||||
|
||||
|
||||
unset(
|
||||
$admin['settings']
|
||||
);
|
||||
|
@ -228,9 +229,9 @@ class Admins_model extends EA_Model {
|
|||
protected function update(array $admin): int
|
||||
{
|
||||
$settings = $admin['settings'];
|
||||
|
||||
|
||||
$settings['id_users'] = $admin['id'];
|
||||
|
||||
|
||||
unset(
|
||||
$admin['settings']
|
||||
);
|
||||
|
|
|
@ -168,6 +168,7 @@ class Providers_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_PROVIDER)
|
||||
->where('users.email', $provider['email'])
|
||||
->where('users.id !=', $provider_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -192,7 +193,7 @@ class Providers_model extends EA_Model {
|
|||
$this->db->where('id_users !=', $provider_id);
|
||||
}
|
||||
|
||||
return $this->db->get_where('user_settings', ['username' => $username])->num_rows() === 0;
|
||||
return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,7 +214,7 @@ class Providers_model extends EA_Model {
|
|||
$service_ids = $provider['services'];
|
||||
|
||||
$settings = $provider['settings'];
|
||||
|
||||
|
||||
unset(
|
||||
$provider['services'],
|
||||
$provider['settings']
|
||||
|
@ -246,7 +247,7 @@ class Providers_model extends EA_Model {
|
|||
protected function update(array $provider): int
|
||||
{
|
||||
$provider['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$service_ids = $provider['services'];
|
||||
|
||||
$settings = $provider['settings'];
|
||||
|
@ -315,7 +316,7 @@ class Providers_model extends EA_Model {
|
|||
{
|
||||
$this->db->where('delete_datetime IS NULL');
|
||||
}
|
||||
|
||||
|
||||
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
|
||||
|
||||
if ( ! $provider)
|
||||
|
@ -396,7 +397,7 @@ class Providers_model extends EA_Model {
|
|||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
* @param bool $with_trashed
|
||||
*
|
||||
*
|
||||
* @return array Returns an array of providers.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
|
@ -708,7 +709,7 @@ class Providers_model extends EA_Model {
|
|||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
* @param bool $with_trashed
|
||||
*
|
||||
*
|
||||
* @return array Returns an array of providers.
|
||||
*/
|
||||
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
|
@ -719,7 +720,7 @@ class Providers_model extends EA_Model {
|
|||
{
|
||||
$this->db->where('delete_datetime IS NULL');
|
||||
}
|
||||
|
||||
|
||||
$providers = $this
|
||||
->db
|
||||
->select()
|
||||
|
|
|
@ -166,6 +166,7 @@ class Secretaries_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_SECRETARY)
|
||||
->where('users.email', $secretary['email'])
|
||||
->where('users.id !=', $secretary_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -190,7 +191,7 @@ class Secretaries_model extends EA_Model {
|
|||
$this->db->where('id_users !=', $secretary_id);
|
||||
}
|
||||
|
||||
return $this->db->get_where('user_settings', ['username' => $username])->num_rows() === 0;
|
||||
return $this->db->get_where('user_settings', ['username' => $username, 'delete_datetime' => NULL])->num_rows() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,7 +207,7 @@ class Secretaries_model extends EA_Model {
|
|||
{
|
||||
$secretary['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$secretary['id_roles'] = $this->get_secretary_role_id();
|
||||
|
||||
$provider_ids = $secretary['providers'] ?? [];
|
||||
|
@ -245,7 +246,7 @@ class Secretaries_model extends EA_Model {
|
|||
protected function update(array $secretary): int
|
||||
{
|
||||
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$provider_ids = $secretary['providers'] ?? [];
|
||||
|
||||
$settings = $secretary['settings'];
|
||||
|
@ -321,7 +322,7 @@ class Secretaries_model extends EA_Model {
|
|||
{
|
||||
throw new InvalidArgumentException('The provided secretary ID was not found in the database: ' . $secretary_id);
|
||||
}
|
||||
|
||||
|
||||
$secretary['settings'] = $this->db->get_where('user_settings', ['id_users' => $secretary_id])->row_array();
|
||||
|
||||
unset(
|
||||
|
@ -391,7 +392,7 @@ class Secretaries_model extends EA_Model {
|
|||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
* @param bool $with_trashed
|
||||
*
|
||||
*
|
||||
* @return array Returns an array of secretaries.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
|
@ -561,7 +562,7 @@ class Secretaries_model extends EA_Model {
|
|||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
* @param bool $with_trashed
|
||||
*
|
||||
*
|
||||
* @return array Returns an array of secretaries.
|
||||
*/
|
||||
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
|
@ -572,7 +573,7 @@ class Secretaries_model extends EA_Model {
|
|||
{
|
||||
$this->db->where('delete_datetime IS NULL');
|
||||
}
|
||||
|
||||
|
||||
$secretaries = $this
|
||||
->db
|
||||
->select()
|
||||
|
|
Loading…
Reference in a new issue