Index: trunk/extensions/Farmer/MediaWikiFarmer.php |
— | — | @@ -149,22 +149,33 @@ |
150 | 150 | * This function does all the fun stuff |
151 | 151 | */ |
152 | 152 | public function run() { |
| 153 | + global $wgCommandLineMode; |
| 154 | + |
153 | 155 | if( !$this->_defaultWiki ) { |
154 | 156 | throw new MWException( 'Default wiki must be set' ); |
155 | 157 | } |
156 | 158 | |
157 | | - // first we try to find the wiki name that was accessed by calling the appropriate function |
| 159 | + // first we try to find the wiki name that was accessed by calling the |
| 160 | + // appropriate function |
158 | 161 | if( is_callable( $this->_matchFunction ) ){ |
159 | 162 | $wiki = call_user_func( $this->_matchFunction, $this ); |
160 | 163 | |
161 | 164 | // if our function coudln't identify the wiki from the environment |
162 | 165 | if ( !$wiki ) { |
163 | | - $wiki = $this->_defaultWiki; |
| 166 | + // if the admin passed the --wiki option in command line mode |
| 167 | + // then use it to get the wiki |
| 168 | + if( $wgCommandLineMode && defined( 'MW_DB' ) ) { |
| 169 | + $wiki = MW_DB; |
| 170 | + if( defined( 'MW_PREFIX' ) && MW_PREFIX ) |
| 171 | + $wiki .= '-' . MW_PREFIX; |
| 172 | + } else { |
| 173 | + $wiki = $this->_defaultWiki; |
| 174 | + } |
164 | 175 | } |
165 | 176 | |
166 | 177 | // sanitize wiki name |
167 | | - // we force to lcase b/c having all types of case combos would just be confusing to end-user |
168 | | - // besides, hostnames are not case sensitive |
| 178 | + // we force to lcase b/c having all types of case combos would just |
| 179 | + // be confusing to end-user besides, hostnames are not case sensitive |
169 | 180 | $wiki = strtolower( preg_replace( '/[^[:alnum:_\-]]/', '', $wiki ) ); |
170 | 181 | |
171 | 182 | // now we have a valid wiki name |
Index: trunk/extensions/Farmer/MediaWikiFarmer_Wiki.php |
— | — | @@ -277,12 +277,14 @@ |
278 | 278 | $wgGroupPermissions['sysop']['read'] = true; |
279 | 279 | |
280 | 280 | //assign permissions to administrators of this wiki |
281 | | - $group = '[farmer]['.$this->_name.'][admin]'; |
| 281 | + if( $farmer->sharingGroups() ){ |
| 282 | + $group = '[farmer]['.$this->_name.'][admin]'; |
282 | 283 | |
283 | | - $grantToWikiAdmins = array( 'read', 'edit' ); |
| 284 | + $grantToWikiAdmins = array( 'read', 'edit' ); |
284 | 285 | |
285 | | - foreach ( $grantToWikiAdmins as $v ) { |
286 | | - $wgGroupPermissions[$group][$v] = true; |
| 286 | + foreach ( $grantToWikiAdmins as $v ) { |
| 287 | + $wgGroupPermissions[$group][$v] = true; |
| 288 | + } |
287 | 289 | } |
288 | 290 | |
289 | 291 | if( $callback = $farmer->initCallback() ) { |
— | — | @@ -504,11 +506,22 @@ |
505 | 507 | } |
506 | 508 | |
507 | 509 | protected function _populateUserGroups() { |
508 | | - $db = $this->getDatabase(); |
509 | 510 | if ( $this->creator ) { |
510 | | - $user = User::newFromname( $this->creator ); |
511 | | - $group = '[farmer]['.$this->name.'][admin]'; |
512 | | - $user->addGroup( $group ); |
| 511 | + if( MediaWikiFarmer::getInstance()->sharingGroups() ){ |
| 512 | + $user = User::newFromname( $this->creator ); |
| 513 | + $group = '[farmer]['.$this->name.'][admin]'; |
| 514 | + $user->addGroup( $group ); |
| 515 | + } else { |
| 516 | + $userId = User::idFromName( $this->creator ); |
| 517 | + if( $userId ) { |
| 518 | + $insert = array( |
| 519 | + array( 'ug_user' => $userId, 'ug_group' => 'sysop' ), |
| 520 | + array( 'ug_user' => $userId, 'ug_group' => 'bureaucrat' ), |
| 521 | + ); |
| 522 | + $db = $this->getDatabase(); |
| 523 | + $db->insert( 'user_groups', $insert, __METHOD__ ); |
| 524 | + } |
| 525 | + } |
513 | 526 | } |
514 | 527 | } |
515 | 528 | |
— | — | @@ -527,7 +540,7 @@ |
528 | 541 | $prefix = $db->getProperty( 'mTablePrefix' ); |
529 | 542 | |
530 | 543 | while( $row = $result->fetchRow() ) { |
531 | | - if( strpos( $row[0], $prefix ) === 0 ) { |
| 544 | + if( $prefix == '' || strpos( $row[0], $prefix ) === 0 ) { |
532 | 545 | $query = 'DROP TABLE `'. $row[0] . '`'; |
533 | 546 | $db->query( $query, __METHOD__ ); |
534 | 547 | } |
— | — | @@ -535,11 +548,12 @@ |
536 | 549 | } |
537 | 550 | |
538 | 551 | protected function _deleteWikiGroups() { |
539 | | - $db = $this->getDatabase(); |
540 | | - $query = 'DELETE FROM ' . $db->tableName( 'user_groups' ) . ' WHERE ug_group LIKE '; |
541 | | - $query .= '\'[farmer]['.$this->_name.']%\''; |
542 | | - |
543 | | - $db->query( $query, __METHOD__ ); |
| 552 | + if( MediaWikiFarmer::getInstance()->sharingGroups() ){ |
| 553 | + $db = $this->getDatabase(); |
| 554 | + $query = 'DELETE FROM ' . $db->tableName( 'user_groups' ) . ' WHERE ug_group LIKE '; |
| 555 | + $query .= '\'[farmer]['.$this->_name.']%\''; |
| 556 | + $db->query( $query, __METHOD__ ); |
| 557 | + } |
544 | 558 | } |
545 | 559 | |
546 | 560 | protected function _deleteInterwiki() { |