delete_email

This commit is contained in:
Synox 2018-02-23 22:12:24 +01:00
parent a3f5c35406
commit 6249e959cd
3 changed files with 18 additions and 18 deletions

View File

@ -24,4 +24,21 @@ class ImapClient {
$emails = _load_emails($mail_ids, $user); $emails = _load_emails($mail_ids, $user);
return $emails; return $emails;
} }
/**
* deletes emails by id and username. The address must match the recipient in the email.
*
* @param $mailid integer imap email id
* @param $user User
* @internal param the $username matching username
*/
function delete_email(string $mailid, User $user) {
if (_load_one_email($mailid, $user) !== null) {
$this->mailbox->deleteMail($mailid);
$this->mailbox->expungeDeletedMails();
} else {
error(404, 'delete error: invalid username/mailid combination');
}
}
} }

View File

@ -40,23 +40,6 @@ function error($status, $text) {
/**
* deletes emails by id and username. The address must match the recipient in the email.
*
* @param $mailid integer imap email id
* @param $user User
* @internal param the $username matching username
*/
function delete_email($mailid, $user) {
global $mailbox;
if (_load_one_email($mailid, $user) !== null) {
$mailbox->deleteMail($mailid);
$mailbox->expungeDeletedMails();
} else {
error(404, 'delete error: invalid username/mailid combination');
}
}
/** /**
* download email by id and username. The $address must match the recipient in the email. * download email by id and username. The $address must match the recipient in the email.

View File

@ -67,7 +67,7 @@ class DeleteEmailPage extends Page {
$this->if_invalid_redirect_to_random($user, $this->config_domains); $this->if_invalid_redirect_to_random($user, $this->config_domains);
$delete_email_id = filter_var($this->email_id, FILTER_SANITIZE_NUMBER_INT); $delete_email_id = filter_var($this->email_id, FILTER_SANITIZE_NUMBER_INT);
delete_email($delete_email_id, $user); $imapClient->delete_email($delete_email_id, $user);
header("location: ?" . $user->address); header("location: ?" . $user->address);
} }
} }