mcramer
2012-08-19 3501f913b6d56e38e1b39ca92a4cb2ef0b3cfb64
Implemented FS#2382 - automatically add alias domain when creating a domain 

6 files modified
54 ■■■■■ changed files
interface/web/admin/form/server_config.tform.php 8 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_server_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_web_edit.htm 4 ●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 19 ●●●● patch | view | raw | blame | history
server/plugins-available/nginx_plugin.inc.php 19 ●●●● patch | view | raw | blame | history
interface/web/admin/form/server_config.tform.php
@@ -390,6 +390,14 @@
            'default' => 'n',
            'value' => array(0 => 'n',1 => 'y')
        ),
        'website_autoalias' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'value' => '',
            'width' => '40',
            'maxlength' => '255'
        ),
        'vhost_conf_dir' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
interface/web/admin/lib/lang/de_server_config.lng
@@ -35,6 +35,8 @@
$wb['nameservers_txt'] = 'Nameserver';
$wb['auto_network_configuration_txt'] = 'Netzwerkkonfiguration';
$wb['website_basedir_txt'] = 'Website basedir';
$wb["website_autoalias_txt"] = 'Website Autoalias';
$wb["website_autoalias_note_txt"] = 'Platzhalter: [client_id], [client_username], [website_id], [website_domain]';
$wb['ip_address_error_wrong'] = 'Ungültiges IP-Adressen-Format.';
$wb['netmask_error_wrong'] = 'Ungültiges Netzmasken-Format.';
$wb['gateway_error_wrong'] = 'Ungültiges Gateway-Format.';
interface/web/admin/lib/lang/en_server_config.lng
@@ -15,6 +15,8 @@
$wb["website_symlinks_txt"] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb["website_basedir_txt"] = 'Website basedir';
$wb["website_autoalias_txt"] = 'Website auto alias';
$wb["website_autoalias_note_txt"] = 'Placeholders: [client_id], [client_username], [website_id], [website_domain]';
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
$wb["getmail_config_dir_txt"] = 'Getmail config dir';
interface/web/admin/templates/server_config_web_edit.htm
@@ -31,6 +31,10 @@
                    {tmpl_var name='website_symlinks_rel'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="website_autoalias">{tmpl_var name='website_autoalias_txt'}</label>
                <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'}
            </div>
            <div class="ctrlHolder apache">
                <label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
                <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
@@ -871,10 +871,25 @@
                        'rewrite_target_ssl' => $rewrite_target_ssl);
            }
        }
        $server_alias = array();
        // get autoalias
        $auto_alias = $web_config['website_autoalias'];
        if($auto_alias != '') {
            // get the client username
            $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'");
            $aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]');
            $aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']);
            $auto_alias = str_replace($aa_search, $aa_replace, $auto_alias);
            unset($client);
            unset($aa_search);
            unset($aa_replace);
            $server_alias[] .= $auto_alias;
        }
        // get alias domains (co-domains and subdomains)
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
        $server_alias = array();
        switch($data['new']['subdomain']) {
            case 'www':
                $server_alias[] .= 'www.'.$data['new']['domain'].' ';
server/plugins-available/nginx_plugin.inc.php
@@ -912,10 +912,25 @@
                    'rewrite_exclude'    => $rewrite_exclude);
            }
        }
        $server_alias = array();
        // get autoalias
        $auto_alias = $web_config['website_autoalias'];
        if($auto_alias != '') {
            // get the client username
            $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'");
            $aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]');
            $aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']);
            $auto_alias = str_replace($aa_search, $aa_replace, $auto_alias);
            unset($client);
            unset($aa_search);
            unset($aa_replace);
            $server_alias[] .= $auto_alias;
        }
        // get alias domains (co-domains and subdomains)
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
        $server_alias = array();
        switch($data['new']['subdomain']) {
            case 'www':
                $server_alias[] = 'www.'.$data['new']['domain'].' ';