http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89311

Revision: 89311
Author:   demon
Date:     2011-06-02 01:26:26 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
Make user right selection in installer actually work, thanks Krinkle for 
spotting this

Modified Paths:
--------------
    trunk/phase3/includes/installer/LocalSettingsGenerator.php
    trunk/phase3/includes/installer/WebInstaller.php
    trunk/phase3/tests/phpunit/includes/BlockTest.php
    trunk/phase3/tests/phpunit/suite.xml

Modified: trunk/phase3/includes/installer/LocalSettingsGenerator.php
===================================================================
--- trunk/phase3/includes/installer/LocalSettingsGenerator.php  2011-06-02 
01:19:41 UTC (rev 89310)
+++ trunk/phase3/includes/installer/LocalSettingsGenerator.php  2011-06-02 
01:26:26 UTC (rev 89311)
@@ -16,6 +16,7 @@
 
        private $extensions = array();
        private $values = array();
+       private $groupPermissions = array();
        private $dbSettings = '';
        private $safeMode = false;
 
@@ -77,6 +78,16 @@
        }
 
        /**
+        * 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.
         *
         * @param $string String
@@ -176,13 +187,26 @@
                        $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 @@
 ## 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 @@
 # or if you have suhosin.get.max_value_length set in php.ini (then set it to
 # that value)
 \$wgResourceLoaderMaxQueryLength = 
{$this->values['wgResourceLoaderMaxQueryLength']};
-";
+
+{$groupRights}";
        }
 
 }

Modified: trunk/phase3/includes/installer/WebInstaller.php
===================================================================
--- trunk/phase3/includes/installer/WebInstaller.php    2011-06-02 01:19:41 UTC 
(rev 89310)
+++ trunk/phase3/includes/installer/WebInstaller.php    2011-06-02 01:26:26 UTC 
(rev 89311)
@@ -147,6 +147,10 @@
                        );
 
                        $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;
                }

Modified: trunk/phase3/tests/phpunit/includes/BlockTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/BlockTest.php   2011-06-02 01:19:41 UTC 
(rev 89310)
+++ trunk/phase3/tests/phpunit/includes/BlockTest.php   2011-06-02 01:26:26 UTC 
(rev 89311)
@@ -2,7 +2,6 @@
 
 /**
  * @group Database
- * @group Broken
  */
 class BlockTest extends MediaWikiLangTestCase {
        

Modified: trunk/phase3/tests/phpunit/suite.xml
===================================================================
--- trunk/phase3/tests/phpunit/suite.xml        2011-06-02 01:19:41 UTC (rev 
89310)
+++ trunk/phase3/tests/phpunit/suite.xml        2011-06-02 01:26:26 UTC (rev 
89311)
@@ -9,7 +9,7 @@
          convertWarningsToExceptions="true"
          stopOnFailure="false"
          strict="true"
-                verbose="true">
+                verbose="false">
        <testsuites>
                <testsuite name="includes">
                        <directory>./includes</directory>


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

Reply via email to