From 095694c3bc0dfbf453119fe9d6a559f1caf2c1a8 Mon Sep 17 00:00:00 2001 From: Felix Pahlow Date: Sat, 15 Jul 2023 17:39:27 +0200 Subject: add unlock log action, closes #2865 --- db/migrations/5.4.13_add_unlock_action.php | 33 ++++++++++++++++++++++++++++++ lib/models/User.class.php | 4 ++++ 2 files changed, 37 insertions(+) create mode 100644 db/migrations/5.4.13_add_unlock_action.php diff --git a/db/migrations/5.4.13_add_unlock_action.php b/db/migrations/5.4.13_add_unlock_action.php new file mode 100644 index 0000000..d3834a1 --- /dev/null +++ b/db/migrations/5.4.13_add_unlock_action.php @@ -0,0 +1,33 @@ +exec(" + INSERT IGNORE INTO `log_actions` + SET `action_id` = MD5('USER_UNLOCK'), + `name` = 'USER_UNLOCK', + `description` = 'Nutzer wird entsperrt', + `info_template` = '%user entsperrt %user(%affected) (%info)', + `active` = '1', + `expires` = '0' + "); + } + + public function down() + { + $actions = ['USER_UNLOCK']; + + DBManager::get()->execute( + "DELETE `log_events` FROM `log_events` JOIN `log_actions` USING (`action_id`) WHERE `name` IN (?)", + [$actions] + ); + DBManager::get()->execute("DELETE FROM `log_actions` WHERE `name` IN (?)", [$actions]); + } +} diff --git a/lib/models/User.class.php b/lib/models/User.class.php index 47ad6f6..5578d43 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -240,6 +240,10 @@ class User extends AuthUserMd5 implements Range, PrivacyObject $this->lock_comment ) ); + } else if ($this->isFieldDirty('locked') && $this->isFieldDirty('lock_comment') && (int)$this->locked === 0) { + StudipLog::log('USER_UNLOCK', + $this->user_id + ); } } } -- cgit v1.0