<?php
require_once('session/start.php');
require_once('vmail.php');
require_role([ROLE_SYSTEMUSER, ROLE_VMAIL_ACCOUNT]);
require_once("inc/debug.php");
global $debugmode;
$section = 'email_vmail';
if ($_GET['action'] == 'edit') {
check_form_token('vmail_edit_mailbox');
$accountlogin = ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT);
if ($accountlogin) {
$section = 'email_edit';
$id = get_vmail_id_by_emailaddr($_SESSION['mailaccount']);
$account = get_account_details($id, false);
$account['forwards'] = [];
} else {
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$account = empty_account();
$account['id'] = null;
if ($id) {
$account['id'] = $id;
$oldaccount = get_account_details($id);
$account['local'] = $oldaccount['local'];
$account['domain'] = $oldaccount['domain'];
} else {
$account['local'] = $_POST['local'];
$account['domain'] = (int) $_POST['domain'];
}
$account['enableextensions'] = false;