From e9f4d5113f1ef90fb9db1487a46415b21e3b228a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jan 2020 11:43:19 -0500 Subject: [PATCH] Added destination select permissions --- app/bridges/app_config.php | 4 +++ app/call_centers/app_config.php | 4 +++ app/call_flows/app_config.php | 5 ++++ app/conference_centers/app_config.php | 4 +++ app/destinations/app_config.php | 5 ++++ app/dialplans/app_config.php | 4 +++ app/extensions/app_config.php | 6 ++++ app/fax/app_config.php | 4 +++ app/gateways/app_config.php | 3 ++ app/ivr_menus/app_config.php | 4 +++ app/phrases/app_config.php | 4 +++ app/recordings/app_config.php | 5 ++++ app/ring_groups/app_config.php | 4 +++ app/time_conditions/app_config.php | 4 +++ app/tones/app_config.php | 6 ++++ app/voicemails/app_config.php | 6 ++++ resources/classes/destinations.php | 42 +++++++++++++++++++++++++-- 17 files changed, 112 insertions(+), 2 deletions(-) diff --git a/app/bridges/app_config.php b/app/bridges/app_config.php index 254bb868bc..4d8a6927ea 100644 --- a/app/bridges/app_config.php +++ b/app/bridges/app_config.php @@ -31,6 +31,10 @@ $apps[$x]['permissions'][$y]['name'] = 'bridge_all'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'bridge_destinations'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; //destination details $y = 0; diff --git a/app/call_centers/app_config.php b/app/call_centers/app_config.php index f3cc18fddb..3b22d856b8 100644 --- a/app/call_centers/app_config.php +++ b/app/call_centers/app_config.php @@ -115,6 +115,10 @@ $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "call_center_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; //default settings $y = 0; diff --git a/app/call_flows/app_config.php b/app/call_flows/app_config.php index 46b0cf9fff..1c73f17f11 100644 --- a/app/call_flows/app_config.php +++ b/app/call_flows/app_config.php @@ -63,6 +63,11 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "call_flow_context"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "call_flow_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; //cache details $apps[$x]['cache']['key'] = "dialplan.\${call_flow_context}"; diff --git a/app/conference_centers/app_config.php b/app/conference_centers/app_config.php index 28930dc42e..b90f39968e 100644 --- a/app/conference_centers/app_config.php +++ b/app/conference_centers/app_config.php @@ -170,6 +170,10 @@ $apps[$x]['permissions'][$y]['name'] = "conference_session_detail_delete"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "conference_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //cache details $apps[$x]['cache']['key'] = "dialplan.\${domain_name}"; diff --git a/app/destinations/app_config.php b/app/destinations/app_config.php index cee70aba94..402fb11c1c 100644 --- a/app/destinations/app_config.php +++ b/app/destinations/app_config.php @@ -92,6 +92,11 @@ $apps[$x]['permissions'][$y]['name'] = "destination_fax"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $y++; + $apps[$x]['permissions'][$y]['name'] = "destination_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; //default settings $y = 0; diff --git a/app/dialplans/app_config.php b/app/dialplans/app_config.php index 7e2d60858a..c64bd511f9 100644 --- a/app/dialplans/app_config.php +++ b/app/dialplans/app_config.php @@ -87,6 +87,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "dialplan_all"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "dialplan_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //cache details $apps[$x]['cache']['key'] = "dialplan.\${dialplan_context}"; diff --git a/app/extensions/app_config.php b/app/extensions/app_config.php index e9c9779b92..90a436c464 100644 --- a/app/extensions/app_config.php +++ b/app/extensions/app_config.php @@ -190,6 +190,12 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "extension_export"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "extension_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + //default settings $y=0; diff --git a/app/fax/app_config.php b/app/fax/app_config.php index 6e07975593..315a0a24e4 100644 --- a/app/fax/app_config.php +++ b/app/fax/app_config.php @@ -169,6 +169,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "fax_send_greeting"; //$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "fax_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //default settings $y=0; diff --git a/app/gateways/app_config.php b/app/gateways/app_config.php index f6b1ae8669..98bbba49df 100644 --- a/app/gateways/app_config.php +++ b/app/gateways/app_config.php @@ -69,6 +69,9 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "gateway_channels"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "gateway_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //default settings $y = 0; diff --git a/app/ivr_menus/app_config.php b/app/ivr_menus/app_config.php index 8626f9a82f..74419482ea 100644 --- a/app/ivr_menus/app_config.php +++ b/app/ivr_menus/app_config.php @@ -99,6 +99,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "ivr_menu_domain"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "ivr_menu_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //default settings $y=0; diff --git a/app/phrases/app_config.php b/app/phrases/app_config.php index 460de62f1a..149ba64e86 100644 --- a/app/phrases/app_config.php +++ b/app/phrases/app_config.php @@ -68,6 +68,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "phrase_domain"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "phrase_desinations"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //cache details $apps[$x]['cache']['key'] = "languages.\${phrase_language}"; diff --git a/app/recordings/app_config.php b/app/recordings/app_config.php index d38de08287..b143de70a8 100644 --- a/app/recordings/app_config.php +++ b/app/recordings/app_config.php @@ -76,6 +76,11 @@ $apps[$x]['permissions'][$y]['groups'][] = "user"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "recording_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //default settings $y=0; diff --git a/app/ring_groups/app_config.php b/app/ring_groups/app_config.php index f300cd1c5c..236a0963a6 100644 --- a/app/ring_groups/app_config.php +++ b/app/ring_groups/app_config.php @@ -125,6 +125,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "ring_group_all"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "ring_group_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //default settings $y=0; diff --git a/app/time_conditions/app_config.php b/app/time_conditions/app_config.php index 6f473c476e..f577ffbcb3 100644 --- a/app/time_conditions/app_config.php +++ b/app/time_conditions/app_config.php @@ -68,6 +68,10 @@ $y++; $apps[$x]['permissions'][$y]['name'] = "time_condition_context"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "time_condition_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //default settings $y=0; diff --git a/app/tones/app_config.php b/app/tones/app_config.php index 584319465f..96a73bb235 100644 --- a/app/tones/app_config.php +++ b/app/tones/app_config.php @@ -44,4 +44,10 @@ $apps[$x]['destinations'][$y]['select_value']['ivr'] = "menu-exec-app:playback tone_stream://\${destination}"; $apps[$x]['destinations'][$y]['select_label'] = "\${name}"; + $y=0; + $apps[$x]['permissions'][$y]['name'] = "tone_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + ?> diff --git a/app/voicemails/app_config.php b/app/voicemails/app_config.php index 8b737e0e7b..f144d1bf4c 100644 --- a/app/voicemails/app_config.php +++ b/app/voicemails/app_config.php @@ -129,6 +129,12 @@ $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "user"; $apps[$x]['permissions'][$y]['groups'][] = "agent"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "voicemail_destinations"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "agent"; //default settings $y=0; diff --git a/resources/classes/destinations.php b/resources/classes/destinations.php index 2aa9de8a04..a7e9b48ce2 100644 --- a/resources/classes/destinations.php +++ b/resources/classes/destinations.php @@ -80,10 +80,11 @@ if (!class_exists('destinations')) { $i = 0; foreach ($apps as $x => &$app) { if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) { - $this->destinations[] = $row; + if (permission_exists($this->singular($row["name"])."_destinations")) { + $this->destinations[] = $row; + } } } - //put the array in order foreach ($this->destinations as $row) { $option_groups[] = $row['label']; @@ -586,6 +587,43 @@ if (!class_exists('destinations')) { } } //method + //define singular function to convert a word in english to singular + public function singular($word) { + //"-es" is used for words that end in "-x", "-s", "-z", "-sh", "-ch" in which case you add + if (substr($word, -2) == "es") { + if (substr($word, -4) == "sses") { // eg. 'addresses' to 'address' + return substr($word,0,-2); + } + elseif (substr($word, -3) == "ses") { // eg. 'databases' to 'database' (necessary!) + return substr($word,0,-1); + } + elseif (substr($word, -3) == "ies") { // eg. 'countries' to 'country' + return substr($word,0,-3)."y"; + } + elseif (substr($word, -3, 1) == "x") { + return substr($word,0,-2); + } + elseif (substr($word, -3, 1) == "s") { + return substr($word,0,-2); + } + elseif (substr($word, -3, 1) == "z") { + return substr($word,0,-2); + } + elseif (substr($word, -4, 2) == "sh") { + return substr($word,0,-2); + } + elseif (substr($word, -4, 2) == "ch") { + return substr($word,0,-2); + } + else { + return rtrim($word, "s"); + } + } + else { + return rtrim($word, "s"); + } + } //method + } //class } /*