From cf4f8d1e3643747bfff55928fa55413715d7db4e Mon Sep 17 00:00:00 2001 From: agree Date: Wed, 5 May 2021 21:28:47 -0400 Subject: [PATCH] Add ability to set default accountcodes --- app/extensions/extension_edit.php | 6 ++++++ resources/functions.php | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index 4ce8328a7c..245e3f9e43 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -397,6 +397,11 @@ if (permission_exists('extension_accountcode')) { $array["extensions"][$i]["accountcode"] = $accountcode; } + else { + if ($action == "add") { + $array["extensions"][$i]["accountcode"] = get_accountcode(); + } + } if (permission_exists("effective_caller_id_name")) { $array["extensions"][$i]["effective_caller_id_name"] = $effective_caller_id_name; } @@ -878,6 +883,7 @@ //set the defaults if (strlen($user_context) == 0) { $user_context = $_SESSION['domain_name']; } if (strlen($max_registrations) == 0) { $max_registrations = $_SESSION['extension']['max_registrations']['numeric']; } + if (strlen($accountcode) == 0) { $accountcode = get_accountcode(); } if (strlen($limit_max) == 0) { $limit_max = '5'; } if (strlen($limit_destination) == 0) { $limit_destination = 'error/user_busy'; } if (strlen($call_timeout) == 0) { $call_timeout = '30'; } diff --git a/resources/functions.php b/resources/functions.php index 031db0bf3d..3921facdb5 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2192,4 +2192,19 @@ function number_pad($number,$n) { } } +//get accountode + if (!function_exists('get_accountcode')) { + function get_accountcode() { + if (strlen($accountcode = $_SESSION['domain']['accountcode']['text']) > 0) { + if ($accountcode == "none") { + return; + } + } + else { + $accountcode = $_SESSION['domain_name']; + } + return $accountcode; + } + } + ?>