diff options
-rw-r--r-- | inc/Mailer.class.php | 14 | ||||
-rw-r--r-- | inc/events.php | 23 |
2 files changed, 26 insertions, 11 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index 2ac2c1d60..e32178bba 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -277,7 +277,7 @@ class Mailer { /** * Add the To: recipients * - * @see setAddress + * @see cleanAddress * @param string|array $address Multiple adresses separated by commas or as array */ public function to($address) { @@ -287,7 +287,7 @@ class Mailer { /** * Add the Cc: recipients * - * @see setAddress + * @see cleanAddress * @param string|array $address Multiple adresses separated by commas or as array */ public function cc($address) { @@ -297,7 +297,7 @@ class Mailer { /** * Add the Bcc: recipients * - * @see setAddress + * @see cleanAddress * @param string|array $address Multiple adresses separated by commas or as array */ public function bcc($address) { @@ -310,7 +310,7 @@ class Mailer { * This is set to $conf['mailfrom'] when not specified so you shouldn't need * to call this function * - * @see setAddress + * @see cleanAddress * @param string $address from address */ public function from($address) { @@ -333,9 +333,9 @@ class Mailer { * for headers. Addresses may not contain Non-ASCII data! * * Example: - * setAddress("föö <foo@bar.com>, me@somewhere.com","TBcc"); + * cc("föö <foo@bar.com>, me@somewhere.com","TBcc"); * - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|array $addresses Multiple adresses separated by commas or as array * @return bool|string the prepared header (can contain multiple lines) */ public function cleanAddress($addresses) { @@ -522,7 +522,7 @@ class Mailer { // clean up addresses if(empty($this->headers['From'])) $this->from($conf['mailfrom']); - $addrs = array('To', 'From', 'Cc', 'Bcc'); + $addrs = array('To', 'From', 'Cc', 'Bcc', 'Reply-To', 'Sender'); foreach($addrs as $addr) { if(isset($this->headers[$addr])) { $this->headers[$addr] = $this->cleanAddress($this->headers[$addr]); diff --git a/inc/events.php b/inc/events.php index f7b1a7a16..9c3169b34 100644 --- a/inc/events.php +++ b/inc/events.php @@ -148,9 +148,10 @@ class Doku_Event_Handler { * if NULL, method is assumed to be a globally available function * @param $method (function) event handler function * @param $param (mixed) data passed to the event handler + * @param $seq (int) sequence number for ordering hook execution (ascending) */ - function register_hook($event, $advise, $obj, $method, $param=null) { - $this->_hooks[$event.'_'.$advise][] = array($obj, $method, $param); + function register_hook($event, $advise, $obj, $method, $param=null, $seq=0) { + $this->_hooks[$event.'_'.$advise][] = array($obj, $method, $param, (int)$seq); } function process_event(&$event,$advise='') { @@ -158,8 +159,8 @@ class Doku_Event_Handler { $evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE'); if (!empty($this->_hooks[$evt_name])) { - foreach ($this->_hooks[$evt_name] as $hook) { - // list($obj, $method, $param) = $hook; + foreach ($this->sort_hooks($this->_hooks[$evt_name]) as $hook) { + // list($obj, $method, $param, $seq) = $hook; $obj =& $hook[0]; $method = $hook[1]; $param = $hook[2]; @@ -174,6 +175,20 @@ class Doku_Event_Handler { } } } + + protected function sort_hooks($hooks) { + usort($hooks, array('Doku_Event_Handler','cmp_hooks')); + return $hooks; + } + + public static function cmp_hooks($a, $b) { + if ($a[3] == $b[3]) { + return 0; + } + + return ($a[3] < $b[3]) ? -1 : 1; + } + } /** |