summaryrefslogtreecommitdiff
path: root/maintenance/importImages.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
commit72e90545454c0e014318fa3c81658e035aac58c1 (patch)
tree9212e3f46868989c4d57ae9a5c8a1a80e4dc0702 /maintenance/importImages.php
parent565a0ccc371ec1a2a0e9b39487cbac18e6f60e25 (diff)
applying patch to version 1.15.0
Diffstat (limited to 'maintenance/importImages.php')
-rw-r--r--maintenance/importImages.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/maintenance/importImages.php b/maintenance/importImages.php
index 4c6082b2..7997b0d5 100644
--- a/maintenance/importImages.php
+++ b/maintenance/importImages.php
@@ -21,6 +21,13 @@ if( count( $args ) > 0 ) {
$dir = $args[0];
+ # Check Protection
+ if (isset($options['protect']) && isset($options['unprotect']))
+ die("Cannot specify both protect and unprotect. Only 1 is allowed.\n");
+
+ if ($options['protect'] == 1)
+ die("You must specify a protection option.\n");
+
# Prepare the list of allowed extensions
global $wgFileExtensions;
$extensions = isset( $options['extensions'] )
@@ -114,6 +121,25 @@ if( count( $args ) > 0 ) {
continue;
}
}
+
+ $doProtect = false;
+ $restrictions = array();
+
+ global $wgRestrictionLevels;
+
+ $protectLevel = isset($options['protect']) ? $options['protect'] : null;
+
+ if ( $protectLevel && in_array( $protectLevel, $wgRestrictionLevels ) ) {
+ $restrictions['move'] = $protectLevel;
+ $restrictions['edit'] = $protectLevel;
+ $doProtect = true;
+ }
+ if (isset($options['unprotect'])) {
+ $restrictions['move'] = '';
+ $restrictions['edit'] = '';
+ $doProtect = true;
+ }
+
$$svar++;
if ( isset( $options['dry'] ) ) {
@@ -121,6 +147,21 @@ if( count( $args ) > 0 ) {
} else if ( $image->recordUpload( $archive->value, $commentText, $license ) ) {
# We're done!
echo( "done.\n" );
+ if ($doProtect) {
+ # Protect the file
+ $article = new Article( $title );
+ echo "\nWaiting for slaves...\n";
+ // Wait for slaves.
+ sleep(2.0);
+ wfWaitForSlaves( 1.0 );
+
+ echo( "\nSetting image restrictions ... " );
+ if ( $article->updateRestrictions($restrictions) )
+ echo( "done.\n" );
+ else
+ echo( "failed.\n" );
+ }
+
} else {
echo( "failed.\n" );
}
@@ -166,6 +207,8 @@ Options:
but the extension <ext>.
--license=<code> Use an optional license template
--dry Dry run, don't import anything
+--protect=<protect> Specify the protect value (autoconfirmed,sysop)
+--unprotect Unprotects all uploaded images
END;
exit();