voicemail.lua 1.4 KB

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