@@ -871,6 +871,9 @@ function onAfterUpdate() {
871871 $ client = $ app ->db ->queryOneRecord ("SELECT client_id FROM sys_group WHERE sys_group.groupid = " .$ app ->functions ->intval ($ client_group_id ));
872872 $ client_id = $ app ->functions ->intval ($ client ["client_id " ]);
873873 }
874+
875+ $ tmp = $ app ->db ->queryOneRecord ("SELECT userid FROM sys_user WHERE default_group = $ client_group_id " );
876+ $ client_user_id = $ app ->functions ->intval (($ tmp ['userid ' ] > 0 )?$ tmp ['userid ' ]:1 );
874877
875878 if (($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' || $ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) && isset ($ this ->dataRecord ["client_group_id " ]) && $ this ->dataRecord ["client_group_id " ] != $ this ->oldDataRecord ["sys_groupid " ]) {
876879 // Set the values for document_root, system_user and system_group
@@ -883,30 +886,30 @@ function onAfterUpdate() {
883886 $ document_root = str_replace ("[client_idhash_4] " , $ this ->id_hash ($ client_id , 4 ), $ document_root );
884887 $ document_root = $ app ->db ->quote ($ document_root );
885888
886- $ sql = "UPDATE web_domain SET system_user = ' $ system_user', system_group = ' $ system_group', document_root = ' $ document_root' WHERE domain_id = " .$ this ->id ;
889+ $ sql = "UPDATE web_domain SET sys_userid = ' $ client_user_id ' , system_user = '$ system_user', system_group = ' $ system_group', document_root = ' $ document_root' WHERE domain_id = " .$ this ->id ;
887890 //$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group' WHERE domain_id = ".$this->id;
888891 $ app ->db ->query ($ sql );
889892
890893 // Update the FTP user(s) too
891894 $ records = $ app ->db ->queryAllRecords ("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = " .$ this ->id );
892895 foreach ($ records as $ rec ) {
893- $ app ->db ->datalogUpdate ('ftp_user ' , "sys_userid = ' " .$ app ->functions ->intval ($ web_rec [ ' sys_userid ' ] )."', sys_groupid = ' " .$ app ->functions ->intval ($ web_rec ['sys_groupid ' ])."', uid = ' $ system_user', gid = ' $ system_group', dir = ' $ document_root' " , 'ftp_user_id ' , $ app ->functions ->intval ($ rec ['ftp_user_id ' ]));
896+ $ app ->db ->datalogUpdate ('ftp_user ' , "sys_userid = ' " .$ app ->functions ->intval ($ client_user_id )."', sys_groupid = ' " .$ app ->functions ->intval ($ web_rec ['sys_groupid ' ])."', uid = ' $ system_user', gid = ' $ system_group', dir = ' $ document_root' " , 'ftp_user_id ' , $ app ->functions ->intval ($ rec ['ftp_user_id ' ]));
894897 }
895898 unset($ records );
896899 unset($ rec );
897900
898901 // Update the Shell user(s) too
899902 $ records = $ app ->db ->queryAllRecords ("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = " .$ this ->id );
900903 foreach ($ records as $ rec ) {
901- $ app ->db ->datalogUpdate ('shell_user ' , "sys_userid = ' " .$ web_rec [ ' sys_userid ' ] ."', sys_groupid = ' " .$ web_rec ['sys_groupid ' ]."', puser = ' $ system_user', pgroup = ' $ system_group', dir = ' $ document_root' " , 'shell_user_id ' , $ app ->functions ->intval ($ rec ['shell_user_id ' ]));
904+ $ app ->db ->datalogUpdate ('shell_user ' , "sys_userid = ' " .$ client_user_id ."', sys_groupid = ' " .$ web_rec ['sys_groupid ' ]."', puser = ' $ system_user', pgroup = ' $ system_group', dir = ' $ document_root' " , 'shell_user_id ' , $ app ->functions ->intval ($ rec ['shell_user_id ' ]));
902905 }
903906 unset($ records );
904907 unset($ rec );
905908
906909 //* Update all subdomains and alias domains
907910 $ records = $ app ->db ->queryAllRecords ("SELECT domain_id, `domain`, `type`, `web_folder` FROM web_domain WHERE parent_domain_id = " .$ this ->id );
908911 foreach ($ records as $ rec ) {
909- $ update_columns = "sys_userid = ' " .$ web_rec [ ' sys_userid ' ] ."', sys_groupid = ' " .$ web_rec ['sys_groupid ' ]."' " ;
912+ $ update_columns = "sys_userid = ' " .$ client_user_id ."', sys_groupid = ' " .$ web_rec ['sys_groupid ' ]."' " ;
910913 if ($ rec ['type ' ] == 'vhostsubdomain ' ) {
911914 $ php_open_basedir = str_replace ("[website_path]/web " , $ document_root .'/ ' .$ rec ['web_folder ' ], $ web_config ["php_open_basedir " ]);
912915 $ php_open_basedir = str_replace ("[website_domain]/web " , $ rec ['domain ' ].'/ ' .$ rec ['web_folder ' ], $ php_open_basedir );
@@ -923,7 +926,7 @@ function onAfterUpdate() {
923926 //* Update all databases
924927 $ records = $ app ->db ->queryAllRecords ("SELECT database_id FROM web_database WHERE parent_domain_id = " .$ this ->id );
925928 foreach ($ records as $ rec ) {
926- $ app ->db ->datalogUpdate ('web_database ' , "sys_userid = ' " .$ app ->functions ->intval ($ web_rec [ ' sys_userid ' ] )."', sys_groupid = ' " .$ app ->functions ->intval ($ web_rec ['sys_groupid ' ])."' " , 'database_id ' , $ app ->functions ->intval ($ rec ['database_id ' ]));
929+ $ app ->db ->datalogUpdate ('web_database ' , "sys_userid = ' " .$ app ->functions ->intval ($ client_user_id )."', sys_groupid = ' " .$ app ->functions ->intval ($ web_rec ['sys_groupid ' ])."' " , 'database_id ' , $ app ->functions ->intval ($ rec ['database_id ' ]));
927930 }
928931 unset($ records );
929932 unset($ rec );
0 commit comments