Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1430428
GroupMembershipChangeLogFormatter.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
GroupMembershipChangeLogFormatter.php
View Options
<?php
namespace
MediaWiki\Extension\CentralAuth\LogFormatter
;
use
LogFormatter
;
/**
* Handles the following log types:
* - gblrights/usergroups
*/
class
GroupMembershipChangeLogFormatter
extends
LogFormatter
{
private
function
makeGroupsList
(
array
$groups
,
array
$metadata
):
string
{
$groupNames
=
[];
$groups
=
array_combine
(
$groups
,
$metadata
);
// Ensure temporary groups are displayed first, to avoid ambiguity like
// "first, second (expires at some point)" (unclear if only second expires or if both expire)
uasort
(
$groups
,
static
fn
(
$first
,
$second
)
=>
(
bool
)
$second
[
'expiry'
]
<=>
(
bool
)
$first
[
'expiry'
]
);
$language
=
$this
->
context
->
getLanguage
();
$user
=
$this
->
context
->
getUser
();
foreach
(
$groups
as
$group
=>
$metadata
)
{
$name
=
$group
;
if
(
$metadata
[
'expiry'
]
)
{
$name
=
$this
->
msg
(
'rightslogentry-temporary-group'
)
->
params
(
$name
,
$language
->
userTimeAndDate
(
$metadata
[
'expiry'
],
$user
)
)
->
escaped
();
}
$groupNames
[]
=
$name
;
}
return
$groups
!==
[]
?
$this
->
formatParameterValue
(
'list'
,
$groupNames
)
:
$this
->
msg
(
'rightsnone'
)->
text
();
}
/**
* @param array $groups
*
* @return array|string
*/
private
function
makeGroupsListWithoutMetadata
(
array
$groups
)
{
return
$groups
!==
[]
?
$this
->
formatParameterValue
(
'list'
,
$groups
)
:
$this
->
msg
(
'rightsnone'
)->
text
();
}
/** @inheritDoc */
protected
function
getMessageKey
()
{
return
'logentry-gblrights-usergroups'
;
}
protected
function
extractParameters
()
{
if
(
$this
->
entry
->
isLegacy
()
)
{
return
parent
::
extractParameters
();
}
$params
=
$this
->
entry
->
getParameters
();
if
(
isset
(
$params
[
'oldMetadata'
]
)
)
{
return
[
3
=>
$this
->
makeGroupsList
(
$params
[
'oldGroups'
],
$params
[
'oldMetadata'
]
),
4
=>
$this
->
makeGroupsList
(
$params
[
'newGroups'
],
$params
[
'newMetadata'
]
),
];
}
return
[
3
=>
$this
->
makeGroupsListWithoutMetadata
(
$params
[
'oldGroups'
]
),
4
=>
$this
->
makeGroupsListWithoutMetadata
(
$params
[
'newGroups'
]
),
];
}
/** @inheritDoc */
protected
function
getMessageParameters
()
{
$params
=
parent
::
getMessageParameters
();
// remove "User:" prefix
$params
[
2
]
=
$this
->
formatParameterValue
(
'user-link'
,
$this
->
entry
->
getTarget
()->
getText
()
);
return
$params
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 18:44 (5 h, 41 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d0/60/b6b8a5bbaafea3980a2444d1ba32
Default Alt Text
GroupMembershipChangeLogFormatter.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment