tbrehm
2009-10-25 3d229b05ddfb1b75b10a7e8f66d3b1b847d4afd2
Added: FS#613 - Add email domain aliases 
8 files modified
9 files added
679 ■■■■■ changed files
install/sql/ispconfig3.sql 4 ●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php 14 ●●●●● patch | view | raw | blame | history
interface/web/client/form/client_template.tform.php 14 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client_template.lng 110 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_limits.htm 4 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_template_edit_limits.htm 4 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_aliasdomain.tform.php 113 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_aliasdomain.lng 11 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_aliasdomain_list.lng 8 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/module.conf.php 4 ●●●● patch | view | raw | blame | history
interface/web/mail/list/mail_aliasdomain.list.php 79 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_aliasdomain_del.php 51 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_aliasdomain_edit.php 141 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_aliasdomain_list.php 26 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_aliasdomain_edit.htm 37 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_aliasdomain_list.htm 57 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql
@@ -69,6 +69,7 @@
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
@@ -125,6 +126,7 @@
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
@@ -389,7 +391,7 @@
  `server_id` int(11) unsigned NOT NULL default '0',
  `source` varchar(255) NOT NULL,
  `destination` text NOT NULL default '',
  `type` enum('alias','forward','catchall') NOT NULL default 'alias',
  `type` enum('alias','aliasdomain','forward','catchall') NOT NULL default 'alias',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`forwarding_id`),
  KEY `server_id` (`server_id`,`source`)
interface/web/client/form/client.tform.php
@@ -364,6 +364,20 @@
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
interface/web/client/form/client_template.tform.php
@@ -143,6 +143,20 @@
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
interface/web/client/lib/lang/en_client.lng
@@ -2,6 +2,7 @@
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailaliasdomain_txt"] = 'Max. number of domain aliases';
$wb["limit_mailforward_txt"] = 'Max. number of email forwarders';
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
@@ -61,6 +62,7 @@
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailaliasdomain_error_notint"] = 'The email domain alias limit must be a number.';
$wb["limit_mailforward_error_notint"] = 'The email forward limit must be a number.';
$wb["limit_mailcatchall_error_notint"] = 'The email catchall limit must be a number.';
$wb["limit_mailrouting_error_notint"] = 'The email routing limit must be a number.';
interface/web/client/lib/lang/en_client_template.lng
@@ -1,55 +1,57 @@
<?php
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailforward_txt"] = 'Max. number of email forwarders';
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
$wb["limit_mailfilter_txt"] = 'Max. number of email filters';
$wb["limit_fetchmail_txt"] = 'Max. number of fetchmail accounts';
$wb["limit_mailquota_txt"] = 'Mailbox quota';
$wb["limit_spamfilter_wblist_txt"] = 'Max. number of spamfilter white / blacklist filters';
$wb["limit_spamfilter_user_txt"] = 'Max. number of spamfilter users';
$wb["limit_spamfilter_policy_txt"] = 'Max. number of spamfilter policys';
$wb["limit_domain_txt"] = 'limit_domain';
$wb["limit_subdomain_txt"] = 'limit_subdomain';
$wb["limit_webquota_txt"] = 'limit_webquota';
$wb["limit_database_txt"] = 'limit_database';
$wb["limit_cron_txt"] = 'Max. number of cron jobs';
$wb["limit_cron_type_txt"] = 'Max. type of cron jobs (chrooted and full implies url)';
$wb["limit_cron_frequency_txt"] = 'Min. delay between executions';
$wb["limit_web_domain_txt"] = 'Max. number of web domains';
$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains';
$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains';
$wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
$wb["limit_dns_zone_txt"] = 'Max. number of DNS zones';
$wb["limit_dns_record_txt"] = 'Max. number DNS records';
$wb["limit_shell_user_txt"] = 'Max. number of Shell users';
$wb["limit_client_txt"] = 'Max. number of Clients';
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailforward_error_notint"] = 'The email forward limit must be a number.';
$wb["limit_mailcatchall_error_notint"] = 'The email catchall limit must be a number.';
$wb["limit_mailrouting_error_notint"] = 'The email routing limit must be a number.';
$wb["limit_mailfilter_error_notint"] = 'The email filter limit must be a number.';
$wb["limit_mailfetchmail_error_notint"] = 'The fetchmail limit must be a number.';
$wb["limit_mailquota_error_notint"] = 'The email quota limit must be a number.';
$wb["limit_spamfilter_wblist_error_notint"] = 'The spamfilter white / blacklist limit must be a number.';
$wb["limit_spamfilter_user_error_notint"] = 'The spamfilter user limit must be a number.';
$wb["limit_spamfilter_policy_error_notint"] = 'The spamfilter policy limit must be a number.';
$wb["limit_web_domain_error_notint"] = 'The website limit must be a number.';
$wb["limit_web_aliasdomain_error_notint"] = 'The website alias domain limit must be a number.';
$wb["limit_web_subdomain_error_notint"] = 'The website subdomain limit must be a number.';
$wb["limit_ftp_user_error_notint"] = 'The ftp user limit must be a number.';
$wb["limit_shell_user_error_notint"] = 'The shell user limit must be a number.';
$wb["limit_dns_zone_error_notint"] = 'The dns zone limit must be a number.';
$wb["limit_dns_zone_error_notint"] = 'The dns record limit must be a number.';
$wb["limit_database_txt"] = 'Max. number of Databases';
$wb["limit_database_error_notint"] = 'The database limit must be a number.';
$wb["limit_cron_error_notint"] = 'The cron limit must be a number.';
$wb["limit_cron_error_frequency"] = 'The cron frequency limit must be a number.';
$wb["error_template_name_empty"] = 'Please enter a Template name';
<?php
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailaliasdomain_txt"] = 'Max. number of domain aliases';
$wb["limit_mailforward_txt"] = 'Max. number of email forwarders';
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
$wb["limit_mailfilter_txt"] = 'Max. number of email filters';
$wb["limit_fetchmail_txt"] = 'Max. number of fetchmail accounts';
$wb["limit_mailquota_txt"] = 'Mailbox quota';
$wb["limit_spamfilter_wblist_txt"] = 'Max. number of spamfilter white / blacklist filters';
$wb["limit_spamfilter_user_txt"] = 'Max. number of spamfilter users';
$wb["limit_spamfilter_policy_txt"] = 'Max. number of spamfilter policys';
$wb["limit_domain_txt"] = 'limit_domain';
$wb["limit_subdomain_txt"] = 'limit_subdomain';
$wb["limit_webquota_txt"] = 'limit_webquota';
$wb["limit_database_txt"] = 'limit_database';
$wb["limit_cron_txt"] = 'Max. number of cron jobs';
$wb["limit_cron_type_txt"] = 'Max. type of cron jobs (chrooted and full implies url)';
$wb["limit_cron_frequency_txt"] = 'Min. delay between executions';
$wb["limit_web_domain_txt"] = 'Max. number of web domains';
$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains';
$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains';
$wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
$wb["limit_dns_zone_txt"] = 'Max. number of DNS zones';
$wb["limit_dns_record_txt"] = 'Max. number DNS records';
$wb["limit_shell_user_txt"] = 'Max. number of Shell users';
$wb["limit_client_txt"] = 'Max. number of Clients';
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailaliasdomain_error_notint"] = 'The email domain alias limit must be a number.';
$wb["limit_mailforward_error_notint"] = 'The email forward limit must be a number.';
$wb["limit_mailcatchall_error_notint"] = 'The email catchall limit must be a number.';
$wb["limit_mailrouting_error_notint"] = 'The email routing limit must be a number.';
$wb["limit_mailfilter_error_notint"] = 'The email filter limit must be a number.';
$wb["limit_mailfetchmail_error_notint"] = 'The fetchmail limit must be a number.';
$wb["limit_mailquota_error_notint"] = 'The email quota limit must be a number.';
$wb["limit_spamfilter_wblist_error_notint"] = 'The spamfilter white / blacklist limit must be a number.';
$wb["limit_spamfilter_user_error_notint"] = 'The spamfilter user limit must be a number.';
$wb["limit_spamfilter_policy_error_notint"] = 'The spamfilter policy limit must be a number.';
$wb["limit_web_domain_error_notint"] = 'The website limit must be a number.';
$wb["limit_web_aliasdomain_error_notint"] = 'The website alias domain limit must be a number.';
$wb["limit_web_subdomain_error_notint"] = 'The website subdomain limit must be a number.';
$wb["limit_ftp_user_error_notint"] = 'The ftp user limit must be a number.';
$wb["limit_shell_user_error_notint"] = 'The shell user limit must be a number.';
$wb["limit_dns_zone_error_notint"] = 'The dns zone limit must be a number.';
$wb["limit_dns_zone_error_notint"] = 'The dns record limit must be a number.';
$wb["limit_database_txt"] = 'Max. number of Databases';
$wb["limit_database_error_notint"] = 'The database limit must be a number.';
$wb["limit_cron_error_notint"] = 'The cron limit must be a number.';
$wb["limit_cron_error_frequency"] = 'The cron frequency limit must be a number.';
$wb["error_template_name_empty"] = 'Please enter a Template name';
?>
interface/web/client/templates/client_edit_limits.htm
@@ -53,6 +53,10 @@
          <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
        <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
        <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
        <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
interface/web/client/templates/client_template_edit_limits.htm
@@ -18,6 +18,10 @@
        <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
        <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
        <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
interface/web/mail/form/mail_aliasdomain.tform.php
New file
@@ -0,0 +1,113 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Domain Alias";
$form["description"]     = "";
$form["name"]             = "mail_aliasdomain";
$form["action"]            = "mail_aliasdomain_edit.php";
$form["db_table"]        = "mail_forwarding";
$form["db_table_idx"]    = "forwarding_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "alias";
$form["list_default"]    = "mail_aliasdomain_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['alias'] = array (
    'title'     => "Domain Alias",
    'width'     => 100,
    'template'     => "templates/mail_aliasdomain_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'server_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'source' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'source_error_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'source_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^\@[\w\.\-]{2,64}\.[a-zA-Z]{2,10}$/',
                                                        'errmsg'=> 'source_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'destination' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('alias' => 'Alias','forward'=>'Forward')
        ),
        'active' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/mail/lib/lang/en_mail_aliasdomain.lng
New file
@@ -0,0 +1,11 @@
<?php
$wb["source_txt"] = 'Source';
$wb["destination_txt"] = 'Destination';
$wb["active_txt"] = 'Active';
$wb["no_domain_perm"] = "You have no permission for this domain.";
$wb["limit_mailaliasdomain_txt"] = 'The max. number of email alias domains for your account is reached.';
$wb["source_destination_identical_txt"] = 'Source and target Domain are the same.';
$wb["source_error_empty"] = 'Source Domain is empty.';
$wb["source_error_unique"] = 'Duplicate source Domain.';
$wb["source_error_regex"] = 'Invalid source domain name.';
?>
interface/web/mail/lib/lang/en_mail_aliasdomain_list.lng
New file
@@ -0,0 +1,8 @@
<?php
$wb["list_head_txt"] = 'Domain alias';
$wb["active_txt"] = 'Active';
$wb["source_txt"] = 'Source';
$wb["destination_txt"] = 'Destination';
$wb["source_txt"] = 'Source';
$wb["add_new_record_txt"] = 'Add new Domain alias';
?>
interface/web/mail/lib/module.conf.php
@@ -14,6 +14,10 @@
                  'target'     => 'content',
                  'link'    => 'mail/mail_domain_list.php');
$items[] = array( 'title'     => 'Domain Alias',
                  'target'     => 'content',
                  'link'    => 'mail/mail_aliasdomain_list.php');
$items[] = array( 'title'     => 'Email Mailbox',
                  'target'     => 'content',
                  'link'    => 'mail/mail_user_list.php');
interface/web/mail/list/mail_aliasdomain.list.php
New file
@@ -0,0 +1,79 @@
<?php
/*
    Datatypes:
    - INTEGER
    - DOUBLE
    - CURRENCY
    - VARCHAR
    - TEXT
    - DATE
*/
// Name of the list
$liste["name"]                 = "mail_aliasdomain";
// Database table
$liste["table"]             = "mail_forwarding";
// Index index field of the database table
$liste["table_idx"]            = "forwarding_id";
// Search Field Prefix
$liste["search_prefix"]     = "search_";
// Records per page
$liste["records_per_page"]     = 15;
// Script File of the list
$liste["file"]                = "mail_aliasdomain_list.php";
// Script file of the edit form
$liste["edit_file"]            = "mail_aliasdomain_edit.php";
// Script File of the delete script
$liste["delete_file"]        = "mail_aliasdomain_del.php";
// Paging Template
$liste["paging_tpl"]        = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"]                = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array(    'field'        => "active",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "=",
                            'prefix'    => "",
                            'suffix'    => "",
                            'width'        => "",
                            'value'        => array('y' => "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>", 'n' => "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>"));
$liste["item"][] = array(    'field'        => "source",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
$liste["item"][] = array(    'field'        => "destination",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
?>
interface/web/mail/mail_aliasdomain_del.php
New file
@@ -0,0 +1,51 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_aliasdomain.list.php";
$tform_def_file = "form/mail_aliasdomain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
interface/web/mail/mail_aliasdomain_edit.php
New file
@@ -0,0 +1,141 @@
<?php
/*
Copyright (c) 2005 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/mail_aliasdomain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_mailaliasdomain',"type = 'aliasdomain'")) {
                $app->error($app->tform->wordbook["limit_mailaliasdomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_mailaliasdomain',"type = 'aliasdomain'")) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_mailaliasdomain_txt"]);
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        $source_domain = substr($this->dataRecord["source"],1);
        $destination_domain = substr($this->dataRecord["destination"],1);
        // Getting Domains of the user
        $sql = "SELECT domain FROM mail_domain WHERE ".$app->tform->getAuthSQL('r').' ORDER BY domain';
        $domains = $app->db->queryAllRecords($sql);
        $source_select = '';
        $destination_select = '';
        if(is_array($domains)) {
            foreach( $domains as $domain) {
                $selected = ($domain["domain"] == @$source_domain)?'SELECTED':'';
                $source_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
                $selected = ($domain["domain"] == @$destination_domain)?'SELECTED':'';
                $destination_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
            }
        }
        $app->tpl->setVar("source_domain",$source_select);
        $app->tpl->setVar("destination_domain",$destination_select);
        parent::onShowEnd();
    }
    function onSubmit() {
        global $app, $conf;
        // Check if source Domain belongs to user
        $domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($_POST["source"])."' AND ".$app->tform->getAuthSQL('r'));
        if($domain["domain"] != $_POST["source"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"];
        // Check if the destination domain belongs to the user
        $domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($_POST["destination"])."' AND ".$app->tform->getAuthSQL('r'));
        if($domain["domain"] != $_POST["destination"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"];
        // Check the client limits, if user is not the admin
        if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
            if(!$app->tform->checkClientLimit('limit_mailaliasdomain',"type = 'aliasdomain'")) {
                $app->error($app->tform->wordbook["limit_mailaliasdomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_mailaliasdomain',"type = 'aliasdomain'")) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_mailaliasdomain_txt"]);
            }
        } // end if user is not admin
        if($this->dataRecord["source"] == $this->dataRecord["destination"]) $app->tform->errorMessage .= $app->tform->wordbook["source_destination_identical_txt"];
        // compose the source and destination field
        $this->dataRecord["source"] = "@".$app->db->quote($this->dataRecord["source"]);
        $this->dataRecord["destination"] = "@".$app->db->quote($this->dataRecord["destination"]);
        // Set the server id of the mailbox = server ID of mail domain.
        $this->dataRecord["server_id"] = $domain["server_id"];
        parent::onSubmit();
    }
    function onAfterInsert() {
        global $app;
        $domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["destination"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->query("update mail_forwarding SET sys_groupid = ".$domain['sys_groupid']." WHERE forwarding_id = ".$this->id);
    }
}
$page = new page_action;
$page->onLoad();
?>
interface/web/mail/mail_aliasdomain_list.php
New file
@@ -0,0 +1,26 @@
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_aliasdomain.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->uses('listform_actions');
// Limit the results to alias domains
$app->listform_actions->SQLExtWhere = "type = 'aliasdomain'";
$app->listform_actions->onLoad();
?>
interface/web/mail/templates/mail_aliasdomain_edit.htm
New file
@@ -0,0 +1,37 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_mail_aliasdomain">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="destination">{tmpl_var name='source_txt'}</label>
        <select name="source" id="source" class="selectInput">
                    {tmpl_var name='source_domain'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="destination">{tmpl_var name='destination_txt'}</label>
        <select name="destination" id="destination" class="selectInput">
                    {tmpl_var name='destination_domain'}
                </select>
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <input type="hidden" name="type" value="aliasdomain">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_aliasdomain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_aliasdomain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/mail/templates/mail_aliasdomain_list.htm
New file
@@ -0,0 +1,57 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_mail_aliasdomain">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onClick="loadContent('mail/mail_aliasdomain_edit.php');">
          <span>{tmpl_var name="add_new_record_txt"}</span>
        </button>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_active" scope="col"><tmpl_var name="active_txt"></th>
            <th class="tbl_col_source" scope="col"><tmpl_var name="source_txt"></th>
            <th class="tbl_col_destination" scope="col"><tmpl_var name="destination_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <td class="tbl_col_active"><select name="search_active" onChange="submitForm('pageForm','mail/mail_aliasdomain_list.php');">{tmpl_var name='search_active'}</select></td>
            <td class="tbl_col_source"><input type="text" name="search_source" value="{tmpl_var name='search_source'}" /></td>
            <td class="tbl_col_destination"><input type="text" name="search_destination" value="{tmpl_var name='search_destination'}" /></td>
            <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','mail/mail_alias_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_active"><a href="#" onClick="loadContent('mail/mail_aliasdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="active"}</a></td>
            <td class="tbl_col_source"><a href="#" onClick="loadContent('mail/mail_aliasdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="source"}</a></td>
            <td class="tbl_col_destination"><a href="#" onClick="loadContent('mail/mail_aliasdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="destination"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">
                <a class="icons16 icoDelete" href="javascript: del_record('mail/mail_aliasdomain_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
              </div>
            </td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="4"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>