Anonymous user
Module:Protection banner: Difference between revisions
try making the algorithm more general
(use the default mediawiki protection level names after all) |
(try making the algorithm more general) |
||
Line 34:
['edit-sysop-all-blp-all'] = 'Wikipedia indefinitely protected biographies of living people',
['edit-autoconfirmed-all-all-indef'] = 'Wikipedia indefinitely semi-protected pages',
['edit-autoconfirmed-category-all-all'] = 'Wikipedia semi-protected categories',▼
['edit-sysop-category-all-all'] = 'Wikipedia protected categories',▼
['move-sysop-talk-all-all'] = 'Wikipedia move-protected talk pages',
['move-sysop-all-all-indef'] = 'Wikipedia indefinitely move-protected pages',
['edit-autoconfirmed-all-all-all'] = 'Wikipedia semi-protected pages',
['all-all-all-all-all'] = 'Wikipedia protected pages',▼
▲ ['edit-autoconfirmed-category-all-all'] = 'Wikipedia semi-protected categories',
▲ ['edit-sysop-category-all-all'] = 'Wikipedia protected categories',
['move-sysop-all-all-all'] = 'Wikipedia move-protected pages',
['all-all-all-office-all'] = 'Wikipedia Office-protected pages',▼
['pc-autoconfirmed-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)',
['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)',
▲ ['all-all-all-all-all'] = 'Wikipedia protected pages',
}
Line 140:
local keyTable = {protType, protLevel, namespace, reason, expiry}
local attemptOrder = {
{true, true, true, true, true}, -- 1
{true, true, true, true, false}, -- 2
Line 148:
{true, true, true, false, false}, -- 6
{true, true, false, false, true}, -- 7
{true,
{true, false, true,
{true, false, false,
{
{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
vandalism =
dispute = 'reasonFirst',
office = true▼
blp = 'reasonFirst',
sock = 'reasonFirst',
}
local reasonBehavior = reasonBehaviors[reason]
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[5], attemptOrder[6] = attemptOrder[6], attemptOrder[5]
elseif not reasonBeavior then
error(reason .. ' is not a valid reason')
end
|