From 156228c730ac944b751f6e8bb7d463c2fee3763c Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 23 Jun 2008 13:09:02 +0000 Subject: allow comma separated list in filter_keys, simpler mail sending --- it.class | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/it.class b/it.class index 6fc2d9c..4dd4d4d 100644 --- a/it.class +++ b/it.class @@ -361,12 +361,12 @@ function replace($replacements, $string, $p = array()) /** * Extract key => value pairs from assoc array by key * @param $array array to filter - * @param $keys array of keys to keep + * @param $keys array or comma separated list of keys to keep */ function filter_keys($array, $keys) { $result = array(); - $keep = array_flip($keys); + $keep = array_flip(is_string($keys) ? explode(",", $keys) : (array)$keys); foreach ($array as $key => $val) if (isset($keep[$key])) @@ -658,6 +658,19 @@ function map($expr, $arr) return (array)$result; } +/** + * Send a mail. Expects array for Header => Content pairs with Body => for the mail body + */ +function mail($p) +{ + $body = $p['Body']; + unset($p['Body']); + $mail = new it_mail($p); + $mail->add_body($body); + + return $mail->send(); +} + } ?> -- cgit v1.2.3