+ /**
+ * Normalise the different Priority headers into a uniform value,
+ * namely that of the X-Priority header (1, 3, 5). Supports:
+ * Priority, X-Priority, Importance.
+ * X-MS-Mail-Priority is not parsed because it always coincides
+ * with one of the other headers.
+ *
+ * NOTE: this is actually a duplicate from the function in
+ * functions/imap_messages. I'm not sure if it's ok here to call
+ * that function?
+ * @param string $sValue literal priority name
+ * @return integer
+ */
+ function parsePriority($sValue) {
+ // don't use function call inside array_shift.
+ $aValue = split('/\w/',trim($sValue));
+ $value = strtolower(array_shift($aValue));
+
+ if ( is_numeric($value) ) {
+ return $value;
+ }
+ if ( $value == 'urgent' || $value == 'high' ) {
+ return 1;
+ } elseif ( $value == 'non-urgent' || $value == 'low' ) {
+ return 5;
+ }
+ // default is normal priority
+ return 3;
+ }
+
+ /**
+ * @param string $value content type header
+ */