bernd commited on 2012-03-05 14:58:37
Zeige 3 geänderte Dateien mit 48 Einfügungen und 19 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2218 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -2,6 +2,7 @@ |
2 | 2 |
|
3 | 3 |
require_once('inc/debug.php'); |
4 | 4 |
require_once('inc/security.php'); |
5 |
+require_once('inc/icons.php'); |
|
5 | 6 |
|
6 | 7 |
require_once('vmail.php'); |
7 | 8 |
|
... | ... |
@@ -44,10 +45,16 @@ $numforwards = max(count($account['forwards']), 1); |
44 | 45 |
output("<script type=\"text/javascript\"> |
45 | 46 |
|
46 | 47 |
var numForwards = {$numforwards}; |
48 |
+ var forwardsCounter = {$numforwards}; |
|
47 | 49 |
|
48 | 50 |
function moreForward() |
49 | 51 |
{ |
50 | 52 |
numForwards += 1; |
53 |
+ forwardsCounter += 1; |
|
54 |
+ |
|
55 |
+ if ( document.getElementById('vmail_forward_' + forwardsCounter) ) { |
|
56 |
+ document.getElementById('vmail_forward_' + forwardsCounter).style.display = '' |
|
57 |
+ } |
|
51 | 58 |
|
52 | 59 |
P1 = document.createElement('p'); |
53 | 60 |
|
... | ... |
@@ -55,7 +62,8 @@ output("<script type=\"text/javascript\"> |
55 | 62 |
|
56 | 63 |
INPUT = document.createElement('input'); |
57 | 64 |
INPUT.type = 'text'; |
58 |
- INPUT.name = 'forward_to_' + numForwards; |
|
65 |
+ INPUT.name = 'forward_to_' + forwardsCounter; |
|
66 |
+ INPUT.id = 'forward_to_' + forwardsCounter; |
|
59 | 67 |
INPUT.value = ''; |
60 | 68 |
|
61 | 69 |
P1.appendChild(TXT1); |
... | ... |
@@ -66,7 +74,8 @@ output("<script type=\"text/javascript\"> |
66 | 74 |
TXT2 = document.createTextNode('Spam-Mails an diese Adresse '); |
67 | 75 |
|
68 | 76 |
SELECT = document.createElement('select'); |
69 |
- SELECT.name = 'spamfilter_action_' + numForwards; |
|
77 |
+ SELECT.id = 'spamfilter_action_' + forwardsCounter; |
|
78 |
+ SELECT.name = 'spamfilter_action_' + forwardsCounter; |
|
70 | 79 |
|
71 | 80 |
SELECT.options[0] = new Option('nicht filtern', 'none', 1); |
72 | 81 |
SELECT.options[1] = new Option('markieren und zustellen', 'tag', 0); |
... | ... |
@@ -77,14 +86,35 @@ output("<script type=\"text/javascript\"> |
77 | 86 |
|
78 | 87 |
DIV = document.createElement('div'); |
79 | 88 |
DIV.className = 'vmail-forward'; |
89 |
+ DIV.id = 'vmail_forward_' + forwardsCounter; |
|
80 | 90 |
|
91 |
+ DELETE = document.getElementById('vmail_forward_1').getElementsByTagName('div')[0].cloneNode(true); |
|
92 |
+ |
|
93 |
+ DIV.appendChild(DELETE); |
|
81 | 94 |
DIV.appendChild(P1); |
82 | 95 |
DIV.appendChild(P2); |
83 | 96 |
|
84 |
- parent = document.getElementById('forward_config'); |
|
97 |
+ parent = document.getElementById('forward_entries'); |
|
85 | 98 |
parent.appendChild(DIV); |
86 | 99 |
} |
87 | 100 |
|
101 |
+ function removeForward(elem) |
|
102 |
+ { |
|
103 |
+ div_id = elem.parentNode.parentNode.id; |
|
104 |
+ div = document.getElementById(div_id); |
|
105 |
+ input = div.getElementsByTagName('input')[0]; |
|
106 |
+ input.value = ''; |
|
107 |
+ select = div.getElementsByTagName('select')[0]; |
|
108 |
+ select.options[0].selected = 'selected'; |
|
109 |
+ if (numForwards >= 1) { |
|
110 |
+ numForwards -= 1; |
|
111 |
+ } |
|
112 |
+ if (numForwards >= 1) { |
|
113 |
+ div.style.display = 'none'; |
|
114 |
+ document.getElementById('forward_entries').removeChild(div); |
|
115 |
+ } |
|
116 |
+ } |
|
117 |
+ |
|
88 | 118 |
function toggleDisplay(checkbox_id, item_id) |
89 | 119 |
{ |
90 | 120 |
if (document.getElementById(checkbox_id).checked == true) { |
... | ... |
@@ -216,26 +246,23 @@ $form .= "<p><input onchange=\"toggleDisplay('forward', 'forward_config')\" type |
216 | 246 |
|
217 | 247 |
$form .= "<div style=\"margin-left: 2em;".($is_forward ? '' : ' display: none;')."\" id=\"forward_config\">"; |
218 | 248 |
|
219 |
-if ($is_forward) |
|
220 |
-{ |
|
249 |
+$form .= '<div id="forward_entries"> |
|
250 |
+'; |
|
251 |
+if (! isset($account['forwards'][0])) { |
|
252 |
+ $account['forwards'][0] = array('destination' => '', 'spamfilter' => 'none'); |
|
253 |
+} |
|
221 | 254 |
for ($i = 0 ; $i < $numforwards ; $i++) |
222 | 255 |
{ |
223 | 256 |
$num = $i+1; |
224 |
- $form .= "<div class=\"vmail-forward\"> |
|
257 |
+ $form .= "<div class=\"vmail-forward\" id=\"vmail_forward_{$num}\"> |
|
258 |
+ <div style=\"float: right;\"><a href=\"#\" onclick=\"removeForward(this);\">".icon_delete("Diese Weiterleitung entfernen")."</a></div> |
|
225 | 259 |
<p>Weiterleiten an <input type=\"text\" id=\"forward_to_{$num}\" name=\"forward_to_{$num}\" value=\"{$account['forwards'][$i]['destination']}\" /></p> |
226 | 260 |
<p>Spam-Mails an diese Adresse ".html_select('spamfilter_action_'.$num, array("none" => 'nicht filtern', "tag" => 'markieren und zustellen', "delete" => 'nicht zustellen'), $account['forwards'][$i]['spamfilter'])."</p> |
227 | 261 |
</div>\n"; |
228 | 262 |
} |
229 |
-} |
|
230 |
-else |
|
231 |
-{ |
|
232 |
- $form .= "<div class=\"vmail-forward\"> |
|
233 |
- <p>Weiterleiten an <input type=\"text\" id=\"forward_to_1\" name=\"forward_to_1\" value=\"\" /></p> |
|
234 |
- <p>Spam-Mails an diese Adresse ".html_select('spamfilter_action_1', array("none" => 'nicht filtern', "tag" => 'markieren und zustellen', "delete" => 'nicht zustellen'), "none")."</p> |
|
235 |
- </div>\n"; |
|
236 |
-} |
|
263 |
+$form .= '</div>'; |
|
237 | 264 |
|
238 |
-$form .= '<p>[ <a href="#" onclick="moreForward();">mehr Empfänger</a> ]</p> |
|
265 |
+$form .= '<p><a href="#" onclick="moreForward();">'.icon_add().' Weiteren Empfänger hinzufügen</a></p> |
|
239 | 266 |
</div>'; |
240 | 267 |
|
241 | 268 |
$form .= '<p><input type="submit" value="Speichern" />    '.internal_link('vmail', 'Abbrechen').'</p>'; |
... | ... |
@@ -136,15 +136,16 @@ if ($_GET['action'] == 'edit') |
136 | 136 |
$num = 1; |
137 | 137 |
while (true) |
138 | 138 |
{ |
139 |
- if (! isset($_POST['forward_to_'.$num])) |
|
140 |
- break; |
|
141 |
- if ($_POST['forward_to_'.$num] == '') |
|
139 |
+ // Die ersten 50 Einträge in jedem Fall prüfen, danach nur so lange zusätzliche Einträge vorhanden |
|
140 |
+ if (! isset($_POST['forward_to_'.$num]) && ! isset($_POST['spamfilter_action_'.$num]) && $num > 50) |
|
142 | 141 |
break; |
142 |
+ if (isset($_POST['forward_to_'.$num]) && chop($_POST['forward_to_'.$num]) != '') { |
|
143 | 143 |
$fwd = array("spamfilter" => $_POST['spamfilter_action_'.$num], "destination" => chop($_POST['forward_to_'.$num])); |
144 | 144 |
array_push($account['forwards'], $fwd); |
145 |
+ } |
|
145 | 146 |
$num++; |
146 | 147 |
} |
147 |
- if ($num == 1) system_failure("Bitte mindestens eine Weiterleitungsadresse angeben."); |
|
148 |
+ if (count($account['forwards']) == 0) system_failure("Bitte mindestens eine Weiterleitungsadresse angeben."); |
|
148 | 149 |
} |
149 | 150 |
|
150 | 151 |
if ((isset($_POST['forward']) && $_POST['forward']!='yes') && ($_POST['mailbox']!='yes')) |