From df3dd784b5aa37f203fefb731eec46be8140893c Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Thu, 20 Feb 2014 17:54:02 +0000 Subject: [PATCH] Add a optional provision template directory in /etc/fusionpbx/templates/provision for Linux and /usr/local/etc/fusionpbx/templates/provision for FreeBSD. --- app/provision/resources/classes/provision.php | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 4c59e4589b..e4cb5ad4db 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -38,9 +38,47 @@ include "root.php"; global $db; $this->db = $db; //set the default template directory - if (strlen($this->template_dir) == 0) { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision"; + switch (PHP_OS) { + case "Linux": + //set the default template dir + if (strlen($this->template_dir) == 0) { + if (file_exists('/etc/fusionpbx/templates/provision')) { + $this->template_dir = '/etc/fusionpbx/templates/provision'; + } + } + break; + case "FreeBSD": + //if the FreeBSD port is installed use the following paths by default. + if (file_exists('/usr/local/etc/fusionpbx/templates/provision')) { + if (strlen($this->template_dir) == 0) { + $this->template_dir = '/usr/local/etc/fusionpbx/templates/provision'; + } + } + else { + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } + break; + case "NetBSD": + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + break; + case "OpenBSD": + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + break; + default: + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } } + //normalize the mac address if (isset($this->mac)) { $this->mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->mac)); @@ -259,7 +297,6 @@ include "root.php"; unset ($prep_statement); //initialize a template object - //include "resources/classes/template.php"; $view = new template(); if (strlen($_SESSION['provision']['template_engine']['text']) > 0) { $view->engine = $_SESSION['provision']['template_engine']['text']; //raintpl, smarty, twig