Fandom

VSTF Wiki

Module:Report

48pages on
this wiki
Add New Page
Talk0
-- <nowiki>
-- @authors Noreplyz
 
--------------------------------------------------------------------------
--[[ 
                                Module:Report
 
     Module for report templates. Proofreads user input.
 
     This module is invoked using Template:Report spam, 
     Template:Report vandalism, Template:Report profile and
     Template:Report filter.
 
--]]
--------------------------------------------------------------------------
 
local p = {}
 
-- remove excess or wrongly entered content
function trim_wiki(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("%.wikia%.com.*", "")
    return s
end
 
function trim_page(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("^.*%.wikia%.com%/wiki%/","")
    s = s:gsub("^.*%.wikia%.com%/","")
    s = s:gsub(" ","_")
    return s
end
 
function trim_user(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("^.*%.wikia%.com%/wiki%/","")
    s = s:gsub("^.*%.wikia%.com%/","")
    s = s:gsub("User:","")
    s = s:gsub("Special:Contributions%/","")
    s = s:gsub("Special:Contribs%/","")
    s = s:gsub(" ","_")
    return s
end
 
function trim_reason(s)
    s = s:match( "^%s*(.-)%s*$" )
    return s
end
 
function trim_id(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("#","")
    return s
end
 
-- creates the general format of the report
-- reportType: string of the type of user (Spammer, Vandal, Profile, Phalanx)
function createReport(frame, reportType)
    local tArgs = frame:getParent()     -- all arguments
    local ret = {}                      -- the return string
 
    -- check how many total users
    local numArgs = 0
    for key, value in ipairs(tArgs.args) do numArgs = numArgs + 1 end
 
    -- report params
    local wiki = trim_wiki(tArgs.args[1] or "")
    local reason = trim_reason(tArgs.args[2] or "")
    local user = ""
    local reporter = tArgs.args[numArgs - 1] or ""
    local time = tArgs.args[numArgs] or ""
 
    -- report-specific params
    local skin = ""
    if reportType == "Profile" then
        skin = "?useskin=wikia"
    end
    local page = ""
    local blockId = ""
    if reportType == "Phalanx" then
        page = trim_page(tArgs.args[2] or "")
        blockId = trim_id(tArgs.args[3] or "")
        reason = tArgs.args[4] or ""
    end
 
    -- start report creation
    ret[#ret + 1] = '<div class="reports">\n'
    ret[#ret + 1] = '*Wiki: <span class="plainlinks">http://' .. wiki .. '.wikia.com</span>\n'
    if reportType == "Phalanx" then
        -- Filter problem only
        ret[#ret + 1] = '*Page: <span class="plainlinks">http://' .. wiki .. '.wikia.com/wiki/' .. page .. '</span>\n'
        ret[#ret + 1] = '*Block ID: <span class="plainlinks">http://community.wikia.com/wiki/Special:PhalanxStats/' .. blockId .. '</span>\n'
    else
        -- Spam, Vandalism or Profile report
        for key, value in ipairs(tArgs.args) do 
            if (key >= 3 and key <= (numArgs - 2)) then
                user = trim_user(value) or ""
                ret[#ret + 1] = '*' .. reportType .. ': <span class="plainlinks">http://' .. wiki .. '.wikia.com/wiki/Special:Contributions/' .. user .. skin .. '</span>\n'
            end
        end
    end
    ret[#ret + 1] = '*Reason: '.. reason ..'\n'
    ret[#ret + 1] = '*Signature: -- [[User:'.. reporter ..'|' .. reporter .. ']] ([[User talk:'.. reporter .. '|talk]]) ' .. time .. '\n'
    ret[#ret + 1] = '</div>'
 
    return table.concat(ret)
end
 
function p.spam(frame)
    return createReport(frame, "Spammer")
end
 
function p.vandalism(frame)
    return createReport(frame, "Vandal")
end
 
function p.profile(frame)
    return createReport(frame, "Profile")
end
 
function p.filter_problem(frame)
    return createReport(frame, "Phalanx")
end
 
return p
-- </nowiki>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.