diff options
Diffstat (limited to 'vmail-model.lua')
-rw-r--r-- | vmail-model.lua | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/vmail-model.lua b/vmail-model.lua index f3f7cac..51261cf 100644 --- a/vmail-model.lua +++ b/vmail-model.lua @@ -751,45 +751,6 @@ mymodule.list_users = function() return cfe({ type="structure", value=users, label="Voicemail Users", errtxt=errtxt }) end -mymodule.get_search_options = function(self, clientdata) - retval = cfe({type="group", value={}, label="User Search"}) - retval.value.username = cfe({label="Extension", seq=1}) - retval.value.firstname = cfe({label="First Name", seq=2}) - retval.value.lastname = cfe({label="Last Name", seq=3}) - return retval -end - -mymodule.search_users = function(self, search) - -- No validation - local res, err = pcall(function() - local connected = vmaildb.databaseconnect() - local where = {} - if search.value.username.value ~= "" then - where[#where+1] = "u.username ~ '"..vmaildb.escape(search.value.username.value).."'" - end - if search.value.firstname.value ~= "" then - where[#where+1] = "v2.value ~ '"..vmaildb.escape(search.value.firstname.value).."'" - end - if search.value.lastname.value ~= "" then - where[#where+1] = "v1.value ~ '"..vmaildb.escape(search.value.lastname.value).."'" - end - -- This crazy query gets the username from voicemail_users, the firstname and lastname from two instances of voicemail_values (using voicemail_params to determine the corresponding nid values) drops usernames starting with "tempuser" and ordering by username - local sql = "SELECT u.username, v1.value lastname, v2.value firstname FROM voicemail_users u LEFT OUTER JOIN voicemail_values v1 ON u.uid = v1.uid AND v1.nid=(SELECT nid FROM voicemail_params WHERE name='lastname') LEFT OUTER JOIN voicemail_values v2 ON u.uid = v2.uid AND v2.nid=(SELECT nid FROM voicemail_params WHERE name='firstname')" - if #where then - sql = sql.." WHERE "..table.concat(where, " AND ") - end - sql = sql.." ORDER BY u.username" - local users = vmaildb.getselectresponse(sql) - search.value.result = cfe({ type="structure", value=users, label="Voicemail Users" }) - if connected then databasedisconnect() end - end) - if not res and err then - search.errtxt = err - end - - return search -end - mymodule.get_delete_user = function(self, clientdata) local result = {} result.username = cfe({ value=clientdata.username or "", label="User Name" }) |