From 5b3cd98a29d6fc4740f58a80b9ddd91813ffb461 Mon Sep 17 00:00:00 2001 From: fusionate Date: Sun, 29 Jan 2023 07:37:38 +0000 Subject: [PATCH] Default Setting - Edit: Add Clone button to duplicate setting. --- core/default_settings/app_config.php | 3 + core/default_settings/app_languages.php | 21 +++++ .../default_setting_clone.php | 86 +++++++++++++++++++ .../default_settings/default_setting_edit.php | 6 ++ resources/app_languages.php | 46 ++++++++++ themes/default/app_config.php | 8 ++ 6 files changed, 170 insertions(+) create mode 100644 core/default_settings/default_setting_clone.php diff --git a/core/default_settings/app_config.php b/core/default_settings/app_config.php index a68af27790..0d221ca63b 100644 --- a/core/default_settings/app_config.php +++ b/core/default_settings/app_config.php @@ -41,6 +41,9 @@ $apps[$x]['permissions'][$y]['name'] = "default_setting_edit"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "default_setting_clone"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; $apps[$x]['permissions'][$y]['name'] = "default_setting_delete"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; diff --git a/core/default_settings/app_languages.php b/core/default_settings/app_languages.php index 1b36c64aad..4a6cfbcbb5 100644 --- a/core/default_settings/app_languages.php +++ b/core/default_settings/app_languages.php @@ -301,6 +301,27 @@ $text['message-toggled']['ru-ru'] = "Переключить выполнено"; $text['message-toggled']['sv-se'] = "Växla Avslutade"; $text['message-toggled']['uk-ua'] = "переключити Завершений"; +$text['message-cloned']['en-us'] = "Setting Cloned"; +$text['message-cloned']['en-gb'] = "Setting Cloned"; +$text['message-cloned']['ar-eg'] = "Setting Cloned"; +$text['message-cloned']['de-at'] = "Setting Cloned"; +$text['message-cloned']['de-ch'] = "Setting Cloned"; +$text['message-cloned']['de-de'] = "Setting Cloned"; +$text['message-cloned']['es-cl'] = "Setting Cloned"; +$text['message-cloned']['es-mx'] = "Setting Cloned"; +$text['message-cloned']['fr-ca'] = "Setting Cloned"; +$text['message-cloned']['fr-fr'] = "Setting Cloned"; +$text['message-cloned']['he-il'] = "Setting Cloned"; +$text['message-cloned']['it-it'] = "Setting Cloned"; +$text['message-cloned']['nl-nl'] = "Setting Cloned"; +$text['message-cloned']['pl-pl'] = "Setting Cloned"; +$text['message-cloned']['pt-br'] = "Setting Cloned"; +$text['message-cloned']['pt-pt'] = "Setting Cloned"; +$text['message-cloned']['ro-ro'] = "Setting Cloned"; +$text['message-cloned']['ru-ru'] = "Setting Cloned"; +$text['message-cloned']['sv-se'] = "Setting Cloned"; +$text['message-cloned']['uk-ua'] = "Setting Cloned"; + $text['message-settings_reloaded']['en-us'] = "Settings Reloaded"; $text['message-settings_reloaded']['en-gb'] = "Settings Reloaded"; $text['message-settings_reloaded']['ar-eg'] = ""; diff --git a/core/default_settings/default_setting_clone.php b/core/default_settings/default_setting_clone.php new file mode 100644 index 0000000000..9fa64f2c14 --- /dev/null +++ b/core/default_settings/default_setting_clone.php @@ -0,0 +1,86 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2023 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//set the include path + $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); + set_include_path(parse_ini_file($conf[0])['document.root']); + +//includes files + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('default_setting_clone')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get submitted variables + $search = $_REQUEST['search']; + $default_setting_uuid = $_REQUEST["id"]; + +//clone the setting + if (is_uuid($default_setting_uuid)) { + //get current setting + $sql = "select * from v_default_settings where default_setting_uuid = :default_setting_uuid "; + $parameters['default_setting_uuid'] = $default_setting_uuid; + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + unset($sql, $parameters); + + //override old values + $default_setting_uuid = uuid(); + $row['default_setting_uuid'] = $default_setting_uuid; + $row['insert_date'] = 'now()'; + $row['insert_user'] = 'user_uuid()'; + $row['update_date'] = null; + $row['update_user'] = null; + + //set new status + $array['default_settings'][0] = $row; + $database = new database; + $database->app_name = 'default_settings'; + $database->app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09'; + $database->save($array); + $message = $database->message; + unset($array); + + } + + $_SESSION["message"] = $text['message-cloned']; + +//redirect the user + $search = preg_replace('#[^a-zA-Z0-9_\-\.]# ', '', $search); + header("Location: default_setting_edit.php?id=".$default_setting_uuid."".($search != '' ? '&search='.$search : null)); + +?> diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index db57725211..54594ab96b 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -273,7 +273,13 @@ echo " \n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'default_settings.php?'.$query_string]); + if (permission_exists('default_setting_clone') && $action == "update") { + echo button::create(['type'=>'button','label'=>$text['button-clone'],'icon'=>$_SESSION['theme']['button_icon_clone'],'name'=>'btn_clone','style'=>'margin-right: 15px;','onclick'=>"modal_open('modal-clone','btn_clone');"]); + } echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','onclick'=>'submit_form();']); + if (permission_exists('default_setting_clone') && $action == "update") { + echo modal::create(['id'=>'modal-clone','type'=>'general','message'=>$text['confirm-clone'],'actions'=>button::create(['type'=>'button','label'=>$text['button-clone'],'icon'=>'clone','id'=>'btn_clone','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); window.location.href='default_setting_clone.php?id=".$default_setting_uuid."'"])]); + } echo "
\n"; echo "
\n"; echo "\n"; diff --git a/resources/app_languages.php b/resources/app_languages.php index 12437531c5..62b5d318ab 100644 --- a/resources/app_languages.php +++ b/resources/app_languages.php @@ -539,6 +539,29 @@ $text['confirm-copy']['sv-se'] = "Vill du verkligen kopiera detta?"; $text['confirm-copy']['uk-ua'] = ""; $text['confirm-copy']['tr-tr'] = "Bunu gerçekten kopyalamak istiyor musunuz?"; +$text['confirm-clone']['en-us'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['en-gb'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['ar-eg'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['de-at'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['de-ch'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['de-de'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['el-gr'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['es-cl'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['es-mx'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['fr-ca'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['fr-fr'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['he-il'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['it-it'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['nl-nl'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['pl-pl'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['pt-br'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['pt-pt'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['ro-ro'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['ru-ru'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['sv-se'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['uk-ua'] = "Do you really want to CLONE this?"; +$text['confirm-clone']['tr-tr'] = "Do you really want to CLONE this?"; + $text['confirm-toggle']['en-us'] = "Do you really want to TOGGLE this?"; $text['confirm-toggle']['en-gb'] = "Do you really want to TOGGLE this?"; $text['confirm-toggle']['ar-eg'] = "Do you really want to TOGGLE this?"; @@ -676,6 +699,29 @@ $text['button-clear']['sv-se'] = "Rensa"; $text['button-clear']['uk-ua'] = ""; $text['button-clear']['tr-tr'] = "Temizle"; +$text['button-clone']['en-us'] = "Clone"; +$text['button-clone']['en-gb'] = "Clone"; +$text['button-clone']['ar-eg'] = "Clone"; +$text['button-clone']['de-at'] = "Clone"; +$text['button-clone']['de-ch'] = "Clone"; +$text['button-clone']['de-de'] = "Clone"; +$text['button-clone']['el-gr'] = "Clone"; +$text['button-clone']['es-cl'] = "Clone"; +$text['button-clone']['es-mx'] = "Clone"; +$text['button-clone']['fr-ca'] = "Clone"; +$text['button-clone']['fr-fr'] = "Clone"; +$text['button-clone']['he-il'] = "Clone"; +$text['button-clone']['it-it'] = "Clone"; +$text['button-clone']['nl-nl'] = "Clone"; +$text['button-clone']['pl-pl'] = "Clone"; +$text['button-clone']['pt-br'] = "Clone"; +$text['button-clone']['pt-pt'] = "Clone"; +$text['button-clone']['ro-ro'] = "Clone"; +$text['button-clone']['ru-ru'] = "Clone"; +$text['button-clone']['sv-se'] = "Clone"; +$text['button-clone']['uk-ua'] = "Clone"; +$text['button-clone']['tr-tr'] = "Clone"; + $text['button-close']['en-us'] = "Close"; $text['button-close']['en-gb'] = "Close"; $text['button-close']['ar-eg'] = ""; diff --git a/themes/default/app_config.php b/themes/default/app_config.php index d69cd91a8b..e05e2f9530 100644 --- a/themes/default/app_config.php +++ b/themes/default/app_config.php @@ -2327,6 +2327,14 @@ $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "4323a528-06f4-4550-9b9b-3190c8325958"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "theme"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "button_icon_clone"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "fas fa-clone"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "814ed631-a315-4bde-a822-4038432ae2a6"; $apps[$x]['default_settings'][$y]['default_setting_category'] = "theme"; $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "keyboard_shortcut_check_all_enabled";