Move DatabaseType to Database.php
[lhc/web/wiklou.git] / maintenance / addwiki.php
index dcce8f4..80a2b14 100644 (file)
  * @ingroup Wikimedia
  */
 
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 class AddWiki extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Add a new wiki to the family. Wikimedia specific!";
-               $this->addArg( 'language', 'Language code of new site' );
-               $this->addArg( 'site', 'Type of site' );
-               $this->addArg( 'dbname', 'Name of database to create' );
+               $this->addArg( 'language', 'Language code of new site, e.g. en' );
+               $this->addArg( 'site', 'Type of site, e.g. wikipedia' );
+               $this->addArg( 'dbname', 'Name of database to create, e.g. enwiki' );
+               $this->addArg( 'domain', 'Domain name of the wiki, e.g. en.wikipedia.org' );
        }
 
-       protected function getDbType() {
+       public function getDbType() {
                return Maintenance::DB_ADMIN;
        }
 
        public function execute() {
-               global $IP, $wgLanguageNames, $wgDefaultExternalStore, $wgNoDBParam;
+               global $IP, $wgDefaultExternalStore, $wgNoDBParam;
 
                $wgNoDBParam = true;
-               $lang = $this->getArg(0);
-               $site = $this->getArg(1);
-               $dbName = $this->getArg(2);
+               $lang = $this->getArg( 0 );
+               $site = $this->getArg( 1 );
+               $dbName = $this->getArg( 2 );
+               $domain = $this->getArg( 3 );
+               $languageNames = Language::getLanguageNames();
 
-               if ( !isset( $wgLanguageNames[$lang] ) ) {
+               if ( !isset( $languageNames[$lang] ) ) {
                        $this->error( "Language $lang not found in \$wgLanguageNames", true );
                }
-               $name = $wgLanguageNames[$lang];
+               $name = $languageNames[$lang];
 
                $dbw = wfGetDB( DB_MASTER );
                $common = "/home/wikipedia/common";
@@ -80,7 +83,7 @@ class AddWiki extends Maintenance {
                $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql" );
                $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql" );
                $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql" );
-               $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/Optin/OptIn.sql" );
+               $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/OptIn/OptIn.sql" );
 
                $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
 
@@ -139,12 +142,22 @@ class AddWiki extends Maintenance {
                fclose( $file );
 
                # Update the sublists
-               shell_exec("cd $common && ./refresh-dblist");
+               shell_exec( "cd $common && ./refresh-dblist" );
 
-               #print "Constructing interwiki SQL\n";
+               # print "Constructing interwiki SQL\n";
                # Rebuild interwiki tables
-               #passthru( '/home/wikipedia/conf/interwiki/update' );
-
+               # passthru( '/home/wikipedia/conf/interwiki/update' );
+               
+               $time = wfTimestamp( TS_RFC2822 );
+               // These arguments need to be escaped twice: once for echo and once for at
+               $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbName ) );
+               $escTime = wfEscapeShellArg( wfEscapeShellArg( $time ) );
+               $escUcsite = wfEscapeShellArg( wfEscapeShellArg( $ucsite ) );
+               $escName = wfEscapeShellArg( wfEscapeShellArg( $name ) );
+               $escLang = wfEscapeShellArg( wfEscapeShellArg( $lang ) );
+               $escDomain = wfEscapeShellArg( wfEscapeShellArg( $domain ) );
+               shell_exec( "echo notifyNewProjects $escDbName $escTime $escUcsite $escName $escLang $escDomain | at now + 15 minutes" );
+               
                $this->output( "Script ended. You still have to:
        * Add any required settings in InitialiseSettings.php
        * Run sync-common-all