Modul:Protection banner: Unterschied zwischen den Versionen

see if this is possible with just two options
(logic fix)
(see if this is possible with just two options)
Zeile 139: Zeile 139:
-- rule for every idiosyncracy that was in the old template system.
-- rule for every idiosyncracy that was in the old template system.
local keyTable = {protType, protLevel, namespace, reason, expiry}
local keyTable = {protType, protLevel, namespace, reason, expiry}
local attemptOrder = {
-- type, level, ns, reason, expiry
{true, true, true, true, true},    -- 1
{true, true, true, true, false},    -- 2
{true, true, false, true, true},    -- 3
{true, true, true, false, true},    -- 4
{true, true, false, true, false},  -- 5
{true, true, true, false, false},  -- 6
{true, true, false, false, true},  -- 7
{true, false, true, true, true},    -- 8
{true, false, true, true, false},  -- 9
{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 reasonBehaviors = {
local reasonBehaviors = {
Zeile 164: Zeile 145:
blp = 'reasonFirst',
blp = 'reasonFirst',
sock = 'reasonFirst',
sock = 'reasonFirst',
office = 'reasonOnly',
office = 'reasonFirst',
}
}


local reasonBehavior = reasonBehaviors[reason]
local reasonBehavior = reasonBehaviors[reason]
if reasonBehavior == 'reasonOnly' then
local attemptOrder
local attempt = cats[reason]
if reasonBehavior == 'reasonFirst' then
if attempt then
attemptOrder = {
return attempt
-- type, level, ns, reason, expiry
else
{true, true, true, true, true},    -- 1
error('the category for key "' .. reason .. '" is undefined')
{true, true, true, true, false},    -- 2
end
{true, true, false, true, true},    -- 3
{true, true, false, true, false},  -- 4
{true, false, true, true, true},    -- 5
{true, false, true, true, false},  -- 6
{true, false, false, true, true},  -- 7
{true, false, false, true, false},  -- 8
{false, false, false, true, false}, -- 9
{true, true, true, false, true},    -- 10
{true, true, true, false, false},  -- 11
{true, true, false, false, true},  -- 12
{true, false, true, false, true},  -- 13
{true, false, true, false, false},  -- 14
{true, false, false, false, true},  -- 15
{true, false, false, false, false}, -- 16
{false, false, false, false, false} -- 17
}
elseif reasonBehavior == 'namespaceFirst' then
elseif reasonBehavior == 'namespaceFirst' then
-- Sort the order so that namespace keys are checked before reason matches.
attemptOrder = {
attemptOrder[3], attemptOrder[4] = attemptOrder[4], attemptOrder[3]
-- type, level, ns, reason, expiry
attemptOrder[5], attemptOrder[6] = attemptOrder[6], attemptOrder[5]
{true, true, true, true, true},    -- 1
elseif reasonBehavior ~= 'reasonFirst' and reason ~= 'all' then
{true, true, true, true, false},    -- 2
{true, true, true, false, true},    -- 3
{true, true, true, false, false},  -- 4
{true, false, true, true, true},   -- 5
{true, false, true, true, false},   -- 6
{true, false, true, false, true},  -- 7
{true, false, true, false, false},  -- 8
{false, false, true, false, false}, -- 9
{true, true, false, true, true},    -- 10
{true, true, false, true, false},  -- 11
{true, true, false, false, true},  -- 12
{true, false, false, true, true},  -- 13
{true, false, false, true, false},  -- 14
{true, false, false, false, true},  -- 15
{true, false, false, false, false}, -- 16
{false, false, false, false, false} -- 17
}
elseif reason ~= 'all' then
error(reason .. ' is not a valid reason')
error(reason .. ' is not a valid reason')
end
end
Anonymer Benutzer