OpenWrt_Luci_Lua/Mi_Lua/xiaoqiang/XQPreference.lua

33 lines
734 B
Lua
Raw Normal View History

2015-05-09 10:48:46 +00:00
--[[
Xiaoqiang Preference - Configuration
author : Afei
]]--
local util = require "luci.util"
module("xiaoqiang.XQPreference",package.seeall)
function get(key, defaultValue, config)
require "luci.model.uci"
if not config then
config = "xiaoqiang"
end
local cursor = luci.model.uci.cursor();
local value = cursor:get(config, "common", key)
return value or defaultValue;
end
function set(key, value, config)
require "luci.model.uci"
if not config then
config = "xiaoqiang"
end
local cursor = luci.model.uci.cursor();
if value == nil then
value = ""
end
cursor:set(config, "common", key, value)
cursor:save(config)
return cursor:commit(config)
end