Module:Contentious topics/talk notice: Difference between revisions

Content deleted Content added
update
various code improvements
Line 48:
local articleOrPage -- the string "article" (if a mainspace page) or "page" (if not)
local protectionLevel -- the edit protection level
local messageBody -- the text within the message box
local messageBox -- the message box itself
local categories = '' -- initialize categories
local manualRestrictions = false -- have we set any restrictions via |parameters?
--[[
Line 66 ⟶ 67:
-- Helpers to add a restriction if it's active and hasn't been added yet
local function addRestrictionmaybeAddRestriction(restriction, bypassLookup)
if yesno(args[restriction]) or bypassLookup then
restrictionFlags[restriction] = true
manualRestrictions = true
end
end
end
local function maybeAddRestriction(restriction) return addRestriction(restriction, false) end
local function alwaysAddRestriction(restriction) return addRestriction(restriction, true) end
restrictionFlags[rrrestriction] = true
end
-- Add the always-available restrictions
Line 109 ⟶ 113:
--[[
Clear duplicate restrictions (e.g. 0RR and 1RR; 1RR and 1RR-nocat, etc; consensus-required is stronger than BRD)
--]]
-- if 0RR, then clear 1RR
-- helper function which clears all revert rules, except for the given one
if restrictionFlags["0RR"] then
local function clearOtherRevertRules(rr)
restrictionFlags["0RR"] = nil
restrictionFlags["0RR-nocat"] = nil
restrictionFlags["1RR"] = nil
restrictionFlags["1RR-nocat"] = nil
restrictionFlags[rr] = true
end
-- then use the most applicable revert rule
if restrictionFlags["0RR"] then
clearOtherRevertRules("0RR")
elseif restrictionFlags["0RR-nocat"] then
clearOtherRevertRules("0RR-nocat")
elseif restrictionFlags["1RR"] then
clearOtherRevertRules("1RR")
end
-- if we make it to this point, 1RR-nocat is the only one potentially enabled
-- so we don't need to disable the rest
 
-- clear BRD if consensus-required is enabled
if restrictionFlags["consensus-required"] then
restrictionFlags["BRD"] = nil
end
-- and finally, convert our set to a list to make it easy to work with
Line 221 ⟶ 212:
if args['placed-date'] then
messageBody = messageBody .. '<p>Restrictions placed: ' .. require('Module:Date')._Date(args['placed-date']):text() .. '</p>'
elseif manualRestrictions then
else
addCategory(categoryDatabase['no-date'])
end