@@ -116,6 +116,14 @@ function onShowEnd() {
116116
117117 }
118118
119+ if ($ this ->id > 0 ) {
120+ //* we are editing a existing record
121+ $ app ->tpl ->setVar ("edit_disabled " , 1 );
122+ $ app ->tpl ->setVar ("server_id_value " , $ this ->dataRecord ["server_id " ]);
123+ } else {
124+ $ app ->tpl ->setVar ("edit_disabled " , 0 );
125+ }
126+
119127 parent ::onShowEnd ();
120128 }
121129
@@ -180,19 +188,36 @@ function onAfterInsert() {
180188 // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
181189 if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' && isset ($ this ->dataRecord ["client_group_id " ])) {
182190 $ client_group_id = intval ($ this ->dataRecord ["client_group_id " ]);
183- $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id WHERE id = " .$ this ->id );
191+ $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id, sys_perm_group = 'ru' WHERE id = " .$ this ->id );
184192 // And we want to update all rr records too, that belong to this record
185193 $ app ->db ->query ("UPDATE dns_rr SET sys_groupid = $ client_group_id WHERE zone = " .$ this ->id );
186194 }
187195 if ($ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ]) && isset ($ this ->dataRecord ["client_group_id " ])) {
188196 $ client_group_id = intval ($ this ->dataRecord ["client_group_id " ]);
189- $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id WHERE id = " .$ this ->id );
197+ $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id, sys_perm_group = 'riud' WHERE id = " .$ this ->id );
190198 // And we want to update all rr records too, that belong to this record
191199 $ app ->db ->query ("UPDATE dns_rr SET sys_groupid = $ client_group_id WHERE zone = " .$ this ->id );
192200 }
193201
194202 }
195203
204+ function onBeforeUpdate () {
205+ global $ app , $ conf ;
206+
207+ //* Check if the server has been changed
208+ // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
209+ if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' && !$ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
210+ //* We do not allow users to change a domain which has been created by the admin
211+ $ rec = $ app ->db ->queryOneRecord ("SELECT origin from dns_soa WHERE id = " .$ this ->id );
212+ if (isset ($ this ->dataRecord ["origin " ]) && $ rec ['origin ' ] != $ this ->dataRecord ["origin " ] && $ app ->tform ->checkPerm ($ this ->id ,'u ' )) {
213+ //* Add a error message and switch back to old server
214+ $ app ->tform ->errorMessage .= $ app ->lng ('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name. ' );
215+ $ this ->dataRecord ["origin " ] = $ rec ['origin ' ];
216+ }
217+ unset($ rec );
218+ }
219+ }
220+
196221 function onAfterUpdate () {
197222 global $ app , $ conf ;
198223
@@ -206,13 +231,13 @@ function onAfterUpdate() {
206231 // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
207232 if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' && isset ($ this ->dataRecord ["client_group_id " ])) {
208233 $ client_group_id = intval ($ this ->dataRecord ["client_group_id " ]);
209- $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id WHERE id = " .$ this ->id );
234+ $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id, sys_perm_group = 'ru' WHERE id = " .$ this ->id );
210235 // And we want to update all rr records too, that belong to this record
211236 $ app ->db ->query ("UPDATE dns_rr SET sys_groupid = $ client_group_id WHERE zone = " .$ this ->id );
212237 }
213238 if ($ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ]) && isset ($ this ->dataRecord ["client_group_id " ])) {
214239 $ client_group_id = intval ($ this ->dataRecord ["client_group_id " ]);
215- $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id WHERE id = " .$ this ->id );
240+ $ app ->db ->query ("UPDATE dns_soa SET sys_groupid = $ client_group_id, sys_perm_group = 'riud' WHERE id = " .$ this ->id );
216241 // And we want to update all rr records too, that belong to this record
217242 $ app ->db ->query ("UPDATE dns_rr SET sys_groupid = $ client_group_id WHERE zone = " .$ this ->id );
218243 }
0 commit comments