Ir para o conteúdo

Módulo:Nível efetivo de proteção

De Wiki TokuDrive
Revisão de 04h42min de 5 de julho de 2026 por Tavoraadmin (discussão | contribs) (Importando predefinição/módulo da Wikipédia em português para manter layout)
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)

local p = {}

-- Retorna a permissão necessária para executar uma determinada ação em um determinado título. -- Se nenhum título for especificado, o título da página mostrada será usado. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action == 'autoreview' then 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 -- Não '*'. Uma página que não está protegida por proteção em cascata é diferente de uma página protegida por proteção em cascata com qualquer pessoa capaz de revisar. Também não , pois isso significaria proteção para proteção em cascata, mas ninguém pode revisar. end elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then error( 'O primeiro parâmetro deve ser um dos seguintes: edit, move, create, upload, undelete, autoreview', 2 ) end if title.namespace == 8 then -- Espaço nomeado MediaWiki. if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- página de 'JavaScript' ('JS') ou de 'CSS'. return 'interfaceadmin' else -- qualquer página que não é de 'JavaScript' ('JS') ou de 'CSS' em MediaWiki. return 'sysop' end elseif title.namespace == 2 and title.isSubpage then if title.contentModel == 'javascript' or title.contentModel == 'css' then -- página de 'JavaScript' ('JS') ou de 'CSS' de usuário. return 'interfaceadmin' elseif title.contentModel == 'json' then -- página de JSON de usuário. return 'sysop' end 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 -- Usado por uma página protegida em cascata. return 'sysop' elseif level == 'templateeditor' then return 'templateeditor' elseif action == 'move' then local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testando se a ação "edit" está correta, já que esta é para a página de origem. O nome da página de destino é testado com a ação "move". if blacklistentry and not blacklistentry.params.autoconfirmed then return 'templateeditor' elseif title.namespace == 6 then return 'filemover' elseif level == 'extendedconfirmed' then return 'extendedconfirmed' else return 'autoconfirmed' end end 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 return 'autoconfirmed' end elseif level == 'editsemiprotected' then -- Criar páginas semiprotegidas retorna isso por algum motivo. 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 -- Você precisa ser registrado, mas não autoconfirmado, para criar páginas que não são de discussão que não sejam rascunhos/esboços. if title.namespace == 0 then return 'autoconfirmed' -- você precisa ser autoconfirmado para criar páginas no espaço principal end return 'user' else return '*' end end

setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end })

return p