Beispiel #1
0
 public function sendEmail($subject, $body, $recipientID, $parameters)
 {
     $emailData = $this->getEMailData($parameters);
     $parameters = explode("::", $parameters);
     $action = $parameters[0];
     $className = $parameters[1];
     $classID = $parameters[2];
     $time = $parameters[3];
     $C = new $className($classID);
     $data = $C->getCalendarDetails($className, $classID);
     $adresse = $data->getAdresse();
     $fromName = Session::currentUser()->A("name");
     $from = Session::currentUser()->A("UserEmail");
     $mail = new htmlMimeMail5();
     $mail->setFrom(utf8_decode($fromName . " <" . $from . ">"));
     if (!ini_get('safe_mode')) {
         $mail->setReturnPath($from);
     }
     $mail->setSubject(utf8_decode($subject));
     /*if($action == "reply"){
     			$ics = "BEGIN:VCALENDAR
     PRODID:-//lightCRM Kalender
     VERSION:2.0
     METHOD:REPLY
     BEGIN:VEVENT
     CREATED:20121130T004454Z
     LAST-MODIFIED:20121201T143509Z
     DTSTAMP:20121201T143509Z
     UID:7715ie5i20hvm0b71p18vhgj70@google.com
     SUMMARY:Test
     STATUS:CONFIRMED
     ORGANIZER;CN=rainer.furtmeier@googlemail.com:mailto:rainer.furtmeier@googl
      email.com
     ATTENDEE;CN=nemi@2sins.de;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;ROLE=REQ-PAR
      TICIPANT;X-NUM-GUESTS=0:mailto:nemi@2sins.de
     DTSTART:20121206T123000Z
     DTEND:20121206T133000Z
     DESCRIPTION:
     SEQUENCE:5
     TRANSP:OPAQUE
     END:VEVENT
     END:VCALENDAR";
     		}*/
     if ($action == "notification") {
         $ics = "BEGIN:VCALENDAR\nPRODID:-//lightCRM Kalender\nVERSION:2.0\nMETHOD:REQUEST\nBEGIN:VTIMEZONE\nTZID:Europe/Berlin\nX-LIC-LOCATION:Europe/Berlin\nBEGIN:DAYLIGHT\nTZOFFSETFROM:+0100\nTZOFFSETTO:+0200\nTZNAME:CEST\nDTSTART:19700329T020000\nRRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\nEND:DAYLIGHT\nBEGIN:STANDARD\nTZOFFSETFROM:+0200\nTZOFFSETTO:+0100\nTZNAME:CET\nDTSTART:19701025T030000\nRRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nLAST-MODIFIED:20120629T094018Z\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "\nUID:" . $data->UID() . "\nSUMMARY:" . $data->summary() . "\nORGANIZER;CN=\"{$fromName}\":MAILTO:{$from}\nDTSTART;TZID=Europe/Berlin:" . date("Ymd", Kalender::parseDay($data->getDay())) . "T" . $data->getTime() . "00\nDTEND;TZID=Europe/Berlin:" . date("Ymd", Kalender::parseDay($data->getEndDay())) . "T" . $data->getEndTime() . "00\nEND:VEVENT\nEND:VCALENDAR";
     }
     $mail->addAttachment(new stringAttachment($ics, "event.ics", 'application/ics'));
     $adresse->replaceByAnsprechpartner($recipientID);
     $body = str_replace("{Anrede}", Util::formatAnrede($_SESSION["S"]->getUserLanguage(), $adresse), $body);
     if ($action == "notification") {
         $mail->setCalendar($ics, "REQUEST");
     }
     #if($action == "reply")
     #	$mail->setCalendar($ics, "REPLY");
     $mail->setTextCharset("UTF-8");
     $mail->setCalendarCharset("UTF-8");
     $mail->setText($body);
     #print_r($mail->getRFC822(array("*****@*****.**")));
     #die();
     $mail->send(array($emailData["recipients"][$recipientID][1]));
     $C->setNotified($className, $classID);
 }
Beispiel #2
0
 /**
  * @param string $iCal
  * @param string $myEmail
  * @param int $answer possible values: accept: 1, maybe: 2, decline: 3
  */
 public static function answerInvitation(string $iCal, string $myEmail, int $answer)
 {
     if ($answer == "1") {
         $text = "akzeptiert";
     }
     if ($answer == "2") {
         $text = "vorläufig akzeptiert";
     }
     if ($answer == "3") {
         $text = "abgelehnt";
     }
     $VC = new vcalendar();
     $VC->parse($iCal);
     $event = $VC->getComponent("vevent");
     $targetAttendee = "MAILTO:" . $myEmail;
     $i = 1;
     while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) {
         if (stripos($valueOccur["value"], $targetAttendee) === false) {
             $i++;
             continue;
         }
         $params = $valueOccur["params"];
         if ($answer == "1") {
             $params["PARTSTAT"] = "ACCEPTED";
         }
         if ($answer == "2") {
             $params["PARTSTAT"] = "TENTATIVE";
         }
         if ($answer == "3") {
             $params["PARTSTAT"] = "DECLINED";
         }
         if (isset($params["RSVP"])) {
             unset($params["RSVP"]);
         }
         $event->setAttendee($targetAttendee, $params, $i);
         $i++;
     }
     $i = 1;
     while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) {
         if (stripos($valueOccur["value"], $targetAttendee) === false) {
             $i++;
             $event->deleteProperty("ATTENDEE");
             continue;
         }
         $i++;
     }
     $event->setProperty("DTSTAMP", gmdate("Ymd") . "T" . gmdate("His") . "Z");
     $event->setProperty("LAST-MODIFIED", gmdate("Ymd") . "T" . gmdate("His") . "Z");
     $VC->deleteComponent("vevent");
     $VC->setComponent($event);
     $VC->setMethod("REPLY");
     $ics = $VC->createCalendar();
     $fromName = Session::currentUser()->A("name");
     $from = Session::currentUser()->A("UserEmail");
     $mail = new htmlMimeMail5();
     $mail->setFrom(utf8_decode($fromName . " <" . $from . ">"));
     if (!ini_get('safe_mode')) {
         $mail->setReturnPath($from);
     }
     $mail->setSubject(utf8_decode("Antwort Termineinladung (" . ucfirst($text) . "): " . $event->getProperty("SUMMARY")));
     $mail->addAttachment(new stringAttachment($ics, "invite.ics", 'application/ics'));
     $mail->setCalendar($ics, "REPLY");
     $mail->setCalendarCharset("UTF-8");
     $mail->setTextCharset("UTF-8");
     $mail->setText("{$fromName} hat diesen Termin {$text}");
     $organizer = str_replace("MAILTO:", "", $event->getProperty("ORGANIZER"));
     return $mail->send(array($organizer));
 }