From 89529808d8d03f8bcd7809c79dc9a511609881ca Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 2 Jun 2011 01:26:26 +0000 Subject: [PATCH] Make user right selection in installer actually work, thanks Krinkle for spotting this --- includes/installer/LocalSettingsGenerator.php | 31 +++++++++++++++++-- includes/installer/WebInstaller.php | 4 +++ tests/phpunit/includes/BlockTest.php | 1 - tests/phpunit/suite.xml | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 94c84e329d..fd84f3b2ab 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -16,6 +16,7 @@ class LocalSettingsGenerator { private $extensions = array(); private $values = array(); + private $groupPermissions = array(); private $dbSettings = ''; private $safeMode = false; @@ -76,6 +77,16 @@ class LocalSettingsGenerator { $this->values['wgEmergencyContact'] = $this->values['wgPasswordSender']; } + /** + * For $wgGroupPermissions, set a given ['group']['permission'] value. + * @param $group String Group name + * @param $rightsArr Array An array of permissions, in the form of: + * array( 'right' => true, 'right2' => false ) + */ + public function setGroupRights( $group, $rightsArr ) { + $this->groupPermissions[$group] = $rightsArr; + } + /** * Returns the escaped version of a string of php code. * @@ -176,13 +187,26 @@ class LocalSettingsGenerator { $locale = ''; } - $rights = $this->values['wgRightsUrl'] ? '' : '#'; + $rightsUrl = $this->values['wgRightsUrl'] ? '' : '#'; $hashedUploads = $this->safeMode ? '' : '#'; $metaNamespace = ''; if( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) { $metaNamespace = "\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n"; } + $groupRights = ''; + if( $this->groupPermissions ) { + $groupRights .= "# The following permissions were set based on your choice in the installer\n"; + foreach( $this->groupPermissions as $group => $rightArr ) { + $group = self::escapePhpString( $group ); + foreach( $rightArr as $right => $perm ) { + $right = self::escapePhpString( $right ); + $groupRights .= "\$wgGroupPermissions['$group']['$right'] = " . + wfBoolToStr( $perm ) . "\n"; + } + } + } + switch( $this->values['wgMainCacheType'] ) { case 'anything': case 'db': @@ -298,7 +322,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { ## For attaching licensing metadata to pages, and displaying an ## appropriate copyright notice / icon. GNU Free Documentation ## License and Creative Commons licenses are supported so far. -{$rights}\$wgEnableCreativeCommonsRdf = true; +{$rightsUrl}\$wgEnableCreativeCommonsRdf = true; \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright \$wgRightsUrl = \"{$this->values['wgRightsUrl']}\"; \$wgRightsText = \"{$this->values['wgRightsText']}\"; @@ -313,7 +337,8 @@ if ( !defined( 'MEDIAWIKI' ) ) { # or if you have suhosin.get.max_value_length set in php.ini (then set it to # that value) \$wgResourceLoaderMaxQueryLength = {$this->values['wgResourceLoaderMaxQueryLength']}; -"; + +{$groupRights}"; } } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index d79e33857d..4ea0cd4071 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -147,6 +147,10 @@ class WebInstaller extends Installer { ); $ls = new LocalSettingsGenerator( $this ); + $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )]; + foreach( $rightsProfile as $group => $rightsArr ) { + $ls->setGroupRights( $group, $rightsArr ); + } echo $ls->getText(); return $this->session; } diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index b751703e2f..811e7eaf35 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -2,7 +2,6 @@ /** * @group Database - * @group Broken */ class BlockTest extends MediaWikiLangTestCase { diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index e6649beb33..661469fa57 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -9,7 +9,7 @@ convertWarningsToExceptions="true" stopOnFailure="false" strict="true" - verbose="true"> + verbose="false"> ./includes -- 2.20.1