/lib/include/Mail/Queue/Body.php

https://github.com/usagi-project/mynets1 · PHP · 335 lines · 92 code · 28 blank · 215 comment · 1 complexity · c047e156f07557e57699ab34d5c88576 MD5 · raw file

  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. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Body.php,v 1.9 2004/08/17 14:30:52 quipo Exp $
  20. /**
  21. * Class contains mail data.
  22. *
  23. * @version $Revision: 1.9 $
  24. * @author Radek Maciaszek <chief@php.net>
  25. */
  26. /**
  27. * Mail_Queue_Body contains mail data
  28. *
  29. * @author Radek Maciaszek <wodzu@pomocprawna.info>
  30. * @version $Revision: 1.9 $
  31. * @package Mail_Queue
  32. * @access public
  33. */
  34. class Mail_Queue_Body {
  35. /**
  36. * Ident
  37. *
  38. * @var integer
  39. */
  40. var $id;
  41. /**
  42. * Create time
  43. *
  44. * @var string
  45. */
  46. var $create_time;
  47. /**
  48. * Time to send mail
  49. *
  50. * @var string
  51. */
  52. var $time_to_send;
  53. /**
  54. * Time when mail was sent
  55. *
  56. * @var string
  57. */
  58. var $sent_time = null;
  59. /**
  60. * User id - who send mail
  61. * MAILQUEUE_UNKNOWN - not login user (guest)
  62. * MAILQUEUE_SYSTEM - mail send by system
  63. *
  64. * @var string
  65. */
  66. var $id_user = MAILQUEUE_SYSTEM;
  67. /**
  68. * use IP
  69. *
  70. * @var string
  71. */
  72. var $ip;
  73. /**
  74. * Sender email
  75. *
  76. * @var string
  77. */
  78. var $sender;
  79. /**
  80. * Reciepient email
  81. *
  82. * @var string
  83. */
  84. var $recipient;
  85. /**
  86. * Email headers (in RFC)
  87. *
  88. * @var string
  89. */
  90. var $headers;
  91. /**
  92. * Email body (in RFC) - could have attachments etc
  93. *
  94. * @var string
  95. */
  96. var $body;
  97. /**
  98. * How many times mail was sent
  99. *
  100. * @var integer
  101. */
  102. var $try_sent = 0;
  103. /**
  104. * Delete mail from database after success send
  105. *
  106. * @var bool
  107. */
  108. var $delete_after_send = true;
  109. /**
  110. * Mail_Queue_Body::Mail_Queue_Body() constructor
  111. *
  112. * @param integer $id Mail ident
  113. * @param string $create_time Create time
  114. * @param strine $time_to_send Time to send
  115. * @param string $sent_time Sent time
  116. * @param integer $id_user Sender user id (who sent mail)
  117. * @param string $ip Sender user ip
  118. * @param strine $sender Sender e-mail
  119. * @param string $recipient Reciepient e-mail
  120. * @param string $headers Mail headers (in RFC)
  121. * @param string $body Mail body (in RFC)
  122. * @param integer $try_sent How many times mail was sent
  123. *
  124. * @return void
  125. *
  126. * @access public
  127. **/
  128. function Mail_Queue_Body($id, $create_time, $time_to_send, $sent_time, $id_user,
  129. $ip, $sender, $recipient, $headers, $body,
  130. $delete_after_send=true, $try_sent=0)
  131. {
  132. $this->id = $id;
  133. $this->create_time = $create_time;
  134. $this->time_to_send = $time_to_send;
  135. $this->sent_time = $sent_time;
  136. $this->id_user = $id_user;
  137. $this->ip = $ip;
  138. $this->sender = $sender;
  139. $this->recipient = $recipient;
  140. $this->headers = $headers;
  141. $this->body = $body;
  142. $this->delete_after_send = $delete_after_send;
  143. $this->try_sent = $try_sent;
  144. }
  145. /**
  146. * Mail_Queue_Body::getId()
  147. *
  148. * @return integer Sender id
  149. * @access public
  150. **/
  151. function getId()
  152. {
  153. return $this->id;
  154. }
  155. /**
  156. * Return mail create time.
  157. *
  158. * Mail_Queue_Body::getCreateTime()
  159. *
  160. * @return string Mail create time
  161. * @access public
  162. **/
  163. function getCreateTime()
  164. {
  165. return $this->create_time;
  166. }
  167. /**
  168. * Return time to send mail.
  169. *
  170. * Mail_Queue_Body::getTimeToSend()
  171. *
  172. * @return string Time to send
  173. * @access public
  174. **/
  175. function getTimeToSend()
  176. {
  177. return $this->time_to_send;
  178. }
  179. /**
  180. * Return mail sent time (if sended) else false.
  181. *
  182. * Mail_Queue_Body::getSentTime()
  183. *
  184. * @return mixed String sent time or false if mail not was sent yet
  185. * @access public
  186. **/
  187. function getSentTime()
  188. {
  189. return empty($this->sent_time) ? false : $this->sent_time;
  190. }
  191. /**
  192. * Return sender id.
  193. *
  194. * Mail_Queue_Body::getIdUser()
  195. *
  196. * @return integer Sender id
  197. * @access public
  198. **/
  199. function getIdUser()
  200. {
  201. return $this->id_user;
  202. }
  203. /**
  204. * Return sender ip.
  205. *
  206. * Mail_Queue_Body::getIp()
  207. *
  208. * @return string IP
  209. * @access public
  210. **/
  211. function getIp()
  212. {
  213. return stripslashes($this->ip);
  214. }
  215. /**
  216. * Return sender e-mail.
  217. *
  218. * Mail_Queue_Body::getSender()
  219. *
  220. * @return string E-mail
  221. * @access public
  222. **/
  223. function getSender()
  224. {
  225. return stripslashes($this->sender);
  226. }
  227. /**
  228. * Return recipient e-mail.
  229. *
  230. * Mail_Queue_Body::getRecipient()
  231. *
  232. * @return string E-mail
  233. * @access public
  234. **/
  235. function getRecipient()
  236. {
  237. return stripslashes($this->recipient);
  238. }
  239. /**
  240. * Return mail headers (in RFC)
  241. *
  242. * Mail_Queue_Body::getHeaders()
  243. *
  244. * @return mixed array|string headers
  245. * @access public
  246. **/
  247. function getHeaders()
  248. {
  249. if (is_array($this->headers)) {
  250. $tmp_headers = array();
  251. foreach ($this->headers as $key => $value) {
  252. $tmp_headers[$key] = stripslashes($value);
  253. }
  254. return $tmp_headers;
  255. }
  256. return stripslashes($this->headers);
  257. }
  258. /**
  259. * Return mail body (in RFC)
  260. *
  261. * Mail_Queue_Body::getBody()
  262. *
  263. * @return string Body
  264. * @access public
  265. **/
  266. function getBody()
  267. {
  268. return stripslashes($this->body);
  269. }
  270. /**
  271. * Return how many times mail was try to sent.
  272. *
  273. * Mail_Queue_Body::getTrySent()
  274. *
  275. * @return integer How many times mail was sent
  276. * @access public
  277. **/
  278. function getTrySent()
  279. {
  280. return $this->try_sent;
  281. }
  282. /**
  283. * Return true if mail must be delete after send from db.
  284. *
  285. * MailBody::isDeleteAfterSend()
  286. *
  287. * @return bool True if must be delete else false.
  288. * @access public
  289. **/
  290. function isDeleteAfterSend()
  291. {
  292. return $this->delete_after_send;
  293. }
  294. /**
  295. * Increase and return try_sent
  296. *
  297. * Mail_Queue_Body::_try()
  298. *
  299. * @return integer How many times mail was sent
  300. * @access public
  301. **/
  302. function _try()
  303. {
  304. return ++$this->try_sent;
  305. }
  306. }
  307. ?>