bernd commited on 2011-06-20 17:46:18
Zeige 3 geänderte Dateien mit 32 Einfügungen und 7 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2012 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -27,7 +27,7 @@ function get_account_details($id, $checkuid = true) |
27 | 27 |
$id = (int) $id; |
28 | 28 |
$uid = (int) $_SESSION['userinfo']['uid']; |
29 | 29 |
$uid_check = ($checkuid ? "useraccount='{$uid}' AND " : ""); |
30 |
- $result = db_query("SELECT id, local, domain, password, spamfilter, forwards, quota, quota_used from mail.v_vmail_accounts WHERE {$uid_check}id={$id} LIMIT 1"); |
|
30 |
+ $result = db_query("SELECT id, local, domain, password, spamfilter, forwards, server, quota, quota_used from mail.v_vmail_accounts WHERE {$uid_check}id={$id} LIMIT 1"); |
|
31 | 31 |
if (mysql_num_rows($result) == 0) |
32 | 32 |
system_failure('Ungültige ID oder kein eigener Account'); |
33 | 33 |
$acc = empty_account(); |
... | ... |
@@ -64,7 +64,7 @@ function get_vmail_accounts() |
64 | 64 |
function get_vmail_domains() |
65 | 65 |
{ |
66 | 66 |
$uid = (int) $_SESSION['userinfo']['uid']; |
67 |
- $result = db_query("SELECT id, domainname FROM mail.v_vmail_domains WHERE useraccount='{$uid}'"); |
|
67 |
+ $result = db_query("SELECT id, domainname, server FROM mail.v_vmail_domains WHERE useraccount='{$uid}'"); |
|
68 | 68 |
if (mysql_num_rows($result) == 0) |
69 | 69 |
system_failure('Sie haben keine Domains für virtuelle Mail-Verarbeitung'); |
70 | 70 |
$ret = array(); |
... | ... |
@@ -116,6 +116,16 @@ function domainselect($selected = NULL, $selectattribute = '') |
116 | 116 |
} |
117 | 117 |
|
118 | 118 |
|
119 |
+function get_max_mailboxquota($server, $oldquota) { |
|
120 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
121 |
+ $server = (int) $server; |
|
122 |
+ $result = db_query("SELECT systemquota - (systemquota_used + mailquota) AS free FROM system.v_quota WHERE uid='{$uid}' AND server='{$server}'"); |
|
123 |
+ $item = mysql_fetch_assoc($result); |
|
124 |
+ DEBUG("Free space: ".$item['free']." / Really: ".($item['free'] + ($oldquota - config('vmail_basequota')))); |
|
125 |
+ return $item['free'] + ($oldquota - config('vmail_basequota')); |
|
126 |
+} |
|
127 |
+ |
|
128 |
+ |
|
119 | 129 |
|
120 | 130 |
|
121 | 131 |
function save_vmail_account($account) |
... | ... |
@@ -140,11 +150,13 @@ function save_vmail_account($account) |
140 | 150 |
$domainlist = get_vmail_domains(); |
141 | 151 |
$valid_domain = false; |
142 | 152 |
$domainname = NULL; |
153 |
+ $server = NULL; |
|
143 | 154 |
foreach ($domainlist as $dom) |
144 | 155 |
{ |
145 | 156 |
if ($dom->id == $account['domain']) |
146 | 157 |
{ |
147 | 158 |
$domainname = $dom->domainname; |
159 |
+ $server = $dom->server; |
|
148 | 160 |
$valid_domain = true; |
149 | 161 |
break; |
150 | 162 |
} |
... | ... |
@@ -198,7 +210,21 @@ function save_vmail_account($account) |
198 | 210 |
break; |
199 | 211 |
} |
200 | 212 |
|
201 |
- $account['quota'] = max((int) config('vmail_basequota'), (int) $account['quota']); |
|
213 |
+ $free = config('vmail_basequota'); |
|
214 |
+ if ($id == NULL) { |
|
215 |
+ // Neues Postfach |
|
216 |
+ $free = get_max_mailboxquota($server, config('vmail_basequota')); |
|
217 |
+ } else { |
|
218 |
+ $free = get_max_mailboxquota($oldaccount['server'], $oldaccount['quota']); |
|
219 |
+ } |
|
220 |
+ |
|
221 |
+ $newquota = max((int) config('vmail_basequota'), (int) $account['quota']); |
|
222 |
+ if ($newquota > config('vmail_basequota') && $newquota > ($free+config('vmail_basequota'))) { |
|
223 |
+ $newquota = $free + config('vmail_basequota'); |
|
224 |
+ warning("Ihr Speicherplatz reicht für diese Postfach-Größe nicht mehr aus. Ihr Postfach wurde auf {$newquota} MB reduziert. Bitte beachten Sie, dass damit Ihr Benutzerkonto keinen freien Speicherplatz mehr aufweist!"); |
|
225 |
+ } |
|
226 |
+ |
|
227 |
+ $account['quota'] = $newquota; |
|
202 | 228 |
|
203 | 229 |
$account['local'] = mysql_real_escape_string($account['local']); |
204 | 230 |
$account['password'] = mysql_real_escape_string($account['password']); |
... | ... |
@@ -36,7 +36,7 @@ if ($_GET['action'] == 'edit') |
36 | 36 |
$account['quota'] = $_POST['quota']; |
37 | 37 |
} |
38 | 38 |
|
39 |
- if ($_POST['forward'] == 'yes') |
|
39 |
+ if (isset($_POST['forward']) && $_POST['forward'] == 'yes') |
|
40 | 40 |
{ |
41 | 41 |
$num = 1; |
42 | 42 |
while (true) |
... | ... |
@@ -52,7 +52,7 @@ if ($_GET['action'] == 'edit') |
52 | 52 |
if ($num == 1) system_failure("Bitte mindestens eine Weiterleitungsadresse angeben."); |
53 | 53 |
} |
54 | 54 |
|
55 |
- if (($_POST['forward']!='yes') && ($_POST['mailbox']!='yes')) |
|
55 |
+ if ((isset($_POST['forward']) && $_POST['forward']!='yes') && ($_POST['mailbox']!='yes')) |
|
56 | 56 |
system_failure("Entweder eine Mailbox oder eine Weiterleitung muss angegeben werden!"); |
57 | 57 |
|
58 | 58 |
DEBUG($account); |
59 | 59 |