Skip to content

Commit

Permalink
update version, add spam check for move operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Артем committed Jan 14, 2019
1 parent abd56ff commit a10ef64
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
42 changes: 41 additions & 1 deletion Antispam/Antispam.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,47 @@ public static function onAbortNewAccount ( $user, &$message ) {

return $allowAccount;
}

public static function onTitleMove( Title $title, Title $newtitle, User $user )
{
global $wgUser, $wgCTExtName;

// Skip antispam test if user is member of special group
if ( $wgUser->isAllowed('cleantalk-bypass') ) {
return;
}
$errors = [];
// Check
$ctResult = CTBody::onSpamCheck(
'check_message', array(
'message' => $newtitle->mUrlform ,
'sender_email' => $wgUser->mEmail,
'sender_nickname' => $wgUser->mName,
)
);
if ( $ctResult->errno != 0 ) {
if(CTBody::JSTest() != 1)
{
$ctResult->allow = 0;
$ctResult->comment = "Forbidden. Please, enable Javascript.";
}
else
{
$ctResult->allow = 1;
}
}

// Disallow edit with CleanTalk comment
if ($ctResult->allow == 0) {
$errors[] = $ctResult->comment;
}

if ($ctResult->inactive === 1) {
CTBody::SendAdminEmail( $wgCTExtName, $ctResult->comment );
}

if (count($errors))
throw new PermissionsError( 'move', $errors );
}
public static function onSkinAfterBottomScripts( $skin, &$text )
{
global $wgCTShowLink, $wgCTSFW, $wgCTDataStoreFile, $wgCTAccessKey;
Expand Down
5 changes: 3 additions & 2 deletions Antispam/Antispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/**
* Extension agent name and version
*/
$wgCTAgent = 'mediawiki-20';
$wgCTAgent = 'mediawiki-21';

/**
* Extension name
Expand Down Expand Up @@ -92,7 +92,7 @@
'author' => 'Denis Shagimuratov',
'url' => 'https://www.mediawiki.org/wiki/Extension:Antispam',
'descriptionmsg' => 'cleantalk-desc',
'version' => '2.0',
'version' => '2.1',
);

$wgAutoloadClasses['CTBody'] = __DIR__ . '/Antispam.body.php';
Expand All @@ -108,3 +108,4 @@
$wgGroupPermissions['sysop']['cleantalk-bypass'] = true;

$wgHooks["SkinAfterBottomScripts"][] = "CTHooks::onSkinAfterBottomScripts";
$wgHooks['TitleMove'][] = 'CTHooks::onTitleMove';
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mediawiki-antispam
================
Version 2.0
Version 2.1
================

0 comments on commit a10ef64

Please sign in to comment.