Procházet zdrojové kódy

Merge branch 'fix/1286-fix_javascript_database_name' into staging/fixes

Kristan Kenney před 5 roky
rodič
revize
ea18723054

+ 1 - 1
web/add/web/index.php

@@ -342,7 +342,7 @@ if (!empty($_POST['ok'])) {
                     $v_ftp_user_data['is_new'] = 1;
                 }
 
-                $v_ftp_username = preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']);
+                $v_ftp_username = $user.'_'.$v_ftp_user_data['v_ftp_user'];
                 $v_ftp_users_updated[] = array(
                     'is_new'            => $v_ftp_user_data['is_new'],
                     'v_ftp_user'        => $return_var == 0 ? $v_ftp_username_full : $v_ftp_username,

+ 1 - 2
web/edit/db/index.php

@@ -27,7 +27,7 @@ unset($output);
 
 // Parse database
 $v_username = $user;
-$v_dbuser = $data[$v_database]['DBUSER'];
+$v_dbuser =  preg_replace("/^".$user."_/", "", $data[$v_database]['DBUSER']);
 $v_password = "";
 $v_host = $data[$v_database]['HOST'];
 $v_type = $data[$v_database]['TYPE'];
@@ -53,7 +53,6 @@ if (!empty($_POST['save'])) {
     
     // Change database user
     if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) {
-        $v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
         $v_dbuser = escapeshellarg($v_dbuser);
         exec (HESTIA_CMD."v-change-database-user ".$v_username." ".escapeshellarg($v_database)." ".$v_dbuser, $output, $return_var);
         check_return_code($return_var,$output);

+ 0 - 9
web/js/pages/add_db.js

@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
-    }
-    
     $(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
 }
 
@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
-    }
     $(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
 }
 

+ 1 - 4
web/js/pages/add_web.js

@@ -42,10 +42,7 @@ App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     }
-
-    if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
-    }
+    
     hint = hint.replace(/[^\w\d]/gi, '');
 
     $(elm).parent().find('.v-ftp-user').val(hint);

+ 8 - 12
web/js/pages/edit_db.js

@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
-    }
-    
     $(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
 }
 
@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
-    }
     $(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
 }
 
@@ -34,7 +25,7 @@ App.Listeners.DB.keypress_db_username = function() {
     var current_val = ref.val();
     if (current_val.trim() != '') {
         App.Actions.DB.update_db_username_hint(ref, current_val);
-    }
+    }    
     
     ref.bind('keypress input', function(evt) {
         clearTimeout(window.frp_usr_tmt);
@@ -50,9 +41,13 @@ App.Listeners.DB.keypress_db_username = function() {
 App.Listeners.DB.keypress_db_databasename = function() {
     var ref = $('input[name="v_database"]');
     var current_val = ref.val();
-    if (current_val.trim() != '') {
-        App.Actions.DB.update_db_databasename_hint(ref, current_val);
+    if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
+        current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
+        ref.val(current_val);
     }
+    if (current_val.trim() != '') {
+        App.Actions.DB.update_db_username_hint(ref, current_val);
+    }   
     
     ref.bind('keypress input', function(evt) {
         clearTimeout(window.frp_dbn_tmt);
@@ -97,6 +92,7 @@ App.Listeners.DB.keypress_v_password();
 App.Listeners.DB.keypress_db_username();
 App.Listeners.DB.keypress_db_databasename();
 
+
 randomString = function(min_length = 16) {
     var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
     var string_length = min_length;

+ 0 - 3
web/js/pages/edit_web.js

@@ -42,9 +42,6 @@ App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
         $(elm).parent().find('.hint').html('');
     }
 
-    if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
-    }
     hint = hint.replace(/[^\w\d]/gi, '');
 
     $(elm).parent().find('.v-ftp-user').val(hint);