@@ -101,8 +101,6 @@ function update_client_templates($clientId, $templates = array()) {
101101 function apply_client_templates ($ clientId ) {
102102 global $ app ;
103103
104- include '../client/form/client.tform.php ' ;
105-
106104 /*
107105 * Get the master-template for the client
108106 */
@@ -111,6 +109,8 @@ function apply_client_templates($clientId) {
111109 $ masterTemplateId = $ record ['template_master ' ];
112110 $ is_reseller = ($ record ['limit_client ' ] != 0 )?true :false ;
113111
112+ include '../client/form/ ' . ($ is_reseller ? 'reseller ' : 'client ' ) . '.tform.php ' ;
113+
114114 if ($ record ['template_additional ' ] != '' ) {
115115 // we have to call the update_client_templates function
116116 $ templates = explode ('/ ' , $ record ['template_additional ' ]);
@@ -124,6 +124,8 @@ function apply_client_templates($clientId) {
124124 if ($ masterTemplateId > 0 ){
125125 $ sql = "SELECT * FROM client_template WHERE template_id = ? " ;
126126 $ limits = $ app ->db ->queryOneRecord ($ sql , $ masterTemplateId );
127+ if ($ is_reseller == true && $ limits ['limit_client ' ] == 0 ) $ limits ['limit_client ' ] = -1 ;
128+ elseif ($ is_reseller == false && $ limits ['limit_client ' ] != 0 ) $ limits ['limit_client ' ] = 0 ;
127129 } else {
128130 // if there is no master template it makes NO SENSE adding sub templates.
129131 // adding subtemplates are stored in client limits, so they would add up
@@ -132,7 +134,7 @@ function apply_client_templates($clientId) {
132134 }
133135
134136 /*
135- * Process the additional tempaltes here (add them to the limits
137+ * Process the additional templates here (add them to the limits
136138 * if != -1)
137139 */
138140 $ addTpl = explode ('/ ' , $ additionalTemplateStr );
@@ -145,6 +147,11 @@ function apply_client_templates($clientId) {
145147 /* maybe the template is deleted in the meantime */
146148 if (is_array ($ addLimits )){
147149 foreach ($ addLimits as $ k => $ v ){
150+ if ($ k == 'limit_client ' ) {
151+ if ($ is_reseller == true && $ v == 0 ) continue ;
152+ elseif ($ is_reseller == false && $ v != 0 ) continue ;
153+ }
154+
148155 /* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */
149156 if (strpos ($ k , 'limit ' ) !== false or strpos ($ k , 'default ' ) !== false or $ k == 'ssh_chroot ' or $ k == 'web_php_options ' or $ k == 'force_suexec ' ){
150157 $ app ->log ('Template processing key ' . $ k . ' for client ' . $ clientId , LOGLEVEL_DEBUG );
0 commit comments