Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Replace deprecated DiffRevisionTools hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Aug 12, 2020
1 parent c9dab27 commit 9b128ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"EmailConfirmed": "SanctionsHooks::onEmailConfirmed",
"ResourceLoaderGetConfigVars": "SanctionsHooks::onResourceLoaderGetConfigVars",
"UserToolLinksEdit": "SanctionsHooks::onUserToolLinksEdit",
"DiffRevisionTools": "SanctionsHooks::onDiffRevisionTools",
"DiffTools": "SanctionsHooks::onDiffTools",
"HistoryRevisionTools": "SanctionsHooks::onHistoryRevisionTools",
"SidebarBeforeOutput": "SanctionsHooks::onSidebarBeforeOutput",
"ContributionsToolLinks": "SanctionsHooks::onContributionsToolLinks",
Expand Down
25 changes: 12 additions & 13 deletions includes/SanctionsHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,29 +203,28 @@ public static function onUserToolLinksEdit( $userId, $userText, &$items ) {
}

/**
* Tools shown as (edit) (undo) (thank)
* @param Revision $newRev object of the "new" revision
* @param array &$links Array of HTML links
* @param Revision $oldRev object of the "old" revision (may be null)
* @return bool
* @param RevisionRecord $newRevRecord New revision
* @param string[] &$links Array of HTML links
* @param RevisionRecord|null $oldRevRecord Old revision (may be null)
* @param UserIdentity $userIdentity Current user
* @return bool|void True or no return value to continue or false to abort
*/
public static function onDiffRevisionTools( Revision $newRev, &$links, $oldRev ) {
$user = RequestContext::getMain()->getUser();
if ( $user == null || !SanctionsUtils::hasVoteRight( $user ) ) {
public static function onDiffTools( $newRevRecord, &$links, $oldRevRecord, $userIdentity ) {
if ( $userIdentity == null || !SanctionsUtils::hasVoteRight( $userIdentity ) ) {
return true;
}

$ids = '';
if ( $oldRev != null ) {
$ids .= $oldRev->getId() . '/';
if ( $oldRevRecord != null ) {
$ids .= $oldRevRecord->getId() . '/';
}
$ids .= $newRev->getId();
$ids .= $newRevRecord->getId();

$titleText = $newRev->getUserText() . '/' . $ids;
$titleText = $newRevRecord->getUser()->getName() . '/' . $ids;
$links[] = Linker::link(
SpecialPage::getTitleFor( 'Sanctions', $titleText ),
wfMessage( 'sanctions-link-on-diff' )->text()
);
);

return true;
}
Expand Down

0 comments on commit 9b128ae

Please sign in to comment.