Module:Effective protection level: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
make the metatable work with the change coming June 5th
(add a metamethod so the action can be passed as the first param to #invoke instead of 'main')
(make the metatable work with the change coming June 5th)
Line 3:
-- Returns the permission required to perform a given action on a given title.
-- If no title is specified, the title of the page being displayed is used.
function p.main_main(frame, action, pagename)
frame = frame or mw.getCurrentFrame()
action = action or frame.args.action or frame.args[1]
pagename = pagename or frame.args.pagename or frame.args[2]
local title
if type(pagename) == 'table' then
title = pagename
pagename = title.prefixedText
else
title = pagename and mw.title.new(pagename) or mw.title.getCurrentTitle()
end
pagename = title.prefixedText
if action == 'autoreview' then
local level = framemw.getCurrentFrame():callParserFunction('PENDINGCHANGELEVEL', pagename)
if level == 'review' then
return 'reviewer'
Line 34 ⟶ 31:
if level == 'sysop' then
return 'sysop'
elseif framemw.getCurrentFrame():callParserFunction('CASCADINGSOURCES', pagename) ~= '' then -- used by a cascading-protected page
return 'sysop'
elseif level == 'templateeditor' then
Line 65 ⟶ 62:
 
setmetatable(p, { __index = function(t, k)
return function(frame, ...frameOrPagename)
if type(frameOrPagename) == 'table' and frameOrPagename.args then
return t.main_main(frame, k, frame...args[1])
else
return t._main(k, frameOrPagename)
end
end
end })
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu