summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorUrban Müller2008-06-23 13:09:02 +0000
committerUrban Müller2008-06-23 13:09:02 +0000
commit156228c730ac944b751f6e8bb7d463c2fee3763c (patch)
tree2da7e38367b854162809c3e463d0bfb16076914d /it.class
parent4f531ee59521e4bd10fca1010e22d88066b43620 (diff)
downloaditools-156228c730ac944b751f6e8bb7d463c2fee3763c.tar.gz
itools-156228c730ac944b751f6e8bb7d463c2fee3763c.tar.bz2
itools-156228c730ac944b751f6e8bb7d463c2fee3763c.zip
allow comma separated list in filter_keys, simpler mail sending
Diffstat (limited to 'it.class')
-rw-r--r--it.class17
1 files 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();
+}
+
}
?>