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('roles.slug', DB_SLUG_ADMIN)
|
||||||
->where('users.email', $admin['email'])
|
->where('users.email', $admin['email'])
|
||||||
->where('users.id !=', $admin_id)
|
->where('users.id !=', $admin_id)
|
||||||
|
->where('users.delete_datetime', NULL)
|
||||||
->get()
|
->get()
|
||||||
->num_rows();
|
->num_rows();
|
||||||
|
|
||||||
|
@ -177,7 +178,7 @@ class Admins_model extends EA_Model {
|
||||||
$this->db->where('id_users !=', $admin_id);
|
$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();
|
$admin['id_roles'] = $this->get_admin_role_id();
|
||||||
|
|
||||||
$settings = $admin['settings'];
|
$settings = $admin['settings'];
|
||||||
|
|
||||||
unset(
|
unset(
|
||||||
$admin['settings']
|
$admin['settings']
|
||||||
);
|
);
|
||||||
|
@ -228,9 +229,9 @@ class Admins_model extends EA_Model {
|
||||||
protected function update(array $admin): int
|
protected function update(array $admin): int
|
||||||
{
|
{
|
||||||
$settings = $admin['settings'];
|
$settings = $admin['settings'];
|
||||||
|
|
||||||
$settings['id_users'] = $admin['id'];
|
$settings['id_users'] = $admin['id'];
|
||||||
|
|
||||||
unset(
|
unset(
|
||||||
$admin['settings']
|
$admin['settings']
|
||||||
);
|
);
|
||||||
|
|
|
@ -168,6 +168,7 @@ class Providers_model extends EA_Model {
|
||||||
->where('roles.slug', DB_SLUG_PROVIDER)
|
->where('roles.slug', DB_SLUG_PROVIDER)
|
||||||
->where('users.email', $provider['email'])
|
->where('users.email', $provider['email'])
|
||||||
->where('users.id !=', $provider_id)
|
->where('users.id !=', $provider_id)
|
||||||
|
->where('users.delete_datetime', NULL)
|
||||||
->get()
|
->get()
|
||||||
->num_rows();
|
->num_rows();
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ class Providers_model extends EA_Model {
|
||||||
$this->db->where('id_users !=', $provider_id);
|
$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'];
|
$service_ids = $provider['services'];
|
||||||
|
|
||||||
$settings = $provider['settings'];
|
$settings = $provider['settings'];
|
||||||
|
|
||||||
unset(
|
unset(
|
||||||
$provider['services'],
|
$provider['services'],
|
||||||
$provider['settings']
|
$provider['settings']
|
||||||
|
@ -246,7 +247,7 @@ class Providers_model extends EA_Model {
|
||||||
protected function update(array $provider): int
|
protected function update(array $provider): int
|
||||||
{
|
{
|
||||||
$provider['update_datetime'] = date('Y-m-d H:i:s');
|
$provider['update_datetime'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
$service_ids = $provider['services'];
|
$service_ids = $provider['services'];
|
||||||
|
|
||||||
$settings = $provider['settings'];
|
$settings = $provider['settings'];
|
||||||
|
@ -315,7 +316,7 @@ class Providers_model extends EA_Model {
|
||||||
{
|
{
|
||||||
$this->db->where('delete_datetime IS NULL');
|
$this->db->where('delete_datetime IS NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
|
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
|
||||||
|
|
||||||
if ( ! $provider)
|
if ( ! $provider)
|
||||||
|
@ -396,7 +397,7 @@ class Providers_model extends EA_Model {
|
||||||
* @param int|null $offset Record offset.
|
* @param int|null $offset Record offset.
|
||||||
* @param string|null $order_by Order by.
|
* @param string|null $order_by Order by.
|
||||||
* @param bool $with_trashed
|
* @param bool $with_trashed
|
||||||
*
|
*
|
||||||
* @return array Returns an array of providers.
|
* @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
|
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 int|null $offset Record offset.
|
||||||
* @param string|null $order_by Order by.
|
* @param string|null $order_by Order by.
|
||||||
* @param bool $with_trashed
|
* @param bool $with_trashed
|
||||||
*
|
*
|
||||||
* @return array Returns an array of providers.
|
* @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
|
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');
|
$this->db->where('delete_datetime IS NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
$providers = $this
|
$providers = $this
|
||||||
->db
|
->db
|
||||||
->select()
|
->select()
|
||||||
|
|
|
@ -166,6 +166,7 @@ class Secretaries_model extends EA_Model {
|
||||||
->where('roles.slug', DB_SLUG_SECRETARY)
|
->where('roles.slug', DB_SLUG_SECRETARY)
|
||||||
->where('users.email', $secretary['email'])
|
->where('users.email', $secretary['email'])
|
||||||
->where('users.id !=', $secretary_id)
|
->where('users.id !=', $secretary_id)
|
||||||
|
->where('users.delete_datetime', NULL)
|
||||||
->get()
|
->get()
|
||||||
->num_rows();
|
->num_rows();
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ class Secretaries_model extends EA_Model {
|
||||||
$this->db->where('id_users !=', $secretary_id);
|
$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['create_datetime'] = date('Y-m-d H:i:s');
|
||||||
$secretary['update_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();
|
$secretary['id_roles'] = $this->get_secretary_role_id();
|
||||||
|
|
||||||
$provider_ids = $secretary['providers'] ?? [];
|
$provider_ids = $secretary['providers'] ?? [];
|
||||||
|
@ -245,7 +246,7 @@ class Secretaries_model extends EA_Model {
|
||||||
protected function update(array $secretary): int
|
protected function update(array $secretary): int
|
||||||
{
|
{
|
||||||
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
$provider_ids = $secretary['providers'] ?? [];
|
$provider_ids = $secretary['providers'] ?? [];
|
||||||
|
|
||||||
$settings = $secretary['settings'];
|
$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);
|
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();
|
$secretary['settings'] = $this->db->get_where('user_settings', ['id_users' => $secretary_id])->row_array();
|
||||||
|
|
||||||
unset(
|
unset(
|
||||||
|
@ -391,7 +392,7 @@ class Secretaries_model extends EA_Model {
|
||||||
* @param int|null $offset Record offset.
|
* @param int|null $offset Record offset.
|
||||||
* @param string|null $order_by Order by.
|
* @param string|null $order_by Order by.
|
||||||
* @param bool $with_trashed
|
* @param bool $with_trashed
|
||||||
*
|
*
|
||||||
* @return array Returns an array of secretaries.
|
* @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
|
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 int|null $offset Record offset.
|
||||||
* @param string|null $order_by Order by.
|
* @param string|null $order_by Order by.
|
||||||
* @param bool $with_trashed
|
* @param bool $with_trashed
|
||||||
*
|
*
|
||||||
* @return array Returns an array of secretaries.
|
* @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
|
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');
|
$this->db->where('delete_datetime IS NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
$secretaries = $this
|
$secretaries = $this
|
||||||
->db
|
->db
|
||||||
->select()
|
->select()
|
||||||
|
|
Loading…
Reference in a new issue