|
|
|
@@ -13,7 +13,7 @@ class DiscordHooks {
|
|
|
|
|
public static function onPageContentSaveComplete( &$wikiPage, &$user, $content, $summary, $isMinor, $isWatch, $section, &$flags, $revision, &$status, $baseRevId, $undidRevId ) {
|
|
|
|
|
global $wgDiscordNoBots, $wgDiscordNoMinor, $wgDiscordNoNull;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'PageContentSaveComplete', $wikiPage->getTitle()->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'PageContentSaveComplete', $wikiPage->getTitle()->getNamespace(), $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -32,15 +32,15 @@ class DiscordHooks {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $wikiPage->getTitle()->inNamespace( NS_FILE ) ) {
|
|
|
|
|
// Don't continue, it's a file which onUploadComplete will handle instead
|
|
|
|
|
if ( $wikiPage->getTitle()->inNamespace( NS_FILE ) && is_null( $revision->getPrevious() ) ) {
|
|
|
|
|
// Don't continue, it's a new file which onUploadComplete will handle instead
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-edit', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $wikiPage->getTitle(), $wikiPage->getTitle()->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
DiscordUtils::createRevisionText( $revision ),
|
|
|
|
|
( $summary ? ('`' . $summary . '`' ) : '' ) )->text();
|
|
|
|
|
( $summary ? ('`' . DiscordUtils::truncateText( $summary ) . '`' ) : '' ) )->plain();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@@ -52,7 +52,7 @@ class DiscordHooks {
|
|
|
|
|
public static function onArticleDeleteComplete( &$article, User &$user, $reason, $id, $content, LogEntry $logEntry, $archivedRevisionCount ) {
|
|
|
|
|
global $wgDiscordNoBots, $wgDiscordNoMinor, $wgDiscordNoNull;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleDeleteComplete', $article->getTitle()->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleDeleteComplete', $article->getTitle()->getNamespace(), $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -63,7 +63,7 @@ class DiscordHooks {
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-articledelete', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $article->getTitle(), $article->getTitle()->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ),
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ),
|
|
|
|
|
$archivedRevisionCount)->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
@@ -76,14 +76,14 @@ class DiscordHooks {
|
|
|
|
|
public static function onArticleUndelete( Title $title, $create, $comment, $oldPageId, $restoredPages ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleUndelete', $title->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleUndelete', $title->getNamespace(), $wgUser ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-articleundelete', DiscordUtils::createUserLinks( $wgUser ),
|
|
|
|
|
($create ? '' : wfMessage( 'discord-undeleterev' )->text() ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $title, $title->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $comment ? ('`' . $comment . '`' ) : '' ))->text();
|
|
|
|
|
( $comment ? ('`' . DiscordUtils::truncateText( $comment ) . '`' ) : '' ))->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@@ -95,7 +95,7 @@ class DiscordHooks {
|
|
|
|
|
public static function onArticleRevisionVisibilitySet( &$title, $ids, $visibilityChangeMap ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleRevisionVisibilitySet', $title->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleRevisionVisibilitySet', $title->getNamespace(), $wgUser ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -113,7 +113,7 @@ class DiscordHooks {
|
|
|
|
|
public static function onArticleProtectComplete( &$article, &$user, $protect, $reason ) {
|
|
|
|
|
global $wgDiscordNoBots;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleProtectComplete', $article->getTitle()->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'ArticleProtectComplete', $article->getTitle()->getNamespace(), $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -124,7 +124,7 @@ class DiscordHooks {
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-articleprotect', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $article->getTitle(), $article->getTitle()->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ),
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ),
|
|
|
|
|
implode(", ", $protect) )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
@@ -137,7 +137,7 @@ class DiscordHooks {
|
|
|
|
|
public static function onTitleMoveComplete( Title &$title, Title &$newTitle, User $user, $oldid, $newid, $reason, Revision $revision ) {
|
|
|
|
|
global $wgDiscordNoBots;
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'TitleMoveComplete', $title->getNamespace() ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'TitleMoveComplete', $title->getNamespace(), $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -149,7 +149,7 @@ class DiscordHooks {
|
|
|
|
|
$msg = wfMessage( 'discord-titlemove', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $title, $title->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $newTitle, $newTitle->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ),
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ),
|
|
|
|
|
DiscordUtils::createRevisionText( $revision ) )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
@@ -160,7 +160,7 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/LocalUserCreated
|
|
|
|
|
*/
|
|
|
|
|
public static function onLocalUserCreated( $user, $autocreated ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'LocalUserCreated', NULL ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'LocalUserCreated', NULL, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -174,7 +174,7 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BlockIpComplete
|
|
|
|
|
*/
|
|
|
|
|
public static function onBlockIpComplete( Block $block, User $user ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'BlockIpComplete', NULL ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'BlockIpComplete', NULL, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -186,7 +186,7 @@ class DiscordHooks {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-blockipcomplete', DiscordUtils::createUserLinks( $user ), DiscordUtils::createUserLinks( $block->getTarget() ),
|
|
|
|
|
( $block->mReason ? ('`' . $block->mReason . '`' ) : '' ),
|
|
|
|
|
( $block->mReason ? ('`' . DiscordUtils::truncateText( $block->mReason ) . '`' ) : '' ),
|
|
|
|
|
$expiryMsg )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
@@ -197,7 +197,7 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnblockUserComplete
|
|
|
|
|
*/
|
|
|
|
|
public static function onUnblockUserComplete( Block $block, User $user ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UnblockUserComplete', NULL ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UnblockUserComplete', NULL, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -211,7 +211,7 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UserGroupsChanged
|
|
|
|
|
*/
|
|
|
|
|
public static function onUserGroupsChanged( User $user, array $added, array $removed, $performer, $reason ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UserGroupsChanged', NULL ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UserGroupsChanged', NULL, $performer ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -222,7 +222,7 @@ class DiscordHooks {
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-usergroupschanged', DiscordUtils::createUserLinks( $performer ),
|
|
|
|
|
DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ),
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ),
|
|
|
|
|
( ( count($added) > 0 ) ? ( '+ ' . join(', ', $added) ) : ''),
|
|
|
|
|
( ( count($removed) > 0 ) ? ( '- ' . join(', ', $removed) ) : '' ) )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
@@ -234,19 +234,20 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UploadComplete
|
|
|
|
|
*/
|
|
|
|
|
public static function onUploadComplete( &$image ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UploadComplete', NS_FILE ) ) {
|
|
|
|
|
$lf = $image->getLocalFile();
|
|
|
|
|
$user = $lf->getUser( $type = 'object' ); // only supported in MW 1.31+
|
|
|
|
|
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'UploadComplete', NS_FILE, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lf = $image->getLocalFile();
|
|
|
|
|
$user = $lf->getUser( $type = 'object' ); // only supported in MW 1.31+
|
|
|
|
|
$comment = $lf->getDescription();
|
|
|
|
|
$isNewRevision = count($lf->getHistory()) > 0;
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-uploadcomplete', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
( $isNewRevision ? wfMessage( 'discord-uploadnewver' )->text() : '' ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $lf->getName(), $lf->getTitle()->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $comment ? ('`' . $comment . '`' ) : '' ),
|
|
|
|
|
( $comment ? ('`' . DiscordUtils::truncateText( $comment ) . '`' ) : '' ),
|
|
|
|
|
DiscordUtils::formatBytes($lf->getSize()),
|
|
|
|
|
$lf->getWidth(),
|
|
|
|
|
$lf->getHeight(),
|
|
|
|
@@ -260,7 +261,7 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/FileDeleteComplete
|
|
|
|
|
*/
|
|
|
|
|
public static function onFileDeleteComplete( $file, $oldimage, $article, $user, $reason ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'FileDeleteComplete', NS_FILE ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'FileDeleteComplete', NS_FILE, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -271,7 +272,7 @@ class DiscordHooks {
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-filedeletecomplete', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $file->getName(), $file->getTitle()->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ) )->text();
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ) )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@@ -281,13 +282,13 @@ class DiscordHooks {
|
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/FileUndeleteComplete
|
|
|
|
|
*/
|
|
|
|
|
public static function onFileUndeleteComplete( $title, $fileVersions, $user, $reason ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'FileUndeleteComplete', NS_FILE ) ) {
|
|
|
|
|
if ( DiscordUtils::isDisabled( 'FileUndeleteComplete', NS_FILE, $user ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = wfMessage( 'discord-fileundeletecomplete', DiscordUtils::createUserLinks( $user ),
|
|
|
|
|
DiscordUtils::createMarkdownLink( $title, $title->getFullUrl( '', '', $proto = PROTO_HTTP ) ),
|
|
|
|
|
( $reason ? ('`' . $reason . '`' ) : '' ) )->text();
|
|
|
|
|
( $reason ? ('`' . DiscordUtils::truncateText( $reason ) . '`' ) : '' ) )->text();
|
|
|
|
|
DiscordUtils::handleDiscord($msg);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|