Просмотр исходного кода

Improved code + Changed behavouir /edit/db to keep in sync with /add/db

Jaap Marcus 5 лет назад
Родитель
Сommit
25bbb3ca9a
3 измененных файлов с 2 добавлено и 15 удалено
  1. 2 2
      web/edit/db/index.php
  2. 0 9
      web/js/pages/add_db.js
  3. 0 4
      web/js/pages/edit_db.js

+ 2 - 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,7 @@ 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 = 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);
 }
 

+ 0 - 4
web/js/pages/edit_db.js

@@ -23,10 +23,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
 App.Listeners.DB.keypress_db_username = function() {
     var ref = $('input[name="v_dbuser"]');
     var current_val = ref.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);
     }