Add trash (#100)

* Add trash

* Add break at end of deleting loop

* Show trash tab only when trashing enabled

* Update translations
This commit is contained in:
Athozus 2023-06-15 19:28:04 +02:00 committed by GitHub
parent de07f6b24b
commit 2e106e3df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 454 additions and 201 deletions

View File

@ -16,6 +16,7 @@ mail = {
inbox = {},
outbox = {},
drafts = {},
trash = {},
contacts = {},
maillists = {},
to = {},
@ -32,7 +33,8 @@ mail = {
hud_notifications = {},
sound_notifications = {},
unreadcolorenable = {},
cccolorenable = {}
cccolorenable = {},
trash_move_enable = {}
},
message_drafts = {}
@ -58,6 +60,7 @@ dofile(MP .. "/ui/mail.lua")
dofile(MP .. "/ui/inbox.lua")
dofile(MP .. "/ui/outbox.lua")
dofile(MP .. "/ui/drafts.lua")
dofile(MP .. "/ui/trash.lua")
dofile(MP .. "/ui/message.lua")
dofile(MP .. "/ui/events.lua")
dofile(MP .. "/ui/contacts.lua")

View File

@ -13,37 +13,19 @@ BCC=BCC
Cancel=Abbrechen
Save draft=Entwurf Speichern
Send=Senden
CC=CC
New=Neu
Delete=Löschen
Edit=Bearbeiten
Name=Name
No drafts=Keine Entwürfe
To=An
Subject=Betreff
Player name=Spielername
That name is already in your contacts=
The contact name cannot be empty.=
Note=Notiz
Back=Zurück
Save=Speichern
Maillist name=Verteilerlistenname
Desc=Beschreibung
Players=Spieler
That name is already in your mailing lists.=
The mailing list name cannot be empty.=
Back=Zurück
Mark Read=Als gelesen makieren
Mark Unread=Als ungelesen makieren
(No description)=(Keine Beschreibung)
No maillist=Keine Verteilerliste
From=Von
You have mail! Type /mail to read=
Read=Lesen
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=Keine Nachrichten
Trash=
Inbox=Posteingang
Outbox=Senden
Drafts=Entwürfe
@ -52,11 +34,29 @@ Mail lists=Verteilerlisten
Options=
Close=Schließen
(No subject)=(Kein Betreff)
From=Von
Reply=Antworten
Reply all=Allen antworten
Forward=Weiter
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=Keine Nachrichten
Read=Lesen
(No description)=(Keine Beschreibung)
No maillist=Keine Verteilerliste
Note=Notiz
Edit=Bearbeiten
New=Neu
Delete=Löschen
You have mail! Type /mail to read=
Subject=Betreff
To=An
Add=Hinzufügen
Remove=Entfernen
Name=Name
CC=CC
Notifications=
Chat notifications=
On join notifications=
@ -66,10 +66,15 @@ Message list=
Show unread in different color=
Show CC/BCC in different color=
Default sorting fields=
From/To=Von/An
Other=
Move deleted messages to trash=
Reset=
Settings=
About=Über
Save=Speichern
Ascending=
Descending=
Date=Datum
From/To=Von/An
Restore=
Trash is empty=

View File

@ -13,37 +13,19 @@ BCC=CCO
Cancel=Cancelar
Save draft=Guardar borrador
Send=Enviar
CC=CC
New=Nuevo
Delete=Borrar
Edit=Editar
Name=Nombre
No drafts=No hay borradores
To=Para
Subject=Asunto
Player name=Nombre del jugador
That name is already in your contacts=Ese nombre ya está en tus contactos
The contact name cannot be empty.=Ese nombre de contacto no puede estar vacío.
Note=Nota
Back=Volver
Save=Guardar
Maillist name=Nombre de la lista de correo
Desc=Desc
Players=Jugadores
That name is already in your mailing lists.=Ese nombre ya está entus listas de correo.
The mailing list name cannot be empty.=Ese nombre de lista de correo no puede estar vacío.
Back=Volver
Mark Read=Marcar como leído
Mark Unread=Marcar como no leído
(No description)=(Sin descripción)
No maillist=Sin lista de correo
From=De
You have mail! Type /mail to read=
Read=Leído
Filter=Filtrar
Allow multiple selection=Permitir selección múltiple
@1 of @2 selected=
(Un)select all=(Des)seleccionar todos
No mail=Sin correo
Trash=
Inbox=Entrada
Outbox=Enviados
Drafts=Borradores
@ -52,11 +34,29 @@ Mail lists=Listas de correo
Options=
Close=Cerrar
(No subject)=(Sin asunto)
From=De
Reply=Responder
Reply all=Responder a todos
Forward=Reenviar
Filter=Filtrar
Allow multiple selection=Permitir selección múltiple
@1 of @2 selected=
(Un)select all=(Des)seleccionar todos
No mail=Sin correo
Read=Leído
(No description)=(Sin descripción)
No maillist=Sin lista de correo
Note=Nota
Edit=Editar
New=Nuevo
Delete=Borrar
You have mail! Type /mail to read=
Subject=Asunto
To=Para
Add=Añadir
Remove=Quitar
Name=Nombre
CC=CC
Notifications=
Chat notifications=
On join notifications=
@ -66,13 +66,18 @@ Message list=
Show unread in different color=
Show CC/BCC in different color=
Default sorting fields=
From/To=De/Para
Other=
Move deleted messages to trash=
Reset=
Settings=
About=Acerca de
Save=Guardar
Ascending=Ascendente
Descending=Descendiente
Date=Fecha
From/To=De/Para
Restore=
Trash is empty=
##### not used anymore #####

View File

@ -13,37 +13,19 @@ BCC=Cci
Cancel=Annuler
Save draft=Enregistrer le brouillon
Send=Envoyer
CC=Cc
New=Nouveau
Delete=Supprimer
Edit=Modifier
Name=Nom
No drafts=Pas de brouillons
To=À
Subject=Objet
Player name=Nom du joueur
That name is already in your contacts=Ce nom est déjà dans vos contacts
The contact name cannot be empty.=Le nom du contact ne peut pas être vide.
Note=Note
Back=Retour
Save=Sauvegarder
Maillist name=Nom de la liste de diffusion
Desc=Desc
Players=Joueurs
That name is already in your mailing lists.=Ce nom est déjà dans vos listes de diffusion.
The mailing list name cannot be empty.=Le nom de la liste de diffusion ne peut pas être vide.
Back=Retour
Mark Read=Marquer comme lu
Mark Unread=Marquer non lu
(No description)=Sans description
No maillist=Aucune liste de diffusion
From=De
You have mail! Type /mail to read=Vous avez reçu un mail ! Entrez /mail pour le consulter
Read=Lire
Filter=Filtre
Allow multiple selection=Autoriser la sélection multiple
@1 of @2 selected=@1 sur @2 sélectionnés
(Un)select all=Tout (dé)selectionner
No mail=Aucun mail
Trash=Corbeille
Inbox=Boîte de réception
Outbox=Envoyés
Drafts=Brouillons
@ -52,11 +34,29 @@ Mail lists=Listes de diffusion
Options=Options
Close=Fermer
(No subject)=(Sans objet)
From=De
Reply=Répondre
Reply all=Répondre à tous
Forward=Transférer
Filter=Filtre
Allow multiple selection=Autoriser la sélection multiple
@1 of @2 selected=@1 sur @2 sélectionnés
(Un)select all=Tout (dé)selectionner
No mail=Aucun mail
Read=Lire
(No description)=Sans description
No maillist=Aucune liste de diffusion
Note=Note
Edit=Modifier
New=Nouveau
Delete=Supprimer
You have mail! Type /mail to read=Vous avez reçu un mail ! Entrez /mail pour le consulter
Subject=Objet
To=À
Add=Ajouter
Remove=Enlever
Name=Nom
CC=Cc
Notifications=Notifications
Chat notifications=Notifications dans le tchat
On join notifications=Notifications à la connexion
@ -66,10 +66,15 @@ Message list=Liste de messages
Show unread in different color=Coloriser les non lus
Show CC/BCC in different color=Coloriser les Cc/Cci
Default sorting fields=Champs de tri par défaut
From/To=De/À
Other=Autre
Move deleted messages to trash=Supprimer les messages dans la corbeille
Reset=Réinitialiser
Settings=Paramètres
About=À propos
Save=Sauvegarder
Ascending=Croissant
Descending=Décroissant
Date=Date
From/To=De/À
Restore=Restaurer
Trash is empty=La corbeille est vide

View File

@ -1,5 +1,4 @@
# textdomain: mail
# author: nyomi
Provided my mt-mods=Feltéve, hogy az én mt-mod-om
Version=Verzió
Licenses=License
@ -7,9 +6,6 @@ Expat (code), WTFPL (textures)=Expat (kód), WTFPL (textúrák)
Communication using this system is NOT guaranteed to be private!=A systemben lévő komunikáció nem garantáltan privát!
Admins are able to view the messages of any player.=Az adminok megtudják nézni minden játékos üzenetjét.
Contributors=Közreműködöttek
Note=Jegyzet
Settings=Beállítások
About=Róla
You have a new message from @1! Subject: @2=Van egy új üzeneted @1-től Cím: @2
To view it, type /mail=Ahhoz hogy megnézd, írd /mail
You could also use the button in your inventory.=A gombot is tudod használni az inventoridban.
@ -17,14 +13,19 @@ BCC=BCC
Cancel=Mégse
Save draft=mentés piszkozatként
Send=Küldés
Subject=Cím
To=Neki
CC=CC
Name=Név
No drafts=Nincsenek piszkozatok
Edit=Szerkesztés
New=Új
Delete=Törlés
Player name=Játékos neve
That name is already in your contacts=A név már a kontaktok között van
The contact name cannot be empty.=A contakt neve nem lehet üres.
Maillist name=Levelező lista neve
Desc=Desc
Players=Játékosok
That name is already in your mailing lists.=A név már benne van a levelező listában
The mailing list name cannot be empty.=A levelező lista neve nem lehet üres
Back=Visza
Mark Read=Jelöld olvasottként
Mark Unread=Jelöld olvasatlanul
Trash=
Inbox=PostaLáda
Outbox=Elküldött
Drafts=Piszkozatok
@ -33,36 +34,29 @@ Mail lists=Levelező lista
Options=Lehetőségek
Close=Bezár
(No subject)=(nincs cím)
Player name=Játékos neve
That name is already in your contacts=A név már a kontaktok között van
The contact name cannot be empty.=A contakt neve nem lehet üres.
Save=Mentés
Maillist name=Levelező lista neve
Desc=Desc
Players=Játékosok
That name is already in your mailing lists.=A név már benne van a levelező listában
The mailing list name cannot be empty.=A levelező lista neve nem lehet üres
Mark Read=Jelöld olvasottként
Mark Unread=Jelöld olvasatlanul
From=Tőle
Read=Olvasott
Reply=Válasz
Reply all=Válaszmindenkinek
Forward=Továbbítás
Filter=Filterek
Allow multiple selection=
@1 of @2 selected=
(Un)select all=(ne válaszd ki) mindegyik választása
No mail=Nincs levél
Reply=Válasz
Reply all=Válaszmindenkinek
Forward=Továbbítás
Date=Dátum
Ascending=Emelkedő
Descending=Sűlyedő
Read=Olvasott
(No description)=(Nincs leírás)
No maillist=Nincs levelező lista
Note=Jegyzet
Edit=Szerkesztés
New=Új
Delete=Törlés
You have mail! Type /mail to read=Van egy leveled! Írd /mail az olvasáshoz
Subject=Cím
To=Neki
Add=Hozzáadás
Remove=Elvétel
Back=Visza
Name=Név
CC=CC
Notifications=Értesítések
Chat notifications=Chates értesítések
On join notifications=Belépési értesírés
@ -72,5 +66,15 @@ Message list=Üzenetek listája
Show unread in different color=Mutasd a nem olvasottakat más színnel
Show CC/BCC in different color=Mutasd a CC-t/BCC-t más színnel
Default sorting fields=Alap válogató terület
From/To=Tól(től)/neki
Other=
Move deleted messages to trash=
Reset=Viszaállítás
Settings=Beállítások
About=Róla
Save=Mentés
Ascending=Emelkedő
Descending=Sűlyedő
Date=Dátum
From/To=Tól(től)/neki
Restore=
Trash is empty=

View File

@ -13,37 +13,19 @@ BCC=BCC
Cancel=Cancelar
Save draft=Salvar rascunho
Send=Enviar
CC=CC
New=Novo
Delete=Apagar
Edit=Editar
Name=Nome
No drafts=Sem rascunhos
To=Para
Subject=Assunto
Player name=Nome do jogador
That name is already in your contacts=Esse nome já consta em sua lista de contatos
The contact name cannot be empty.=Informe o nome do destinatário
Note=Nota
Back=Voltar
Save=Salvar
Maillist name=Nome da lista de discussão
Desc=Descrição
Players=Jogador
That name is already in your mailing lists.=Esse nome ja está sendo usado em sua lista de discussões
The mailing list name cannot be empty.=O nome da lista de discussões deve ser informado
Back=Voltar
Mark Read=Marcar como lido
Mark Unread=Marcar como não lido
(No description)=(sem descrição)
No maillist=Sem lista de discussão
From=De
You have mail! Type /mail to read=Você recebeu e-mail! Tecle /mail para ler
Read=Ler
Filter=Filtrar
Allow multiple selection=Permitir selecionar vários
@1 of @2 selected=
(Un)select all=Desmarcar todos
No mail=Sem e-mails no momento
Trash=
Inbox=Entrada
Outbox=Enviadas
Drafts=Rascunhos
@ -52,11 +34,29 @@ Mail lists=Lista de correios
Options=Opções
Close=Fechar
(No subject)=(Sem assunto)
From=De
Reply=Responder
Reply all=Responder Todos
Forward=Encaminhar
Filter=Filtrar
Allow multiple selection=Permitir selecionar vários
@1 of @2 selected=
(Un)select all=Desmarcar todos
No mail=Sem e-mails no momento
Read=Ler
(No description)=(sem descrição)
No maillist=Sem lista de discussão
Note=Nota
Edit=Editar
New=Novo
Delete=Apagar
You have mail! Type /mail to read=Você recebeu e-mail! Tecle /mail para ler
Subject=Assunto
To=Para
Add=Adicionar
Remove=Remover
Name=Nome
CC=CC
Notifications=Notificações
Chat notifications=Notificação de conversa
On join notifications=Notificação ao entrar
@ -66,13 +66,18 @@ Message list=Lista de mensagens
Show unread in different color=Exibir mensagens não lidas em uma cor diferente
Show CC/BCC in different color=Exibir mensagens com copia em uma cor diferente
Default sorting fields=Ordenamento de campos padrão
From/To=De/Para
Other=
Move deleted messages to trash=
Reset=
Settings=Ajustes
About=Sobre
Save=Salvar
Ascending=Ascendente
Descending=Descendente
Date=Data
From/To=De/Para
Restore=
Trash is empty=
##### not used anymore #####

View File

@ -13,38 +13,20 @@ BCC=密送
Cancel=取消
Save draft=保存草稿
Send=发送
CC=抄送
New=新
Delete=删除
Edit=编辑
Name=名字
#if new means new mail, it would be New=新邮件
No drafts=没有草稿
To=收件人
Subject=主题
Player name=玩家名字
That name is already in your contacts=
The contact name cannot be empty.=
Note=备注
Back=返回
Save=保存
Maillist name=建组名
Desc=描述
Players=玩家
That name is already in your mailing lists.=
The mailing list name cannot be empty.=
Back=返回
Mark Read=标记为已读
Mark Unread=标记为未读
(No description)=(无描述)
No maillist=无建组
From=发件人
You have mail! Type /mail to read=
Read=浏览
Filter=筛选
Allow multiple selection=允许多选
@1 of @2 selected=
(Un)select all=(取消)选中所有
No mail=无邮件
Trash=
Inbox=收件箱
Outbox=已发送
Drafts=草稿
@ -53,11 +35,29 @@ Mail lists=建组
Options=
Close=关闭
(No subject)=(无主题)
From=发件人
Reply=回复
Reply all=回复所有
Forward=转发
Filter=筛选
Allow multiple selection=允许多选
@1 of @2 selected=
(Un)select all=(取消)选中所有
No mail=无邮件
Read=浏览
(No description)=(无描述)
No maillist=无建组
Note=备注
Edit=编辑
New=新
Delete=删除
You have mail! Type /mail to read=
Subject=主题
To=收件人
Add=添加
Remove=移除
Name=名字
CC=抄送
Notifications=
Chat notifications=
On join notifications=
@ -67,13 +67,18 @@ Message list=
Show unread in different color=
Show CC/BCC in different color=
Default sorting fields=
From/To=
Other=
Move deleted messages to trash=
Reset=
Settings=
About=关于
Save=保存
Ascending=升序
Descending=降序
Date=时间
From/To=
Restore=
Trash is empty=
##### not used anymore #####

View File

@ -13,37 +13,19 @@ BCC=密件副本
Cancel=取消
Save draft=儲存草稿
Send=發送
CC=副本
New=新建
Delete=刪除
Edit=編輯
Name=名稱
No drafts=沒有草稿
To=收件人
Subject=主旨
Player name=玩家名稱
That name is already in your contacts=
The contact name cannot be empty.=
Note=備註
Back=返回
Save=儲存
Maillist name=郵件列表名稱
Desc=描述
Players=玩家
That name is already in your mailing lists.=
The mailing list name cannot be empty.=
Back=返回
Mark Read=標記已讀
Mark Unread=標記未讀
(No description)=(沒有描述)
No maillist=沒有郵件列表
From=寄件者
You have mail! Type /mail to read=
Read=閱讀
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=沒有郵件
Trash=
Inbox=收件箱
Outbox=寄件備份
Drafts=草稿
@ -52,11 +34,29 @@ Mail lists=郵件列表
Options=
Close=關閉
(No subject)=(沒有主旨)
From=寄件者
Reply=回覆
Reply all=回覆所有人
Forward=轉寄
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=沒有郵件
Read=閱讀
(No description)=(沒有描述)
No maillist=沒有郵件列表
Note=備註
Edit=編輯
New=新建
Delete=刪除
You have mail! Type /mail to read=
Subject=主旨
To=收件人
Add=加入
Remove=移除
Name=名稱
CC=副本
Notifications=
Chat notifications=
On join notifications=
@ -66,10 +66,15 @@ Message list=
Show unread in different color=
Show CC/BCC in different color=
Default sorting fields=
From/To=
Other=
Move deleted messages to trash=
Reset=
Settings=
About=關於
Save=儲存
Ascending=
Descending=
Date=日期
From/To=
Restore=
Trash is empty=

View File

@ -13,37 +13,19 @@ BCC=
Cancel=
Save draft=
Send=
CC=
New=
Delete=
Edit=
Name=
No drafts=
To=
Subject=
Player name=
That name is already in your contacts=
The contact name cannot be empty.=
Note=
Back=
Save=
Maillist name=
Desc=
Players=
That name is already in your mailing lists.=
The mailing list name cannot be empty.=
Back=
Mark Read=
Mark Unread=
(No description)=
No maillist=
From=
You have mail! Type /mail to read=
Read=
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=
Trash=
Inbox=
Outbox=
Drafts=
@ -52,11 +34,29 @@ Mail lists=
Options=
Close=
(No subject)=
From=
Reply=
Reply all=
Forward=
Filter=
Allow multiple selection=
@1 of @2 selected=
(Un)select all=
No mail=
Read=
(No description)=
No maillist=
Note=
Edit=
New=
Delete=
You have mail! Type /mail to read=
Subject=
To=
Add=
Remove=
Name=
CC=
Notifications=
Chat notifications=
On join notifications=
@ -66,10 +66,15 @@ Message list=
Show unread in different color=
Show CC/BCC in different color=
Default sorting fields=
From/To=
Other=
Move deleted messages to trash=
Reset=
Settings=
About=
Save=
Ascending=
Descending=
Date=
From/To=
Restore=
Trash is empty=

View File

@ -8,6 +8,7 @@ local function populate_entry(e)
e.inbox = e.inbox or {}
e.outbox = e.outbox or {}
e.drafts = e.drafts or {}
e.trash = e.trash or {}
e.lists = e.lists or {}
e.settings = e.settings or {}
return e
@ -42,6 +43,43 @@ function mail.get_message(playername, msg_id)
return msg
end
end
for _, msg in ipairs(entry.drafts) do
if msg.id == msg_id then
return msg
end
end
for _, msg in ipairs(entry.trash) do
if msg.id == msg_id then
return msg
end
end
end
-- get player boxes where a message appears
function mail.get_message_boxes(playername, msg_id)
local entry = mail.get_storage_entry(playername)
local boxes = {}
for _, msg in ipairs(entry.inbox) do
if msg.id == msg_id then
table.insert(boxes, "inbox")
end
end
for _, msg in ipairs(entry.outbox) do
if msg.id == msg_id then
table.insert(boxes, "outbox")
end
end
for _, msg in ipairs(entry.drafts) do
if msg.id == msg_id then
table.insert(boxes, "drafts")
end
end
for _, msg in ipairs(entry.trash) do
if msg.id == msg_id then
table.insert(boxes, "trash")
end
end
return boxes
end
local function safe_find(str, sub)
@ -109,7 +147,7 @@ function mail.mark_unread(playername, msg_ids)
end
-- deletes a mail by its id
function mail.delete_mail(playername, msg_ids)
function mail.delete_mail(playername, msg_ids, delete_in_trash)
local entry = mail.get_storage_entry(playername)
if type(msg_ids) ~= "table" then -- if this is not a table
msg_ids = { msg_ids }
@ -138,8 +176,54 @@ function mail.delete_mail(playername, msg_ids)
end
end
end
if delete_in_trash then
for i = #entry.trash, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.trash[i].id == deleted_msg then
table.remove(entry.trash, i)
break
end
end
end
end
mail.set_storage_entry(playername, entry)
mail.hud_update(playername, entry.inbox)
return
end
-- move to trash mails by id
function mail.trash_mail(playername, msg_ids)
local entry = mail.get_storage_entry(playername)
if type(msg_ids) ~= "table" then -- if this is not a table
msg_ids = { msg_ids }
end
for _, id in ipairs(msg_ids) do
local msg = mail.get_message(playername, id)
msg.previous_boxes = mail.get_message_boxes(playername, id)
table.insert(entry.trash, 1, msg)
end
mail.set_storage_entry(playername, entry)
mail.delete_mail(playername, msg_ids)
return
end
-- restore a mail from trash
function mail.restore_mail(playername, msg_id)
local entry = mail.get_storage_entry(playername)
for i, msg in ipairs(entry.trash) do
if msg.id == msg_id then
-- not anymore store previous boxes in json
local previous_boxes = msg.previous_boxes
msg.previous_boxes = nil
-- restore it in all previous boxes
for _, box in ipairs(previous_boxes) do
table.insert(entry[box], msg)
end
-- then delete it from trash
table.remove(entry.trash, i)
end
end
mail.set_storage_entry(playername, entry)
mail.hud_update(playername, entry.inbox)
return
end
@ -271,6 +355,7 @@ function mail.get_setting_default_value(setting_name)
cccolorenable = true,
defaultsortfield = 3,
defaultsortdirection = 1,
trash_move_enable = true,
}
return default_values[setting_name]
end

View File

@ -1,22 +1,28 @@
-- translation
local S = minetest.get_translator("mail")
local drafts_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] .. S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. [[;3;false;false]
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;edit;]] .. S("Edit") .. [[]
button[6,1.70;2.5,0.5;delete;]] .. S("Delete") .. [[]
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
tablecolumns[color;text;text]
table[0,0.7;5.75,9.35;drafts;#999,]] .. S("To") .. "," .. S("Subject")
function mail.show_drafts(name)
local trash_tab = ""
if mail.get_setting(name, "trash_move_enable") then
trash_tab = "," .. S("Trash")
end
local drafts_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] ..
S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. trash_tab .. [[;3;false;false]
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;edit;]] .. S("Edit") .. [[]
button[6,1.70;2.5,0.5;delete;]] .. S("Delete") .. [[]
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
tablecolumns[color;text;text]
table[0,0.7;5.75,9.35;drafts;#999,]] .. S("To") .. "," .. S("Subject")
local formspec = { drafts_formspec }
local entry = mail.get_storage_entry(name)
local messages = entry.drafts

View File

@ -15,7 +15,8 @@ local function nonempty(x)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "mail:inbox" and formname ~= "mail:outbox" and formname ~= "mail:drafts" then
if formname ~= "mail:inbox" and formname ~= "mail:outbox"
and formname ~= "mail:drafts" and formname ~= "mail:trash" then
return
elseif fields.quit then
return
@ -50,6 +51,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- split inbox and outbox msgs for different tests
local entry = mail.get_storage_entry(name)
local messagesDrafts = entry.drafts
local messagesTrash = entry.trash
local getInbox = messageGetter(entry.inbox, inboxsortfield, sortdirection == "2", filter)
local getOutbox = messageGetter(entry.outbox, outboxsortfield, sortdirection == "2", filter)
@ -154,6 +156,23 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return true
end
if fields.trash then -- trash table
local evt = minetest.explode_table_event(fields.trash)
if evt.row == 1 then -- header
if mail.selected_idxs.sortfield[name] == evt.column-1 then -- if already this field, then change direction
mail.selected_idxs.sortdirection[name] = mail.selected_idxs.sortdirection[name] == "2" and "1" or "2"
end
mail.selected_idxs.sortfield[name] = evt.column-1 -- update column
mail.show_mail_menu(name)
return
end
mail.selected_idxs.trash[name] = evt.row - 1
if evt.type == "DCL" and messagesTrash[mail.selected_idxs.trash[name]] then
mail.show_message(name, messagesTrash[mail.selected_idxs.trash[name]].id)
end
return true
end
if fields.boxtab == "1" then
mail.selected_idxs.boxtab[name] = 1
mail.show_inbox(name, sortfieldindex, sortdirection, filter)
@ -166,11 +185,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
mail.selected_idxs.boxtab[name] = 3
mail.show_drafts(name)
elseif fields.boxtab == "4" then
mail.selected_idxs.boxtab[name] = 4
mail.show_trash(name)
elseif fields.read then
if formname == "mail:inbox" and nonempty(mail.selected_idxs.inbox[name]) then -- inbox table
mail.show_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]])
elseif formname == "mail:outbox" and nonempty(mail.selected_idxs.outbox[name]) then -- outbox table
mail.show_message(name, mail.selected_idxs.outbox[name][#mail.selected_idxs.outbox[name]])
elseif formname == "mail:trash" and messagesTrash[mail.selected_idxs.trash[name]] then
mail.show_message(name, messagesTrash[mail.selected_idxs.trash[name]].id)
end
elseif fields.edit then
@ -186,19 +211,39 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
elseif fields.delete then
local trash_enabled = mail.get_setting(name, "trash_move_enable")
if formname == "mail:inbox" and mail.selected_idxs.inbox[name] then -- inbox table
mail.delete_mail(name, mail.selected_idxs.inbox[name])
if trash_enabled then
mail.trash_mail(name, mail.selected_idxs.inbox[name])
else
mail.delete_mail(name, mail.selected_idxs.inbox[name])
end
mail.selected_idxs.inbox[name] = {}
elseif formname == "mail:outbox" and mail.selected_idxs.outbox[name] then -- outbox table
mail.delete_mail(name, mail.selected_idxs.outbox[name])
if trash_enabled then
mail.trash_mail(name, mail.selected_idxs.outbox[name])
else
mail.delete_mail(name, mail.selected_idxs.outbox[name])
end
mail.selected_idxs.outbox[name] = {}
elseif formname == "mail:drafts" and messagesDrafts[mail.selected_idxs.drafts[name]] then -- drafts table
mail.delete_mail(name, messagesDrafts[mail.selected_idxs.drafts[name]].id)
if trash_enabled then
mail.trash_mail(name, messagesDrafts[mail.selected_idxs.drafts[name]].id)
else
mail.delete_mail(name, messagesDrafts[mail.selected_idxs.drafts[name]].id)
end
mail.selected_idxs.drafts[name] = nil
elseif formname == "mail:trash" and messagesTrash[mail.selected_idxs.trash[name]] then -- trash table
mail.delete_mail(name, messagesTrash[mail.selected_idxs.trash[name]].id, true)
end
mail.show_mail_menu(name, sortfieldindex, sortdirection, filter)
elseif fields.restore then
mail.restore_mail(name, messagesTrash[mail.selected_idxs.trash[name]].id)
mail.show_mail_menu(name, sortfieldindex, sortdirection, filter)
elseif fields.reply then
if formname == "mail:inbox" and mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]])

