home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Mail / Queue / Body.php next >
Encoding:
PHP Script  |  2008-07-02  |  7.8 KB  |  343 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PEAR :: Mail :: Queue :: Body                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Radek Maciaszek <chief@php.net>                             |
  17. // |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: Body.php,v 1.10 2005/12/08 15:43:57 quipo Exp $
  21.  
  22. /**
  23. * Class contains mail data.
  24. *
  25. * @version  $Revision: 1.10 $
  26. * @author   Radek Maciaszek <chief@php.net>
  27. */
  28.  
  29. /**
  30. * Mail_Queue_Body contains mail data
  31. *
  32. * @author   Radek Maciaszek <wodzu@pomocprawna.info>
  33. * @version  $Revision: 1.10 $
  34. * @package  Mail_Queue
  35. * @access   public
  36. */
  37. class Mail_Queue_Body {
  38.  
  39.     /**
  40.      * Ident
  41.      *
  42.      * @var integer
  43.      */
  44.     var $id;
  45.  
  46.     /**
  47.      * Create time
  48.      *
  49.      * @var string
  50.      */
  51.     var $create_time;
  52.  
  53.     /**
  54.      * Time to send mail
  55.      *
  56.      * @var string
  57.      */
  58.     var $time_to_send;
  59.  
  60.     /**
  61.      * Time when mail was sent
  62.      *
  63.      * @var string
  64.      */
  65.     var $sent_time = null;
  66.  
  67.     /**
  68.      * User id - who send mail
  69.      * MAILQUEUE_UNKNOWN - not login user (guest)
  70.      * MAILQUEUE_SYSTEM - mail send by system
  71.      *
  72.      * @var string
  73.      */
  74.     var $id_user = MAILQUEUE_SYSTEM;
  75.  
  76.     /**
  77.      * use IP
  78.      *
  79.      * @var string
  80.      */
  81.     var $ip;
  82.  
  83.     /**
  84.      * Sender email
  85.      *
  86.      * @var string
  87.      */
  88.     var $sender;
  89.  
  90.     /**
  91.      * Reciepient email
  92.      *
  93.      * @var string
  94.      */
  95.     var $recipient;
  96.  
  97.     /**
  98.      * Email headers (in RFC)
  99.      *
  100.      * @var string
  101.      */
  102.     var $headers;
  103.  
  104.     /**
  105.      * Email body (in RFC) - could have attachments etc
  106.      *
  107.      * @var string
  108.      */
  109.     var $body;
  110.  
  111.     /**
  112.      * How many times mail was sent
  113.      *
  114.      * @var integer
  115.      */
  116.     var $try_sent = 0;
  117.  
  118.     /**
  119.      * Delete mail from database after success send
  120.      *
  121.      * @var bool
  122.      */
  123.     var $delete_after_send = true;
  124.  
  125.     /**
  126.      * Mail_Queue_Body::Mail_Queue_Body() constructor
  127.      *
  128.      * @param integer $id Mail ident
  129.      * @param string $create_time  Create time
  130.      * @param strine $time_to_send  Time to send
  131.      * @param string $sent_time  Sent time
  132.      * @param integer $id_user  Sender user id (who sent mail)
  133.      * @param string $ip Sender user ip
  134.      * @param strine $sender  Sender e-mail
  135.      * @param string $recipient Reciepient e-mail
  136.      * @param string $headers Mail headers (in RFC)
  137.      * @param string $body Mail body (in RFC)
  138.      * @param integer $try_sent  How many times mail was sent
  139.      *
  140.      * @return void
  141.      *
  142.      * @access public
  143.      */
  144.     function Mail_Queue_Body($id, $create_time, $time_to_send, $sent_time, $id_user,
  145.                        $ip, $sender, $recipient, $headers, $body,
  146.                        $delete_after_send=true, $try_sent=0)
  147.     {
  148.         $this->id                = $id;
  149.         $this->create_time       = $create_time;
  150.         $this->time_to_send      = $time_to_send;
  151.         $this->sent_time         = $sent_time;
  152.         $this->id_user           = $id_user;
  153.         $this->ip                = $ip;
  154.         $this->sender            = $sender;
  155.         $this->recipient         = $recipient;
  156.         $this->headers           = $headers;
  157.         $this->body              = $body;
  158.         $this->delete_after_send = $delete_after_send;
  159.         $this->try_sent          = $try_sent;
  160.     }
  161.  
  162.     /**
  163.      * Mail_Queue_Body::getId()
  164.      *
  165.      * @return integer  Sender id
  166.      * @access public
  167.      */
  168.     function getId()
  169.     {
  170.         return $this->id;
  171.     }
  172.  
  173.     /**
  174.      * Return mail create time.
  175.      *
  176.      * Mail_Queue_Body::getCreateTime()
  177.      *
  178.      * @return string  Mail create time
  179.      * @access public
  180.      */
  181.     function getCreateTime()
  182.     {
  183.         return $this->create_time;
  184.     }
  185.  
  186.     /**
  187.      * Return time to send mail.
  188.      *
  189.      * Mail_Queue_Body::getTimeToSend()
  190.      *
  191.      * @return string  Time to send
  192.      * @access public
  193.      */
  194.     function getTimeToSend()
  195.     {
  196.         return $this->time_to_send;
  197.     }
  198.  
  199.     /**
  200.      * Return mail sent time (if sended) else false.
  201.      *
  202.      * Mail_Queue_Body::getSentTime()
  203.      *
  204.      * @return mixed  String sent time or false if mail not was sent yet
  205.      * @access public
  206.      */
  207.     function getSentTime()
  208.     {
  209.         return empty($this->sent_time) ? false : $this->sent_time;
  210.     }
  211.  
  212.     /**
  213.      * Return sender id.
  214.      *
  215.      * Mail_Queue_Body::getIdUser()
  216.      *
  217.      * @return integer  Sender id
  218.      * @access public
  219.      */
  220.     function getIdUser()
  221.     {
  222.         return $this->id_user;
  223.     }
  224.  
  225.     /**
  226.      * Return sender ip.
  227.      *
  228.      * Mail_Queue_Body::getIp()
  229.      *
  230.      * @return string  IP
  231.      * @access public
  232.      */
  233.     function getIp()
  234.     {
  235.         return stripslashes($this->ip);
  236.     }
  237.  
  238.     /**
  239.      * Return sender e-mail.
  240.      *
  241.      * Mail_Queue_Body::getSender()
  242.      *
  243.      * @return string E-mail
  244.      * @access public
  245.      */
  246.     function getSender()
  247.     {
  248.         return stripslashes($this->sender);
  249.     }
  250.  
  251.     /**
  252.      * Return recipient e-mail.
  253.      *
  254.      * Mail_Queue_Body::getRecipient()
  255.      *
  256.      * @return string|array E-mail(s)
  257.      * @access public
  258.      */
  259.     function getRecipient()
  260.     {
  261.         if (is_array($this->recipient)) {
  262.             $tmp_recipients = array();
  263.             foreach ($this->recipient as $key => $value) {
  264.                 $tmp_recipients[$key] = stripslashes($value);
  265.             }
  266.             return $tmp_recipients;
  267.         }
  268.         return stripslashes($this->recipient);
  269.     }
  270.  
  271.     /**
  272.      * Return mail headers (in RFC)
  273.      *
  274.      * Mail_Queue_Body::getHeaders()
  275.      *
  276.      * @return mixed array|string headers
  277.      * @access public
  278.      */
  279.     function getHeaders()
  280.     {
  281.         if (is_array($this->headers)) {
  282.             $tmp_headers = array();
  283.             foreach ($this->headers as $key => $value) {
  284.                 $tmp_headers[$key] = stripslashes($value);
  285.             }
  286.             return $tmp_headers;
  287.         }
  288.         return stripslashes($this->headers);
  289.     }
  290.  
  291.     /**
  292.      * Return mail body (in RFC)
  293.      *
  294.      * Mail_Queue_Body::getBody()
  295.      *
  296.      * @return string  Body
  297.      * @access public
  298.      */
  299.     function getBody()
  300.     {
  301.         return stripslashes($this->body);
  302.     }
  303.  
  304.     /**
  305.      * Return how many times mail was try to sent.
  306.      *
  307.      * Mail_Queue_Body::getTrySent()
  308.      *
  309.      * @return integer  How many times mail was sent
  310.      * @access public
  311.      */
  312.     function getTrySent()
  313.     {
  314.         return $this->try_sent;
  315.     }
  316.  
  317.     /**
  318.      * Return true if mail must be delete after send from db.
  319.      *
  320.      * MailBody::isDeleteAfterSend()
  321.      *
  322.      * @return bool  True if must be delete else false.
  323.      * @access public
  324.      */
  325.     function isDeleteAfterSend()
  326.     {
  327.         return $this->delete_after_send;
  328.     }
  329.  
  330.     /**
  331.      * Increase and return try_sent
  332.      *
  333.      * Mail_Queue_Body::_try()
  334.      *
  335.      * @return integer  How many times mail was sent
  336.      * @access public
  337.      */
  338.     function _try()
  339.     {
  340.         return ++$this->try_sent;
  341.     }
  342. }
  343. ?>