<?
if ($_SESSION['username'] == "admin") {
	if (sizeof($_POST['action']) > 0) {
		if (strlen($_POST['email_address']) > 0) {
			$who = explode("|", $str->fromHTML($_POST['who']));
			$record["object_id"] = $who[0];
			$record["object_type"] = $who[1];
			$record["action"] = "'".$str->fromHTML(implode("'|'", $_POST['action']))."'";
			$record["email_address"] = $str->fromHTML($_POST['email_address']);
			$rs = $db->AutoExecute($settings->config['notifications_tablename'], $record, 'INSERT');
			if ($rs) {
				$msg = $lang->get("Notification rule added.");
				$statusBarMessage[] = array($msg, 0);
			} else {
				$msg = $lang->get("Failed to add notification.");
				$statusBarMessage[] = array($msg, 1);
			}
		} else {
			$msg = $lang->get("Please type an email address.");
			$statusBarMessage[] = array($msg, 1);
		}
	} else {
		$msg = $lang->get("Please select at least one action.");
		$statusBarMessage[] = array($msg, 1);
	}
}
?>