applications/luci-asterisk: add meetme support, data integrity improvements
[project/luci.git] / applications / luci-asterisk / luasrc / model / cbi / asterisk / meetme.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local ast = require "luci.asterisk"
16
17 cbimap = Map("asterisk", "MeetMe - Rooms")
18
19 meetme = cbimap:section(TypedSection, "meetme", "MeetMe Rooms")
20 meetme.addremove = true
21 meetme.anonymous = true
22 meetme.template = "cbi/tblsection"
23 meetme:option(Value, "_description", "Description", "Short room description")
24
25 room = meetme:option(Value, "room", "Room Number", "Unique room identifier")
26
27 function room.write(self, s, val)
28         if val and #val > 0 then
29                 local old = self:cfgvalue(s)
30                 self.map.uci:foreach("asterisk", "dialplanmeetme",
31                         function(v)
32                                 if v.room == old then
33                                         self.map:set(v['.name'], "room", val)
34                                 end
35                         end)
36                 Value.write(self, s, val)
37         end
38 end
39
40
41 meetme:option(Value, "pin", "PIN", "PIN required to access")
42 meetme:option(Value, "adminpin", "Admin PIN", "PIN required for administration")
43
44 function meetme.remove(self, s)
45         return ast.meetme.remove(self.map:get(s, "room"), self.map.uci)
46 end
47
48
49 return cbimap