Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(use the default mediawiki protection level names after all) |
(try making the algorithm more general) |
||
Line 34: | Line 34: | ||
['edit-sysop-all-blp-all'] = 'Wikipedia indefinitely protected biographies of living people', |
['edit-sysop-all-blp-all'] = 'Wikipedia indefinitely protected biographies of living people', |
||
['edit-autoconfirmed-all-all-indef'] = 'Wikipedia indefinitely semi-protected pages', |
['edit-autoconfirmed-all-all-indef'] = 'Wikipedia indefinitely semi-protected pages', |
||
⚫ | |||
⚫ | |||
['move-sysop-talk-all-all'] = 'Wikipedia move-protected talk pages', |
['move-sysop-talk-all-all'] = 'Wikipedia move-protected talk pages', |
||
['move-sysop-all-all-indef'] = 'Wikipedia indefinitely move-protected pages', |
['move-sysop-all-all-indef'] = 'Wikipedia indefinitely move-protected pages', |
||
['edit-autoconfirmed-all-all-all'] = 'Wikipedia semi-protected pages', |
['edit-autoconfirmed-all-all-all'] = 'Wikipedia semi-protected pages', |
||
⚫ | |||
⚫ | |||
⚫ | |||
['move-sysop-all-all-all'] = 'Wikipedia move-protected pages', |
['move-sysop-all-all-all'] = 'Wikipedia move-protected pages', |
||
⚫ | |||
['pc-autoconfirmed-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)', |
['pc-autoconfirmed-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)', |
||
['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)', |
['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)', |
||
⚫ | |||
⚫ | |||
} |
} |
||
Line 140: | Line 140: | ||
local keyTable = {protType, protLevel, namespace, reason, expiry} |
local keyTable = {protType, protLevel, namespace, reason, expiry} |
||
local attemptOrder = { |
local attemptOrder = { |
||
-- type, level, ns, reason, expiry |
|||
{true, true, true, true, true}, -- 1 |
{true, true, true, true, true}, -- 1 |
||
{true, true, true, true, false}, -- 2 |
{true, true, true, true, false}, -- 2 |
||
Line 148: | Line 148: | ||
{true, true, true, false, false}, -- 6 |
{true, true, true, false, false}, -- 6 |
||
{true, true, false, false, true}, -- 7 |
{true, true, false, false, true}, -- 7 |
||
{true, |
{true, false, true, true, true}, -- 8 |
||
{true, false, true, |
{true, false, true, true, false}, -- 9 |
||
{true, false, false, |
{true, false, false, true, true}, -- 10 |
||
{ |
{true, false, true, false, true}, -- 11 |
||
{true, false, false, true, false}, -- 12 |
|||
{true, false, true, false, false}, -- 13 |
|||
{true, false, false, false, true}, -- 14 |
|||
{true, false, false, false, false}, -- 15 |
|||
{false, false, false, false, false} -- 16 |
|||
} |
} |
||
local |
local reasonBehaviors = { |
||
vandalism = |
vandalism = 'namespaceFirst', |
||
dispute = 'reasonFirst', |
|||
⚫ | |||
blp = 'reasonFirst', |
|||
sock = 'reasonFirst', |
|||
⚫ | |||
} |
} |
||
local reasonBehavior = reasonBehaviors[reason] |
|||
if reasonFirst[reason] then |
|||
if reasonBehavior == 'reasonOnly' then |
|||
local attempt = cats[reason] |
|||
if attempt then |
|||
return attempt |
|||
else |
|||
error('the category for key "' .. reason .. '" is undefined') |
|||
end |
|||
elseif reasonBehavior == 'namespaceFirst' then |
|||
-- Sort the order so that namespace keys are checked before reason matches. |
|||
attemptOrder[3], attemptOrder[4] = attemptOrder[4], attemptOrder[3] |
attemptOrder[3], attemptOrder[4] = attemptOrder[4], attemptOrder[3] |
||
attemptOrder[5], attemptOrder[6] = attemptOrder[6], attemptOrder[5] |
attemptOrder[5], attemptOrder[6] = attemptOrder[6], attemptOrder[5] |
||
elseif not reasonBeavior then |
|||
table.insert(attemptOrder, 2, {false, false, false, true, false}) -- To deal with office-protection |
|||
error(reason .. ' is not a valid reason') |
|||
end |
end |
||