Refactored policy structure

Previously, all modules in an org were fully copied into that
org. Now, the only copy of the modules is at modpol.modules, and orgs
have a policy table at [org].policies, which overrides the config
table in any given module.
This commit is contained in:
Nathan Schneider
2022-02-09 22:14:26 -07:00
parent f950b5b94c
commit 2028f1ee85
7 changed files with 76 additions and 52 deletions

View File

@ -145,9 +145,10 @@ function modpol.interactions.org_dashboard(user, org_string)
-- prepare modules menu
local modules = {}
if org.modules then
for k,v in pairs(org.modules) do
if not v.hide then -- hide utility modules
if modpol.modules then
for k,v in pairs(modpol.modules) do
if not v.hide and -- hide utility modules
org.policies[k] then -- org includes it
local module_entry = v.name
table.insert(modules, module_entry)
end
@ -228,8 +229,9 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
elseif fields.modules
and fields.modules ~= "View..." then
local module = nil
for k,v in pairs(org.modules) do
if fields.modules == v.name then
for k,v in pairs(modpol.modules) do
if fields.modules == v.name
and org.policies[v.slug] then
module = v
end end
if module then
@ -411,10 +413,10 @@ function modpol.interactions.text_query(user, query, func)
-- set up formspec
local formspec = {
"formspec_version[4]",
"size[10,4]",
"size[10,6]",
"label[0.5,1;", minetest.formspec_escape(query), "]",
"field[0.5,1.25;9,0.8;input;;]",
"button[0.5,2.5;1,0.8;yes;OK]",
"field[0.5,3.25;9,0.8;input;;]",
"button[0.5,4.5;1,0.8;yes;OK]",
}
local formspec_string = table.concat(formspec, "")
-- present to player