Completed
Push — master ( 7d58bb...687957 )
by Morris
17:49
created

UserManagement::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Lukas Reschke <[email protected]>
4
 *
5
 * @author Bjoern Schiessle <[email protected]>
6
 * @author Lukas Reschke <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
namespace OCA\AdminAudit\Actions;
26
27
28
use OCP\IUser;
29
30
/**
31
 * Class UserManagement logs all user management related actions.
32
 *
33
 * @package OCA\AdminAudit\Actions
34
 */
35
class UserManagement extends Action {
36
	/**
37
	 * Log creation of users
38
	 *
39
	 * @param array $params
40
	 */
41
	public function create(array $params) {
42
		$this->log(
43
			'User created: "%s"',
44
			$params,
45
			[
46
				'uid',
47
			]
48
		);
49
	}
50
51
	/**
52
	 * Log deletion of users
53
	 *
54
	 * @param array $params
55
	 */
56
	public function delete(array $params) {
57
		$this->log(
58
			'User deleted: "%s"',
59
			$params,
60
			[
61
				'uid',
62
			]
63
		);
64
	}
65
66
	/**
67
	 * Log enabling of users
68
	 *
69
	 * @param array $params
70
	 */
71
	public function change(array $params) {
72
		if ($params['feature'] === 'enabled') {
73
			$this->log(
74
				$params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
75
				['user' => $params['user']->getUID()],
76
				[
77
					'user',
78
				]
79
			);
80
		}
81
	}
82
83
	/**
84
	 * Logs changing of the user scope
85
	 *
86
	 * @param IUser $user
87
	 */
88
	public function setPassword(IUser $user) {
89
		if($user->getBackendClassName() === 'Database') {
90
			$this->log(
91
				'Password of user "%s" has been changed',
92
				[
93
					'user' => $user->getUID(),
94
				],
95
				[
96
					'user',
97
				]
98
			);
99
		}
100
	}
101
}
102