+ } 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()) {
+ $allow = true;
+ break;
+ }
+ }
+
+ if($allow && isset($this->emails[$del_id])) {
+ list($count) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM actions "
+ ."WHERE uid='{$this->uid}' AND pid='"
+ .FwdPlugin::rtti()."' AND data='$del_id'"));
+ if($count) {
+ $philter->set_error("This email is still in use and can't be deleted !");
+ return false;
+ } else {
+ mysql_query("DELETE FROM emails WHERE uid='{$this->uid}' "
+ ."AND email='{$this->emails[$del_id]->email}'");
+ unset($this->emails[$del_id]);
+ }
+ } else {
+ $philter->set_error("you must have at least one active email !");
+ return false;
+ }