bernd commited on 2011-04-22 13:25:18
Zeige 5 geänderte Dateien mit 45 Einfügungen und 9 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1990 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -90,6 +90,15 @@ $form .= " |
90 | 90 |
|
91 | 91 |
$form.= "<p style=\"margin-left: 2em;\" class=\"spamfilter_options\">Unerwünschte E-Mails (Spam, Viren) in diesem Postfach ".html_select('spamfilter_action', array("none" => 'nicht filtern', "folder" => 'in Unterordner »Spam« ablegen', "tag" => 'markieren und zustellen', "delete" => 'nicht zustellen (löschen)'), $account['spamfilter'])."</p>"; |
92 | 92 |
|
93 |
+$quota = 256; |
|
94 |
+if ($is_mailbox and $account['quota']) { |
|
95 |
+ $quota = $account['quota']; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+$form .= "<p style=\"margin-left: 2em;\" class=\"quota_options\">Größe des Postfachs: <input type=\"text\" id=\"quota\" name=\"quota\" value=\"{$quota}\" /> MB<br /><span style=\"font-size: 80%\"><em>Hinweis: Die Differenz zwischen dem hier gesetzten Wert und dem Sockelbetrag von ".config('vmail_basequota')." MB wird vom Speicherplatz Ihres Benutzer-Kontos angezogen.</em></span></p>"; |
|
99 |
+ |
|
100 |
+ |
|
101 |
+ |
|
93 | 102 |
$form .= "<p><input type=\"checkbox\" id=\"forward\" name=\"forward\" value=\"yes\" ".($is_forward ? 'checked="checked" ' : '')." /><label for=\"forward\"> <strong>Weiterleitung an andere E-Mail-Adressen</strong></label></p>"; |
94 | 103 |
|
95 | 104 |
|
... | ... |
@@ -15,6 +15,7 @@ function empty_account() |
15 | 15 |
'password' => NULL, |
16 | 16 |
'spamfilter' => 'folder', |
17 | 17 |
'spamexpire' => 7, |
18 |
+ 'quota' => 256, |
|
18 | 19 |
'forwards' => array() |
19 | 20 |
); |
20 | 21 |
return $account; |
... | ... |
@@ -197,6 +198,8 @@ function save_vmail_account($account) |
197 | 198 |
break; |
198 | 199 |
} |
199 | 200 |
|
201 |
+ $account['quota'] = max((int) config('vmail_basequota'), (int) $account['quota']); |
|
202 |
+ |
|
200 | 203 |
$account['local'] = mysql_real_escape_string($account['local']); |
201 | 204 |
$account['password'] = mysql_real_escape_string($account['password']); |
202 | 205 |
$account['spamexpire'] = (int) $account['spamexpire']; |
... | ... |
@@ -204,8 +207,8 @@ function save_vmail_account($account) |
204 | 207 |
$query = ''; |
205 | 208 |
if ($id == NULL) |
206 | 209 |
{ |
207 |
- $query = "INSERT INTO mail.vmail_accounts (local, domain, spamfilter, spamexpire, password) VALUES "; |
|
208 |
- $query .= "('{$account['local']}', {$account['domain']}, {$spam}, {$account['spamexpire']}, {$password});"; |
|
210 |
+ $query = "INSERT INTO mail.vmail_accounts (local, domain, spamfilter, spamexpire, password, quota) VALUES "; |
|
211 |
+ $query .= "('{$account['local']}', {$account['domain']}, {$spam}, {$account['spamexpire']}, {$password}, {$account['quota']});"; |
|
209 | 212 |
} |
210 | 213 |
else |
211 | 214 |
{ |
... | ... |
@@ -214,7 +217,7 @@ function save_vmail_account($account) |
214 | 217 |
else |
215 | 218 |
$password=''; |
216 | 219 |
$query = "UPDATE mail.vmail_accounts SET local='{$account['local']}', domain={$account['domain']}{$password}, "; |
217 |
- $query .= "spamfilter={$spam}, spamexpire={$account['spamexpire']} "; |
|
220 |
+ $query .= "spamfilter={$spam}, spamexpire={$account['spamexpire']}, quota={$account['quota']} "; |
|
218 | 221 |
$query .= "WHERE id={$id} LIMIT 1;"; |
219 | 222 |
} |
220 | 223 |
db_query($query); |
... | ... |
@@ -237,11 +240,20 @@ function save_vmail_account($account) |
237 | 240 |
} |
238 | 241 |
db_query($forward_query); |
239 | 242 |
} |
240 |
- if ($account['password'] != 'NULL') |
|
243 |
+ if ($password != 'NULL') |
|
241 | 244 |
{ |
242 | 245 |
# notify the vmail subsystem of this new account |
243 | 246 |
mail('vmail@'.config('vmail_server'), 'command', "user={$account['local']}\nhost={$domainname}", "X-schokokeks-org-message: command"); |
244 | 247 |
} |
248 |
+ |
|
249 |
+ // Update Mail-Quota-Cache |
|
250 |
+ $result = db_query("SELECT useraccount, server, SUM(quota-(SELECT value FROM misc.config WHERE `key`='vmail_basequota')) AS quota, SUM(GREATEST(quota_used-(SELECT value FROM misc.config WHERE `key`='vmail_basequota'), 0)) AS used FROM mail.v_vmail_accounts GROUP BY useraccount, server"); |
|
251 |
+ while ($line = mysql_fetch_assoc($result)) { |
|
252 |
+ if ($line['quota'] !== NULL) { |
|
253 |
+ db_query("REPLACE INTO mail.vmailquota (uid, server, quota, used) VALUES ('{$line['useraccount']}', '{$line['server']}', '{$line['quota']}', '{$line['used']}')"); |
|
254 |
+ } |
|
255 |
+ } |
|
256 |
+ |
|
245 | 257 |
return true; |
246 | 258 |
} |
247 | 259 |
|
... | ... |
@@ -26,11 +26,23 @@ else |
26 | 26 |
$quota = array(); |
27 | 27 |
foreach ($usedquota as $q) |
28 | 28 |
{ |
29 |
- $percent = round(( $q["used"] / $q["quota"] ) * 100 ); |
|
29 |
+ $mailbar = ''; |
|
30 |
+ $mailstring = ''; |
|
31 |
+ $mailpercent = round(( $q['mailquota'] / $q["systemquota"]) * 100); |
|
32 |
+ $mailwidth = 2 * min($mailpercent, 100); |
|
33 |
+ |
|
34 |
+ if ($q["mailquota"] > 0) { |
|
35 |
+ $mailstring = "<br />(davon {$q["mailquota"]} MB für Postfächer reserviert)"; |
|
36 |
+ $mailbar = "<div style=\"font-size: 1px; background-color: blue; height: 10px; width: {$mailwidth}px; margin: 0; padding: 0; float: left;\"> </div>"; |
|
37 |
+ } |
|
38 |
+ |
|
39 |
+ $percent = round(( ($q["systemquota_used"]+$q["mailquota"]) / $q["systemquota"] ) * 100 ); |
|
30 | 40 |
$color = ( $percent > 99 ? 'red' : ($percent > 80 ? "yellow" : "green" )); |
31 |
- $width = 2 * min($percent, 100); |
|
32 |
- $quota[] = "<p>Server <strong>{$q['server']}</strong><br />{$percent}%: {$q['used']} MB von {$q['quota']} MB belegt.</p> |
|
33 |
- <div style=\"margin: 0; padding: 0; width: 200px; border: 1px solid black;\"><div style=\"font-size: 1px; background-color: {$color}; height: 10px; width: {$width}px; margin: 0; padding: 0;\"> </div></div>"; |
|
41 |
+ $width = 2 * min($percent, 100) - $mailwidth; |
|
42 |
+ |
|
43 |
+ $used_space = $q['systemquota_used'] + $q['mailquota']; |
|
44 |
+ $quota[] = "<p>Server <strong>{$q['server']}</strong><br />{$percent}%: {$used_space} MB von {$q['systemquota']} MB belegt{$mailstring}.</p> |
|
45 |
+ <div style=\"margin: 0; padding: 0; width: 200px; border: 1px solid black;\">{$mailbar}<div style=\"font-size: 1px; background-color: {$color}; height: 10px; width: {$width}px; margin: 0; margin-left: {$mailwidth}px; padding: 0;\"> </div></div>"; |
|
34 | 46 |
|
35 | 47 |
} |
36 | 48 |
$realname = $acc['name'] ? $acc['name'] : $_SESSION['customerinfo']['name']; |
... | ... |
@@ -73,7 +73,7 @@ function get_account_details($uid, $customerno=0) |
73 | 73 |
function get_used_quota($uid) |
74 | 74 |
{ |
75 | 75 |
$uid = (int) $uid; |
76 |
- $result = db_query("SELECT s.hostname AS server, used, COALESCE(us.quota, u.quota) AS quota FROM system.usedquota AS uq LEFT JOIN system.useraccounts AS u USING (uid) LEFT JOIN system.servers AS s ON (s.id=uq.server) LEFT JOIN system.user_server AS us ON (us.uid=uq.uid AND us.server=uq.server) WHERE uq.uid='{$uid}'"); |
|
76 |
+ $result = db_query("SELECT s.hostname AS server, systemquota, systemquota_used, mailquota, mailquota_used FROM system.v_quota AS q LEFT JOIN system.servers AS s ON (s.id=q.server) WHERE uid='{$uid}'"); |
|
77 | 77 |
$ret = array(); |
78 | 78 |
while ($line = mysql_fetch_assoc($result)) |
79 | 79 |
$ret[] = $line; |
80 | 80 |