Harej has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/351097 )
Change subject: Prevent CreateCollaborationHub and CreateHubFeature from being
shown to those who cannot create pages.
......................................................................
Prevent CreateCollaborationHub and CreateHubFeature from being shown
to those who cannot create pages.
Change-Id: I507acec92d29a871d4e0df7a9db43cc01dfbe746
---
M includes/SpecialCreateCollaborationHub.php
M includes/SpecialCreateHubFeature.php
2 files changed, 12 insertions(+), 6 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit
refs/changes/97/351097/1
diff --git a/includes/SpecialCreateCollaborationHub.php
b/includes/SpecialCreateCollaborationHub.php
index 321fab6..51c4261 100644
--- a/includes/SpecialCreateCollaborationHub.php
+++ b/includes/SpecialCreateCollaborationHub.php
@@ -25,6 +25,10 @@
* @param $par string
*/
public function execute( $par ) {
+ if ( !$this->getUser()->isAllowed( 'createpage' ) ) {
+ throw new PermissionsError( 'createpage' );
+ }
+
$out = $this->getContext()->getOutput();
$out->addModules( [
'ext.CollaborationKit.hubtheme'
@@ -150,11 +154,7 @@
return Status::newFatal(
'collaborationkit-createhub-nopermission' );
}
- $title = Title::newFromText( $pagename );
- if ( !$title ) {
- return Status::newFatal(
'collaborationkit-createhub-invalidtitle' );
- }
-
+ // Create member list
$memberListTitle = Title::newFromText(
$pagename
. '/'
@@ -175,6 +175,7 @@
return $memberResult;
}
+ // Create announcements page
$announcementsTitle = Title::newFromText( $pagename
. '/'
. $this->msg(
'collaborationkit-hub-pagetitle-announcements' )
@@ -184,7 +185,7 @@
if ( !$announcementsTitle ) {
return Status::newFatal(
'collaborationkit-createhub-invalidtitle' );
}
- // Ensure that a valid context is provided to the API in unit
tests
+
$context = $this->getContext();
$der = new DerivativeContext( $context );
$request = new DerivativeRequest(
@@ -216,6 +217,7 @@
);
}
+ // Now, to create the hub itself
$result = CollaborationHubContentHandler::edit(
$title,
$data['display_name'],
diff --git a/includes/SpecialCreateHubFeature.php
b/includes/SpecialCreateHubFeature.php
index 12d75fc..6a486f4 100644
--- a/includes/SpecialCreateHubFeature.php
+++ b/includes/SpecialCreateHubFeature.php
@@ -21,6 +21,10 @@
* @param string $par
*/
public function execute( $par ) {
+ if ( !$this->getUser()->isAllowed( 'createpage' ) ) {
+ throw new PermissionsError( 'createpage' );
+ }
+
$output = $this->getContext()->getOutput();
$output->addModules( 'ext.CollaborationKit.iconbrowser' );
$output->addModuleStyles( [
--
To view, visit https://gerrit.wikimedia.org/r/351097
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I507acec92d29a871d4e0df7a9db43cc01dfbe746
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Harej <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits