@@ -46,12 +46,20 @@ 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+ $ sysuser = $ app ->db ->queryOneRecord ('SELECT userid FROM sys_user WHERE default_group = ? ' ,$ client_group_id );
60+ $ sysuser_id = (is_array ($ sysuser ) && isset ($ sysuser ['userid ' ]) && $ sysuser ['userid ' ] > 0 )?$ sysuser ['userid ' ]:1 ;
61+ $ app ->db ->query ("UPDATE web_domain SET sys_userid = ?, sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ? " , $ sysuser_id , $ client_group_id , $ this ->id );
62+ }
5563 }
5664 if ($ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ]) && isset ($ page_form ->dataRecord ["client_group_id " ])) {
5765 $ client_group_id = $ app ->functions ->intval ($ page_form ->dataRecord ["client_group_id " ]);
@@ -62,7 +70,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
6270 $ web_config = $ app ->getconf ->get_server_config ($ app ->functions ->intval ($ page_form ->dataRecord ['server_id ' ]), 'web ' );
6371 if (isset ($ app ->tform ) && is_object ($ app ->tform )) $ web_rec = $ app ->tform ->getDataRecord ($ page_form ->id );
6472 else $ web_rec = $ app ->remoting_lib ->getDataRecord ($ page_form ->id );
65-
73+
6674 if ($ vhostdomain_type == 'domain ' ) {
6775 $ document_root = str_replace ("[website_id] " , $ page_form ->id , $ web_config ["website_path " ]);
6876 $ document_root = str_replace ("[website_idhash_1] " , $ this ->id_hash ($ page_form ->id , 1 ), $ document_root );
@@ -97,7 +105,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
97105 $ document_root = str_replace ("[client_idhash_2] " , $ this ->id_hash ($ client_id , 2 ), $ document_root );
98106 $ document_root = str_replace ("[client_idhash_3] " , $ this ->id_hash ($ client_id , 3 ), $ document_root );
99107 $ document_root = str_replace ("[client_idhash_4] " , $ this ->id_hash ($ client_id , 4 ), $ document_root );
100-
108+
101109 if ($ event_name == 'sites:web_vhost_domain:on_after_update ' ) {
102110 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 " ]) {
103111
@@ -280,7 +288,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
280288 $ php_open_basedir = str_replace ("[website_path] " , $ document_root , $ web_config ["php_open_basedir " ]);
281289 $ php_open_basedir = str_replace ("[website_domain] " , $ app ->functions ->idn_encode ($ page_form ->dataRecord ['domain ' ]), $ php_open_basedir );
282290 $ htaccess_allow_override = $ web_config ["htaccess_allow_override " ];
283-
291+
284292 $ sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ? " ;
285293 $ app ->db ->query ($ sql , $ system_user , $ system_group , $ document_root , $ htaccess_allow_override , $ php_open_basedir , $ page_form ->id );
286294 }
0 commit comments