Content deleted Content added
Undid revision 941148733 by MSGJ (talk) per followup discussion at Template talk:Requested move#Hide advice when it was followed |
SilverLocust (talk | contribs) Automatically detect the highest protection level (if sysop or templateeditor level) that would prevent a "moved" outcome. Then {{RM/dated}} checks the title is still protected, and shows a green/pink padlock if so. |
||
Line 95:
end
return 'yes'
end
--------------------------------------------------------------------------------
-- Confirm protection levels (used at [[Template:Requested move/dated]])
--------------------------------------------------------------------------------
function p.protected(frame)
local args = getArgs(frame, {parentOnly = true})
if args.protected then
local levels = mw.title.new(args.protected).protectionLevels
local levelMove = levels['move'] and levels['move'][1]
local levelEdit = levels['edit'] and levels['edit'][1]
local levelCreate = levels['create'] and levels['create'][1]
if levelMove == 'sysop'
or levelEdit == 'sysop'
or levelEdit == 'editprotected'
or levelCreate == 'sysop' then
return 'sysop'
elseif levelMove == 'templateeditor'
or levelEdit == 'templateeditor'
or levelCreate == 'templateeditor' then
return 'templateeditor'
end
end
end
Line 193 ⟶ 217:
if not new or new == 'NewName' then
argsByNum[1].new = defaultNewPagename
end
end
----------------------------------------------------------------------------
-- Check for page protection
----------------------------------------------------------------------------
local highestProtection = ''
local protectedTitle = ''
-- Checking page protection requires use of .protectionLevels(), one of the
-- "expensive" parser functions, which stop working after 500 uses total.
-- Without some limit set, this starts breaking near 250 distinct titles.
local titleLimit = 80
local titlesChecked = 0
local titles = {}
-- Consolidate duplicate titles (i.e., when moving A to B and B to C)
for i = 1,argsByNumCount do
titles[mw.title.new(argsByNum[i]['current'])] = true
titles[mw.title.new(argsByNum[i]['new'])] = true
end
-- Check each title t, while ignoring the "true" value
for t, _ in pairs(titles) do
if titlesChecked < titleLimit then
local levels = t.protectionLevels
titlesChecked = titlesChecked + 1
local levelMove = levels['move'] and levels['move'][1]
local levelEdit = levels['edit'] and levels['edit'][1]
local levelCreate = levels['create'] and levels['create'][1]
if levelMove == 'sysop'
or levelEdit == 'sysop'
or levelEdit == 'editprotected'
or levelCreate == 'sysop' then
highestProtection = 'sysop'
protectedTitle = tostring(t)
break
elseif levelMove == 'templateeditor'
or levelEdit == 'templateeditor'
or levelCreate == 'templateeditor' then
highestProtection = 'templateeditor'
protectedTitle = tostring(t)
end
else
-- End the "for" loop if the titleLimit is reached
break
end
end
Line 377 ⟶ 446:
rmd[#rmd + 1] = '|' .. new1param .. argsByNum[1].new
-- Add
if multi then
for i = 2, argsByNumCount do
Line 387 ⟶ 456:
rmd[#rmd + 1] = '|new' .. numString .. '=' .. new
end
end
-- The old multi template always has a bar before the closing curly▼
-- braces, so we will do that too.▼
-- Highest page protection (if admin or template-editor)
if highestProtection == 'sysop' or highestProtection == 'templateeditor' then
rmd[#rmd + 1] = '|protected=' .. protectedTitle
end
-- Pass through demo=yes to the
if args.demo ~= nil then
rmd[#rmd + 1] = '|demo='
rmd[#rmd + 1] = args.demo
end
if multi then
rmd[#rmd + 1] = '|'
end
|