Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
54.55% |
6 / 11 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
TemporaryAccountLogFormatter | |
54.55% |
6 / 11 |
|
50.00% |
1 / 2 |
5.50 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMessageParameters | |
44.44% |
4 / 9 |
|
0.00% |
0 / 1 |
4.54 |
1 | <?php |
2 | |
3 | namespace MediaWiki\CheckUser\Logging; |
4 | |
5 | use LogEntry; |
6 | use LogFormatter; |
7 | use MediaWiki\Linker\Linker; |
8 | use MediaWiki\User\UserFactory; |
9 | use Message; |
10 | |
11 | class TemporaryAccountLogFormatter extends LogFormatter { |
12 | |
13 | private UserFactory $userFactory; |
14 | |
15 | public function __construct( |
16 | LogEntry $entry, |
17 | UserFactory $userFactory |
18 | ) { |
19 | parent::__construct( $entry ); |
20 | $this->userFactory = $userFactory; |
21 | } |
22 | |
23 | /** |
24 | * @inheritDoc |
25 | */ |
26 | protected function getMessageParameters() { |
27 | $params = parent::getMessageParameters(); |
28 | |
29 | // Update the logline depending on if the user had their access enabled or disabled |
30 | if ( $this->entry->getSubtype() === 'change-access' ) { |
31 | // Message keys used: |
32 | // - 'checkuser-temporary-account-change-access-level-enable' |
33 | // - 'checkuser-temporary-account-change-access-level-disable' |
34 | $params[3] = $this->msg( 'checkuser-temporary-account-change-access-level-' . $params[3], $params[1] ); |
35 | } elseif ( $this->entry->getSubtype() === 'view-ips' ) { |
36 | // Replace temporary user page link with contributions page link. |
37 | // Don't use LogFormatter::makeUserLink, because that adds tools links. |
38 | $tempUserName = $this->entry->getTarget()->getText(); |
39 | $params[2] = Message::rawParam( |
40 | Linker::userLink( 0, $this->userFactory->newUnsavedTempUser( $tempUserName ) ) |
41 | ); |
42 | } |
43 | |
44 | return $params; |
45 | } |
46 | } |