Merge pull request #28 from opi/master

[fix] Do not limit amount of mail aliases & forward.
This commit is contained in:
Alexis Gavoty 2014-12-08 20:44:50 +01:00
commit 83718fd05e

View file

@ -299,15 +299,24 @@ end
function get_mails(user) function get_mails(user)
local mails = { mail = "", mailalias = {}, maildrop = {} } local mails = { mail = "", mailalias = {}, maildrop = {} }
-- default mail
mails["mail"] = cache:get(user.."-mail")
-- mail aliases
if cache:get(user.."-mail|2") then if cache:get(user.."-mail|2") then
for _, v in ipairs({2, 3, 4, 5, 6, 7, 8, 9, 10}) do local i = 2
table.insert(mails["mailalias"], cache:get(user.."-mail|"..v)) while cache:get(user.."-mail|"..i) do
table.insert(mails["mailalias"], cache:get(user.."-mail|"..i))
i = i + 1
end end
end end
mails["mail"] = cache:get(user.."-mail")
-- mail forward
if cache:get(user.."-maildrop|2") then if cache:get(user.."-maildrop|2") then
for _, v in ipairs({2, 3, 4, 5, 6, 7, 8, 9, 10}) do local i = 2
table.insert(mails["maildrop"], cache:get(user.."-maildrop|"..v)) while cache:get(user.."-maildrop|"..i) do
table.insert(mails["maildrop"], cache:get(user.."-maildrop|"..i))
i = i + 1
end end
end end
return mails return mails
@ -589,9 +598,15 @@ function do_edit ()
maildrop = drops }) maildrop = drops })
then then
cache:delete(user.."-"..conf["ldap_identifier"]) cache:delete(user.."-"..conf["ldap_identifier"])
for _, v in ipairs({2, 3, 4, 5, 6, 7, 8, 9, 10}) do local i = 2
cache:delete(user.."-maildrop|"..v) while cache:get(user.."-mail|"..i) do
cache:delete(user.."-mail|"..v) cache:delete(user.."-mail|"..i)
i = i + 1
end
local i = 2
while cache:get(user.."-maildrop|"..i) do
cache:delete(user.."-maildrop|"..i)
i = i + 1
end end
set_headers(user) -- Ugly trick to reload cache set_headers(user) -- Ugly trick to reload cache
flash("win", t("information_updated")) flash("win", t("information_updated"))