cvs: pear /Mail_Mime mime.php
| From: | Cipriano Groenendal | Date: | Sun, 09 Apr 2006 15:03:28 +0000 |
| Subject: | cvs: pear /Mail_Mime mime.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39510@lists.php.net to get a copy of this message | ||
cipri Sun Apr 9 15:03:28 2006 UTC
Modified files:
/pear/Mail_Mime mime.php
Log:
Bug #2952: Added $overwrite param to &headers() to allow headers to be overwritten.
http://cvs.php.net/viewcvs.cgi/pear/Mail_Mime/mime.php?r1=1.48&r2=1.49&diff_format=u
Index: pear/Mail_Mime/mime.php
diff -u pear/Mail_Mime/mime.php:1.48 pear/Mail_Mime/mime.php:1.49
--- pear/Mail_Mime/mime.php:1.48 Sun Apr 9 14:36:11 2006
+++ pear/Mail_Mime/mime.php Sun Apr 9 15:03:28 2006
@@ -35,7 +35,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> (port to PEAR) |
// +-----------------------------------------------------------------------+
//
-// $Id: mime.php,v 1.48 2006/04/09 14:36:11 cipri Exp $
+// $Id: mime.php,v 1.49 2006/04/09 15:03:28 cipri Exp $
require_once('PEAR.php');
require_once('Mail/mimePart.php');
@@ -475,17 +475,18 @@
* @param array $xtra_headers The extra headers that should be passed
* to the &headers() function.
* See that function for more info.
+ * @param bool $overwrite Overwrite the existing headers with new.
* @return string The complete e-mail.
* @access public
*/
- function getMessage($separation = null, $build_params = null, $xtra_headers = null)
+ function getMessage($separation = null, $build_params = null, $xtra_headers = null, $overwrite
= false)
{
if ($separation === null)
{
$separation = MAIL_MIME_CRLF;
}
$body = $this->get($build_params);
- $head = $this->txtHeaders($xtra_headers);
+ $head = $this->txtHeaders($xtra_headers, $overwrite);
$mail = $head . $separation . $body;
return $mail;
}
@@ -642,10 +643,11 @@
*
* @param array $xtra_headers Assoc array with any extra headers.
* Optional.
+ * @param bool $overwrite Overwrite already existing headers.
* @return array Assoc array with the mime headers
* @access public
*/
- function &headers($xtra_headers = null)
+ function &headers($xtra_headers = null, $overwrite = false)
{
// Content-Type header should already be present,
// So just add mime version header
@@ -653,7 +655,11 @@
if (isset($xtra_headers)) {
$headers = array_merge($headers, $xtra_headers);
}
- $this->_headers = array_merge($headers, $this->_headers);
+ if ($overwrite){
+ $this->_headers = array_merge($this->_headers, $headers);
+ }else{
+ $this->_headers = array_merge($headers, $this->_headers);
+ }
$encodedHeaders = $this->_encodeHeaders($this->_headers);
return $encodedHeaders;
@@ -665,12 +671,13 @@
*
* @param array $xtra_headers Assoc array with any extra headers.
* Optional.
+ * @param bool $overwrite Overwrite the existing heaers with new.
* @return string Plain text headers
* @access public
*/
- function txtHeaders($xtra_headers = null)
+ function txtHeaders($xtra_headers = null, $overwrite = false)
{
- $headers = $this->headers($xtra_headers);
+ $headers = $this->headers($xtra_headers, $overwrite);
$ret = '';
foreach ($headers as $key => $val) {
$ret .= "$key: $val" . MAIL_MIME_CRLF;