@@ -139,37 +139,31 @@ function loadFormDef($file) {
139139
140140 //* Load the user profile
141141 function loadUserProfile ($ client_id = 0 ) {
142- global $ app ,$ conf ;
143-
144- $ client_id = intval ($ client_id );
145-
146- if ($ client_id == 0 ) {
147- $ this ->sys_username = 'admin ' ;
148- $ this ->sys_userid = 1 ;
149- $ this ->sys_default_group = 1 ;
150- $ this ->sys_groups = 1 ;
151- } else {
152- //* Load the client data
153- $ client = $ app ->db ->queryOneRecord ("SELECT username FROM client WHERE client_id = $ client_id " );
154- if ($ client ["username " ] == '' ) {
155- $ this ->errorMessage .= 'No client with ID $client_id found. ' ;
156- return false ;
157- }
158- //* load system user
159- $ user = $ app ->db ->queryOneRecord ("SELECT * FROM sys_user WHERE username = ' " .$ app ->db ->quote ($ client ["username " ])."' " );
160- if (empty ($ user ["userid " ])) {
161- $ this ->errorMessage .= 'No user with the username ' .$ client ['username ' ].' found. ' ;
162- return false ;
163- }
164- $ this ->sys_username = $ user ['username ' ];
165- $ this ->sys_userid = $ user ['userid ' ];
166- $ this ->sys_default_group = $ user ['default_group ' ];
167- $ this ->sys_groups = $ user ['groups ' ];
168- }
169-
170- return true ;
171-
172- }
142+ global $ app ,$ conf ;
143+
144+ $ client_id = intval ($ client_id );
145+
146+ if ($ client_id == 0 ) {
147+ $ this ->sys_username = 'admin ' ;
148+ $ this ->sys_userid = 1 ;
149+ $ this ->sys_default_group = 1 ;
150+ $ this ->sys_groups = 1 ;
151+ } else {
152+ //* load system user
153+ $ user = $ app ->db ->queryOneRecord ("SELECT * FROM sys_user WHERE sysuser_id = $ client_id " );
154+ if (empty ($ user ["userid " ])) {
155+ $ this ->errorMessage .= 'No sysuser with the ID $client_id found. ' ;
156+ return false ;
157+ }
158+ $ this ->sys_username = $ user ['username ' ];
159+ $ this ->sys_userid = $ user ['userid ' ];
160+ $ this ->sys_default_group = $ user ['default_group ' ];
161+ $ this ->sys_groups = $ user ['groups ' ];
162+ }
163+
164+ return true ;
165+
166+ }
173167
174168
175169 /**
0 commit comments