@@ -275,7 +275,26 @@ function onBeforeUpdate() {
275275 }
276276 }
277277 }
278-
278+
279+ if ($ app ->tform ->errorMessage == '' ) {
280+ // force update of the used database user
281+ if ($ this ->dataRecord ['database_user_id ' ]) {
282+ $ user_old_rec = $ app ->db ->queryOneRecord ('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $ app ->functions ->intval ($ this ->dataRecord ['database_user_id ' ]));
283+ if ($ user_old_rec ) {
284+ $ user_new_rec = $ user_old_rec ;
285+ $ user_new_rec ['server_id ' ] = $ this ->dataRecord ['server_id ' ];
286+ $ app ->db ->datalogSave ('web_database_user ' , 'UPDATE ' , 'database_user_id ' , $ this ->dataRecord ['database_user_id ' ], $ user_old_rec , $ user_new_rec );
287+ }
288+ }
289+ if ($ this ->dataRecord ['database_ro_user_id ' ]) {
290+ $ user_old_rec = $ app ->db ->queryOneRecord ('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $ app ->functions ->intval ($ this ->dataRecord ['database_ro_user_id ' ]));
291+ if ($ user_old_rec ) {
292+ $ user_new_rec = $ user_old_rec ;
293+ $ user_new_rec ['server_id ' ] = $ this ->dataRecord ['server_id ' ];
294+ $ app ->db ->datalogSave ('web_database_user ' , 'UPDATE ' , 'database_user_id ' , $ this ->dataRecord ['database_ro_user_id ' ], $ user_old_rec , $ user_new_rec );
295+ }
296+ }
297+ }
279298
280299 parent ::onBeforeUpdate ();
281300 }
@@ -344,6 +363,27 @@ function onBeforeInsert() {
344363 }
345364 }
346365
366+ if ($ app ->tform ->errorMessage == '' ) {
367+ // force update of the used database user
368+ if ($ this ->dataRecord ['database_user_id ' ]) {
369+ $ user_old_rec = $ app ->db ->queryOneRecord ('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $ app ->functions ->intval ($ this ->dataRecord ['database_user_id ' ]));
370+ if ($ user_old_rec ) {
371+ $ user_new_rec = $ user_old_rec ;
372+ $ user_new_rec ['server_id ' ] = $ this ->dataRecord ['server_id ' ];
373+ $ app ->db ->datalogSave ('web_database_user ' , 'UPDATE ' , 'database_user_id ' , $ this ->dataRecord ['database_user_id ' ], $ user_old_rec , $ user_new_rec );
374+ }
375+ }
376+ if ($ this ->dataRecord ['database_ro_user_id ' ]) {
377+ $ user_old_rec = $ app ->db ->queryOneRecord ('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $ app ->functions ->intval ($ this ->dataRecord ['database_ro_user_id ' ]));
378+ if ($ user_old_rec ) {
379+ $ user_new_rec = $ user_old_rec ;
380+ $ user_new_rec ['server_id ' ] = $ this ->dataRecord ['server_id ' ];
381+ $ app ->db ->datalogSave ('web_database_user ' , 'UPDATE ' , 'database_user_id ' , $ this ->dataRecord ['database_ro_user_id ' ], $ user_old_rec , $ user_new_rec );
382+ }
383+ }
384+ }
385+
386+
347387 parent ::onBeforeInsert ();
348388 }
349389
0 commit comments