Source for file customer_mail.class.php

Documentation is available at customer_mail.class.php

  1. <?php   /*
  2.    *@=@=@=@ START LICENSE @=@=@=@*
  3.    Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
  4.    
  5.    stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
  6.    
  7.    This software is a computer program whose purpose is to make a
  8.    web hosting platform
  9.    
  10.    This software is governed by the CeCILL  license under French law and
  11.    abiding by the rules of distribution of free software.  You can  use, 
  12.    modify and/ or redistribute the software under the terms of the CeCILL
  13.    license as circulated by CEA, CNRS and INRIA at the following URL
  14.    "http://www.cecill.info". 
  15.    
  16.    As a counterpart to the access to the source code and  rights to copy,
  17.    modify and redistribute granted by the license, users are provided only
  18.    with a limited warranty  and the software's author,  the holder of the
  19.    economic rights,  and the successive licensors  have only  limited
  20.    liability. 
  21.    
  22.    In this respect, the user's attention is drawn to the risks associated
  23.    with loading,  using,  modifying and/or developing or reproducing the
  24.    software by the user in light of its specific status of free software,
  25.    that may mean  that it is complicated to manipulate,  and  that  also
  26.    therefore means  that it is reserved for developers  and  experienced
  27.    professionals having in-depth computer knowledge. Users are therefore
  28.    encouraged to load and test the software's suitability as regards their
  29.    requirements in conditions enabling the security of their systems and/or 
  30.    data to be ensured and,  more generally, to use and operate it in the 
  31.    same conditions as regards security. 
  32.    
  33.    The fact that you are presently reading this means that you have had
  34.    knowledge of the CeCILL license and that you accept its terms.
  35.    *@=@=@=@ END   LICENSE @=@=@=@*
  36.  
  37. */?><?php  
  38. /**
  39.  * CustomerMail Class
  40.  * 
  41.  * 
  42.  * @author SimpliciWeb
  43.  * @version $Id: customer_mail.class.php 606 2007-07-19 10:14:30Z stephanet $
  44.  * @package Common
  45.  * @subpackage FrameWork
  46.  */    
  47.  
  48. /**
  49.  * Require xPliciMail.class.php
  50.  */
  51. require_once('xPliciMail.class.php');
  52.  
  53. /**
  54.  * Send customer mail (based on the database {@link TTextEmailBody})
  55.  *
  56.  * @author SimpliciWeb
  57.  * @version $Id: customer_mail.class.php 606 2007-07-19 10:14:30Z stephanet $
  58.  * @package Common
  59.  * @subpackage FrameWork
  60.  */
  61.     class CustomerMail extends xPliciMail  {
  62.     
  63.         /**
  64.          * Set database used to get subject and content for mail
  65.          *
  66.          * @var string 
  67.          */
  68.         var $m_database_selected = "";
  69.         
  70.         /**
  71.          * Constructor, init the requests and objects
  72.          *
  73.          * @return CustomerMail 
  74.          */
  75.         function CustomerMail({
  76.             parent::xPliciMail();
  77.         }
  78.  
  79.         /**
  80.          * Set database selected
  81.          *
  82.          * @param string $p_database 
  83.          */
  84.         function setDatabaseSelected($p_database)
  85.         {
  86.             $this->m_database_selected = $p_database;
  87.         }
  88.         /**
  89.          * Get database selected
  90.          *
  91.          * @return string 
  92.          */
  93.         function getDatabaseSelected()
  94.         {
  95.             return $this->m_database_selected;
  96.         }
  97.  
  98.  
  99.         /**
  100.          * Send a mail for test
  101.          *
  102.          * @param string $p_subject 
  103.          * @param string $p_content 
  104.          * @param string $recipients_by_coma 
  105.          * @return bool TRUE on error
  106.          */
  107.         function sendForTest($p_subject$p_content$recipients_by_coma{
  108.             
  109.             $this->setRecipients($recipients_by_coma);
  110.             $this->setSubject($p_subject);
  111.             
  112.             return $this->xSend($p_content);
  113.         }
  114.         
  115.         /**
  116.          * Send a email
  117.          *
  118.          * @param string $p_type  Get From database
  119.          * @param array $p_parameters 
  120.          * @param string $recipients_by_coma 
  121.          * @param string $p_database_selected 
  122.          * @return bool TRUE on error
  123.          */
  124.         function send($p_type$p_parameters$recipients_by_coma ""$p_database_selected=""{
  125.             global $g_object_loader;
  126.             $object_ttextemailbody =$g_object_loader->getTTextEmailBody();
  127.             if ($recipients_by_coma == "" && isset($p_parameters['cus_email']))
  128.                 $recipients_by_coma $p_parameters['cus_email'];
  129.             
  130.  
  131.             // Set database selected
  132.             $object_ttextemailbody->setDatabaseSelected($p_database_selected);
  133.  
  134.             // verifier le $p_type
  135.             if ($object_ttextemailbody->isNotValidTfiId($p_type)) {
  136.                 return true;    
  137.             }
  138.  
  139.             // mettre le bon sujet $p_subject
  140.             $object_ttextemailbody->getSubject($p_type$p_subject);
  141.             
  142.             // mettre le bon content dans $p_content
  143.             $object_ttextemailbody->get($p_type$p_content);
  144.             
  145.             // prendre le $p_parameters et affecter les valeurs possibles au type
  146.             //            et faire le remplacer
  147.             $object_ttextemailbody->getParametersForType($p_type$parameters_needed);
  148.             $parameters_needed_id array_keys($parameters_needed);
  149.             
  150.             for ($i=0$i<sizeof($parameters_needed_id)$i++{
  151.                 $key =     $parameters_needed_id[$i];
  152.                 
  153.                 $the_value getFromArray($key$p_parameters'');
  154.                 //echo($key."<=>".$the_value."<br />");
  155.                 if ($key == 'cus_email')
  156.                     $the_value strtolower($the_value);
  157.                 else if ($key == 'cus_last_name')
  158.                     $the_value strtoupper($the_value);
  159.                 else if ($key == 'cus_first_name')
  160.                     $the_value ucfirst(strtolower($the_value));
  161.                 else if ($key == 'cus_sex'{
  162.                     if ($the_value == 'MR')
  163.                         $the_value plici_lang('lang_str_mr77');
  164.                     else if ($the_value == 'MM')
  165.                         $the_value plici_lang('lang_str_mm');
  166.                     else if ($the_value == 'ME')
  167.                         $the_value plici_lang('lang_str_me');
  168.                 else if ($key == 'cus_birthday'{
  169.                     $the_value print_date($the_value);
  170.                 
  171.                                                                                            
  172.                 $p_subject str_replace $key$the_value$p_subject );
  173.                 $p_content str_replace($key$the_value$p_content);
  174.             }
  175.             
  176.  
  177.             $p_content $this->convertContentWithBaseMailTemplate($p_content);
  178.  
  179.  
  180.  
  181.             if (0<strlen(trim($p_database_selected)))
  182.             {
  183.                 // Load information about the slave website group
  184.                 $object_tglobalscope =$g_object_loader->getTGlobalScopeVariable();
  185.                 // Declare var
  186.                 $email_setting array();
  187.                 // Load slave email setting
  188.                 $object_tglobalscope->getMailSettings($email_settingtrue$p_database_selected);
  189.                 // Set slave var
  190.                 $this->eraseSubjectPrefix();
  191.                 $this->setSubjectPrefix($email_setting['subject_prefixe']);
  192.                 $this->setFromEmail($email_setting['from']);
  193.                 $this->setFromName($email_setting['from_name']);
  194.             }
  195.  
  196.             $this->setRecipients($recipients_by_coma);
  197.             $this->setSubject($p_subject);
  198.  
  199.             return $this->xSend($p_content);
  200.         
  201.         }
  202.     
  203.         
  204.     
  205.     }
  206.  
  207. ?>

Documentation generated on Tue, 25 Mar 2008 15:33:22 +0100 by phpDocumentor 1.3.2