Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/72495


Change subject: Make the opt-in/-out feature optional per wiki
......................................................................

Make the opt-in/-out feature optional per wiki

AFTv5 is in the process of being disabled on dewiki. Existing feedbacks should
still be accessible for now, but it should no longer be possible to submit
new feedback.

Via config, one could already "disable" lottery & whitelist/blacklist categories
but not the ability to opt-in for AFTv5. This patch introduces that.

Setting $wgArticleFeedbackv5EnableProtection to false will get rid of the AFTv5
entry in ?action=protect, will ignore existing opt-in/-outs, and will get rid of
the links to opt-in/-out.

Bug: 50926
Change-Id: I97824072bcd9ead44ddc4e3605a2fd932bda3141
---
M ArticleFeedbackv5.hooks.php
M ArticleFeedbackv5.permissions.php
M ArticleFeedbackv5.php
M ArticleFeedbackv5.utils.php
M SpecialArticleFeedbackv5.php
M modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
8 files changed, 49 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5 
refs/changes/95/72495/1

diff --git a/ArticleFeedbackv5.hooks.php b/ArticleFeedbackv5.hooks.php
index de27c9c..ea5e88f 100644
--- a/ArticleFeedbackv5.hooks.php
+++ b/ArticleFeedbackv5.hooks.php
@@ -226,6 +226,7 @@
                        $wgArticleFeedbackv5Tracking,
                        $wgArticleFeedbackv5LinkBuckets,
                        $wgArticleFeedbackv5Namespaces,
+                       $wgArticleFeedbackv5EnableProtection,
                        $wgArticleFeedbackv5LearnToEdit,
                        $wgArticleFeedbackv5SurveyUrls,
                        $wgArticleFeedbackv5ThrottleThresholdPostsPerHour,
@@ -243,6 +244,7 @@
                $vars['wgArticleFeedbackv5Tracking'] = 
$wgArticleFeedbackv5Tracking;
                $vars['wgArticleFeedbackv5LinkBuckets'] = 
$wgArticleFeedbackv5LinkBuckets;
                $vars['wgArticleFeedbackv5Namespaces'] = 
$wgArticleFeedbackv5Namespaces;
+               $vars['wgArticleFeedbackv5EnableProtection'] = 
$wgArticleFeedbackv5EnableProtection;
                $vars['wgArticleFeedbackv5LearnToEdit'] = 
$wgArticleFeedbackv5LearnToEdit;
                $vars['wgArticleFeedbackv5SurveyUrls'] = 
$wgArticleFeedbackv5SurveyUrls;
                $vars['wgArticleFeedbackv5ThrottleThresholdPostsPerHour'] = 
