@@ -199,78 +199,79 @@ function onShowEnd() {
199199function onSubmit () {
200200 global $ app , $ conf ;
201201
202- /* check if the domain module is used - and check if the selected domain can be used! */
203- $ app ->uses ('ini_parser,getconf ' );
204- $ settings = $ app ->getconf ->get_global_config ('domains ' );
205- if ($ settings ['use_domain_module ' ] == 'y ' ) {
206- if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' || $ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
207- $ this ->dataRecord ['client_group_id ' ] = $ app ->tools_sites ->getClientIdForDomain ($ this ->dataRecord ['origin ' ]);
208- }
209- $ domain_check = $ app ->tools_sites ->checkDomainModuleDomain ($ this ->dataRecord ['origin ' ]);
210- if (!$ domain_check ) {
211- // invalid domain selected
212- $ app ->tform ->errorMessage .= $ app ->tform ->lng ("origin_error_empty " )."<br /> " ;
213- } else {
214- $ this ->dataRecord ['origin ' ] = $ domain_check .'. ' ;
202+ if ($ app ->tform ->getCurrentTab () == 'dns_soa ' ) {
203+ /* check if the domain module is used - and check if the selected domain can be used! */
204+ $ app ->uses ('ini_parser,getconf ' );
205+ $ settings = $ app ->getconf ->get_global_config ('domains ' );
206+ if ($ settings ['use_domain_module ' ] == 'y ' ) {
207+ if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' || $ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
208+ $ this ->dataRecord ['client_group_id ' ] = $ app ->tools_sites ->getClientIdForDomain ($ this ->dataRecord ['origin ' ]);
209+ }
210+ $ domain_check = $ app ->tools_sites ->checkDomainModuleDomain ($ this ->dataRecord ['origin ' ]);
211+ if (!$ domain_check ) {
212+ // invalid domain selected
213+ $ app ->tform ->errorMessage .= $ app ->tform ->lng ("origin_error_empty " )."<br /> " ;
214+ } else {
215+ $ this ->dataRecord ['origin ' ] = $ domain_check .'. ' ;
216+ }
215217 }
216- }
217218
218- if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
219- // Get the limits of the client
220- $ client_group_id = $ _SESSION ["s " ]["user " ]["default_group " ];
221- $ client = $ app ->db ->queryOneRecord ("SELECT limit_dns_zone, dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $ client_group_id " );
219+ if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
220+ // Get the limits of the client
221+ $ client_group_id = $ _SESSION ["s " ]["user " ]["default_group " ];
222+ $ client = $ app ->db ->queryOneRecord ("SELECT limit_dns_zone, dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $ client_group_id " );
222223
223- $ client ['dns_servers_ids ' ] = explode (', ' , $ client ['dns_servers ' ]);
224+ $ client ['dns_servers_ids ' ] = explode (', ' , $ client ['dns_servers ' ]);
224225
225- // Check if chosen server is in authorized servers for this client
226- if (!(is_array ($ client ['dns_servers_ids ' ]) && in_array ($ this ->dataRecord ["server_id " ], $ client ['dns_servers_ids ' ])) && $ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
227- $ app ->error ($ app ->tform ->wordbook ['error_not_allowed_server_id ' ]);
228- }
226+ // Check if chosen server is in authorized servers for this client
227+ if (!(is_array ($ client ['dns_servers_ids ' ]) && in_array ($ this ->dataRecord ["server_id " ], $ client ['dns_servers_ids ' ])) && $ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
228+ $ app ->error ($ app ->tform ->wordbook ['error_not_allowed_server_id ' ]);
229+ }
229230
230- // When the record is updated
231- if ($ this ->id > 0 ) {
232- // restore the server ID if the user is not admin and record is edited
233- $ tmp = $ app ->db ->queryOneRecord ("SELECT server_id FROM dns_soa WHERE id = " .$ app ->functions ->intval ($ this ->id ));
234- $ this ->dataRecord ["server_id " ] = $ tmp ["server_id " ];
235- unset($ tmp );
236- // When the record is inserted
237- } else {
238- // Check if the user may add another maildomain.
239- if ($ client ["limit_dns_zone " ] >= 0 ) {
240- $ tmp = $ app ->db ->queryOneRecord ("SELECT count(id) as number FROM dns_soa WHERE sys_groupid = $ client_group_id " );
241- if ($ tmp ["number " ] >= $ client ["limit_dns_zone " ]) {
242- $ app ->error ($ app ->tform ->wordbook ["limit_dns_zone_txt " ]);
231+ // When the record is updated
232+ if ($ this ->id > 0 ) {
233+ // restore the server ID if the user is not admin and record is edited
234+ $ tmp = $ app ->db ->queryOneRecord ("SELECT server_id FROM dns_soa WHERE id = " .$ app ->functions ->intval ($ this ->id ));
235+ $ this ->dataRecord ["server_id " ] = $ tmp ["server_id " ];
236+ unset($ tmp );
237+ // When the record is inserted
238+ } else {
239+ // Check if the user may add another maildomain.
240+ if ($ client ["limit_dns_zone " ] >= 0 ) {
241+ $ tmp = $ app ->db ->queryOneRecord ("SELECT count(id) as number FROM dns_soa WHERE sys_groupid = $ client_group_id " );
242+ if ($ tmp ["number " ] >= $ client ["limit_dns_zone " ]) {
243+ $ app ->error ($ app ->tform ->wordbook ["limit_dns_zone_txt " ]);
244+ }
243245 }
244246 }
245247 }
246- }
247248
248- /*
249- // Update the serial number of the SOA record
250- $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
251- $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
252- */
249+ /*
250+ // Update the serial number of the SOA record
251+ $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
252+ $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
253+ */
253254
254255
255- //* Check if soa, ns and mbox have a dot at the end
256- if (strlen ($ this ->dataRecord ["origin " ]) > 0 && substr ($ this ->dataRecord ["origin " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["origin " ] .= '. ' ;
257- if (strlen ($ this ->dataRecord ["ns " ]) > 0 && substr ($ this ->dataRecord ["ns " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["ns " ] .= '. ' ;
258- if (strlen ($ this ->dataRecord ["mbox " ]) > 0 && substr ($ this ->dataRecord ["mbox " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["mbox " ] .= '. ' ;
256+ //* Check if soa, ns and mbox have a dot at the end
257+ if (strlen ($ this ->dataRecord ["origin " ]) > 0 && substr ($ this ->dataRecord ["origin " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["origin " ] .= '. ' ;
258+ if (strlen ($ this ->dataRecord ["ns " ]) > 0 && substr ($ this ->dataRecord ["ns " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["ns " ] .= '. ' ;
259+ if (strlen ($ this ->dataRecord ["mbox " ]) > 0 && substr ($ this ->dataRecord ["mbox " ], -1 , 1 ) != '. ' ) $ this ->dataRecord ["mbox " ] .= '. ' ;
259260
260- //* Replace @ in mbox
261- if (stristr ($ this ->dataRecord ["mbox " ], '@ ' )) {
262- $ this ->dataRecord ["mbox " ] = str_replace ('@ ' , '. ' , $ this ->dataRecord ["mbox " ]);
263- }
261+ //* Replace @ in mbox
262+ if (stristr ($ this ->dataRecord ["mbox " ], '@ ' )) {
263+ $ this ->dataRecord ["mbox " ] = str_replace ('@ ' , '. ' , $ this ->dataRecord ["mbox " ]);
264+ }
264265
265- $ this ->dataRecord ["xfer " ] = preg_replace ('/\s+/ ' , '' , $ this ->dataRecord ["xfer " ]);
266- $ this ->dataRecord ["also_notify " ] = preg_replace ('/\s+/ ' , '' , $ this ->dataRecord ["also_notify " ]);
266+ $ this ->dataRecord ["xfer " ] = preg_replace ('/\s+/ ' , '' , $ this ->dataRecord ["xfer " ]);
267+ $ this ->dataRecord ["also_notify " ] = preg_replace ('/\s+/ ' , '' , $ this ->dataRecord ["also_notify " ]);
267268
268- //* Check if a secondary zone with the same name already exists
269- $ tmp = $ app ->db ->queryOneRecord ("SELECT count(id) as number FROM dns_slave WHERE origin = ? AND server_id = ? " , $ this ->dataRecord ["origin " ], $ this ->dataRecord ["server_id " ]);
270- if ($ tmp ["number " ] > 0 ) {
271- $ app ->error ($ app ->tform ->wordbook ["origin_error_unique " ]);
269+ //* Check if a secondary zone with the same name already exists
270+ $ tmp = $ app ->db ->queryOneRecord ("SELECT count(id) as number FROM dns_slave WHERE origin = ? AND server_id = ? " , $ this ->dataRecord ["origin " ], $ this ->dataRecord ["server_id " ]);
271+ if ($ tmp ["number " ] > 0 ) {
272+ $ app ->error ($ app ->tform ->wordbook ["origin_error_unique " ]);
273+ }
272274 }
273-
274275 parent ::onSubmit ();
275276}
276277
0 commit comments