* @ingroup Maintenance
*/
-require_once( "Maintenance.php" );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class Protect extends Maintenance {
public function __construct() {
$reason = $this->getOption( 'r', '' );
$protection = "sysop";
- if ( $this->hasOption('semiprotect') ) {
+ if ( $this->hasOption( 'semiprotect' ) ) {
$protection = "autoconfirmed";
- } elseif ( $this->hasOption('unprotect') ) {
+ } elseif ( $this->hasOption( 'unprotect' ) ) {
$protection = "";
}
$wgUser = User::newFromName( $userName );
$restrictions = array( 'edit' => $protection, 'move' => $protection );
- $wgTitle = Title::newFromText( $args[0] );
+ $wgTitle = Title::newFromText( $this->getArg() );
if ( !$wgTitle ) {
- $this->error( "Invalid title\n", true );
+ $this->error( "Invalid title", true );
}
$wgArticle = new Article( $wgTitle );
# un/protect the article
$this->output( "Updating protection status... " );
- $success = $wgArticle->updateRestrictions($restrictions, $reason);
+ $success = $wgArticle->updateRestrictions( $restrictions, $reason );
if ( $success ) {
$this->output( "done\n" );
} else {