Globally reduce copyright headers
[project/luci.git] / modules / luci-mod-freifunk / luasrc / model / cbi / freifunk / profile.lua
1 -- Copyright 2011-2012 Manuel Munz <freifunk at somakoma dot de>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local uci = require "luci.model.uci".cursor()
5 local ipkg = require "luci.model.ipkg"
6 local community = uci:get("freifunk", "community", "name")
7
8 if community == nil then
9         luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error"))
10         return
11 else
12         community = "profile_" .. community
13         m = Map(community, translate("Community settings"), translate("These are the settings of your local community."))
14         c = m:section(NamedSection, "profile", "community")
15
16         local name = c:option(Value, "name", "Name")
17         name.rmempty = false
18
19         local homepage = c:option(Value, "homepage", translate("Homepage"))
20
21         local cc = c:option(Value, "country", translate("Country code"))
22         function cc.cfgvalue(self, section)
23                 return uci:get(community, "wifi_device", "country")
24         end
25         function cc.write(self, sec, value)
26                 if value then
27                         uci:set(community, "wifi_device", "country", value)
28                         uci:save(community)
29                 end
30         end
31
32         local ssid = c:option(Value, "ssid", translate("ESSID"))
33         ssid.rmempty = false
34
35         local prefix = c:option(Value, "mesh_network", translate("Mesh prefix"))
36         prefix.datatype = "ip4addr"
37         prefix.rmempty = false
38
39         local splash_net = c:option(Value, "splash_network", translate("Network for client DHCP addresses"))
40         splash_net.datatype = "ip4addr"
41         splash_net.rmempty = false
42
43         local splash_prefix = c:option(Value, "splash_prefix", translate("Client network size"))
44         splash_prefix.datatype = "range(0,32)"
45         splash_prefix.rmempty = false
46
47         local ipv6 = c:option(Flag, "ipv6", translate("Enable IPv6"))
48         ipv6.rmempty = true
49
50         local ipv6_config = c:option(ListValue, "ipv6_config", translate("IPv6 Config"))
51         ipv6_config:depends("ipv6", 1)
52         ipv6_config:value("static")
53         if ipkg.installed ("auto-ipv6-ib") then
54                 ipv6_config:value("auto-ipv6-random")
55                 ipv6_config:value("auto-ipv6-fromv4")
56         end
57         ipv6_config.rmempty = true
58
59         local ipv6_prefix = c:option(Value, "ipv6_prefix", translate("IPv6 Prefix"), translate("IPv6 network in CIDR notation."))
60         ipv6_prefix:depends("ipv6", 1)
61         ipv6_prefix.datatype = "ip6addr"
62         ipv6_prefix.rmempty = true
63
64         local vap = c:option(Flag, "vap", translate("VAP"), translate("Enable a virtual access point (VAP) by default if possible."))
65         vap.rmempty = true
66
67         local lat = c:option(Value, "latitude", translate("Latitude"))
68         lat.datatype = "range(-180, 180)"
69         lat.rmempty = false
70
71         local lon = c:option(Value, "longitude", translate("Longitude"))
72         lon.rmempty = false
73         return m
74 end