The function accepts two parameters. The first is a string containing the action to check, which must be one of "edit", "create", "move", "upload", or "autoreview". The second is optional, and can either be the name of the page to check, or a title returned from the mw.title functions. If the second parameter is omitted, the page being displayed is the one checked against. The return value is a string containing the name of the group required to perform the given action.
From wikitext
The parameters are the same as when it is called directly.
localp={}-- 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.functionp._main(action,pagename)localtitleiftype(pagename)=='table'andpagename.prefixedTextthentitle=pagenameelseifpagenamethentitle=mw.title.new(pagename)elsetitle=mw.title.getCurrentTitle()endpagename=title.prefixedTextifaction~='edit'andaction~='move'andaction~='create'andaction~='upload'thenerror('First parameter must be one of edit, move, create, upload',2)endiftitle.namespace==8then-- MediaWiki namespaceiftitle.contentModel=='javascript'ortitle.contentModel=='css'then-- site JS or CSS pagereturn'interfaceadmin'else-- any non-JS/CSS MediaWiki pagereturn'sysop'endelseiftitle.namespace==2andtitle.isSubpagetheniftitle.contentModel=='javascript'ortitle.contentModel=='css'then-- user JS or CSS pagereturn'interfaceadmin'elseiftitle.contentModel=='json'then-- user JSON pagereturn'sysop'endendlocallevel=title.protectionLevels[action]andtitle.protectionLevels[action][1]iflevel=='sysop'orlevel=='editprotected'thenreturn'sysop'elseiftitle.cascadingProtection.restrictions[action]andtitle.cascadingProtection.restrictions[action][1]then-- used by a cascading-protected pagereturn'sysop'elseifaction=='move'thenlocalblacklistentry=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.ifblacklistentryandnotblacklistentry.params.autoconfirmedthenreturn'autocomfirmed'endendlocalblacklistentry=mw.ext.TitleBlacklist.test(action,pagename)ifblacklistentrythenreturn'autoconfirmed'elseiflevel=='editsemiprotected'then-- create-semiprotected pages return this for some reasonreturn'autoconfirmed'elseiflevelthenreturnlevelelseifaction=='upload'thenreturn'uploader'elsereturn'*'endendsetmetatable(p,{__index=function(t,k)returnfunction(frame)returnt._main(k,frame.args[1])endend})returnp