From a2bfb8ff94b5dc8092d3a7926c201582aec85eee Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 9 Jan 2016 09:43:14 -0700 Subject: [PATCH] Add a new method call format_mac to make the code more reusable. --- app/provision/resources/classes/provision.php | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index d5841d8641..b709d49da1 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -126,6 +126,28 @@ include "root.php"; } } + //set the mac address in the correct format for the specific vendor + public format_mac($mac, $vendor) { + switch (strtolower($vendor)) { + case "aastra": + $mac = strtoupper($mac); + break; + case "mitel": + $mac = strtoupper($mac); + break; + case "polycom": + $mac = strtolower($mac); + break; + case "snom": + $mac = strtolower($mac); + break; + default: + $mac = strtolower($mac); + $mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); + } + return $mac; + } + function render() { //debug @@ -703,23 +725,7 @@ include "root.php"; unset ($prep_statement); //set the mac address in the correct format - switch (strtolower($device_vendor)) { - case "aastra": - $mac = strtoupper($mac); - break; - case "mitel": - $mac = strtoupper($mac); - break; - case "polycom": - $mac = strtolower($mac); - break; - case "snom": - $mac = strtolower($mac); - break; - default: - $mac = strtolower($mac); - $mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); - } + $this->format_mac($mac, $device_vendor); //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number $view->assign("mac" , $mac);