$wgArticleFeedbackv5ThrottleThresholdPostsPerHour;
@@ -615,9 +617,17 @@
         * @return bool
         */
        public static function onProtectionForm( Page $article, &$output ) {
-               global $wgLang, $wgUser, $wgArticleFeedbackv5Namespaces;
+               global $wgLang,
+                               $wgUser,
+                               $wgArticleFeedbackv5Namespaces,
+                               $wgArticleFeedbackv5EnableProtection;
 
                if ( !$article->exists() ) {
+                       return true;
+               }
+
+               // check if opt-in/-out is enabled
+               if ( !$wgArticleFeedbackv5EnableProtection ) {
                        return true;
                }
 
@@ -771,12 +781,19 @@
         * @return bool
         */
        public static function onProtectionSave( Page $article, &$errorMsg ) {
-               global $wgRequest, $wgArticleFeedbackv5Namespaces;
+               global $wgRequest,
+                               $wgArticleFeedbackv5Namespaces,
+                               $wgArticleFeedbackv5EnableProtection;
 
                if ( !$article->exists() ) {
                        return true;
                }
 
+               // check if opt-in/-out is enabled
+               if ( !$wgArticleFeedbackv5EnableProtection ) {
+                       return true;
+               }
+
                // only on pages in namespaces where it is enabled
                if ( !$article->getTitle()->inNamespaces( 
$wgArticleFeedbackv5Namespaces ) ) {
                        return true;
diff --git a/ArticleFeedbackv5.permissions.php 
b/ArticleFeedbackv5.permissions.php
index 8eb79d4..9d73372 100644
--- a/ArticleFeedbackv5.permissions.php
+++ b/ArticleFeedbackv5.permissions.php
@@ -109,6 +109,12 @@
         * @return ResultWrapper|false false if not restricted or details of 
restriction set
         */
        public static function getProtectionRestriction( $articleId ) {
+               // check if opt-in/-out is enabled
+               global $wgArticleFeedbackv5EnableProtection;
+               if ( !$wgArticleFeedbackv5EnableProtection ) {
+                       return false;
+               }
+
                if ( isset( self::$current[$articleId] ) ) {
                        return self::$current[$articleId];
                }
@@ -172,9 +178,15 @@
         * @return bool
         */
        public static function setRestriction( $articleId, $permission, $expiry 
) {
+               // check if opt-in/-out is enabled
+               global $wgArticleFeedbackv5EnableProtection;
+               if ( !$wgArticleFeedbackv5EnableProtection ) {
+                       return false;
+               }
+
                // make sure an articleId was passed
                if ( !$articleId ) {
-                       return;
+                       return false;
                }
 
                // check if valid permission
diff --git a/ArticleFeedbackv5.php b/ArticleFeedbackv5.php
index 9304666..33b5952 100644
--- a/ArticleFeedbackv5.php
+++ b/ArticleFeedbackv5.php
@@ -165,6 +165,10 @@
 // Which categories the pages must not belong to have the rating widget added 
(with _ in text)
 $wgArticleFeedbackv5BlacklistCategories = array( 'Article_Feedback_Blacklist' 
);
 
+// Enables/disables the ability to opt-in/-out of AFTv5 on article basis via
+// page protection settings
+$wgArticleFeedbackv5EnableProtection = true;
+
 // Only load the module / enable the tool in these namespaces
 // Default to $wgContentNamespaces (defaults to array( NS_MAIN ) ).
 $wgArticleFeedbackv5Namespaces = $wgContentNamespaces;
diff --git a/ArticleFeedbackv5.utils.php b/ArticleFeedbackv5.utils.php
index 8ac6e4a..4998b45 100644
--- a/ArticleFeedbackv5.utils.php
+++ b/ArticleFeedbackv5.utils.php
@@ -106,6 +106,7 @@
         */
        public static function isFeedbackEnabled( $pageId ) {
                global $wgArticleFeedbackv5Namespaces,
+                               $wgArticleFeedbackv5EnableProtection,
                                $wgUser;
 
                $title = Title::newFromID( $pageId );
@@ -124,7 +125,7 @@
                $enable &= !$wgUser->isBlocked();
 
                // check if a, to this user sufficient, permission level is 
defined
-               if ( isset( $restriction->pr_level ) ) {
+               if ( $wgArticleFeedbackv5EnableProtection && isset( 
$restriction->pr_level ) ) {
                        $enable &= $wgUser->isAllowed( $restriction->pr_level );
 
                } else {
diff --git a/SpecialArticleFeedbackv5.php b/SpecialArticleFeedbackv5.php
index ac96d38..03d71c4 100644
--- a/SpecialArticleFeedbackv5.php
+++ b/SpecialArticleFeedbackv5.php
@@ -452,6 +452,12 @@
         * @return string
         */
        protected function buildStatusBox() {
+               // check if opt-in/-out is enabled
+               global $wgArticleFeedbackv5EnableProtection;
+               if ( !$wgArticleFeedbackv5EnableProtection ) {
+                       return '';
+               }
+
                if ( !$this->pageId ) {
                        return '';
                }
diff --git a/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js 
b/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js
index 5422009..176ff40 100644
--- a/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js
+++ b/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.startup.js
@@ -117,6 +117,7 @@
         * be displaying here.
         */
        if (
+               mw.config.get( 'wgArticleFeedbackv5EnableProtection', 1 ) &&
                !$.aftUtils.whitelist( article ) &&
                !$.aftUtils.blacklist( article ) &&
                $.aftUtils.canSetStatus( true )
diff --git 
a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
index 3e182ce..afcd3f3 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -1854,12 +1854,14 @@
                                var article = $.aftUtils.article();
 
                                /*
-                                * Don't show the link if page is 
enabled/disabled via the categories.
+                                * Don't show the link if AFTv5 protection is 
disabled.
+                                * Also don't show it if page is 
enabled/disabled via the categories.
                                 * To change that, one would have to edit the 
page and remove that
                                 * category, not change it via the link for 
page protection that we'll
                                 * be displaying here.
                                 */
                                if (
+                                       !mw.config.get( 
'wgArticleFeedbackv5EnableProtection', 1 ) ||
                                        $.aftUtils.whitelist( article ) ||
                                        $.aftUtils.blacklist( article )
                                ) {
diff --git a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js 
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
index f2ddb1d..1ab837b 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.utils.js
@@ -78,7 +78,7 @@
 
                // for special page, it doesn't matter if the article has AFT 
applied
                if ( location != 'special' ) {
-                       if ( article.permissionLevel !== false ) {
+                       if ( mw.config.get( 
'wgArticleFeedbackv5EnableProtection', 1 ) && article.permissionLevel !== false 
) {
                                // check if a, to this user sufficient, 
permission level is defined
                                enable &= $.aftUtils.permissions( article, 
article.permissionLevel );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/72495
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97824072bcd9ead44ddc4e3605a2fd932bda3141
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to