모듈:Effective protection level 편집하기

귀하는 로그인되어 있지 않습니다. 이대로 편집하면 귀하의 IP 주소가 편집 기록에 남게 됩니다.

편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.

최신판 당신의 편집
3번째 줄: 3번째 줄:
-- Returns the permission required to perform a given action on a given title.
-- 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.
-- If no title is specified, the title of the page being displayed is used.
function p._main(action, pagename)
function p.main(action, pagename)
local frame = mw.getCurrentFrame()
local title
local title
if type(pagename) == 'table' and pagename.prefixedText then
if type(pagename) == 'table' then
title = pagename
title = pagename
elseif pagename then
pagename = title.prefixedText
title = mw.title.new(pagename)
else
else
title = mw.title.getCurrentTitle()
title = mw.title.new(pagename) or mw.title.getCurrentTitle()
end
end
pagename = title.prefixedText
if action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then
if action == 'autoreview' then
error( 'First parameter must be one of edit, move, create, upload', 2 )
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
level = level and level.autoreview
if level == 'review' then
return 'reviewer'
elseif level ~= '' then
return level
else
return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review
end
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )
end
end
if title.namespace == 8 then -- MediaWiki namespace
if title.namespace == 8 then -- MediaWiki namespace
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
return 'sysop'
return 'interfaceadmin'
elseif title.namespace == 2 and ( mw.ustring.find( pagename, '/.*%.js$') or mw.ustring.find( pagename, '/.*%.css$') ) then -- user .js or .css page
else -- any non-JS/CSS MediaWiki page
return 'sysop'
else
local level = frame:callParserFunction('PROTECTIONLEVEL', action, pagename)
if level == 'sysop' then
return 'sysop'
return 'sysop'
end
elseif frame:callParserFunction('CASCADINGSOURCES', pagename) ~= '' then -- used by a cascading-protected page
elseif title.namespace == 2 and title.isSubpage then
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page
return 'interfaceadmin'
elseif title.contentModel == 'json' then -- user JSON page
return 'sysop'
return 'sysop'
end
elseif title.namespace == 6 and action == 'move' then -- Special permission is required to move files. Note this breaks the hierarchy, because both templateeditor and filemover are required to move template-protected files. This isn't a real concern currently, since template protection shouldn't be applied to files.
end
if action == 'undelete' then
return 'sysop'
end
local level = title.protectionLevels[action] and title.protectionLevels[action][1]
if level == 'sysop' or level == 'editprotected' then
return 'sysop'
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page
return 'sysop'
elseif level == 'templateeditor' then
return 'templateeditor'
elseif action == 'move' then
local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.
if blacklistentry and not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif title.namespace == 6 then
return 'filemover'
return 'filemover'
elseif level == 'extendedconfirmed' then
elseif level ~= '' then
return 'extendedconfirmed'
return level
else
-- If we get this far, the page is unprotected. Figure out what group is needed to perform the action they're trying to do normally, and return that.
elseif action == 'upload' or action == 'move' then
return 'autoconfirmed'
return 'autoconfirmed'
end
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
end
return 'user'
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)
if blacklistentry then
if not blacklistentry.params.autoconfirmed then
return 'templateeditor'
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
else
else
return 'autoconfirmed'
return '*'
end
end
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason
return 'autoconfirmed'
elseif level then
return level
elseif action == 'upload' then
return 'autoconfirmed'
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
return 'user'
else
return '*'
end
end
end
end


setmetatable(p, { __index = function(t, k)
-- Make this usable from wikitext rather than just other lua modules
return function(frame)
function p.p(frame)
return t._main(k, frame.args[1])
local parent = frame:getParent()
end
return p.main(parent.args.action or parent.args[1], parent.args.title or parent.args[2])
end })
end


return p
return p
가온 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는 가온 위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다. 저작권이 있는 내용을 허가 없이 저장하지 마세요!
취소 편집 도움말 (새 창에서 열림)

이 문서에서 사용한 틀: