[WEB] Show plugin permissions
#4
Looking at the code you aren't actually using g_PluginInfo. You're looping through all the known commands and getting the info from there. As of yet every plugin I've seen uses "<PluginName>.<Permission>" in their permissions. You could thus get the name by using something like this:
local PluginName = a_CBPermission:match("^.-%.")
This would of course mean that you'd mostly have lowercase plugin names like "worldedit" instead of "WorldEdit" (unless a plugin has permissions that look weird)

If you would actually use the Info.lua file you would use something like this:
cPluginManager:ForEachPlugin(
	function(a_Plugin)
		if (not cFile:Exists(a_Plugin:GetLocalFolder() .. "/Info.lua")) then
			-- The plugin doesn\'t have a Info.lua file
			return false
		end
		
		local PluginInfoLoader = loadfile(a_Plugin:GetLocalFolder() .. "/Info.lua")
		local LoaderEnv = {}
		
		-- This way the function can\'t overwrite any of the functions in this environment.
		-- And we can extract the g_PluginInfo variable
		setfenv(PluginInfoLoader, LoaderEnv)
		
		local PluginInfo = LoaderEnv["g_PluginInfo"]
		local PluginName = PluginInfo.Name -- You can also use a_Plugin:GetName() of course.
		
		-- For each command like usually.
		for CommandString, CommandInfo in pairs(PluginInfo.Commands) do
			ins(Row, "<tr></td><td valign=\'top\'>" .. CommandString .. "<br/></td><td valign=\'top\'>" .. (CommandInfo.Permission or "") .. "<br/></td><td valign=\'top\'>" .. (CommandInfo.HelpString or "") .. "<br/></td><td valign=\'top\'></tr>")
		end
	end
)
Keep in mind that I haven't tested this Wink It could fail miserably.

I believe the prettifier escaped some single quotes. You probably need to fix that before testing Wink
Reply
Thanks given by:


Messages In This Thread
[WEB] Show plugin permissions - by JonnyBoy0719 - 10-08-2015, 04:46 AM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 05:03 AM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 06:17 AM
RE: [WEB] Show plugin permissions - by xoft - 10-08-2015, 07:07 AM
RE: [WEB] Show plugin permissions - by xoft - 10-08-2015, 07:09 AM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 04:36 PM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 08:58 PM
RE: [WEB] Show plugin permissions - by xoft - 10-08-2015, 09:13 PM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 09:15 PM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-08-2015, 10:27 PM
RE: [WEB] Show plugin permissions - by xoft - 10-08-2015, 11:08 PM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-09-2015, 12:22 AM
RE: [WEB] Show plugin permissions - by NiLSPACE - 10-13-2015, 05:28 PM
RE: [WEB] Show plugin permissions - by chrobione - 12-11-2015, 10:56 AM
RE: [WEB] Show plugin permissions - by chrobione - 12-11-2015, 06:11 PM



Users browsing this thread: 2 Guest(s)