@@ -92,7 +92,7 @@ function onSubmit() {
9292 }
9393 }
9494 }
95-
95+
9696 //* Resellers shall not be able to create another reseller
9797 if ($ _SESSION ["s " ]["user " ]["typ " ] == 'user ' ) {
9898 $ this ->dataRecord ['limit_client ' ] = 0 ;
@@ -181,18 +181,26 @@ function onShowEnd() {
181181
182182 $ app ->tpl ->setVar ('template_additional_list ' , $ text );
183183 $ app ->tpl ->setVar ('app_module ' , 'client ' );
184-
184+
185+ // Check wether per domain relaying is enabled or not
186+ $ global_config = $ app ->getconf ->get_global_config ('mail ' );
187+ if ($ global_config ['show_per_domain_relay_options ' ] == 'y ' ) {
188+ $ app ->tpl ->setVar ("show_per_domain_relay_options " , 1 );
189+ } else {
190+ $ app ->tpl ->setVar ("show_per_domain_relay_options " , 0 );
191+ }
192+
185193
186194 //* Set the 'customer no' default value
187195 if ($ this ->id == 0 ) {
188-
196+
189197 if ($ app ->auth ->is_admin ()) {
190198 //* Logged in User is admin
191199 //* get the system config
192200 $ app ->uses ('getconf ' );
193201 $ system_config = $ app ->getconf ->get_global_config ();
194202 if ($ system_config ['misc ' ]['customer_no_template ' ] != '' ) {
195-
203+
196204 //* Set customer no default
197205 $ customer_no = $ app ->functions ->intval ($ system_config ['misc ' ]['customer_no_start ' ]+$ system_config ['misc ' ]['customer_no_counter ' ]);
198206 $ customer_no_string = str_replace ('[CUSTOMER_NO] ' ,$ customer_no ,$ system_config ['misc ' ]['customer_no_template ' ]);
@@ -203,7 +211,7 @@ function onShowEnd() {
203211 //* get the record of the reseller
204212 $ client_group_id = $ app ->functions ->intval ($ _SESSION ["s " ]["user " ]["default_group " ]);
205213 $ reseller = $ app ->db ->queryOneRecord ("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ? " , $ client_group_id );
206-
214+
207215 if ($ reseller ['customer_no_template ' ] != '' ) {
208216 if (isset ($ this ->dataRecord ['customer_no ' ])&& $ this ->dataRecord ['customer_no ' ]!='' ) $ customer_no_string = $ this ->dataRecord ['customer_no ' ];
209217 else {
@@ -215,7 +223,7 @@ function onShowEnd() {
215223 }
216224 }
217225 }
218-
226+
219227 if ($ app ->auth ->is_admin ()) {
220228 // Fill the client select field
221229 $ sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name " ;
@@ -234,7 +242,7 @@ function onShowEnd() {
234242 }
235243 $ app ->tpl ->setVar ("parent_client_id " , $ client_select );
236244 }
237-
245+
238246 parent ::onShowEnd ();
239247
240248 }
@@ -317,15 +325,15 @@ function onAfterInsert() {
317325 $ app ->uses ('client_templates ' );
318326 $ app ->client_templates ->update_client_templates ($ this ->id , $ this ->_template_additional );
319327 }
320-
328+
321329 if ($ this ->dataRecord ['customer_no ' ] == $ this ->dataRecord ['customer_no_org ' ]) {
322330 if ($ app ->auth ->is_admin ()) {
323331 //* Logged in User is admin
324332 //* get the system config
325333 $ app ->uses ('getconf ' );
326334 $ system_config = $ app ->getconf ->get_global_config ();
327335 if ($ system_config ['misc ' ]['customer_no_template ' ] != '' ) {
328-
336+
329337 //* save new counter value
330338 $ system_config ['misc ' ]['customer_no_counter ' ]++;
331339 $ system_config_str = $ app ->ini_parser ->get_ini_string ($ system_config );
@@ -336,15 +344,15 @@ function onAfterInsert() {
336344 //* get the record of the reseller
337345 $ client_group_id = $ app ->functions ->intval ($ _SESSION ["s " ]["user " ]["default_group " ]);
338346 $ reseller = $ app ->db ->queryOneRecord ("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ? " , $ client_group_id );
339-
347+
340348 if ($ reseller ['customer_no_template ' ] != '' ) {
341349 //* save new counter value
342350 $ customer_no_counter = $ app ->functions ->intval ($ reseller ['customer_no_counter ' ]+1 );
343351 $ app ->db ->query ("UPDATE client SET customer_no_counter = ? WHERE client_id = ? " , $ customer_no_counter , $ reseller ['client_id ' ]);
344352 }
345353 }
346354 }
347-
355+
348356 //* Send welcome email
349357 $ client_group_id = $ app ->functions ->intval ($ _SESSION ["s " ]["user " ]["default_group " ]);
350358 $ sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ? " ;
@@ -369,7 +377,7 @@ function onAfterInsert() {
369377 $ subject = str_replace ('{ ' .$ key .'} ' , $ val , $ subject );
370378 }
371379 }
372-
380+
373381 //* Get sender address
374382 if ($ app ->auth ->is_admin ()) {
375383 $ app ->uses ('getconf ' );
@@ -384,7 +392,7 @@ function onAfterInsert() {
384392 //* Send the email
385393 $ app ->functions ->mail ($ client ['email ' ], $ subject , $ message , $ from );
386394 }
387-
395+
388396
389397 parent ::onAfterInsert ();
390398 }
@@ -466,7 +474,7 @@ function onAfterUpdate() {
466474 $ active_col = 'disablesmtp ' ;
467475 $ reverse = true ;
468476 }
469-
477+
470478 if (!isset ($ prev_active [$ current ])) $ prev_active [$ current ] = array ();
471479 if (!isset ($ prev_sysuser [$ current ])) $ prev_sysuser [$ current ] = array ();
472480
@@ -498,7 +506,7 @@ function onAfterUpdate() {
498506 $ active_col = 'disablesmtp ' ;
499507 $ reverse = true ;
500508 }
501-
509+
502510 $ entries = $ app ->db ->queryAllRecords ('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ? ' , $ keycolumn , $ current , $ sys_groupid );
503511 foreach ($ entries as $ item ) {
504512 $ set_active = ($ reverse == true ? 'n ' : 'y ' );
@@ -551,22 +559,22 @@ function onAfterUpdate() {
551559 $ sql = "UPDATE sys_user SET modules = ? WHERE client_id = ? " ;
552560 $ app ->db ->query ($ sql , $ modules , $ client_id );
553561 }
554-
562+
555563 //* Client has been moved to another reseller
556564 if ($ _SESSION ['s ' ]['user ' ]['typ ' ] == 'admin ' && isset ($ this ->dataRecord ['parent_client_id ' ]) && $ this ->dataRecord ['parent_client_id ' ] != $ this ->oldDataRecord ['parent_client_id ' ]) {
557565 //* Get groupid of the client
558566 $ tmp = $ app ->db ->queryOneRecord ("SELECT groupid FROM sys_group WHERE client_id = ? " , $ this ->id );
559567 $ groupid = $ tmp ['groupid ' ];
560568 unset($ tmp );
561-
569+
562570 //* Remove sys_user of old reseller from client group
563571 if ($ this ->oldDataRecord ['parent_client_id ' ] > 0 ) {
564572 //* get userid of the old reseller remove it from the group of the client
565573 $ tmp = $ app ->db ->queryOneRecord ("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ? " , $ this ->oldDataRecord ['parent_client_id ' ]);
566574 $ app ->auth ->remove_group_from_user ($ tmp ['userid ' ], $ groupid );
567575 unset($ tmp );
568576 }
569-
577+
570578 //* Add sys_user of new reseller to client group
571579 if ($ this ->dataRecord ['parent_client_id ' ] > 0 ) {
572580 //* get userid of the reseller and add it to the group of the client
0 commit comments