Source for file class.MAIL.php

Documentation is available at class.MAIL.php

  1. <?php
  2.  
  3. /**
  4.  * Stellt Methoden zur Verschickung von Emails zur Verfügung
  5.  *
  6.  * Es gibt nur eine Instanz dieser Klasse (singleton)
  7.  *
  8.  * @author Kay Koch
  9.  * @package src
  10.  * @since 22.12.04
  11.  * @subpackage mail
  12.  * @version 1
  13.  */
  14.  
  15. if (version_compare(PHP_VERSION'5'))
  16. {
  17.     die('This file was generated for PHP 5');
  18. }
  19.  
  20. /**
  21.  * include src_mail_htmlMimeMail5
  22.  *
  23.  * @author Kay Koch, <kay.koch@gmx.de>
  24.  */
  25. require_once ('src/mail/class.htmlMimeMail5.php');
  26.  
  27. /* user defined includes */
  28. // section -64--88-122--2-933bcb:100f60e4e57:-7fc4-includes begin
  29. // section -64--88-122--2-933bcb:100f60e4e57:-7fc4-includes end
  30.  
  31. /* user defined constants */
  32. // section -64--88-122--2-933bcb:100f60e4e57:-7fc4-constants begin
  33. // section -64--88-122--2-933bcb:100f60e4e57:-7fc4-constants end
  34.  
  35. /**
  36.  * Stellt Methoden zur Verschickung von Emails zur Verfügung
  37.  *
  38.  * Es gibt nur eine Instanz dieser Klasse (singleton)
  39.  *
  40.  * @access public
  41.  * @author Kay Koch
  42.  * @package src
  43.  * @since 22.12.04
  44.  * @subpackage mail
  45.  * @version 1
  46.  */
  47. {
  48.     // --- ATTRIBUTES ---
  49.  
  50.     
  51.     /**
  52.      * Instance der Klasse
  53.      *
  54.      * @access private
  55.      * @var MAIL 
  56.      */
  57.     private static $oInstance null;
  58.  
  59.     /**
  60.      * URL der Anwendng
  61.      *
  62.      * @access private
  63.      * @var string 
  64.      */
  65.     private $url '';
  66.  
  67.     /**
  68.      * Name des Startscriptes der Anwendung
  69.      *
  70.      * @access private
  71.      * @var string 
  72.      */
  73.     private $scriptName '';
  74.  
  75.     // --- OPERATIONS ---
  76.  
  77.     
  78.     /**
  79.      * Verschickt eine Mail zur Bestätigung der Buchung.
  80.      * Die Mail beinhaltet alle relevanten Angaben und einen Link zur
  81.      * Bestätigung durch den Benutzer
  82.      *
  83.      * @access public
  84.      * @author Kay Koch, <kay.koch@gmx.de>
  85.      * @param array 
  86.      * @return boolean 
  87.      */
  88.     public function sendUserMail($buchung$oSee)
  89.     {
  90.         $returnValue = (bool) false;
  91.  
  92.         // section -64--88-122--2-933bcb:100f60e4e57:-7fc3 begin
  93.         try
  94.         {
  95.             $mail new src_mail_htmlMimeMail5();
  96.             $this->link $this->scriptName "?buch_id=" $buchung['buch_id'"&pwd=" $buchung['pwd'"&confirm=t&action=bestaetigung"// Link zur Bestätigung
  97.             $this->to $buchung['vorname'" " $buchung['name']// Anrede
  98.             $this->deleteTime $this->getDeleteTime()// Datum/Uhrzeit bis Löschung der Anmeldung
  99.             $mail->setTextCharset("UTF-8");
  100.             $mail->setSubject("Reservierung: " $buchung['seename'" / " $buchung['realdatum']);
  101.             $mail->setText(src_tools_TEMPLATE :: getTemplate("email_user"$this));
  102.             $mail->setFrom($this->getFormatedEmail($oSee->oAnsprechpartner));
  103.             if (!$mail->send(array $buchung['email']))) // mail wird gesendet
  104.                 throw new Exception(36);
  105.             $returnValue true;
  106.         catch (Exception $e)
  107.         {
  108.             src_tools_ERROR :: setError($e__METHOD__);
  109.         }
  110.         // section -64--88-122--2-933bcb:100f60e4e57:-7fc3 end
  111.  
  112.         return (bool) $returnValue;
  113.     }
  114.  
  115.     /**
  116.      * sendet eine Wochenmail mit dem PDF als Anhang
  117.      *
  118.      * @access public
  119.      * @author Kay Koch, <kay.koch@gmx.de>
  120.      * @param EINSEE 
  121.      * @param string 
  122.      * @param date 
  123.      * @return boolean 
  124.      */
  125.     public function sendWeekMail($oSee$pdfLocation ''$datum null)
  126.     {
  127.         $returnValue = (bool) false;
  128.  
  129.         // section -64--88-122--2-1328c7a:1027db0d532:-7ff5 begin
  130.         try
  131.         {
  132.             $mail new src_mail_htmlMimeMail5();
  133.             $oFlags new src_foundation_tables_FLAGS();
  134.             $oLVSTKontakt new src_foundation_datatypes_EINKONTAKT($oFlags->lvstResp_id);
  135.             if (!file_exists($pdfLocation))
  136.                 throw new Exception(17);
  137.             $this->link $this->url $pdfLocation// Link zur Bestätigung
  138.             $this->to $oSee->oVorOrtKontakt->vorname " " $oSee->oVorOrtKontakt->name// Anrede
  139.             $mail->setSubject("Wochenbericht - " $oSee->name "_" $datum);
  140.             $mail->setText(src_tools_TEMPLATE :: getTemplate("email_week"$this));
  141.             $mail->addAttachment(new fileAttachment($pdfLocation));
  142.             $mail->setFrom($this->getFormatedEmail($oLVSTKontakt));
  143.             $mail->setCc($this->getFormatedEmail($oSee->oAnsprechpartner));
  144.             $mail->setBcc("kay.koch@gmx.de");
  145.  
  146.             if (!$mail->send(array ($oSee->oVorOrtKontakt->email ))) // mail wird gesendet
  147.                 throw new Exception(35);
  148.             $returnValue true;
  149.  
  150.         catch (Exception $e)
  151.         {
  152.             src_tools_ERROR :: setError($e__METHOD__);
  153.         }
  154.         // section -64--88-122--2-1328c7a:1027db0d532:-7ff5 end
  155.  
  156.         return (bool) $returnValue;
  157.     }
  158.  
  159.     /**
  160.      * erstellt einen Header für die Anmeldungsemail
  161.      *
  162.      * @access private
  163.      * @author Kay Koch, <kay.koch@gmx.de>
  164.      * @param EINKONTAKT 
  165.      * @return string 
  166.      */
  167.     private function getFormatedEmail($oEinkontakt)
  168.     {
  169.         $returnValue = (string) '';
  170.  
  171.         // section -64--88-122--2-27bfcc9b:103db49df5b:-7fde begin
  172.         $returnValue $oEinkontakt->vorname " " $oEinkontakt->name " <" $oEinkontakt->email ">";
  173.         // section -64--88-122--2-27bfcc9b:103db49df5b:-7fde end
  174.  
  175.         return (string) $returnValue;
  176.     }
  177.  
  178.     /**
  179.      * erstellt eine Instanz der Klasse und speichert die Admin-Adresse
  180.      *
  181.      * @access public
  182.      * @author Kay Koch, <kay.koch@gmx.de>
  183.      * @return src_mail_MAIL 
  184.      */
  185.     public static function singleton()
  186.     {
  187.         $returnValue null;
  188.  
  189.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fb6 begin
  190.         if (!isset (self :: $oInstance))
  191.         {
  192.             $c = __CLASS__;
  193.             self :: $oInstance new $c;
  194.             self :: $oInstance->setScriptName();
  195.         }
  196.         $returnValue self :: $oInstance;
  197.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fb6 end
  198.  
  199.         return $returnValue;
  200.     }
  201.  
  202.     /**
  203.      * setzt den Namen des Startscriptes und die URL
  204.      *
  205.      * @access private
  206.      * @author Kay Koch, <kay.koch@gmx.de>
  207.      * @param string 
  208.      * @return void 
  209.      */
  210.     private function setScriptName()
  211.     {
  212.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fae begin
  213.         $this->url "http://" $_SERVER['SERVER_NAME'dirname($_SERVER['SCRIPT_NAME']"/";
  214.         $this->scriptName "http://" $_SERVER['SERVER_NAME'$_SERVER['SCRIPT_NAME'];
  215.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fae end
  216.     }
  217.  
  218.     /**
  219.      * Konstruktor
  220.      *
  221.      * nicht benutzt da Singleton
  222.      *
  223.      * @access private
  224.      * @author Kay Koch, <kay.koch@gmx.de>
  225.      * @return void 
  226.      */
  227.     private function __construct()
  228.     {
  229.         // section -64--88-122--2-b711fbe:103b621333c:-7fd4 begin
  230.         // section -64--88-122--2-b711fbe:103b621333c:-7fd4 end
  231.     }
  232.  
  233.     /**
  234.      * getDeleteTime
  235.      *
  236.      *  liefert das Datum bis zum Verfall der Buchung
  237.      *
  238.      * @access private
  239.      * @author Kay Koch, <kay.koch@gmx.de>
  240.      * @return void 
  241.      */
  242.     private function getDeleteTime()
  243.     {
  244.         $returnValue = (string) '';
  245.         //
  246.         $oFlags new src_foundation_tables_FLAGS();
  247.         $dayOfChange $oFlags->dayOfChange;
  248.         $timeOfChange $oFlags->timeOfChange;
  249.         $dayOfOrder src_tools_TIME :: sqlT2realT(strftime("%Y-%m-%d"time())"%w");
  250.         // Datum/Uhrzeit bis Löschung der Anmeldung
  251.         if ($dayOfOrder == $dayOfChange// heute wird um $timeOfChange die woch abgeschlossen
  252.             $returnValue strftime("%A - %d. %B %Y um "time()) $timeOfChange "h (!! HEUTE ABEND !!)"// verkürzt auf 23:00h
  253.         else
  254.             $returnValue strftime("%A - %d. %B %Y um %H:%Mh"time(24 60 60)// in 24 Stunden
  255.         //
  256.         return (string) $returnValue;
  257.     }
  258.  
  259. /* end of class src_mail_MAIL */
  260. ?>

Documentation generated on Sat, 24 Mar 2007 09:59:36 +0100 by phpDocumentor 1.3.1