[Mediawiki-l] default protection level of new pages / files

Florian Knorn florian at knorn.org
Thu Nov 23 11:05:20 UTC 2006


Ok, managed to do it myself (I'm getting better, hehe :-))

In case somebody finds this useful, here is my semi-quick&dirty solution:

1. In your LocalSettings.php create a variable
      $wgDefaultProtectionLevel = array( 'edit' => 'mitarbeiter',
                                               'move' => 'mitarbeiter');
   ... where you should replace 'mitarbeiter' by the specific level you
   want / need.

2. In includes/Article.php find the insertNewArticle function (for me it
   [with MediaWiki 1.8.2] it was around line 1100...), and add the
   following code to the end of the function (but, of course, before the
   doRedirect command):

   /* default protection level hack */
   global $wgDefaultProtectionLevel;

   $ok = $this->updateRestrictions( $wgDefaultProtectionLevel,
                                                    'Initial protect' );
   if( !$ok ) {
      throw new FatalError( "Unknown error at restriction save time." );
   }
   /*  end default protection level hack */

There you go, new pages should now automatically be protected with the
levels you chose in the LocalSettings...

Cheers everyone,

Florian :-)



Florian Knorn wrote:
> Hi there !
> 
> How can I auto-protect pages when they are created? I.e. I want all
> newly created pages to have a specific protection level by default...
> how can I do this?
> 
> Thanks for your help and best regards,
> 
> Florian
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l



More information about the MediaWiki-l mailing list