Skip to content

Commit

Permalink
feat: Remove status DELETED - force physical deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
KminekMatej committed Sep 15, 2024
1 parent f3f216f commit 5e1c271
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
1 change: 0 additions & 1 deletion app/module/attendance/manager/HistoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public function getEventHistory(int $eventId): array
{
return $this->mapAll($this->database->table(History::TABLE)
->where("event_id", $eventId)
->where(User::TABLE . ".status != ?", User::STATUS_DELETED)
->order("created DESC")
->order("id ASC")
->fetchAll());
Expand Down
31 changes: 7 additions & 24 deletions app/module/user/manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,9 @@ public function updateByArray(int $id, array $array): int
$userModel = $this->getById($id);

if ($userModel->getStatus() == User::STATUS_INIT && isset($array["status"]) && $array["status"] != User::STATUS_INIT) {
if ($array["status"] == User::STATUS_DELETED) {
$this->mailService->mailLoginDenied($userModel->getFullName(), $userModel->getEmail());
} else {
//user status has been changed from INIT - need to notify him about the upgrade
$array["canLogin"] = 1;
$this->mailService->mailLoginApproved($userModel->getFullName(), $userModel->getEmail());
}
//user status has been changed from INIT - need to notify him about the upgrade
$array["canLogin"] = 1;
$this->mailService->mailLoginApproved($userModel->getFullName(), $userModel->getEmail());
}

if (array_key_exists("roles", $array) && is_array($array["roles"])) {
Expand Down Expand Up @@ -664,6 +660,10 @@ public function delete(int $resourceId, ?int $subResourceId = null): int
{
$this->allowDelete($resourceId);

if ($this->userModel == User::STATUS_INIT) {
$this->mailService->mailLoginDenied($this->userModel->getFullName(), $this->userModel->getEmail());
}

return parent::deleteRecord($resourceId);
}

Expand Down Expand Up @@ -908,23 +908,6 @@ public function getAllFields(): array
return $this->userFields;
}

/**
* @return BaseModel[]
*/
public function getList(?array $idList = null, string $idField = "id", ?int $limit = null, ?int $offset = null, ?string $order = null): array
{
$rows = $this->database->table($this->getTable())->where("status != ?", User::STATUS_DELETED);
if ($idList !== null) {
$rows->where($idField, $idList);
}

if (is_int($limit) && is_int($offset)) {
$rows->limit($limit, $offset);
}

return $this->mapAll($rows->fetchAll());
}

/**
* Adds user to live table or update time if user is already there.
* Also deletes old records
Expand Down
1 change: 0 additions & 1 deletion app/module/user/model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class User extends BaseModel
public const ROLE_USER_CLASS = "info";
public const ROLE_ATTENDANCE_CLASS = "warning";
public const STATUS_MEMBER = "MEMBER";
public const STATUS_DELETED = "DELETED";
public const STATUS_PLAYER = "PLAYER";
public const STATUS_SICK = "SICK";
public const STATUS_INIT = "INIT";
Expand Down

0 comments on commit 5e1c271

Please sign in to comment.