From 1f2a3b559bd8241458ff686b8112f9036f43da7e Mon Sep 17 00:00:00 2001 From: aschwarz Date: Mon, 22 May 2023 09:34:30 +0200 Subject: [PATCH] =?UTF-8?q?Empf=C3=A4ngerliste=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/admin_phpmailer.php | 61 ++++++-------------------------- js/components/admin_phpmailer.js | 61 ++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/controller/admin_phpmailer.php b/controller/admin_phpmailer.php index c2cc2cf..52427d0 100644 --- a/controller/admin_phpmailer.php +++ b/controller/admin_phpmailer.php @@ -15,58 +15,16 @@ $absender = get_parameter(2); $mailpwd = get_parameter(3); -$empfaenger = $_POST['empfaenger']; -# $empfaenger = "S-1"; + +$empfaenger = $_POST['mailhidden']; $mail_bcc = array(); - -for ($i = 0; $i < sizeof($empfaenger); $i++) { - $trenner = explode("-", $empfaenger[$i]); - - - if ($trenner[0] == 'S') { - $query = "select mail - from jumi_admin a, jumi_admin_rollen_user_zuord b - where a.uid=b.uid - and b.rid=$trenner[1]"; - - $result = $db->query($query) or die("Cannot execute query"); - - while ($row = $result->fetch_array()) { - array_push($mail_bcc, "$row[mail]"); - } - } - - if ($trenner[0] == 'C') { - $query1 = "select mail - from jumi_chor_saenger"; - - $result1 = $db->query($query1) or die("Cannot execute query1"); - - while ($row1 = $result1->fetch_array()) { - array_push($mail_bcc, "$row1[mail]"); - } - } - - if ($trenner[0] == 'V') { - $query2 = "select mail - from jumi_mailverteiler a, jumi_mailverteiler_entries b, jumi_mailverteiler_user_zuord c - where a.mvid=c.mvid - and b.mveid=c.mveid - and c.mvid=$trenner[1]"; - - $result2 = $db->query($query2) or die("Cannot execute query2"); - - while ($row2 = $result2->fetch_array()) { - array_push($mail_bcc, "$row2[mail]"); - } - } +$mail_bccplain = explode("|", $empfaenger); +foreach($mail_bccplain as $mail_empfaenger) { + $mail_empfaenger = trim($mail_empfaenger); + array_push($mail_bcc, "$mail_empfaenger"); } - - - -# Doppelte Mailadressen entfernen. Fall jemand in mehreren Gruppen aktiv ist. -$mail_bcc = array_unique($mail_bcc); - +# doppelte und leere Arrays löschen +$mail_bcc = array_filter(array_unique($mail_bcc)); $mail = new PHPMailer(); @@ -123,6 +81,7 @@ catch (Exception $e) { exit; } + } if ($function == 'showmail') { @@ -188,4 +147,6 @@ $mail_bcc = array_unique($mail_bcc); echo $out; #echo "Mailadressen"; } + + ?> \ No newline at end of file diff --git a/js/components/admin_phpmailer.js b/js/components/admin_phpmailer.js index 868cd14..bfb419c 100644 --- a/js/components/admin_phpmailer.js +++ b/js/components/admin_phpmailer.js @@ -16,6 +16,7 @@ cache: false, processData:false, success: function(result){ +//alert(result); if(result!=''){ var a = result.split('|***|'); if(a[1]=="success"){ @@ -112,14 +113,15 @@ function showmail(){ result_array[i] = result_array[i].replace(/^\s*/, "").replace(/\s*$/, ""); // Add additional code here, such as: var name_array = result_array[i].split('|'); - //name += name_array[i][0] +"->"+ name_array[i][1]+","; - name += name_array[0]+", "; - mail += name_array[1]+", "; - komplett += name_array[0]+"|"+name_array[1]+", "; + name += name_array[0]+", "; + mail += name_array[1]+"|"; + komplett += name_array[0]+"|"+name_array[1]+","; } name = name.substring(0,name.length-2); - mail = mail.substring(0,mail.length-2); - komplett = komplett.substring(0,komplett.length-2); + //mail = mail.substring(0,mail.length-1); + + // auskommentiert, das letzte Komma wird beim deleteContact benötigt: komplett_neu = komplett_neu.replace(contact+',' , ''); + //komplett = komplett.substring(0,komplett.length-1); $('#empf').html(name); document.getElementById("mailhidden").value = mail; document.getElementById("komplett").value = komplett; @@ -133,9 +135,46 @@ function showmail(){ } -function test(){ - //komma getrennte Werte bei Mehrfachauswahl -alert('hier'); - $('#empf').html('klappt'); +function deleteContact(contact){ -} \ No newline at end of file + //komma getrennte Werte bei Mehrfachauswahl + var komplett_neu = document.getElementById("komplett").value; + komplett_neu = komplett_neu.replace(contact+',' , ''); + + //letztes Komma entfernen, damit die For Schleife nicht einmal zu viel durchläuft + komplett_neu = komplett_neu.substring(0,komplett_neu.length-1); + + if(komplett_neu != ''){ + var name = ""; + var mail = ""; + var komplett = ""; + var komplett_neu_array = komplett_neu.split(','); + //Alexander2 Schwarz2|alexander@ja-schwarz.de,Alexander3 Schwarz3|technik@ju-and-mi.de, + + + for(var i = 0; i < komplett_neu_array.length; i++) { + + // Trim the excess whitespace. + komplett_neu_array[i] = komplett_neu_array[i].replace(/^\s*/, "").replace(/\s*$/, ""); + // Add additional code here, such as: + var name_array = komplett_neu_array[i].split('|'); + //name += name_array[i][0] +"->"+ name_array[i][1]+","; + name += name_array[0]+", "; + mail += name_array[1]+"|"; + komplett += name_array[0]+"|"+name_array[1]+","; + } + name = name.substring(0,name.length-2); + //mail = mail.substring(0,mail.length-1); + + // auskommentiert, das letzte Komma wird beim deleteContact benötigt: komplett_neu = komplett_neu.replace(contact+',' , ''); + //komplett = komplett.substring(0,komplett.length-1); + $('#empf').html(name); + document.getElementById("mailhidden").value = mail; + document.getElementById("komplett").value = komplett; + }else{ + $('.selectpicker').selectpicker('deselectAll'); + $('#empf').html(''); + document.getElementById("mailhidden").value = ''; + document.getElementById("komplett").value = ''; + } +}