Make user right selection in installer actually work, thanks Krinkle for spotting...
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 2 Jun 2011 01:26:26 +0000 (01:26 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 2 Jun 2011 01:26:26 +0000 (01:26 +0000)
includes/installer/LocalSettingsGenerator.php
includes/installer/WebInstaller.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/suite.xml

index 94c84e3..fd84f3b 100644 (file)
@@ -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}";
        }
 
 }
index d79e338..4ea0cd4 100644 (file)
@@ -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;
                }
index b751703..811e7ea 100644 (file)
@@ -2,7 +2,6 @@
 
 /**
  * @group Database
- * @group Broken
  */
 class BlockTest extends MediaWikiLangTestCase {
        
index e6649be..661469f 100644 (file)
@@ -9,7 +9,7 @@
          convertWarningsToExceptions="true"
          stopOnFailure="false"
          strict="true"
-                verbose="true">
+                verbose="false">
        <testsuites>
                <testsuite name="includes">
                        <directory>./includes</directory>