]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/undelete.php
MediaWiki 1.16.0
[autoinstallsdev/mediawiki.git] / maintenance / undelete.php
1 <?php
2 /**
3  * Undelete a page by fetching it from the archive table
4  *
5  * @file
6  * @ingroup Maintenance
7  */
8
9 require_once( dirname(__FILE__) . '/Maintenance.php' );
10
11 class Undelete extends Maintenance {
12         public function __construct() {
13                 parent::__construct();
14                 $this->mDescription = "Undelete a page";
15                 $this->addOption( 'u', 'The user to perform the undeletion', false, true );
16                 $this->addOption( 'r', 'The reason to undelete', false, true );
17                 $this->addArg( 'pagename', 'Page to undelete' );
18         }
19
20         public function execute() {
21                 global $wgUser;
22
23                 $user = $this->getOption( 'u', 'Command line script' );
24                 $reason = $this->getOption( 'r', '' );
25                 $pageName = $this->getArg();
26
27                 $title = Title::newFromText( $pageName );
28                 if ( !$title ) {
29                         $this->error( "Invalid title", true );
30                 }
31                 $wgUser = User::newFromName( $user );
32                 $archive = new PageArchive( $title );
33                 $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' );
34                 $archive->undelete( array(), $reason );
35                 $this->output( "done\n" );
36         }
37 }
38
39 $maintClass = "Undelete";
40 require_once( DO_MAINTENANCE );