ソースを参照

allow priority to be set in Email

euromark 12 年 前
コミット
7debb3d1a2

+ 0 - 1
Controller/Component/CommonComponent.php

@@ -551,7 +551,6 @@ class CommonComponent extends Component {
 		if ($type === 'canonical' && $prep) {
 			$content = h($content);
 		}
-		# custom: <meta name=”GOOGLEBOT” content=”unavailable_after: … GMT”>
 		Configure::write('Meta.'.$type, $content);
 	}
 

+ 22 - 0
Lib/EmailLib.php

@@ -17,6 +17,7 @@ if (!defined('BR')) {
  * - allow wrapLength to be adjusted
  * - Configure::read('Config.x-mailer') can modify the x-mailer
  * - basic validation supported
+ * - allow priority to be set (1 to 5)
  *
  * @author Mark Scherer
  * @license MIT
@@ -33,6 +34,8 @@ class EmailLib extends CakeEmail {
 
 	protected $_wrapLength = null;
 
+	protected $_priority = null;
+
 	public function __construct($config = null) {
 		if ($config === null) {
 			$config = 'default';
@@ -485,6 +488,11 @@ class EmailLib extends CakeEmail {
 			'bcc' => $this->_bcc,
 			'transport' => $this->_transportName
 		);
+		if ($this->_priority) {
+			$this->_headers['X-Priority'] = $this->_priority;
+			//$this->_headers['X-MSMail-Priority'] = 'High';
+			//$this->_headers['Importance'] = 'High';
+		}
 
 		try {
 			$this->_debug = parent::send($message);
@@ -547,6 +555,20 @@ class EmailLib extends CakeEmail {
 	}
 
 	/**
+	 * Set/Get priority
+	 *
+	 * @param int $priority 1 (highest) to 5 (lowest)
+	 * @return int|CakeEmail
+	 */
+	public function priority($priority = null) {
+		if ($priority === null) {
+			return $this->_priority;
+		}
+		$this->_priority = $priority;
+		return $this;
+	}
+
+	/**
 	 * Fix line length
 	 *
 	 * @overwrite

+ 1 - 2
Model/Behavior/BitmaskedBehavior.php

@@ -7,7 +7,7 @@ App::uses('ModelBehavior', 'Model');
  * An implementation of bitwise masks for row-level operations.
  * You can submit/register flags in different ways. The easiest way is using a static model function.
  * It should contain the bits like so (starting with 1):
- * 	1 => w, 2 => x, 4 => y, 8 => z, ... (bits as keys - names as values)
+ *   1 => w, 2 => x, 4 => y, 8 => z, ... (bits as keys - names as values)
  * The order doesn't matter, as long as no bit is used twice.
  *
  * The theoretical limit for a 64-bit integer would be 64 bits (2^64).
@@ -18,7 +18,6 @@ App::uses('ModelBehavior', 'Model');
  * @author Mark Scherer
  * @cake 2.x
  * @license MIT
- * @uses ModelBehavior
  * @link http://www.dereuromark.de/2012/02/26/bitmasked-using-bitmasks-in-cakephp/
  * 2012-02-24 ms
  */

+ 1 - 1
Model/MyModel.php

@@ -164,7 +164,7 @@ class MyModel extends Model {
 	}
 
 	/**
-	 * Catch database errors before its too late
+	 * Catch database errors before it's too late
 	 * //TODO: testing
 	 * 2010-11-04 ms
 	 */