blob: b86a2a80f111a67876df8f42352907d837e407f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<?php
namespace SMW\MediaWiki\Hooks;
use SMW\ApplicationFactory;
use SMW\MediaWiki\Jobs\UpdateJob;
use SMW\NamespaceExaminer;
use Title;
use User;
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BlockIpComplete
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnblockUserComplete
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UserGroupsChanged
*
* Act on events that happen outside of the normal parser process to ensure that
* changes to pre-defined properties related to a user status can be invoked.
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class UserChange extends HookHandler {
/**
* @var NamespaceExaminer
*/
private $namespaceExaminer;
/**
* @var string
*/
private $origin = '';
/**
* @since 3.0
*
* @param NamespaceExaminer $namespaceExaminer
*/
public function __construct( NamespaceExaminer $namespaceExaminer ) {
$this->namespaceExaminer = $namespaceExaminer;
}
/**
* @since 3.0
*
* @param string $origin
*/
public function setOrigin( $origin ) {
$this->origin = $origin;
}
/**
* @since 3.0
*
* @param User|string $user
*/
public function process( $user ) {
if ( !$this->namespaceExaminer->isSemanticEnabled( NS_USER ) ) {
return false;
}
if ( $user instanceof User ) {
$user = $user->getName();
}
$updateJob = ApplicationFactory::getInstance()->newJobFactory()->newUpdateJob(
Title::newFromText( $user, NS_USER ),
[
UpdateJob::FORCED_UPDATE => true,
'origin' => $this->origin
]
);
$updateJob->insert();
return true;
}
}
|