View File

@ -13,8 +13,14 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
local sortfield = ({"from","subject","time"})[sortfieldindex]
local messages = mail.sort_messages(entry.inbox, sortfield, sortdirection == "2", filter)
local trash_tab = ""
if mail.get_setting(name, "trash_move_enable") then
trash_tab = "," .. S("Trash")
end
local inbox_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] .. S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. [[;1;false;false]
tabheader[0.3,1;boxtab;]] ..
S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. trash_tab .. [[;1;false;false]
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;read;]] .. S("Read") .. [[]

View File

@ -11,5 +11,7 @@ function mail.show_mail_menu(playername, sortfield, sortdirection, filter)
mail.show_outbox(playername, sortfield, sortdirection, filter)
elseif index == 3 then
mail.show_drafts(playername)
elseif index == 4 then
mail.show_trash(playername)
end
end

View File

@ -13,8 +13,14 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
local sortfield = ({"to","subject","time"})[sortfieldindex]
local messages = mail.sort_messages(entry.outbox, sortfield, sortdirection == "2", filter)
local trash_tab = ""
if mail.get_setting(name, "trash_move_enable") then
trash_tab = "," .. S("Trash")
end
local outbox_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] .. S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. [[;2;false;false]
tabheader[0.3,1;boxtab;]] ..
S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. trash_tab .. [[;2;false;false]
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;read;]] .. S("Read") .. [[]

View File

@ -35,6 +35,11 @@ function mail.show_settings(name)
S("Ascending") .. "," .. S("Descending") .. [[;]] ..
tostring(mail.get_setting(name, "defaultsortdirection")) .. [[;true]
box[0,3.2;3,0.45;#466432]
label[0.2,3.2;]] .. S("Other") .. [[]
checkbox[0,3.6;trash_move_enable;]] .. S("Move deleted messages to trash") .. [[;]] ..
tostring(mail.get_setting(name, "trash_move_enable")) .. [[]
button[0,5.5;2.5,0.5;save;]] .. S("Save") .. [[]
button[2.7,5.5;2.5,0.5;reset;]] .. S("Reset") .. [[]
]] .. mail.theme
@ -79,6 +84,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.cccolorenable then
mail.selected_idxs.cccolorenable[playername] = fields.cccolorenable == "true"
elseif fields.trash_move_enable then
mail.selected_idxs.trash_move_enable[playername] = fields.trash_move_enable == "true"
elseif fields.save then
-- checkboxes
mail.set_setting(playername, "chat_notifications", mail.selected_idxs.chat_notifications[playername])
@ -87,6 +95,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
mail.set_setting(playername, "sound_notifications", mail.selected_idxs.sound_notifications[playername])
mail.set_setting(playername, "unreadcolorenable", mail.selected_idxs.unreadcolorenable[playername])
mail.set_setting(playername, "cccolorenable", mail.selected_idxs.cccolorenable[playername])
mail.set_setting(playername, "trash_move_enable", mail.selected_idxs.trash_move_enable[playername])
-- dropdowns
local defaultsortfield = fields.defaultsortfield or mail.get_setting("defaultsortfield")
local defaultsortdirection = fields.defaultsortdirection or mail.get_setting("defaultsortdirection")

52
ui/trash.lua Normal file
View File

@ -0,0 +1,52 @@
-- translation
local S = minetest.get_translator("mail")
local trash_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] ..
S("Inbox") .. "," .. S("Outbox").. "," .. S("Drafts") .. "," .. S("Trash") .. [[;4;false;false]
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;read;]] .. S("Read") .. [[]
button[6,1.70;2.5,0.5;restore;]] .. S("Restore") .. [[]
button[6,2.45;2.5,0.5;delete;]] .. S("Delete") .. [[]
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
button[6,8.7;2.5,0.5;options;]] .. S("Options") .. [[]
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
tablecolumns[color;text;text]
table[0,0.7;5.75,9.35;trash;#999,]] .. S("From/To") .. "," .. S("Subject")
function mail.show_trash(name)
local formspec = { trash_formspec }
local entry = mail.get_storage_entry(name)
local messages = entry.trash
if messages[1] then
for _, message in ipairs(messages) do
formspec[#formspec + 1] = ","
formspec[#formspec + 1] = ","
formspec[#formspec + 1] = minetest.formspec_escape(message.to)
formspec[#formspec + 1] = ","
if message.subject ~= "" then
if string.len(message.subject) > 30 then
formspec[#formspec + 1] = minetest.formspec_escape(string.sub(message.subject, 1, 27))
formspec[#formspec + 1] = "..."
else
formspec[#formspec + 1] = minetest.formspec_escape(message.subject)
end
else
formspec[#formspec + 1] = S("(No subject)")
end
end
if mail.selected_idxs.trash[name] then
formspec[#formspec + 1] = ";"
formspec[#formspec + 1] = tostring(mail.selected_idxs.trash[name] + 1)
end
formspec[#formspec + 1] = "]"
else
formspec[#formspec + 1] = "]label[2.25,4.5;" .. S("Trash is empty") .. "]"
end
minetest.show_formspec(name, "mail:trash", table.concat(formspec, ""))
end