Globally reduce copyright headers
[project/luci.git] / applications / luci-app-asterisk / luasrc / model / cbi / asterisk / voicemail.lua
1 -- Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local ast = require "luci.asterisk"
5
6 cbimap = Map("asterisk", "Voicemail - Mailboxes")
7
8 voicemail = cbimap:section(TypedSection, "voicemail", "Voicemail Boxes")
9 voicemail.addremove = true
10 voicemail.anonymous = true
11 voicemail.template = "cbi/tblsection"
12
13 context = voicemail:option(ListValue, "context", "Context")
14 context:value("default")
15
16 number = voicemail:option(Value, "number",
17         "Mailbox Number", "Unique mailbox identifier")
18
19 function number.write(self, s, val)
20         if val and #val > 0 then
21                 local old = self:cfgvalue(s)
22                 self.map.uci:foreach("asterisk", "dialplanvoice",
23                         function(v)
24                                 if v.voicebox == old then
25                                         self.map:set(v['.name'], "voicebox", val)
26                                 end
27                         end)
28                 Value.write(self, s, val)
29         end
30 end
31
32
33 voicemail:option(Value, "name", "Ownername", "Human readable display name")
34 voicemail:option(Value, "password", "Password", "Access protection")
35 voicemail:option(Value, "email", "eMail", "Where to send voice messages")
36 voicemail:option(Value, "page", "Pager", "Pager number")
37
38 zone = voicemail:option(ListValue, "zone", "Timezone", "Used time format")
39 zone.titleref = luci.dispatcher.build_url("admin/asterisk/voicemail/settings")
40 cbimap.uci:foreach("asterisk", "voicezone",
41         function(s) zone:value(s['.name']) end)
42
43 function voicemail.remove(self, s)
44         return ast.voicemail.remove(self.map:get(s, "number"), self.map.uci)
45 end
46
47
48 return cbimap