User:AnomieBOT/source/tasks/PERTableUpdater.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Replace underscores with spaces in page titles read from urns.
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Handle template-protection, currently lumped in with CAT:EP.
Line 130:
# 1: semi-protected
# 2: semi-protected via title blacklist
# 3: Usertemplate CSS/JS pageprotected
# 4: fullyUser protectedCSS/JS page
# 5: fully protected
# 6: fully protected via title blacklist, or cascading protection
# 67: MediaWiki-namespace page
my @data=(
[[10,828],'PER','Wikipedia protected edit requests','protected','editprotected','x-wp-editprotected',[qw/red red red clear yellow clear yellow yellow/]],
[[10,828],'SPER','Wikipedia semi-protected edit requests','semi-protected','editsemiprotected','x-wp-editsemiprotected',[qw/red clear yellow red red red red red/]],
[[0],'EDITREQ','Requested edits','COI','requestedit','x-wp-requestedit',[qw/clear yellow yellow red red red red red/]],
);
my $starttime=time;
Line 210 ⟶ 211:
 
# Protection scoring "bitmap":
# 0x1000x200 = MediaWiki-namespace auto-protection
# 0x800x100 = Cascading protection
# 0x400x80 = Full protection
# 0x200x40 = User script auto-protection
# 0x20 = Template-protection
# 0x10 = Semi-protection
# 0x08 = Directly-applied protection
Line 223 ⟶ 225:
if($p->{'ns'}==8){
$pd->{'prottype'}='MediaWiki page';
$protscore=0x1000x200;
} elsif($p->{'ns'}==2 && $t=~m!/.*\.js$!){
$pd->{'prottype'}='User JS page';
$protscore=0x200x40;
} elsif($p->{'ns'}==2 && $t=~m!/.*\.css$!){
$pd->{'prottype'}='User CSS page';
$protscore=0x200x40;
}
while(my ($re,$data)=each %tb){
next unless $t=~/^(?:$re)$/si;
next unless(exists($p->{'missing'}) || ($data->{'opts'}{'noedit'}//0));
my $sc=exists($data->{'opts'}{'autoconfirmed'})?0x12:0x420x22;
next if $sc<$protscore;
$pd->{'prottype'}=$data->{'source'};
Line 247 ⟶ 249:
next unless $pp->{'type'} eq 'edit';
my $sc=0;
$sc|=0x400x80 if $pp->{'level'} eq 'sysop';
$sc|=0x20 if $pp->{'level'} eq 'templateeditor';
$sc|=0x10 if $pp->{'level'} eq 'autoconfirmed';
$sc|=exists($pp->{'source'})?0x800x100:0x08;
$sc|=0x800x100 if exists($pp->{'cascade'});
next if $sc<$protscore;
if(exists($pp->{'source'})){
Line 258 ⟶ 261:
$pg=$t;
$pd->{'prottype'}='Fully protected' if $pp->{'level'} eq 'sysop';
$pd->{'prottype'}='Template-protected' if $pp->{'level'} eq 'templateeditor';
$pd->{'prottype'}='Semiprotected' if $pp->{'level'} eq 'autoconfirmed';
$pd->{'prottype'}.=' with cascading' if exists($pp->{'cascade'});
Line 272 ⟶ 276:
}
$pd->{'color'}=$colors->[3] if($protscore & 0x20);
$pd->{'color'}=$colors->[4] if($protscore & 0x40){;
if($protscore & $pd->0x80){'color'}=$colors->[4];
$pd->{'color'}=$colors->[5] if($protscore & 0x02);
$pd->{'color'}=$colors->[56] if($protscore & 0x800x02);
}
$pd->{'color'}=$colors->[5] if($protscore & 0x80);
$pd->{'color'}=$colors->[6] if($protscore & 0x100);
$pd->{'color'}=$colors->[7] if($protscore & 0x200);
$pd->{'color'}='green' if($pd->{'color'} eq 'clear' && grep($p->{'ns'}==$_, @$greenns));