modules/email/save.php
90ff5748
 <?php
 
 require_once('session/start.php');
 
 require_once('vmail.php');
 
 require_role(ROLE_SYSTEMUSER);
 
 require_once("inc/debug.php");
 global $debugmode;
 
 
 if ($_GET['action'] == 'edit')
 {
   check_form_token('vmail_edit_mailbox');
   $id = (int) $_GET['id'];
 
   $account = empty_account();
   $account['id'] = NULL;
   if ($id)
     $account['id'] = $id;
   $account['local'] = $_POST['local'];
   $account['domain'] = (int) $_POST['domain'];
   $account['spamfilter'] = $_POST['spamfilter_action'];
83d84151
   $account['password'] = $_POST['password'];
ba107713
   if (($account['password'] == '') && ($_POST['mailbox'] == 'yes'))
     system_failure("Sie haben ein leeres Passwort eingegeben!");
beab525e
   if ($_POST['password'] == '**********')
     $account['password'] = '';
83d84151
   if ($_POST['mailbox'] != 'yes')
a15eafe2
   {
83d84151
     $account['password'] = NULL;
a15eafe2
     $account['spamfilter'] = 'none';
   }
83d84151
 
   if ($_POST['forward'] == 'yes')
   {
     $num = 1;
     while (true)
     {
       if (! isset($_POST['forward_to_'.$num]))
         break;
45b069aa
       if ($_POST['forward_to_'.$num] == '')
         break;
83d84151
       $fwd = array("spamfilter" => $_POST['spamfilter_action_'.$num], "destination" => $_POST['forward_to_'.$num]);
       array_push($account['forwards'], $fwd);
       $num++;
     }
ba107713
     if ($num == 1) system_failure("Bitte mindestens eine Weiterleitungsadresse angeben.");
83d84151
   }
ba107713
 
   if (($_POST['forward']!='yes') && ($_POST['mailbox']!='yes'))
     system_failure("Entweder eine Mailbox oder eine Weiterleitung muss angegeben werden!");
90ff5748
 
   DEBUG($account);
 
   save_vmail_account($account);
 
   if (! ($debugmode || we_have_an_error()))
63a0529b
     header('Location: vmail');
3e33ab37
 }
 elseif ($_GET['action'] == 'delete')
 {
   $title = "E-mail-Adresse löschen";
   $section = 'vmail_vmail';
 
   $account = get_account_details( (int) $_GET['id'] );
 
   $domain = NULL;
   $domains = get_vmail_domains();
   foreach ($domains as $dom)
     if ($dom->id == $account['domain'])
     {
       $domain = $dom->domainname;
       break;
     }
   $account_string = $account['local'] . "@" . $domain;
   $sure = user_is_sure();
   if ($sure === NULL)
   {
     are_you_sure("action=delete&amp;id={$account['id']}", "Möchten Sie die E-Mail-Adresse »{$account_string}« wirklich löschen?");
   }
   elseif ($sure === true)
   {
     delete_account($account['id']);
     if (! $debugmode)
63a0529b
       header("Location: vmail");
3e33ab37
   }
   elseif ($sure === false)
   {
     if (! $debugmode)
63a0529b
       header("Location: vmail");
3e33ab37
   }
90ff5748
 
 }
 else
   system_failure("Unimplemented action");
 
 output('');
 
 
 ?>