Skip to content

Commit 3501f91

Browse files
author
mcramer
committed
Implemented FS#2382 - automatically add alias domain when creating a domain
1 parent 8e0d366 commit 3501f91

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@
390390
'default' => 'n',
391391
'value' => array(0 => 'n',1 => 'y')
392392
),
393+
'website_autoalias' => array(
394+
'datatype' => 'VARCHAR',
395+
'formtype' => 'TEXT',
396+
'default' => '',
397+
'value' => '',
398+
'width' => '40',
399+
'maxlength' => '255'
400+
),
393401
'vhost_conf_dir' => array(
394402
'datatype' => 'VARCHAR',
395403
'formtype' => 'TEXT',

interface/web/admin/lib/lang/de_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ $wb['hostname_txt'] = 'Hostname';
3535
$wb['nameservers_txt'] = 'Nameserver';
3636
$wb['auto_network_configuration_txt'] = 'Netzwerkkonfiguration';
3737
$wb['website_basedir_txt'] = 'Website basedir';
38+
$wb["website_autoalias_txt"] = 'Website Autoalias';
39+
$wb["website_autoalias_note_txt"] = 'Platzhalter: [client_id], [client_username], [website_id], [website_domain]';
3840
$wb['ip_address_error_wrong'] = 'Ungültiges IP-Adressen-Format.';
3941
$wb['netmask_error_wrong'] = 'Ungültiges Netzmasken-Format.';
4042
$wb['gateway_error_wrong'] = 'Ungültiges Gateway-Format.';

interface/web/admin/lib/lang/en_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ $wb["website_path_txt"] = 'Website path';
1515
$wb["website_symlinks_txt"] = 'Website symlinks';
1616
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
1717
$wb["website_basedir_txt"] = 'Website basedir';
18+
$wb["website_autoalias_txt"] = 'Website auto alias';
19+
$wb["website_autoalias_note_txt"] = 'Placeholders: [client_id], [client_username], [website_id], [website_domain]';
1820
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
1921
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
2022
$wb["getmail_config_dir_txt"] = 'Getmail config dir';

interface/web/admin/templates/server_config_web_edit.htm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
3131
{tmpl_var name='website_symlinks_rel'}
3232
</div>
3333
</div>
34+
<div class="ctrlHolder">
35+
<label for="website_autoalias">{tmpl_var name='website_autoalias_txt'}</label>
36+
<input name="website_autoalias" id="website_autoalias" value="{tmpl_var name='website_autoalias'}" size="40" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='website_autoalias_note_txt'}
37+
</div>
3438
<div class="ctrlHolder apache">
3539
<label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
3640
<input name="vhost_conf_dir" id="vhost_conf_dir" value="{tmpl_var name='vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" />

server/plugins-available/apache2_plugin.inc.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,25 @@ function update($event_name,$data) {
871871
'rewrite_target_ssl' => $rewrite_target_ssl);
872872
}
873873
}
874-
874+
875+
$server_alias = array();
876+
877+
// get autoalias
878+
$auto_alias = $web_config['website_autoalias'];
879+
if($auto_alias != '') {
880+
// get the client username
881+
$client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'");
882+
$aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]');
883+
$aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']);
884+
$auto_alias = str_replace($aa_search, $aa_replace, $auto_alias);
885+
unset($client);
886+
unset($aa_search);
887+
unset($aa_replace);
888+
$server_alias[] .= $auto_alias;
889+
}
890+
875891
// get alias domains (co-domains and subdomains)
876892
$aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
877-
$server_alias = array();
878893
switch($data['new']['subdomain']) {
879894
case 'www':
880895
$server_alias[] .= 'www.'.$data['new']['domain'].' ';

server/plugins-available/nginx_plugin.inc.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,25 @@ function update($event_name,$data) {
912912
'rewrite_exclude' => $rewrite_exclude);
913913
}
914914
}
915-
915+
916+
$server_alias = array();
917+
918+
// get autoalias
919+
$auto_alias = $web_config['website_autoalias'];
920+
if($auto_alias != '') {
921+
// get the client username
922+
$client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'");
923+
$aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]');
924+
$aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']);
925+
$auto_alias = str_replace($aa_search, $aa_replace, $auto_alias);
926+
unset($client);
927+
unset($aa_search);
928+
unset($aa_replace);
929+
$server_alias[] .= $auto_alias;
930+
}
931+
916932
// get alias domains (co-domains and subdomains)
917933
$aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
918-
$server_alias = array();
919934
switch($data['new']['subdomain']) {
920935
case 'www':
921936
$server_alias[] = 'www.'.$data['new']['domain'].' ';

0 commit comments

Comments
 (0)