@@ -46,12 +46,18 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
4646 $ vhostdomain_type = 'domain ' ;
4747 if ($ page_form ->dataRecord ['type ' ] == 'vhostalias ' ) $ vhostdomain_type = 'aliasdomain ' ;
4848 elseif ($ page_form ->dataRecord ['type ' ] == 'vhostsubdomain ' ) $ vhostdomain_type = 'subdomain ' ;
49-
50- // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
51- // also make sure that the user can not delete domain created by a admin
49+
50+ // make sure that the record belongs to the client group and not the admin group when a admin inserts it
51+ // also make sure that the user can not delete domain created by a admin if client protection is enabled
5252 if ($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' && isset ($ page_form ->dataRecord ["client_group_id " ])) {
5353 $ client_group_id = $ app ->functions ->intval ($ page_form ->dataRecord ["client_group_id " ]);
54- $ app ->db ->query ("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ? " , $ client_group_id , $ page_form ->id );
54+ $ app ->uses ('getconf ' );
55+ $ global_config = $ app ->getconf ->get_global_config ('sites ' );
56+ if ($ global_config ['client_protection ' ] == 'y ' ) {
57+ $ app ->db ->query ("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ? " , $ client_group_id , $ this ->id );
58+ } else {
59+ $ app ->db ->query ("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ? " , $ client_group_id , $ this ->id );
60+ }
5561 }
5662 if ($ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ]) && isset ($ page_form ->dataRecord ["client_group_id " ])) {
5763 $ client_group_id = $ app ->functions ->intval ($ page_form ->dataRecord ["client_group_id " ]);
@@ -62,7 +68,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
6268 $ web_config = $ app ->getconf ->get_server_config ($ app ->functions ->intval ($ page_form ->dataRecord ['server_id ' ]), 'web ' );
6369 if (isset ($ app ->tform ) && is_object ($ app ->tform )) $ web_rec = $ app ->tform ->getDataRecord ($ page_form ->id );
6470 else $ web_rec = $ app ->remoting_lib ->getDataRecord ($ page_form ->id );
65-
71+
6672 if ($ vhostdomain_type == 'domain ' ) {
6773 $ document_root = str_replace ("[website_id] " , $ page_form ->id , $ web_config ["website_path " ]);
6874 $ document_root = str_replace ("[website_idhash_1] " , $ this ->id_hash ($ page_form ->id , 1 ), $ document_root );
@@ -97,7 +103,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
97103 $ document_root = str_replace ("[client_idhash_2] " , $ this ->id_hash ($ client_id , 2 ), $ document_root );
98104 $ document_root = str_replace ("[client_idhash_3] " , $ this ->id_hash ($ client_id , 3 ), $ document_root );
99105 $ document_root = str_replace ("[client_idhash_4] " , $ this ->id_hash ($ client_id , 4 ), $ document_root );
100-
106+
101107 if ($ event_name == 'sites:web_vhost_domain:on_after_update ' ) {
102108 if (($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' || $ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) && isset ($ page_form ->dataRecord ["client_group_id " ]) && $ page_form ->dataRecord ["client_group_id " ] != $ page_form ->oldDataRecord ["sys_groupid " ]) {
103109
@@ -280,7 +286,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
280286 $ php_open_basedir = str_replace ("[website_path] " , $ document_root , $ web_config ["php_open_basedir " ]);
281287 $ php_open_basedir = str_replace ("[website_domain] " , $ app ->functions ->idn_encode ($ page_form ->dataRecord ['domain ' ]), $ php_open_basedir );
282288 $ htaccess_allow_override = $ web_config ["htaccess_allow_override " ];
283-
289+
284290 $ sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ? " ;
285291 $ app ->db ->query ($ sql , $ system_user , $ system_group , $ document_root , $ htaccess_allow_override , $ php_open_basedir , $ page_form ->id );
286292 }
0 commit comments