<?php
require_once('session/start.php');
require_once('class/domain.php');
require_once('mailaccounts.php');
require_once('inc/icons.php');
require_role(ROLE_SYSTEMUSER);
$user = $_SESSION['userinfo'];
title("E-Mail-Accounts");
if (isset($_GET['action']) && $_GET['action'] == 'save') {
if (isset($_GET['id'])) {
check_form_token('email_imap_edit');
$account = $_POST['user'].'@'.$_POST['domain'];
if (isset($_POST['enabled']) && $_POST['enabled'] == 'true') {
$enabled = 'Y';
} else {
$enabled = 'N';
}
$acc = array('id' => $_GET['id'], 'account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
if ($_POST['password'] != '') {
$acc['password'] = $_POST['password'];
}
$error = check_valid($acc);
if ($error != "") {
input_error($error);
$title = "E-Mail-Accounts";
output("");
} else {
change_mailaccount($_GET['id'], $acc);