@@ -150,10 +150,14 @@ function onShowEnd() {
150150 }
151151
152152 /*
153- * If the names are restricted -> remove the client , so that the
153+ * If the names are restricted -> remove the restriction , so that the
154154 * data can be edited
155155 */
156156 if ($ interfaceConf ['restrict_names ' ] == true ){
157+ /* get the restriction */
158+ $ restriction = '[CLIENTNAME]_ ' ;
159+ if (isset ($ interfaceConf ['restrict_dbname ' ])) $ restriction = $ interfaceConf ['restrict_dbname ' ];
160+ $ tmpRestriction = $ restriction ;
157161 /* Get the group-id */
158162 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
159163 // Get the group-id of the user
@@ -168,18 +172,19 @@ function onShowEnd() {
168172 $ clientName = $ tmp ['name ' ];
169173 if ($ clientName == "" ) $ clientName = 'default ' ;
170174 $ clientName = convertClientName ($ clientName );
175+ $ restriction = str_replace ('[CLIENTNAME] ' , $ clientName , $ restriction );
171176 if ($ this ->dataRecord ['database_name ' ] != "" ){
172177 /* REMOVE the restriction */
173- $ app ->tpl ->setVar ("database_name " , str_replace ($ clientName . ' _ ' , '' , $ this ->dataRecord ['database_name ' ]));
174- $ app ->tpl ->setVar ("database_user " , str_replace ($ clientName . ' _ ' , '' , $ this ->dataRecord ['database_user ' ]));
178+ $ app ->tpl ->setVar ("database_name " , str_replace ($ restriction , '' , $ this ->dataRecord ['database_name ' ]));
179+ $ app ->tpl ->setVar ("database_user " , str_replace ($ restriction , '' , $ this ->dataRecord ['database_user ' ]));
175180 }
176181 if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' || $ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
177- $ app ->tpl ->setVar ("database_name_prefix " , ' {client}_ ' );
178- $ app ->tpl ->setVar ("database_user_prefix " , ' {client}_ ' );
182+ $ app ->tpl ->setVar ("database_name_prefix " , $ tmpRestriction );
183+ $ app ->tpl ->setVar ("database_user_prefix " , $ tmpRestriction );
179184 }
180185 else {
181- $ app ->tpl ->setVar ("database_name_prefix " , $ clientName . ' _ ' );
182- $ app ->tpl ->setVar ("database_user_prefix " , $ clientName . ' _ ' );
186+ $ app ->tpl ->setVar ("database_name_prefix " , $ restriction );
187+ $ app ->tpl ->setVar ("database_user_prefix " , $ restriction );
183188 }
184189 }
185190
@@ -231,6 +236,10 @@ function onBeforeUpdate() {
231236 * If the names should be restricted -> do it!
232237 */
233238 if ($ interfaceConf ['restrict_names ' ] == true ){
239+ /* get the restriction */
240+ $ restriction = '[CLIENTNAME]_ ' ;
241+ if (isset ($ interfaceConf ['restrict_dbname ' ])) $ restriction = $ interfaceConf ['restrict_dbname ' ];
242+
234243 /* Get the group-id */
235244 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
236245 // Get the group-id of the user
@@ -245,17 +254,17 @@ function onBeforeUpdate() {
245254 $ clientName = $ tmp ['name ' ];
246255 if ($ clientName == "" ) $ clientName = 'default ' ;
247256 $ clientName = convertClientName ($ clientName );
248- $ nameSuffix = $ clientName . ' _ ' ;
257+ $ restriction = str_replace ( ' [CLIENTNAME] ' , $ clientName, $ restriction ) ;
249258 }
250259 else {
251- $ nameSuffix = '' ;
260+ $ restriction = '' ;
252261 }
253262
254263 $ error = false ;
255264
256265 //* Prevent that the database name and charset is changed
257266 $ old_record = $ app ->tform ->getDataRecord ($ this ->id );
258- if ($ old_record ["database_name " ] != $ nameSuffix . $ this ->dataRecord ["database_name " ]) {
267+ if ($ old_record ["database_name " ] != $ restriction . $ this ->dataRecord ["database_name " ]) {
259268 $ app ->tform ->errorMessage .= $ app ->tform ->wordbook ["database_name_change_txt " ].'<br /> ' ;
260269 $ error = true ;
261270 }
@@ -278,21 +287,24 @@ function onBeforeUpdate() {
278287
279288 if ($ error == false ){
280289 /* restrict the names if there is no error */
281- $ this ->dataRecord ['database_name ' ] = $ nameSuffix . $ this ->dataRecord ['database_name ' ];
282- $ this ->dataRecord ['database_user ' ] = $ nameSuffix . $ this ->dataRecord ['database_user ' ];
290+ $ this ->dataRecord ['database_name ' ] = $ restriction . $ this ->dataRecord ['database_name ' ];
291+ $ this ->dataRecord ['database_user ' ] = $ restriction . $ this ->dataRecord ['database_user ' ];
283292 }
284293
285294 parent ::onBeforeUpdate ();
286295 }
287296
288297 function onBeforeInsert () {
289298 global $ app , $ conf , $ interfaceConf ;
290- global $ interfaceConf ;
291299
292300 /*
293301 * If the names should be restricted -> do it!
294302 */
295303 if ($ interfaceConf ['restrict_names ' ] == true ){
304+ /* get the restriction */
305+ $ restriction = '[CLIENTNAME]_ ' ;
306+ if (isset ($ interfaceConf ['restrict_dbname ' ])) $ restriction = $ interfaceConf ['restrict_dbname ' ];
307+
296308 /* Get the group-id */
297309 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
298310 // Get the group-id of the user
@@ -307,9 +319,11 @@ function onBeforeInsert() {
307319 $ clientName = $ tmp ['name ' ];
308320 if ($ clientName == "" ) $ clientName = 'default ' ;
309321 $ clientName = convertClientName ($ clientName );
322+ $ restriction = str_replace ('[CLIENTNAME] ' , $ clientName , $ restriction );
323+
310324 /* restrict the names */
311- $ this ->dataRecord ['database_name ' ] = $ clientName . ' _ ' . $ this ->dataRecord ['database_name ' ];
312- $ this ->dataRecord ['database_user ' ] = $ clientName . ' _ ' . $ this ->dataRecord ['database_user ' ];
325+ $ this ->dataRecord ['database_name ' ] = $ restriction . $ this ->dataRecord ['database_name ' ];
326+ $ this ->dataRecord ['database_user ' ] = $ restriction . $ this ->dataRecord ['database_user ' ];
313327 }
314328 parent ::onBeforeInsert ();
315329 }
0 commit comments