模块:Effective protection level:修订间差异

imported>Xiplus
+JSON頁保護
imported>S8321414
Per request
 
(未显示3个用户的5个中间版本)
第13行: 第13行:
end
end
pagename = title.prefixedText
pagename = title.prefixedText
if action == 'autoreview' then
if action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
error( 'First parameter must be one of edit, move, create, upload, undelete', 2 )
level = level and level.autoreview
end
if level == 'review' then
if title.namespace == 8 then -- MediaWiki namespace
return 'reviewer'
if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.text == 'Gadgets-definition' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
elseif level ~= '' then
return 'interfaceadmin'
return level
else -- any non-JS/CSS MediaWiki page
else
return 'sysop'
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 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'
end
end
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )
end
end
if title.namespace == 8 then -- MediaWiki namespace
if action == 'undelete' then
return 'sysop'
elseif title.namespace == 2 and title.isSubpage and ( title.contentModel == 'javascript' or title.contentModel == 'css' or title.contentModel == 'json' ) then -- user JS, CSS or JSON page
return 'sysop'
return 'sysop'
end
end
第41行: 第42行:
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.
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
if blacklistentry and not blacklistentry.params.autoconfirmed then
return 'templateeditor'
return 'sysop'
elseif title.namespace == 6 then
elseif title.namespace == 6 then
return 'filemover'
return 'filemover'
第53行: 第54行:
if blacklistentry then
if blacklistentry then
if not blacklistentry.params.autoconfirmed then
if not blacklistentry.params.autoconfirmed then
return 'templateeditor'
return 'sysop'
elseif level == 'extendedconfirmed' then
elseif level == 'extendedconfirmed' then
return 'extendedconfirmed'
return 'extendedconfirmed'
第65行: 第66行:
elseif action == 'upload' then
elseif action == 'upload' then
return 'autoconfirmed'
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
else
return '*'
return '*'