Editing Module:Protection banner
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 132: | Line 132: | ||
elseif effectiveExpiry ~= 'unknown' then | elseif effectiveExpiry ~= 'unknown' then | ||
obj.expiry = validateDate(effectiveExpiry, 'expiry date') | obj.expiry = validateDate(effectiveExpiry, 'expiry date') | ||
elseif args.expiry then | |||
if cfg.indefStrings[args.expiry] then | |||
obj.expiry = 'indef' | |||
elseif type(args.expiry) == 'number' then | |||
obj.expiry = args.expiry | |||
else | |||
obj.expiry = validateDate(args.expiry, 'expiry date') | |||
end | |||
end | end | ||
Line 169: | Line 177: | ||
end | end | ||
return setmetatable(obj, Protection) | return setmetatable(obj, Protection) | ||
end | end | ||
Line 182: | Line 182: | ||
return self.level ~= '*' | return self.level ~= '*' | ||
end | end | ||
function Protection:isTemporary() | function Protection:isTemporary() | ||
Line 196: | Line 188: | ||
function Protection:makeProtectionCategory() | function Protection:makeProtectionCategory() | ||
if not self: | local cfg = self._cfg | ||
local title = self.title | |||
-- Exit if the page is not protected. | |||
if not self:isProtected() then | |||
return '' | return '' | ||
end | end | ||
-- Get the expiry key fragment. | -- Get the expiry key fragment. | ||
Line 216: | Line 209: | ||
namespaceFragment = 'talk' | namespaceFragment = 'talk' | ||
end | end | ||
-- Define the order that key fragments are tested in. This is done with an | -- Define the order that key fragments are tested in. This is done with an | ||
-- array of tables containing the value to be tested, along with its | -- array of tables containing the value to be tested, along with its | ||
Line 320: | Line 313: | ||
end | end | ||
return '' | return '' | ||
end | |||
function Protection:needsExpiry() | |||
local cfg = self._cfg | |||
local actionNeedsCheck = cfg.expiryCheckActions[self.action] | |||
return not self.expiry and ( | |||
actionNeedsCheck or ( | |||
actionNeedsCheck == nil | |||
and self.reason -- the old {{pp-protected}} didn't check for expiry | |||
and not cfg.reasonsWithoutExpiryCheck[self.reason] | |||
) | |||
) | |||
end | end | ||
function Protection:isIncorrect() | function Protection:isIncorrect() | ||
local expiry = self.expiry | local expiry = self.expiry | ||
return not self: | return not self:isProtected() | ||
or type(expiry) == 'number' and expiry < os.time() | or type(expiry) == 'number' and expiry < os.time() | ||
end | end | ||
Line 339: | Line 344: | ||
function Protection:makeCategoryLinks() | function Protection:makeCategoryLinks() | ||
local msg = self._cfg.msg | local msg = self._cfg.msg | ||
local ret = {self:makeProtectionCategory()} | local ret = { self:makeProtectionCategory() } | ||
if self:needsExpiry() then | |||
ret[#ret + 1] = makeCategoryLink( | |||
msg['tracking-category-expiry'], | |||
self.title.text | |||
) | |||
end | |||
if self:isIncorrect() then | if self:isIncorrect() then | ||
ret[#ret + 1] = makeCategoryLink( | ret[#ret + 1] = makeCategoryLink( | ||
Line 652: | Line 663: | ||
function Blurb:_makeVandalTemplateParameter() | function Blurb:_makeVandalTemplateParameter() | ||
return | return require('Module:Vandal-m')._main{ | ||
self._args.user or self._protectionObj.title.baseText | |||
} | } | ||
end | end | ||
Line 854: | Line 864: | ||
-- Render the banner | -- Render the banner | ||
if protectionObj: | if protectionObj:isProtected() then | ||
ret[#ret + 1] = tostring( | ret[#ret + 1] = tostring( | ||
(yesno(args.small) and Padlock or Banner) | (yesno(args.small) and Padlock or Banner) |