Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/101476
Change subject: Use SpecialBlockModifyFormFields hook ...................................................................... Use SpecialBlockModifyFormFields hook Keeps in the JS hack if using an older MW version Change-Id: I22e857467945347a04e5aa616e4e4d8cf49007a0 --- M StopForumSpam.hooks.php M StopForumSpam.php M ext.SFS.formhack.js 3 files changed, 34 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/StopForumSpam refs/changes/76/101476/1 diff --git a/StopForumSpam.hooks.php b/StopForumSpam.hooks.php index 6c21323..ec1dcf0 100644 --- a/StopForumSpam.hooks.php +++ b/StopForumSpam.hooks.php @@ -17,6 +17,23 @@ } /** + * @param SpecialPage $sp + * @param array $fields + * @return bool + */ + public static function onSpecialBlockModifyFormFields( SpecialPage $sp, &$fields ) { + if ( $sp->getUser()->isAllowed( 'stopforumspam' ) ) { + $fields['SFS'] = array( + 'type' => 'check', + 'label-message' => 'stopforumspam-checkbox', + 'default' => false, + ); + } + + return true; + } + + /** * Triggers the data submission process * @param Block $block * @param User $user who made the block diff --git a/StopForumSpam.php b/StopForumSpam.php index 0d4c456..66975ea 100644 --- a/StopForumSpam.php +++ b/StopForumSpam.php @@ -34,6 +34,7 @@ $wgAutoloadClasses['StopForumSpam'] = __DIR__ . '/StopForumSpam.body.php'; $wgHooks['SpecialBlockBeforeFormDisplay'][] = 'SFSHooks::onSpecialBlockBeforeFormDisplay'; +$wgHooks['SpecialBlockModifyFormFields'][] = 'SFSHooks::onSpecialBlockModifyFormFields'; $wgHooks['BlockIpComplete'][] = 'SFSHooks::onBlockIpComplete'; $wgHooks['AbuseFilter-computeVariable'][] = 'SFSHooks::abuseFilterComputeVariable'; $wgHooks['AbuseFilter-generateUserVars'][] = 'SFSHooks::abuseFilterGenerateUserVars'; diff --git a/ext.SFS.formhack.js b/ext.SFS.formhack.js index d31c77c..ecd61d6 100644 --- a/ext.SFS.formhack.js +++ b/ext.SFS.formhack.js @@ -6,19 +6,22 @@ var $blockTarget = $( '#mw-bi-target' ), $SFSbox; - // this will be needed until gerrit change #101063 is merged - $SFSbox = $('<tr>') - .addClass( 'mw-htmlform-field-HTMLCheckField') - .append( '<td class="mw-label"><label> </label></td>' ) - .append( $('<td>') - .addClass('mw-input') - .append('<input name="wpSFS" type="checkbox" value="1" id="mw-input-wpSFS" />') - .append(' ') - .append( $('<label>') - .attr('for', 'mw-input-wpSFS') - .text( mw.message( 'stopforumspam-checkbox').text() ) - ) - ); + // Back-compat for pre-1.23 + $SFSbox = $( '#mw-input-wpSFS' ); + if ( $SFSbox.length === 0 ) { + $SFSbox = $('<tr>') + .addClass( 'mw-htmlform-field-HTMLCheckField') + .append( '<td class="mw-label"><label> </label></td>' ) + .append( $('<td>') + .addClass('mw-input') + .append('<input name="wpSFS" type="checkbox" value="1" id="mw-input-wpSFS" />') + .append(' ') + .append( $('<label>') + .attr('for', 'mw-input-wpSFS') + .text( mw.message( 'stopforumspam-checkbox').text() ) + ) + ); + } $( '#mw-input-wpHardBlock' ).closest( 'tr').after( $SFSbox ); -- To view, visit https://gerrit.wikimedia.org/r/101476 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I22e857467945347a04e5aa616e4e4d8cf49007a0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/StopForumSpam Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits