IE bugfixes, js simplification
[old-projects.git] / philter / philter / include / emails.inc.php
index 15935eb..4ef2277 100644 (file)
@@ -112,15 +112,15 @@ class EmailPool {
                 .   "<td align=\"center\" width=\"10%\">\n"
                 .   "    <input type=\"checkbox\" name=\"emails[$id][active]\""
                 .   ($email->is_active() ? " checked=\"checked\"" : "")." /></td>\n"
-                .   "<td align=\"center\"><input type=\"button\" name=\"d$id\" "
-                .   "value=\"Del\" onclick=\"del_onclick(this)\" /></td>\n"
+                .   "<td align=\"center\"><input type=\"button\" "
+                .   "value=\"Del\" onclick=\"del_onclick($id)\" /></td>\n"
                 .   "</tr>\n";
             $pair = !$pair;
         }
 
         $res .= "</table>\n"
             .   "<center>\n"
-            .   "    <input id=\"emailsDel\" type=\"hidden\" name=\"emails[del]\" value=\"\" />\n"
+            .   "    <input id=\"emailsDel\" type=\"hidden\" name=\"emails[del]\" value=\"-1\" />\n"
             .   "    <input type=\"submit\" name=\"emails[apply]\" value=\"Apply changes\" />\n"
             .   "</center>\n"
             .   "</form>\n";
@@ -183,13 +183,17 @@ class EmailPool {
                 $philter->set_error($_POST['emails']['new']." is not a valid email");
                 return false;
             }
-        } elseif(!empty($_POST['emails']['del'])) {      // delete one email
+        } elseif(isset($_POST['emails']['del']) && $_POST['emails']['del'] != -1) {      // delete one email
             $del_id = $_POST['emails']['del'];
             // we compute a list of all actives emails
             $allow = false;
-            foreach($this->emails as $id=>$mail)
-                if($del_id!=$id && $mail->is_active())
+
+            foreach($this->emails as $id=>$mail) {
+                if($del_id!=$id && $mail->is_active()) {
                     $allow = true;
+                    break;
+                }
+            }
             
             if($allow && isset($this->emails[$del_id])) {
                 list($count) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM actions "