mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
Fixed ics invitations sending with correct participants calendar
This commit is contained in:
parent
75bd5bea91
commit
0ee71cffc4
@ -98,7 +98,7 @@
|
||||
<td colspan="3"><input type="text" name="ansprechpartner" id="ansprechpartner" size="40">[LINKANSPRECHPARTNER]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{|Verantwortlicher intern|}:</td>
|
||||
<td>{|Verantwortlicher intern*|}:</td>
|
||||
<td colspan="3"><input type="text" name="adresseintern" id="adresseintern" size="40"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -148,7 +148,7 @@
|
||||
<legend> </legend>
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td valign="top">{|Personen|}:</td>
|
||||
<td valign="top">{|Teilnehmer intern*|}:</td>
|
||||
<td colspan="3">
|
||||
<select name="personen[]" id="personen" style="width: 250px" multiple>
|
||||
[PERSONEN]
|
||||
|
@ -595,9 +595,6 @@ class Kalender {
|
||||
$this->app->ExitXentral();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function KalenderData()
|
||||
{
|
||||
$user = $this->app->User->GetID();
|
||||
@ -971,14 +968,12 @@ class Kalender {
|
||||
$this->app->ExitXentral();
|
||||
}
|
||||
|
||||
function KalenderEventData()
|
||||
{
|
||||
$event = $this->app->Secure->GetGET("id");
|
||||
$cmd = $this->app->Secure->GetGET("cmd");
|
||||
header('Content-type: application/json');
|
||||
switch($cmd) {
|
||||
case "getEinladung": // Ajax to prepare the pop up for invitation mask
|
||||
|
||||
/*
|
||||
* Retrieve the participants and the organizer of an event
|
||||
* Result structure 2-dimensional array of name,email
|
||||
* The first entry is the organizer and can reoccurr as participant
|
||||
*/
|
||||
function KalenderGetParticipants($event) {
|
||||
/*
|
||||
*
|
||||
* Organizer:
|
||||
@ -1012,7 +1007,10 @@ class Kalender {
|
||||
}
|
||||
|
||||
// Add Organizer
|
||||
$ret['einladungcc'] = $ret['einladungcc'].$organizer_to_name." <".$organizer_to.">";
|
||||
$organizer = array();
|
||||
$organizer['name'] = $organizer_to_name;
|
||||
$organizer['email'] = $organizer_to;
|
||||
$ret[] = $organizer;
|
||||
|
||||
$address = $data['adresse'];
|
||||
$recipient_to = "";
|
||||
@ -1034,19 +1032,16 @@ class Kalender {
|
||||
}
|
||||
}
|
||||
|
||||
$vorlage = $this->app->erp->Geschaeftsbriefvorlage($sprache, "EinladungKalender", $projekt);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$vorlage['betreff'] = str_replace('{' . strtoupper($key) . '}', $value, $vorlage['betreff']);
|
||||
$vorlage['text'] = str_replace('{' . strtoupper($key) . '}', $value, $vorlage['text']);
|
||||
}
|
||||
|
||||
// Add primary recipient
|
||||
$recipient = array();
|
||||
if ($recipient_to != "") {
|
||||
if ($recipient_to_name == "") {
|
||||
$recipient_to_name = $recipient_to;
|
||||
}
|
||||
$ret['einladungcc'] = $ret['einladungcc'].", ".$recipient_to_name." <".$recipient_to.">";
|
||||
|
||||
$recipient['name'] = $recipient_to_name;
|
||||
$recipient['email'] = $recipient_to;
|
||||
$ret[] = $recipient;
|
||||
}
|
||||
|
||||
// jetzt holen wir alle Email-Adressen
|
||||
@ -1060,13 +1055,47 @@ class Kalender {
|
||||
}
|
||||
}
|
||||
|
||||
$emailadressen = $this->app->DB->SelectArr("SELECT id, name, email FROM adresse WHERE email != '' AND id IN (" . implode(",", $emailadressenlist) . ") AND geloescht!='1' AND email != '$recipient_to' AND email != '$organizer_to'");
|
||||
$emailadressen = $this->app->DB->SelectArr("SELECT name, email FROM adresse WHERE email != '' AND id IN (" . implode(",", $emailadressenlist) . ") AND geloescht!='1' AND email != '$recipient_to'");
|
||||
|
||||
if (!empty($emailadressen)) {
|
||||
$ret = array_merge($ret, $emailadressen);
|
||||
}
|
||||
return($ret);
|
||||
}
|
||||
|
||||
function KalenderEventData()
|
||||
{
|
||||
$event = $this->app->Secure->GetGET("id");
|
||||
$cmd = $this->app->Secure->GetGET("cmd");
|
||||
header('Content-type: application/json');
|
||||
switch($cmd) {
|
||||
case "getEinladung": // Ajax to prepare the pop up for invitation mask
|
||||
|
||||
$emailadressen = $this->KalenderGetParticipants($event);
|
||||
$comma = "";
|
||||
|
||||
// Remove organizer
|
||||
if (count($emailadressen) > 1) {
|
||||
unset($emailadressen[0]);
|
||||
}
|
||||
|
||||
foreach ($emailadressen as $email) {
|
||||
if ($email['name'] != "")
|
||||
$ret['einladungcc'] .= ", ".$email['name'] . " <" . $email['email'] . ">";
|
||||
$ret['einladungcc'] .= $comma.$email['name'] . " <" . $email['email'] . ">";
|
||||
else
|
||||
$ret['einladungcc'] .= ", ".$email['email'] . ",";
|
||||
$ret['einladungcc'] .= $comma.$email['email'];
|
||||
$comma = ", ";
|
||||
}
|
||||
|
||||
$data = $this->app->DB->SelectRow("SELECT k.adresse, k.ansprechpartner_id, k.adresseintern, IFNULL(a.sprache,''),k.projekt,k.bezeichnung,k.beschreibung,k.ort,
|
||||
DATE_FORMAT(k.von,'%d.%m.%Y %H:%i') as von, DATE_FORMAT(k.bis,'%d.%m.%Y %H:%i') as bis
|
||||
FROM kalender_event k LEFT JOIN adresse a ON a.id=k.adresse WHERE k.id='" . $event . "' LIMIT 1");
|
||||
|
||||
$vorlage = $this->app->erp->Geschaeftsbriefvorlage($sprache, "EinladungKalender", $projekt);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$vorlage['betreff'] = str_replace('{' . strtoupper($key) . '}', $value, $vorlage['betreff']);
|
||||
$vorlage['text'] = str_replace('{' . strtoupper($key) . '}', $value, $vorlage['text']);
|
||||
}
|
||||
|
||||
$ret['betreff'] = $vorlage['betreff'];
|
||||
@ -1087,7 +1116,7 @@ class Kalender {
|
||||
$ret['status'] = 0;
|
||||
$ret['statusText'] = "Bitte mindestens einen Empfänger angeben!";
|
||||
}
|
||||
else if($this->KalenderMail($id,$betreff,$text,$emailcc))
|
||||
else if($this->KalenderMailNew($id,$betreff,$text,$emailcc))
|
||||
{
|
||||
$ret['status'] = 1;
|
||||
$ret['statusText'] = "Einladung wurde per Mail versendet.";
|
||||
@ -1272,9 +1301,153 @@ class Kalender {
|
||||
}
|
||||
|
||||
/*
|
||||
* Pick participants and create invitation mail
|
||||
* Create invitation mail
|
||||
* All (!) E-mail recipients are in $recipients, participants for ICS are in the event
|
||||
* Use new sendmail with multiple recipients
|
||||
*/
|
||||
public function KalenderMailNew($event,$betreff='',$text='',$recipients)
|
||||
{
|
||||
|
||||
$arraufgabe = $this->app->DB->SelectArr("SELECT *,DATE_FORMAT(von,'%d.%m.%Y') as datum,
|
||||
DATE_FORMAT(bis,'%d.%m.%Y') as datumbis,
|
||||
DATE_FORMAT(von,'%Y%m%d') as icaldatumvon,
|
||||
DATE_FORMAT(bis,'%Y%m%d') as icaldatumbis, DATE_FORMAT(von,'%H%i00') as icaluhrzeitvon, DATE_FORMAT(bis,'%H%i00') as icaluhrzeitbis,
|
||||
DATE_FORMAT(von,'%H:%i') as zeit,
|
||||
DATE_FORMAT(bis,'%H:%i') as zeitbis
|
||||
FROM kalender_event WHERE id='$event' LIMIT 1");
|
||||
|
||||
if($betreff=="")
|
||||
$betreff = "Einladung für Termin ".$arraufgabe[0]["bezeichnung"];
|
||||
|
||||
if($text=="")
|
||||
{
|
||||
if($arraufgabe[0]["datumbis"]!="00.00.0000" && $arraufgabe[0]["datum"]!=$arraufgabe[0]["datumbis"])
|
||||
{
|
||||
$text = "Datum: ".$arraufgabe[0]["datum"]." bis ".$arraufgabe[0]["datumbis"];//Hallo hier die mail";
|
||||
}
|
||||
else {
|
||||
if($arraufgabe[0]["zeit"]!="00:00" && $arraufgabe[0]["zeitbis"]!="00:00")
|
||||
$text = "Datum: ".$arraufgabe[0]["datum"]." von ".$arraufgabe[0]["zeit"]." bis ".$arraufgabe[0]["zeitbis"];//Hallo hier die mail";
|
||||
else if($arraufgabe[0]["zeit"]!="00:00")
|
||||
$text = "Datum: ".$arraufgabe[0]["datum"]." um ".$arraufgabe[0]["zeit"];
|
||||
else
|
||||
$text = "Datum: ".$arraufgabe[0]["datum"];
|
||||
}
|
||||
} else {
|
||||
$text .= "\r\n";
|
||||
}
|
||||
$text .= "\r\n";
|
||||
|
||||
$beschreibung = $arraufgabe[0]["bezeichnung"];
|
||||
|
||||
$venue = $arraufgabe[0]["ort"];
|
||||
$start = $arraufgabe[0]["icaldatumvon"];
|
||||
$start_time = $arraufgabe[0]["icaluhrzeitvon"];
|
||||
$end = $arraufgabe[0]["icaldatumbis"];
|
||||
$end_time = $arraufgabe[0]["icaluhrzeitbis"];
|
||||
|
||||
$status = 'TENTATIVE';
|
||||
$sequence = 0;
|
||||
|
||||
$event_id = $event;
|
||||
|
||||
$ical = "BEGIN:VCALENDAR\r\n";
|
||||
$ical .= "VERSION:2.0\r\n";
|
||||
$ical .= "PRODID:-//Xenomporio//Termin//DE\r\n";
|
||||
$ical .= "METHOD:REQUEST\r\n";
|
||||
$ical .= "BEGIN:VEVENT\r\n";
|
||||
|
||||
// Add participants
|
||||
$participants = $this->KalenderGetParticipants($event);
|
||||
// The first one is the organizer
|
||||
|
||||
$organizer_name = $participants[0]['name'];
|
||||
$organizer_email = $participants[0]['email'];
|
||||
$ical .= "ORGANIZER;CN=$organizer_name:mailto:$organizer_email\r\n";
|
||||
|
||||
if (count($participants) > 1) {
|
||||
|
||||
unset($participants[0]);
|
||||
|
||||
foreach($participants as $participant) {
|
||||
$participant_name = $participant['name'];
|
||||
$participant_email = $participant['email'];
|
||||
$ical .= "ATTENDEE;CN=$participant_name;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE:mailto:$participant_email\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$ical .= "UID:".strtoupper(md5($event_id))."-xenomporio\r\n";
|
||||
$ical .= "SEQUENCE:".$sequence."\r\n";
|
||||
$ical .= "STATUS:".$status."\r\n";
|
||||
$ical .= "DTSTAMPTZID=Europe/Berlin:".date('Ymd').'T'.date('His')."\r\n";
|
||||
$ical .= "DTSTART:".$start."T".$start_time."\r\n";
|
||||
$ical .= "DTEND:".$end."T".$end_time."\r\n";
|
||||
$ical .= "LOCATION:".$venue."\r\n";
|
||||
$ical .= "SUMMARY:".$beschreibung."\r\n";
|
||||
$ical .= "BEGIN:VALARM\r\n";
|
||||
$ical .= "TRIGGER:-PT15M\r\n";
|
||||
$ical .= "ACTION:DISPLAY\r\n";
|
||||
$ical .= "DESCRIPTION:Reminder\r\n";
|
||||
$ical .= "END:VALARM\r\n";
|
||||
$ical .= "END:VEVENT\r\n";
|
||||
$ical .= "END:VCALENDAR\r\n";
|
||||
|
||||
$datei = $this->app->erp->GetTMP().'Einladung_'.$beschreibung.'_'.$arraufgabe[0]["datum"].".ics";
|
||||
file_put_contents($datei,$ical);
|
||||
if($start!='00000000'){
|
||||
$dateien = array($datei);
|
||||
}
|
||||
else{
|
||||
$dateien = '';
|
||||
}
|
||||
|
||||
$bcc = array();
|
||||
|
||||
if($recipients!='')
|
||||
{
|
||||
//$to="";
|
||||
//$to_name="";
|
||||
|
||||
$parts = explode(',',$recipients);
|
||||
$cparts = (!empty($parts)?count($parts):0);
|
||||
for($i=0;$i<$cparts;$i++)
|
||||
{
|
||||
$from = strstr($parts[$i], '<', true); // Ab PHP 5.3.0
|
||||
$email = strstr($parts[$i], '<'); // Ab PHP 5.3.0
|
||||
if($from !="" )
|
||||
{
|
||||
$email = str_replace(['<','>'],'',$email);
|
||||
} else {
|
||||
$email = $parts[$i];
|
||||
}
|
||||
|
||||
if($i==0)
|
||||
{
|
||||
if($to==""){
|
||||
$to = $email;
|
||||
$to_name = $from;
|
||||
}
|
||||
} else {
|
||||
if($email!=$to)
|
||||
{
|
||||
if($from=="") $bcc[]=$email;
|
||||
else $bcc[]=$email;//$from." <".$email.">";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->app->erp->MailSend($this->app->erp->GetFirmaMail(),$this->app->erp->GetFirmaAbsender(),$to,$to_name,$betreff,$text,$dateien,"",false,$bcc);
|
||||
|
||||
unlink($datei);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Original version
|
||||
*/
|
||||
|
||||
public function KalenderMail($event,$betreff='',$text='',$emailcc='')
|
||||
{
|
||||
$datum = '';
|
||||
@ -1343,8 +1516,8 @@ class Kalender {
|
||||
$ical .= "PRODID:-//Xenomporio//Termin//DE\r\n";
|
||||
$ical .= "METHOD:REQUEST\r\n";
|
||||
$ical .= "BEGIN:VEVENT\r\n";
|
||||
$ical .= "ORGANIZER;CN=$initiator_to_name:MAILTO:$initiator_to\"\r\n";
|
||||
$ical .= "ATTENDEE;CN=$to_name:MAILTO:$to;RSVP=TRUE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION\r\n";
|
||||
$ical .= "ORGANIZER;SENT-BY=\"MAILTO:$initiator_to\"\r\n";
|
||||
$ical .= "ATTENDEE;CN=$to;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE:mailto:$initiator_to\r\n";
|
||||
$ical .= "UID:".strtoupper(md5($event_id))."-xenomporio\r\n";
|
||||
$ical .= "SEQUENCE:".$sequence."\r\n";
|
||||
$ical .= "STATUS:".$status."\r\n";
|
||||
|
Loading…
Reference in New Issue
Block a user