From 89e4329a8068e3631d3f64f6896fa3907c687cf5 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 08 Jan 2015 09:08:50 -0500
Subject: [PATCH] Layout fix: tab toggle and monitor tables

---
 server/lib/classes/monitor_tools.inc.php |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php
index ce1debb..50eb45b 100644
--- a/server/lib/classes/monitor_tools.inc.php
+++ b/server/lib/classes/monitor_tools.inc.php
@@ -62,6 +62,9 @@
 				$mainver = array_filter($mainver);
 				$mainver = current($mainver).'.'.next($mainver);
 				switch ($mainver){
+				case "14.10":
+					$relname = "(Utopic Unicorn)";
+					break;
 				case "14.04":
 					$relname = "(Trusty Tahr)";
 					break;
@@ -675,6 +678,59 @@
 		$app->dbmaster->query($sql);
 	}
 
+	public function send_notification_email($template, $placeholders, $recipients) {
+		global $conf;
+
+		if(!is_array($recipients) || count($recipients) < 1) return false;
+		if(!is_array($placeholders)) $placeholders = array();
+
+		if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) {
+			$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt');
+		} elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) {
+			$lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt');
+		} elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) {
+			$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt');
+		} else {
+			$lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt');
+		}
+
+		//* get mail headers, subject and body
+		$mailHeaders = '';
+		$mailBody = '';
+		$mailSubject = '';
+		$inHeader = true;
+		for($l = 0; $l < count($lines); $l++) {
+			if($lines[$l] == '') {
+				$inHeader = false;
+				continue;
+			}
+			if($inHeader == true) {
+				$parts = explode(':', $lines[$l], 2);
+				if(strtolower($parts[0]) == 'subject') $mailSubject = trim($parts[1]);
+				unset($parts);
+				$mailHeaders .= trim($lines[$l]) . "\n";
+			} else {
+				$mailBody .= trim($lines[$l]) . "\n";
+			}
+		}
+		$mailBody = trim($mailBody);
+
+		//* Replace placeholders
+		$mailHeaders = strtr($mailHeaders, $placeholders);
+		$mailSubject = strtr($mailSubject, $placeholders);
+		$mailBody = strtr($mailBody, $placeholders);
+
+		for($r = 0; $r < count($recipients); $r++) {
+			mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders);
+		}
+
+		unset($mailSubject);
+		unset($mailHeaders);
+		unset($mailBody);
+		unset($lines);
+
+		return true;
+	}
 
 }
 

--
Gitblit v1.9.1