Quota-Threshold für Notification einstellbar
bernd

bernd commited on 2011-07-17 13:28:37
Zeige 3 geänderte Dateien mit 23 Einfügungen und 4 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2024 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -97,6 +97,9 @@ if ($is_mailbox and $account['quota']) {
97 97
 
98 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 abgezogen.</em></span></p>";
99 99
 
100
+$quota_notify = ($account['quota_threshold'] >= 0) ? ' checked="checked" ' : '';
101
+$quota_threshold = ($account['quota_threshold'] >= 0) ? $account['quota_threshold'] : '';
102
+$form .= "<p style=\"margin-left: 2em;\" class=\"quota_options\"><input type=\"checkbox\" id=\"quota_notify\" name=\"quota_notify\" value=\"1\" {$quota_notify} /><label for=\"quota_notify\">Benachrichtigung wenn weniger als</label> <input type=\"text\" name=\"quota_threshold\" id=\"quota_threshold\" value=\"{$quota_threshold}\" /> MB Speicherplatz zur Verfügung stehen.</p>";
100 103
 
101 104
 
102 105
 $form .= "<p><input type=\"checkbox\" id=\"forward\" name=\"forward\" value=\"yes\" ".($is_forward ? 'checked="checked" ' : '')." /><label for=\"forward\">&#160;<strong>Weiterleitung an andere E-Mail-Adressen</strong></label></p>";
... ...
@@ -16,6 +16,7 @@ function empty_account()
16 16
 		'spamfilter' => 'folder',
17 17
 		'spamexpire' => 7,
18 18
     'quota' => config('vmail_basequota'),
19
+    'quota_threshold' => 20,
19 20
 		'forwards' => array()
20 21
 		);
21 22
 	return $account;
... ...
@@ -27,7 +28,7 @@ function get_account_details($id, $checkuid = true)
27 28
 	$id = (int) $id;
28 29
 	$uid = (int) $_SESSION['userinfo']['uid'];
29 30
 	$uid_check = ($checkuid ? "useraccount='{$uid}' AND " : "");
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
+	$result = db_query("SELECT id, local, domain, password, spamfilter, forwards, server, quota, quota_used, quota_threshold from mail.v_vmail_accounts WHERE {$uid_check}id={$id} LIMIT 1");
31 32
 	if (mysql_num_rows($result) == 0)
32 33
 		system_failure('Ungültige ID oder kein eigener Account');
33 34
 	$acc = empty_account();
... ...
@@ -43,6 +44,9 @@ function get_account_details($id, $checkuid = true)
43 44
 	    array_push($acc['forwards'], array("id" => $item['id'], 'spamfilter' => $item['spamfilter'], 'destination' => $item['destination']));
44 45
 	  }
45 46
 	}
47
+  if ($acc['quota_threshold'] === NULL) {
48
+    $acc['quota_threshold'] = -1;
49
+  }
46 50
 	return $acc;
47 51
 }
48 52
 
... ...
@@ -226,6 +230,13 @@ function save_vmail_account($account)
226 230
   
227 231
   $account['quota'] = $newquota;
228 232
 
233
+  if ($account['quota_threshold'] == -1) {
234
+    $account['quota_threshold'] = 'NULL';
235
+  }
236
+  else {
237
+    $account['quota_threshold'] = min( (int) $account['quota_threshold'], (int) $account['quota'] );
238
+  }
239
+  
229 240
   $account['local'] = mysql_real_escape_string($account['local']);
230 241
   $account['password'] = mysql_real_escape_string($account['password']);
231 242
   $account['spamexpire'] = (int) $account['spamexpire'];
... ...
@@ -233,8 +244,8 @@ function save_vmail_account($account)
233 244
   $query = '';
234 245
   if ($id == NULL)
235 246
   {
236
-    $query = "INSERT INTO mail.vmail_accounts (local, domain, spamfilter, spamexpire, password, quota) VALUES ";
237
-    $query .= "('{$account['local']}', {$account['domain']}, {$spam}, {$account['spamexpire']}, {$password}, {$account['quota']});";
247
+    $query = "INSERT INTO mail.vmail_accounts (local, domain, spamfilter, spamexpire, password, quota, quota_threshold) VALUES ";
248
+    $query .= "('{$account['local']}', {$account['domain']}, {$spam}, {$account['spamexpire']}, {$password}, {$account['quota']}, {$account['quota_threshold']});";
238 249
   }
239 250
   else
240 251
   {
... ...
@@ -243,7 +254,7 @@ function save_vmail_account($account)
243 254
     else
244 255
       $password='';
245 256
     $query = "UPDATE mail.vmail_accounts SET local='{$account['local']}', domain={$account['domain']}{$password}, ";
246
-    $query .= "spamfilter={$spam}, spamexpire={$account['spamexpire']}, quota={$account['quota']} ";
257
+    $query .= "spamfilter={$spam}, spamexpire={$account['spamexpire']}, quota={$account['quota']}, quota_threshold={$account['quota_threshold']} ";
247 258
     $query .= "WHERE id={$id} LIMIT 1;";
248 259
   }
249 260
   db_query($query); 
... ...
@@ -36,6 +36,11 @@ if ($_GET['action'] == 'edit')
36 36
     $account['quota'] = $_POST['quota'];
37 37
   }
38 38
 
39
+  $account['quota_threshold'] = -1;
40
+  if (isset($_POST['quota_notify']) && isset($_POST['quota_threshold']) && $_POST['quota_notify'] == 1) {
41
+    $account['quota_threshold'] = $_POST['quota_threshold'];
42
+  }
43
+
39 44
   if (isset($_POST['forward']) && $_POST['forward'] == 'yes')
40 45
   {
41 46
     $num = 1;
42 47