Skip to content

Commit 833c193

Browse files
author
Marius Burkard
committed
Merge branch '1431-missing-var' into 'develop'
Fix global enabling/disabling of relay host options See merge request ispconfig/ispconfig3!1439
2 parents 5f2405d + 73836bc commit 833c193

File tree

4 files changed

+71
-42
lines changed

4 files changed

+71
-42
lines changed

interface/web/admin/form/system_config.tform.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
'datatype' => 'VARCHAR',
278278
'formtype' => 'CHECKBOX',
279279
'default' => 'n',
280+
'value' => array(0 => 'n', 1 => 'y')
280281
),
281282
'mailbox_show_autoresponder_tab' => array (
282283
'datatype' => 'VARCHAR',

interface/web/client/client_edit.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function onSubmit() {
9292
}
9393
}
9494
}
95-
95+
9696
//* Resellers shall not be able to create another reseller
9797
if($_SESSION["s"]["user"]["typ"] == 'user') {
9898
$this->dataRecord['limit_client'] = 0;
@@ -181,18 +181,26 @@ function onShowEnd() {
181181

182182
$app->tpl->setVar('template_additional_list', $text);
183183
$app->tpl->setVar('app_module', 'client');
184-
184+
185+
// Check wether per domain relaying is enabled or not
186+
$global_config = $app->getconf->get_global_config('mail');
187+
if($global_config['show_per_domain_relay_options'] == 'y') {
188+
$app->tpl->setVar("show_per_domain_relay_options", 1);
189+
} else {
190+
$app->tpl->setVar("show_per_domain_relay_options", 0);
191+
}
192+
185193

186194
//* Set the 'customer no' default value
187195
if($this->id == 0) {
188-
196+
189197
if($app->auth->is_admin()) {
190198
//* Logged in User is admin
191199
//* get the system config
192200
$app->uses('getconf');
193201
$system_config = $app->getconf->get_global_config();
194202
if($system_config['misc']['customer_no_template'] != '') {
195-
203+
196204
//* Set customer no default
197205
$customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']);
198206
$customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']);
@@ -203,7 +211,7 @@ function onShowEnd() {
203211
//* get the record of the reseller
204212
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
205213
$reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id);
206-
214+
207215
if($reseller['customer_no_template'] != '') {
208216
if(isset($this->dataRecord['customer_no'])&& $this->dataRecord['customer_no']!='') $customer_no_string = $this->dataRecord['customer_no'];
209217
else {
@@ -215,7 +223,7 @@ function onShowEnd() {
215223
}
216224
}
217225
}
218-
226+
219227
if($app->auth->is_admin()) {
220228
// Fill the client select field
221229
$sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name";
@@ -234,7 +242,7 @@ function onShowEnd() {
234242
}
235243
$app->tpl->setVar("parent_client_id", $client_select);
236244
}
237-
245+
238246
parent::onShowEnd();
239247

240248
}
@@ -317,15 +325,15 @@ function onAfterInsert() {
317325
$app->uses('client_templates');
318326
$app->client_templates->update_client_templates($this->id, $this->_template_additional);
319327
}
320-
328+
321329
if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
322330
if($app->auth->is_admin()) {
323331
//* Logged in User is admin
324332
//* get the system config
325333
$app->uses('getconf');
326334
$system_config = $app->getconf->get_global_config();
327335
if($system_config['misc']['customer_no_template'] != '') {
328-
336+
329337
//* save new counter value
330338
$system_config['misc']['customer_no_counter']++;
331339
$system_config_str = $app->ini_parser->get_ini_string($system_config);
@@ -336,15 +344,15 @@ function onAfterInsert() {
336344
//* get the record of the reseller
337345
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
338346
$reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id);
339-
347+
340348
if($reseller['customer_no_template'] != '') {
341349
//* save new counter value
342350
$customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
343351
$app->db->query("UPDATE client SET customer_no_counter = ? WHERE client_id = ?", $customer_no_counter, $reseller['client_id']);
344352
}
345353
}
346354
}
347-
355+
348356
//* Send welcome email
349357
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
350358
$sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?";
@@ -369,7 +377,7 @@ function onAfterInsert() {
369377
$subject = str_replace('{'.$key.'}', $val, $subject);
370378
}
371379
}
372-
380+
373381
//* Get sender address
374382
if($app->auth->is_admin()) {
375383
$app->uses('getconf');
@@ -384,7 +392,7 @@ function onAfterInsert() {
384392
//* Send the email
385393
$app->functions->mail($client['email'], $subject, $message, $from);
386394
}
387-
395+
388396

389397
parent::onAfterInsert();
390398
}
@@ -466,7 +474,7 @@ function onAfterUpdate() {
466474
$active_col = 'disablesmtp';
467475
$reverse = true;
468476
}
469-
477+
470478
if(!isset($prev_active[$current])) $prev_active[$current] = array();
471479
if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array();
472480

@@ -498,7 +506,7 @@ function onAfterUpdate() {
498506
$active_col = 'disablesmtp';
499507
$reverse = true;
500508
}
501-
509+
502510
$entries = $app->db->queryAllRecords('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $current, $sys_groupid);
503511
foreach($entries as $item) {
504512
$set_active = ($reverse == true ? 'n' : 'y');
@@ -551,22 +559,22 @@ function onAfterUpdate() {
551559
$sql = "UPDATE sys_user SET modules = ? WHERE client_id = ?";
552560
$app->db->query($sql, $modules, $client_id);
553561
}
554-
562+
555563
//* Client has been moved to another reseller
556564
if($_SESSION['s']['user']['typ'] == 'admin' && isset($this->dataRecord['parent_client_id']) && $this->dataRecord['parent_client_id'] != $this->oldDataRecord['parent_client_id']) {
557565
//* Get groupid of the client
558566
$tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $this->id);
559567
$groupid = $tmp['groupid'];
560568
unset($tmp);
561-
569+
562570
//* Remove sys_user of old reseller from client group
563571
if($this->oldDataRecord['parent_client_id'] > 0) {
564572
//* get userid of the old reseller remove it from the group of the client
565573
$tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ?", $this->oldDataRecord['parent_client_id']);
566574
$app->auth->remove_group_from_user($tmp['userid'], $groupid);
567575
unset($tmp);
568576
}
569-
577+
570578
//* Add sys_user of new reseller to client group
571579
if($this->dataRecord['parent_client_id'] > 0) {
572580
//* get userid of the reseller and add it to the group of the client

interface/web/client/client_template_edit.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,31 @@
5151

5252
class page_action extends tform_actions {
5353

54-
54+
5555
function onSubmit() {
5656
global $app;
57-
57+
5858
//* Resellers shall not be able to create another reseller or set reseller specific settings
5959
if($_SESSION["s"]["user"]["typ"] == 'user') {
6060
$this->dataRecord['limit_client'] = 0;
6161
$this->dataRecord['limit_domainmodule'] = 0;
6262
}
63-
63+
6464
parent::onSubmit();
6565
}
66-
66+
67+
function onShowEnd() {
68+
global $app;
69+
// Check wether per domain relaying is enabled or not
70+
$global_config = $app->getconf->get_global_config('mail');
71+
if($global_config['show_per_domain_relay_options'] == 'y') {
72+
$app->tpl->setVar("show_per_domain_relay_options", 1);
73+
} else {
74+
$app->tpl->setVar("show_per_domain_relay_options", 0);
75+
}
76+
parent::onShowEnd();
77+
}
78+
6779
function onBeforeUpdate() {
6880
global $app;
6981

interface/web/client/reseller_edit.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function onSubmit() {
9494
}
9595
}
9696
}
97-
97+
9898
if($this->id != 0) {
9999
$this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ?', $this->id);
100100
if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) {
@@ -175,21 +175,29 @@ function onShowEnd() {
175175

176176
$app->tpl->setVar('template_additional_list', $text);
177177
$app->tpl->setVar('app_module', 'client');
178-
178+
179+
// Check wether per domain relaying is enabled or not
180+
$global_config = $app->getconf->get_global_config('mail');
181+
if($global_config['show_per_domain_relay_options'] == 'y') {
182+
$app->tpl->setVar("show_per_domain_relay_options", 1);
183+
} else {
184+
$app->tpl->setVar("show_per_domain_relay_options", 0);
185+
}
186+
179187
//* Set the 'customer no' default value
180188
if($this->id == 0) {
181189
//* get the system config
182190
$app->uses('getconf');
183191
$system_config = $app->getconf->get_global_config();
184192
if($system_config['misc']['customer_no_template'] != '') {
185-
193+
186194
//* Set customer no default
187195
$customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']);
188196
$customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']);
189197
$app->tpl->setVar('customer_no',$customer_no_string);
190198
}
191199
}
192-
200+
193201
parent::onShowEnd();
194202

195203
}
@@ -200,9 +208,9 @@ function onShowEnd() {
200208
*/
201209
function onAfterInsert() {
202210
global $app, $conf;
203-
211+
204212
$app->uses('auth');
205-
213+
206214
// Create the group for the reseller
207215
$groupid = $app->db->datalogInsert('sys_group', array("name" => $this->dataRecord["username"], "description" => '', "client_id" => $this->id), 'groupid');
208216
$groups = $groupid;
@@ -217,7 +225,7 @@ function onAfterInsert() {
217225
$language = $this->dataRecord["language"];
218226

219227
$password = $app->auth->crypt_password(stripslashes($password));
220-
228+
221229
// Create the controlpaneluser for the reseller
222230
$sql = "INSERT INTO sys_user (`username`,`passwort`,`modules`,`startmodule`,`app_theme`,`typ`, `active`,`language`,`groups`,`default_group`,`client_id`)
223231
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
@@ -238,26 +246,26 @@ function onAfterInsert() {
238246

239247
$sql = "UPDATE client SET default_mailserver = ?, default_webserver = ?, default_dnsserver = ?, default_slave_dnsserver = ?, default_dbserver = ? WHERE client_id = ?";
240248
$app->db->query($sql, $default_mailserver, $default_webserver, $default_dnsserver, $default_dnsserver, $default_dbserver, $this->id);
241-
249+
242250
if(isset($this->dataRecord['template_master'])) {
243251
$app->uses('client_templates');
244252
$app->client_templates->update_client_templates($this->id, $this->_template_additional);
245253
}
246-
254+
247255
if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
248256
//* get the system config
249257
$app->uses('getconf');
250258
$system_config = $app->getconf->get_global_config();
251259
if($system_config['misc']['customer_no_template'] != '') {
252-
260+
253261
//* save new counter value
254262
$system_config['misc']['customer_no_counter']++;
255263
$system_config_str = $app->ini_parser->get_ini_string($system_config);
256264
$app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1);
257-
265+
258266
}
259267
}
260-
268+
261269
//* Send welcome email
262270
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
263271
$sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?";
@@ -283,7 +291,7 @@ function onAfterInsert() {
283291
$subject = str_replace('{'.$key.'}', $val, $subject);
284292
}
285293
}
286-
294+
287295
//* Get sender address
288296
if($app->auth->is_admin()) {
289297
$app->uses('getconf');
@@ -311,7 +319,7 @@ function onAfterUpdate() {
311319
global $app, $conf;
312320

313321
$app->uses('auth');
314-
322+
315323
// username changed
316324
if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['username']) && $this->dataRecord['username'] != '' && $this->oldDataRecord['username'] != $this->dataRecord['username']) {
317325
$username = $this->dataRecord["username"];
@@ -328,7 +336,7 @@ function onAfterUpdate() {
328336
if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') {
329337
$password = $this->dataRecord["password"];
330338
$client_id = $this->id;
331-
339+
332340
$password = $app->auth->crypt_password(stripslashes($password));
333341
$sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?";
334342
$app->db->query($sql, $password, $client_id);
@@ -357,12 +365,12 @@ function onAfterUpdate() {
357365
$sql = "UPDATE sys_user SET modules = ? WHERE client_id = ?";
358366
$app->db->query($sql, $modules, $client_id);
359367
}
360-
368+
361369
if(isset($this->dataRecord['template_master'])) {
362370
$app->uses('client_templates');
363371
$app->client_templates->update_client_templates($this->id, $this->_template_additional);
364372
}
365-
373+
366374
if(!isset($this->dataRecord['locked'])) $this->dataRecord['locked'] = 'n';
367375
if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["locked"] != $this->oldDataRecord['locked']) {
368376
/** lock all the things like web, mail etc. - easy to extend */
@@ -412,7 +420,7 @@ function onAfterUpdate() {
412420
$active_col = 'disablesmtp';
413421
$reverse = true;
414422
}
415-
423+
416424
if(!isset($prev_active[$current])) $prev_active[$current] = array();
417425
if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array();
418426

@@ -444,7 +452,7 @@ function onAfterUpdate() {
444452
$active_col = 'disablesmtp';
445453
$reverse = true;
446454
}
447-
455+
448456
$entries = $app->db->queryAllRecords('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $current, $sys_groupid);
449457
foreach($entries as $item) {
450458
$set_active = ($reverse == true ? 'n' : 'y');
@@ -469,7 +477,7 @@ function onAfterUpdate() {
469477
unset($entries);
470478
unset($to_disable);
471479
}
472-
480+
473481
if(!isset($this->dataRecord['canceled'])) $this->dataRecord['canceled'] = 'n';
474482
if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["canceled"] != $this->oldDataRecord['canceled']) {
475483
if($this->dataRecord['canceled'] == 'y') {

0 commit comments

Comments
 (0)