in webui/js/ponymail.js [2967:3155]
function admin_email_preview(stats, json) {
admin_current_email = json.mid;
admin_email_meta = json;
let cp = document.getElementById("panel");
let div = new HTML('div', {
style: {
margin: '5px'
}
});
cp.inject(div);
div.inject(new HTML('h1', {}, "Editing email " + json.mid + ":"));
// Author
let author_field = new HTML('div', {
class: 'email_kv_edit'
});
let author_key = new HTML('div', {
class: 'email_key'
}, "From: ");
let author_value = new HTML('input', {
id: 'email_from',
style: {
width: "480px"
},
value: json.from
});
author_field.inject([author_key, author_value]);
div.inject(author_field);
// Subject
let subject_field = new HTML('div', {
class: 'email_kv_edit'
});
let subject_key = new HTML('div', {
class: 'email_key'
}, "Subject: ");
let subject_value = new HTML('input', {
id: 'email_subject',
style: {
width: "480px"
},
value: json.subject
});
subject_field.inject([subject_key, subject_value]);
div.inject(subject_field);
// Date
let date_field = new HTML('div', {
class: 'email_kv_edit'
});
let date_key = new HTML('div', {
class: 'email_key'
}, "Date: ");
let date_value = new HTML('div', {
class: 'email_value'
}, new Date(json.epoch * 1000.0).ISOBare());
date_field.inject([date_key, date_value]);
div.inject(date_field);
// List
let listname = json.list_raw.replace(".", "@", 1).replace(/[<>]/g, "");
let list_field = new HTML('div', {
class: 'email_kv_edit'
});
let list_key = new HTML('div', {
class: 'email_key'
}, "List: ");
let list_value = new HTML('input', {
id: 'email_listname',
style: {
width: "480px"
},
value: listname
});
list_field.inject([list_key, list_value]);
div.inject(list_field);
// Private email?
let priv_field = new HTML('div', {
class: 'email_kv_edit'
});
let priv_key = new HTML('div', {
class: 'email_key'
}, "Visibility: ");
let priv_value = new HTML('select', {
id: 'email_private'
});
priv_value.inject(new HTML('option', {
value: 'no',
style: {
color: 'green'
},
selected: json.private ? null : "selected"
}, "Public"));
priv_value.inject(new HTML('option', {
value: 'yes',
style: {
color: 'red'
},
selected: json.private ? "selected" : null
}, "Private"));
priv_field.inject([priv_key, priv_value]);
div.inject(priv_field);
// Attachments?
if (json.attachments && json.attachments.length > 0) {
let attach_field = new HTML('div', {
class: 'email_kv'
});
let attach_key = new HTML('div', {
class: 'email_key'
}, "Attachment(s): ");
let alinks = [];
for (let attachment of json.attachments) {
let link = `${G_apiURL}api/email.lua?attachment=true&id=${encodeURIComponent(json.mid)}&file=${encodeURIComponent(attachment.hash)}`;
let a = new HTML('a', {
href: link,
target: '_blank'
}, attachment.filename);
alinks.push(a);
let fs = ` ${attachment.size} bytes`;
if (attachment.size >= 1024) fs = ` ${Math.floor(attachment.size/1024)} KB`;
if (attachment.size >= 1024 * 1024) fs = ` ${Math.floor(attachment.size/(1024*10.24))/100} MB`;
alinks.push(fs);
let adel = new HTML('a', {
onclick: `admin_del_attachment('${attachment.hash}');`,
href: "javascript:void(0);"
}, "Delete attachment");
alinks.push(adel);
alinks.push(new HTML('br'));
}
let attach_value = new HTML('div', {
class: 'email_value'
}, alinks);
attach_field.inject([attach_key, attach_value]);
div.inject(attach_field);
}
let text = new HTML('textarea', {
id: 'email_body',
style: {
width: "100%",
height: "480px"
}
}, json.body);
div.inject(text);
let btn_edit = new HTML('button', {
onclick: "admin_save_email();"
}, "Save changes to archive");
let btn_del = new HTML('button', {
onclick: "admin_delete_email();",
style: {
marginLeft: "36px",
color: 'red'
}
}, "Delete email from archives");
let btn_hide = new HTML('button', {
onclick: "admin_hide_email();",
style: {
marginLeft: "36px",
color: 'purple'
}
}, "Hide email from archives");
if (admin_email_meta.deleted) {
btn_hide = new HTML('button', {
onclick: "admin_unhide_email();",
style: {
marginLeft: "36px",
color: 'purple'
}
}, "Unhide email from archives");
}
div.inject(new HTML('br'));
div.inject(btn_edit);
div.inject(btn_hide);
div.inject(btn_del);
div.inject(new HTML('br'));
div.inject(new HTML('small', {}, "Modifying emails will remove the option to view their sources via the web interface, as the source may contain traces that reveal the edit."))
div.inject(new HTML('br'));
if (!mgmt_prefs.login.credentials.fully_delete) {
div.inject(new HTML('small', {}, "Emails that are deleted may still be recovered by the base system administrator. For complete expungement, please contact the system administrator."))
} else {
div.inject(new HTML('small', {style:{color: 'red'}}, "As full delete enforcement is enabled on this server, emails are removed forever from the archive when deleted, and cannot be recovered."))
}
}