jenkins-bot has submitted this change and it was merged.

Change subject: Add AllowedNamespaces configuration variables for hubs and lists
......................................................................


Add AllowedNamespaces configuration variables for hubs and lists

Users* may want to change the namespaces in which hubs/lists are
allowed in order to fullfill unexpected use cases. We don't care;
we'll just leave it an option.

Separate variables are used for hubs and lists as uses may vary for
each.

Hubs now also specifically check if subpages are allowed for the
namespace in case a user misconfigures their wiki.

Allowed namespaces are set to user (2) and project (4) by default.
Unless that's the other way around. I've forgotten already, but it's
those two.

* All mentions of 'users' here refers to sysadmins with localsettings
access, not onwiki users.

This is a follow-up on initial implementation for T141004.

Change-Id: If70bff87c8324f425d32511d94beaac17017cf41
---
M extension.json
M includes/content/CollaborationHubContentHandler.php
M includes/content/CollaborationListContentHandler.php
3 files changed, 21 insertions(+), 2 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index dbdfeb3..1747618 100644
--- a/extension.json
+++ b/extension.json
@@ -33,6 +33,18 @@
                "CollaborationHubContent": "CollaborationHubContentHandler",
                "CollaborationListContent": "CollaborationListContentHandler"
        },
+       "config": {
+               "CollaborationHubAllowedNamespaces": {
+                       "_merge_strategy": "array_plus",
+                       "2": true,
+                       "4": true
+               },
+               "CollaborationListAllowedNamespaces": {
+                       "_merge_strategy": "array_plus",
+                       "2": true,
+                       "4": true
+               }
+       },
        "SpecialPages": {
                "CreateCollaborationHub": "SpecialCreateCollaborationHub",
                "CreateHubFeature": "SpecialCreateHubFeature"
diff --git a/includes/content/CollaborationHubContentHandler.php 
b/includes/content/CollaborationHubContentHandler.php
index d6a8e0e..5786ad9 100644
--- a/includes/content/CollaborationHubContentHandler.php
+++ b/includes/content/CollaborationHubContentHandler.php
@@ -7,7 +7,12 @@
        }
 
        public function canBeUsedOn( Title $title ) {
-               if ( $title->inNamespace( NS_PROJECT ) || $title->inNamespace( 
NS_USER ) ) {
+               global $wgCollaborationHubAllowedNamespaces;
+
+               $namespace = $title->getNamespace();
+               if ( in_array( $namespace, array_keys( array_filter( 
$wgCollaborationHubAllowedNamespaces ) ) )
+                       && MWNamespace::hasSubpages( $namespace ) ) {
+
                        return true;
                }
                return false;
diff --git a/includes/content/CollaborationListContentHandler.php 
b/includes/content/CollaborationListContentHandler.php
index b10da7c..db94e5e 100644
--- a/includes/content/CollaborationListContentHandler.php
+++ b/includes/content/CollaborationListContentHandler.php
@@ -20,7 +20,9 @@
        }
 
        public function canBeUsedOn( Title $title ) {
-               if ( $title->inNamespace( NS_PROJECT ) || $title->inNamespace( 
NS_USER ) ) {
+               global $wgCollaborationListAllowedNamespaces;
+
+               if ( in_array( $title->getNamespace(), array_keys( 
array_filter( $wgCollaborationListAllowedNamespaces ) ) ) ) {
                        return true;
                }
                return false;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If70bff87c8324f425d32511d94beaac17017cf41
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Isarra <zhoris...@gmail.com>
Gerrit-Reviewer: Harej <jamesmh...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to