Skip to content

Commit 021ef64

Browse files
committed
use domain option on dns forms, fixes FS#3028
1 parent 80e18c2 commit 021ef64

File tree

9 files changed

+206
-7
lines changed

9 files changed

+206
-7
lines changed

interface/web/dns/dns_import.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,44 @@
151151

152152
}
153153

154+
/*
155+
* Now we have to check, if we should use the domain-module to select the domain
156+
* or not
157+
*/
158+
$app->uses('ini_parser,getconf');
159+
$settings = $app->getconf->get_global_config('domains');
160+
if ($settings['use_domain_module'] == 'y') {
161+
/*
162+
* The domain-module is in use.
163+
*/
164+
$domains = $app->tools_sites->getDomainModuleDomains();
165+
/*
166+
* We can leave domain empty if domain is filename
167+
*/
168+
$domain_select = "<option value=''></option>\r\n";
169+
if(is_array($domains) && sizeof($domains) > 0) {
170+
/* We have domains in the list, so create the drop-down-list */
171+
foreach( $domains as $domain) {
172+
$domain_select .= "<option value=" . $domain['domain_id'] ;
173+
if ($domain['domain'] == $_POST['domain']) {
174+
$domain_select .= " selected";
175+
}
176+
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . ".</option>\r\n";
177+
}
178+
}
179+
$app->tpl->setVar("domain_option", $domain_select);
180+
/* check if the selected domain can be used! */
181+
if ($domain) {
182+
$domain_check = $app->tools_sites->checkDomainModuleDomain($domain);
183+
if(!$domain_check) {
184+
// invalid domain selected
185+
$domain = NULL;
186+
} else {
187+
$domain = $domain_check;
188+
}
189+
}
190+
}
191+
154192
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_import.lng';
155193
include $lng_file;
156194
$app->tpl->setVar($wb);

interface/web/dns/dns_slave_edit.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,39 @@ function onShowEnd() {
106106

107107
}
108108

109+
/*
110+
* Now we have to check, if we should use the domain-module to select the domain
111+
* or not
112+
*/
113+
$app->uses('ini_parser,getconf');
114+
$settings = $app->getconf->get_global_config('domains');
115+
if ($settings['use_domain_module'] == 'y') {
116+
/*
117+
* The domain-module is in use.
118+
*/
119+
$domains = $app->tools_sites->getDomainModuleDomains();
120+
$domain_select = '';
121+
if(is_array($domains) && sizeof($domains) > 0) {
122+
/* We have domains in the list, so create the drop-down-list */
123+
foreach( $domains as $domain) {
124+
$domain_select .= "<option value=" . $domain['domain_id'] ;
125+
if ($domain['domain'].'.' == $this->dataRecord["origin"]) {
126+
$domain_select .= " selected";
127+
}
128+
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . ".</option>\r\n";
129+
}
130+
}
131+
else {
132+
/*
133+
* We have no domains in the domain-list. This means, we can not add ANY new domain.
134+
* To avoid, that the variable "domain_option" is empty and so the user can
135+
* free enter a domain, we have to create a empty option!
136+
*/
137+
$domain_select .= "<option value=''></option>\r\n";
138+
}
139+
$app->tpl->setVar("domain_option", $domain_select);
140+
}
141+
109142
if($this->id > 0) {
110143
//* we are editing a existing record
111144
$app->tpl->setVar("edit_disabled", 1);
@@ -120,6 +153,19 @@ function onShowEnd() {
120153
function onSubmit() {
121154
global $app, $conf;
122155

156+
/* check if the domain module is used - and check if the selected domain can be used! */
157+
$app->uses('ini_parser,getconf');
158+
$settings = $app->getconf->get_global_config('domains');
159+
if ($settings['use_domain_module'] == 'y') {
160+
$domain_check = $app->tools_sites->checkDomainModuleDomain($this->dataRecord['origin']);
161+
if(!$domain_check) {
162+
// invalid domain selected
163+
$app->tform->errorMessage .= $app->tform->lng("origin_error_empty")."<br />";
164+
} else {
165+
$this->dataRecord['origin'] = $domain_check.'.';
166+
}
167+
}
168+
123169
if($_SESSION["s"]["user"]["typ"] != 'admin') {
124170
// Get the limits of the client
125171
$client_group_id = intval($_SESSION["s"]["user"]["default_group"]);

interface/web/dns/dns_soa_edit.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,39 @@ function onShowEnd() {
147147

148148
}
149149

150+
/*
151+
* Now we have to check, if we should use the domain-module to select the domain
152+
* or not
153+
*/
154+
$app->uses('ini_parser,getconf');
155+
$settings = $app->getconf->get_global_config('domains');
156+
if ($settings['use_domain_module'] == 'y') {
157+
/*
158+
* The domain-module is in use.
159+
*/
160+
$domains = $app->tools_sites->getDomainModuleDomains();
161+
$domain_select = '';
162+
if(is_array($domains) && sizeof($domains) > 0) {
163+
/* We have domains in the list, so create the drop-down-list */
164+
foreach( $domains as $domain) {
165+
$domain_select .= "<option value=" . $domain['domain_id'] ;
166+
if ($domain['domain'].'.' == $this->dataRecord["origin"]) {
167+
$domain_select .= " selected";
168+
}
169+
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . ".</option>\r\n";
170+
}
171+
}
172+
else {
173+
/*
174+
* We have no domains in the domain-list. This means, we can not add ANY new domain.
175+
* To avoid, that the variable "domain_option" is empty and so the user can
176+
* free enter a domain, we have to create a empty option!
177+
*/
178+
$domain_select .= "<option value=''></option>\r\n";
179+
}
180+
$app->tpl->setVar("domain_option", $domain_select);
181+
}
182+
150183
if($this->id > 0) {
151184
//* we are editing a existing record
152185
$app->tpl->setVar("edit_disabled", 1);
@@ -161,6 +194,19 @@ function onShowEnd() {
161194
function onSubmit() {
162195
global $app, $conf;
163196

197+
/* check if the domain module is used - and check if the selected domain can be used! */
198+
$app->uses('ini_parser,getconf');
199+
$settings = $app->getconf->get_global_config('domains');
200+
if ($settings['use_domain_module'] == 'y') {
201+
$domain_check = $app->tools_sites->checkDomainModuleDomain($this->dataRecord['origin']);
202+
if(!$domain_check) {
203+
// invalid domain selected
204+
$app->tform->errorMessage .= $app->tform->lng("origin_error_empty")."<br />";
205+
} else {
206+
$this->dataRecord['origin'] = $domain_check.'.';
207+
}
208+
}
209+
164210
if($_SESSION["s"]["user"]["typ"] != 'admin') {
165211
// Get the limits of the client
166212
$client_group_id = $_SESSION["s"]["user"]["default_group"];

interface/web/dns/dns_wizard.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,39 @@
157157
}
158158
}
159159

160+
/*
161+
* Now we have to check, if we should use the domain-module to select the domain
162+
* or not
163+
*/
164+
$app->uses('ini_parser,getconf');
165+
$settings = $app->getconf->get_global_config('domains');
166+
if ($settings['use_domain_module'] == 'y') {
167+
/*
168+
* The domain-module is in use.
169+
*/
170+
$domains = $app->tools_sites->getDomainModuleDomains();
171+
$domain_select = '';
172+
if(is_array($domains) && sizeof($domains) > 0) {
173+
/* We have domains in the list, so create the drop-down-list */
174+
foreach( $domains as $domain) {
175+
$domain_select .= "<option value=" . $domain['domain_id'] ;
176+
if ($domain['domain'] == $_POST['domain']) {
177+
$domain_select .= " selected";
178+
}
179+
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . ".</option>\r\n";
180+
}
181+
}
182+
else {
183+
/*
184+
* We have no domains in the domain-list. This means, we can not add ANY new domain.
185+
* To avoid, that the variable "domain_option" is empty and so the user can
186+
* free enter a domain, we have to create a empty option!
187+
*/
188+
$domain_select .= "<option value=''></option>\r\n";
189+
}
190+
$app->tpl->setVar("domain_option", $domain_select);
191+
}
192+
160193
if($_POST['create'] == 1) {
161194

162195
$error = '';
@@ -180,8 +213,19 @@
180213

181214
// apply filters
182215
if(isset($_POST['domain']) && $_POST['domain'] != ''){
183-
$_POST['domain'] = $app->functions->idn_encode($_POST['domain']);
184-
$_POST['domain'] = strtolower($_POST['domain']);
216+
/* check if the domain module is used - and check if the selected domain can be used! */
217+
if ($settings['use_domain_module'] == 'y') {
218+
$domain_check = $app->tools_sites->checkDomainModuleDomain($_POST['domain']);
219+
if(!$domain_check) {
220+
// invalid domain selected
221+
$_POST['domain'] = '';
222+
} else {
223+
$_POST['domain'] = $domain_check;
224+
}
225+
} else {
226+
$_POST['domain'] = $app->functions->idn_encode($_POST['domain']);
227+
$_POST['domain'] = strtolower($_POST['domain']);
228+
}
185229
}
186230
if(isset($_POST['ns1']) && $_POST['ns1'] != ''){
187231
$_POST['ns1'] = $app->functions->idn_encode($_POST['ns1']);

interface/web/dns/lib/lang/es_dns_import.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ $wb['error_no_valid_zone_file_txt'] = '¡Esto parece que no hay archivo de zona
99
$wb['zonefile_to_import_txt'] = 'Archivo de zona';
1010
$wb['domain_field_desc_txt'] = 'Se puede dejar vacío si el nombre de dominio es el nombre del archivo o el contenido de la zona de archivo.';
1111
$wb['title'] = 'Archivos de zona de importación';
12-
$wb['no_file_uploaded_error'] = 'No hay fichero en zona subida';
12+
$wb['no_file_uploaded_error'] = 'No se ha subido un fichero de zona';
1313
$wb['zone_file_import_txt'] = 'Importar Archivo de Zona';
1414
?>

interface/web/dns/templates/dns_import.htm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ <h2><tmpl_var name="list_head_txt"></h2>
3232
</tmpl_if>
3333
<div class="ctrlHolder">
3434
<label for="domain">{tmpl_var name='domain_txt'}</label>
35-
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" onkeydown="keydown(event.which);" /><p class="value">{tmpl_var name='domain_field_desc_txt'}</p>
35+
<tmpl_if name="domain_option">
36+
<select name="domain" id="domain" class="selectInput">
37+
{tmpl_var name='domain_option'}
38+
</select>
39+
<tmpl_else>
40+
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" onkeydown="keydown(event.which);" />
41+
</tmpl_if>
42+
<p class="value"><tmpl_var name='domain_field_desc_txt'}</p>
3643
</div>
3744
<div class="ctrlHolder">
3845
<label for="file">{tmpl_var name='zonefile_to_import_txt'}</label>

interface/web/dns/templates/dns_slave_edit.htm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ <h2><tmpl_var name="list_head_txt"></h2>
3737
</tmpl_if>
3838
<div class="ctrlHolder">
3939
<label for="origin">{tmpl_var name='origin_txt'}</label>
40-
<input name="origin" id="origin" value="{tmpl_var name='origin'}" size="30" maxlength="255" type="text" class="textInput" />
40+
<tmpl_if name="domain_option">
41+
<select name="origin" id="origin" class="selectInput">
42+
{tmpl_var name='domain_option'}
43+
</select>
44+
<tmpl_else>
45+
<input name="origin" id="origin" value="{tmpl_var name='origin'}" size="30" maxlength="255" type="text" class="textInput" />
46+
</tmpl_if>
4147
<p class="formHint">{tmpl_var name='eg_domain_tld'}</p>
4248
</div>
4349
<div class="ctrlHolder">

interface/web/dns/templates/dns_soa_edit.htm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ <h2><tmpl_var name="list_head_txt"></h2>
5656
</tmpl_if>
5757
<div class="ctrlHolder">
5858
<label for="origin">{tmpl_var name='origin_txt'}</label>
59-
<input name="origin" id="origin" value="{tmpl_var name='origin'}" size="30" maxlength="255" type="text" class="textInput" />
59+
<tmpl_if name="domain_option">
60+
<select name="origin" id="origin" class="selectInput">
61+
{tmpl_var name='domain_option'}
62+
</select>
63+
<tmpl_else>
64+
<input name="origin" id="origin" value="{tmpl_var name='origin'}" size="30" maxlength="255" type="text" class="textInput" />
65+
</tmpl_if>
6066
<p class="formHint">{tmpl_var name='eg_domain_tld'}</p>
6167
</div>
6268
<div class="ctrlHolder">

interface/web/dns/templates/dns_wizard.htm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ <h2><tmpl_var name="list_head_txt"></h2>
5151
<tmpl_if name="DOMAIN_VISIBLE">
5252
<div class="ctrlHolder">
5353
<label for="domain">{tmpl_var name='domain_txt'}</label>
54-
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
54+
<tmpl_if name="domain_option">
55+
<select name="domain" id="domain" class="selectInput">
56+
{tmpl_var name='domain_option'}
57+
</select>
58+
<tmpl_else>
59+
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
60+
</tmpl_if>
5561
</div>
5662
</tmpl_if>
5763
<tmpl_if name="IP_VISIBLE">

0 commit comments

Comments
 (0)