From 0140ae098dd90de2cc4728f17dee9b941c0e0f50 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 17 Jun 2017 14:02:19 -0600 Subject: [PATCH] Update app_defaults.php --- app/extensions/app_defaults.php | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/app/extensions/app_defaults.php b/app/extensions/app_defaults.php index d06a2f30f8..4a5bb372ad 100644 --- a/app/extensions/app_defaults.php +++ b/app/extensions/app_defaults.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2017 the Initial Developer. All Rights Reserved. Contributor(s): @@ -26,9 +26,32 @@ //if the extensions dir doesn't exist then create it if ($domains_processed == 1) { - if (strlen($_SESSION['switch']['extensions']['dir']) > 0) { - if (!is_dir($_SESSION['switch']['extensions']['dir'])) { event_socket_mkdir($_SESSION['switch']['extensions']['dir']); } - } + + //create the directory + if (strlen($_SESSION['switch']['extensions']['dir']) > 0) { + if (!is_dir($_SESSION['switch']['extensions']['dir'])) { event_socket_mkdir($_SESSION['switch']['extensions']['dir']); } + } + + //update the directory first and last names + $sql = "select * from v_extensions "; + $sql .= "where directory_first_name <> '' and directory_last_name is null "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $extensions = $prep_statement->fetchall(PDO::FETCH_ASSOC); + foreach($extensions as $row) { + $name = explode(' ', $row['directory_first_name']); + if (strlen($name[1]) > 0) { + $sql = "UPDATE v_extensions "; + $sql .= "SET directory_first_name = '".$name[0]."', "; + $sql .= "directory_last_name = '".$name[1]."' "; + $sql .= "WHERE extension_uuid = '". $row['extension_uuid'] ."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } + } -?> \ No newline at end of file +?>