luci-app-samba: use flag for "Share home-directories" option
[project/luci.git] / applications / luci-app-samba / luasrc / model / cbi / samba.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 m = Map("samba", translate("Network Shares"))
6
7 s = m:section(TypedSection, "samba", "Samba")
8 s.anonymous = true
9
10 s:tab("general",  translate("General Settings"))
11 s:tab("template", translate("Edit Template"))
12
13 s:taboption("general", Value, "name", translate("Hostname"))
14 s:taboption("general", Value, "description", translate("Description"))
15 s:taboption("general", Value, "workgroup", translate("Workgroup"))
16 h = s:taboption("general", Flag, "homes", translate("Share home-directories"),
17         translate("Allow system users to reach their home directories via " ..
18                 "network shares"))
19 h.rmempty = false
20
21 tmpl = s:taboption("template", Value, "_tmpl",
22         translate("Edit the template that is used for generating the samba configuration."), 
23         translate("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. " ..
24                 "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab."))
25
26 tmpl.template = "cbi/tvalue"
27 tmpl.rows = 20
28
29 function tmpl.cfgvalue(self, section)
30         return nixio.fs.readfile("/etc/samba/smb.conf.template")
31 end
32
33 function tmpl.write(self, section, value)
34         value = value:gsub("\r\n?", "\n")
35         nixio.fs.writefile("//etc/samba/smb.conf.template", value)
36 end
37
38
39 s = m:section(TypedSection, "sambashare", translate("Shared Directories"))
40 s.anonymous = true
41 s.addremove = true
42 s.template = "cbi/tblsection"
43
44 s:option(Value, "name", translate("Name"))
45 pth = s:option(Value, "path", translate("Path"))
46 if nixio.fs.access("/etc/config/fstab") then
47         pth.titleref = luci.dispatcher.build_url("admin", "system", "fstab")
48 end
49
50 s:option(Value, "users", translate("Allowed users")).rmempty = true
51
52 ro = s:option(Flag, "read_only", translate("Read-only"))
53 ro.rmempty = false
54 ro.enabled = "yes"
55 ro.disabled = "no"
56
57 go = s:option(Flag, "guest_ok", translate("Allow guests"))
58 go.rmempty = false
59 go.enabled = "yes"
60 go.disabled = "no"
61
62 cm = s:option(Value, "create_mask", translate("Create mask"),
63         translate("Mask for new files"))
64 cm.rmempty = true
65 cm.size = 4
66
67 dm = s:option(Value, "dir_mask", translate("Directory mask"),
68         translate("Mask for new directories"))
69 dm.rmempty = true
70 dm.size = 4
71
72
73 return m