Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(make Blurb be responsible for setting its own fields) |
(put Protection in charge of generating its own category links) |
||
Line 301: | Line 301: | ||
end |
end |
||
function Protection: |
function Protection:needsExpiry() |
||
local cfg = self._cfg |
local cfg = self._cfg |
||
return not self.expiry |
|||
and cfg.expiryCheckActions[self.action] |
and cfg.expiryCheckActions[self.action] |
||
and self.reason -- the old {{pp-protected}} didn't check for expiry |
and self.reason -- the old {{pp-protected}} didn't check for expiry |
||
and not cfg.reasonsWithoutExpiryCheck[self.reason] |
and not cfg.reasonsWithoutExpiryCheck[self.reason] |
||
then |
|||
⚫ | |||
⚫ | |||
end |
end |
||
function Protection: |
function Protection:isIncorrect() |
||
local expiry = self.expiry |
local expiry = self.expiry |
||
return not self:isProtected() |
|||
or type(expiry) == 'number' and expiry < os.time() |
or type(expiry) == 'number' and expiry < os.time() |
||
then |
|||
⚫ | |||
⚫ | |||
end |
end |
||
function Protection: |
function Protection:isTemplateProtectedNonTemplate() |
||
local action, namespace = self.action, self.title.namespace |
local action, namespace = self.action, self.title.namespace |
||
return self.level == 'templateeditor' |
|||
and ( |
and ( |
||
(action ~= 'edit' and action ~= 'move') |
(action ~= 'edit' and action ~= 'move') |
||
or (namespace ~= 10 and namespace ~= 828) |
or (namespace ~= 10 and namespace ~= 828) |
||
) |
) |
||
end |
|||
then |
|||
⚫ | |||
function Protection:makeCategoryLinks() |
|||
local msg = self._cfg.msg |
|||
local ret = { self:makeProtectionCategory() } |
|||
if self:needsExpiry() then |
|||
⚫ | |||
⚫ | |||
if self:isIncorrect() then |
|||
⚫ | |||
⚫ | |||
if self:isTemplateProtectedNonTemplate() then |
|||
⚫ | |||
end |
end |
||
return table.concat(ret) |
|||
end |
end |
||
Line 916: | Line 922: | ||
-- Render the categories |
-- Render the categories |
||
if yesno(args.category) ~= false then |
if yesno(args.category) ~= false then |
||
ret[#ret + 1] = protectionObj: |
ret[#ret + 1] = protectionObj:makeCategoryLinks() |
||
ret[#ret + 1] = protectionObj:makeExpiryCategory() |
|||
ret[#ret + 1] = protectionObj:makeErrorCategory() |
|||
ret[#ret + 1] = protectionObj:makeTemplateCategory() |
|||
end |
end |
||