Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4095568
CentralAuthHooks.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
CentralAuthHooks.php
View Options
<?php
namespace
MediaWiki\Extension\GlobalBlocking
;
use
MediaWiki\Context\IContextSource
;
use
MediaWiki\Context\RequestContext
;
use
MediaWiki\Extension\CentralAuth\Hooks\CentralAuthInfoFieldsHook
;
use
MediaWiki\Extension\CentralAuth\User\CentralAuthUser
;
use
MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockingLinkBuilder
;
use
MediaWiki\Extension\GlobalBlocking\Services\GlobalBlockLookup
;
use
MediaWiki\Linker\LinkRenderer
;
use
MediaWiki\SpecialPage\SpecialPage
;
use
MessageLocalizer
;
/**
* Hook handlers for hooks provided by the CentralAuth extension.
*/
class
CentralAuthHooks
implements
CentralAuthInfoFieldsHook
{
private
MessageLocalizer
$messageLocalizer
;
public
function
__construct
(
private
readonly
GlobalBlockLookup
$globalBlockLookup
,
private
readonly
GlobalBlockingLinkBuilder
$globalBlockingLinkBuilder
,
private
readonly
LinkRenderer
$linkRenderer
,
)
{
$this
->
messageLocalizer
=
RequestContext
::
getMain
();
}
/** @inheritDoc */
public
function
onCentralAuthInfoFields
(
CentralAuthUser
$centralAuthUser
,
IContextSource
$context
,
array
&
$attribs
)
{
$target
=
$centralAuthUser
->
getName
();
$relevantGlobalBlockId
=
$this
->
globalBlockLookup
->
getGlobalBlockId
(
$target
);
if
(
$relevantGlobalBlockId
)
{
// If the user is globally blocked, then link the "yes" to Special:GlobalBlockList to be able to show
// the global block that is applied to the user.
$data
=
$this
->
linkRenderer
->
makeKnownLink
(
SpecialPage
::
getTitleFor
(
'GlobalBlockList'
,
$target
),
$this
->
messageLocalizer
->
msg
(
'centralauth-admin-yes'
)->
text
()
);
}
else
{
$data
=
$this
->
messageLocalizer
->
msg
(
'centralauth-admin-no'
)->
escaped
();
}
// Add action links after the "yes" or "no" to allow users to manage global blocks on the user.
$globalBlockActionLinks
=
$this
->
globalBlockingLinkBuilder
->
getActionLinks
(
$context
->
getAuthority
(),
$target
,
$context
,
true
);
if
(
$globalBlockActionLinks
!==
''
)
{
$data
.=
$this
->
messageLocalizer
->
msg
(
'word-separator'
)->
escaped
()
.
$globalBlockActionLinks
;
}
// If there's no blocks or actions, just don't display anything
if
(
!
$relevantGlobalBlockId
&&
$globalBlockActionLinks
===
''
)
{
return
;
}
$attribs
[
'globalblock'
]
=
[
'label'
=>
'globalblocking-centralauth-admin-info-globalblock'
,
'data'
=>
$data
,
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 13:56 (4 w, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4d/48/b780675bd9899a16a78afd6f0508
Default Alt Text
CentralAuthHooks.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment