Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ For details on the changes in each release, see [the Releases page](https://gith
- the `[ldap]user_flag_groups[immortal]` open must also be defined
- the `[site]account_policy_url` option has been renamed to `[site]pi_qualification_docs_url`
- the `[site]account_expiration_policy_url` option must be defined
- the SQL trigger for `audit_log` to update `user_last_logins` should be removed:
```sql
drop trigger update_last_logins;
```

### 1.5 -> 1.6

Expand Down
1 change: 1 addition & 0 deletions resources/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

$days_idle = $SQL->convertLastLoginToDaysIdle($SQL->getUserLastLogin($USER->uid));
$SQL->addLog("user_login", $OPERATOR->uid);
$SQL->updateUserLastLogin($OPERATOR->uid);

$USER->updateIsQualified(); // in case manual changes have been made to PI groups

Expand Down
14 changes: 14 additions & 0 deletions resources/lib/UnitySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ public function addLog(string $action_type, string $recipient): void
$stmt->execute();
}

public function updateUserLastLogin(string $uid): void
{
$table = self::TABLE_USER_LAST_LOGINS;
$stmt = $this->conn->prepare("
INSERT INTO $table
(operator, last_login)
VALUES(:uid, CURRENT_TIMESTAMP)
ON DUPLICATE KEY UPDATE
last_login=CURRENT_TIMESTAMP
");
$stmt->bindParam(":uid", $uid);
$stmt->execute();
}

/** @return user_last_login[] */
public function getAllUserLastLogins(): array
{
Expand Down
13 changes: 0 additions & 13 deletions tools/docker-dev/sql/bootstrap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ CREATE TABLE user_last_logins (
last_login TIMESTAMP
) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

DELIMITER //
CREATE TRIGGER update_last_login
AFTER INSERT ON audit_log
FOR EACH ROW
BEGIN
IF NEW.action_type = 'user_login' THEN
INSERT INTO user_last_logins (operator, last_login)
VALUES (NEW.operator, NEW.timestamp)
ON DUPLICATE KEY UPDATE last_login = NEW.timestamp;
END IF;
END;//
DELIMITER ;

-- --------------------------------------------------------

--
Expand Down