Skip to content

Commit 6dfc1f8

Browse files
author
vogelor
committed
Added a new module called "domain". With this module you can manage all domains (web + mail). Per default this module is not active. To activate it, you have to change the System Interface Config -> domains -> use the domain module. You also have to activate the domain-module for the admin (and for every client if you want). Important: you can not use this module if you have reseller!
1 parent abdc67d commit 6dfc1f8

29 files changed

+911
-10
lines changed

install/sql/ispconfig3.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,22 @@ CREATE TABLE `dns_template` (
262262
PRIMARY KEY (`template_id`)
263263
) ENGINE=MyISAM AUTO_INCREMENT=1;
264264

265+
--
266+
-- Tabellenstruktur für Tabelle `domain`
267+
--
268+
269+
CREATE TABLE `domain` (
270+
`domain_id` int(11) unsigned NOT NULL auto_increment,
271+
`sys_userid` int(11) unsigned NOT NULL default '0',
272+
`sys_groupid` int(11) unsigned NOT NULL default '0',
273+
`sys_perm_user` varchar(5) NOT NULL default '',
274+
`sys_perm_group` varchar(5) NOT NULL default '',
275+
`sys_perm_other` varchar(5) NOT NULL default '',
276+
`domain` varchar(255) NOT NULL default '',
277+
PRIMARY KEY (`domain_id`),
278+
UNIQUE KEY `domain` (`domain`)
279+
) ENGINE=MyISAM;
280+
265281
-- --------------------------------------------------------
266282

267283
--

install/tpl/system.ini.master

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ shelluser_prefix=[CLIENTNAME]
2020
dblist_phpmyadmin_link=y
2121
phpmyadmin_url=
2222

23-
[tools]
23+
[tools]
24+
25+
[domains]
26+
use_domain_module=n
27+
new_domain_html=Please contact our support to create a new domain for you.

interface/lib/lang/de.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ $wb['top_menu_dns'] = 'DNS';
3232
$wb['top_menu_tools'] = 'Tools';
3333
$wb['top_menu_help'] = 'Support';
3434
$wb['top_menu_billing'] = 'Billing';
35+
$wb['top_menu_domain'] = 'Domänen';
3536
?>

interface/lib/lang/en.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ $wb['top_menu_dns'] = 'DNS';
3232
$wb['top_menu_tools'] = 'Tools';
3333
$wb['top_menu_help'] = 'Help';
3434
$wb['top_menu_billing'] = 'Billing';
35+
$wb['top_menu_domain'] = 'Domains';
3536
$wb['toolsarea_head_txt'] = 'Tools';
3637
?>

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,31 @@
162162
)
163163
);
164164

165+
$form["tabs"]['domains'] = array (
166+
'title' => "Domains",
167+
'width' => 70,
168+
'template' => "templates/system_config_domains_edit.htm",
169+
'fields' => array (
170+
##################################
171+
# Begin Datatable fields
172+
##################################
173+
'use_domain_module' => array (
174+
'datatype' => 'VARCHAR',
175+
'formtype' => 'CHECKBOX',
176+
'default' => 'n',
177+
'value' => array(0 => 'n',1 => 'y')
178+
),
179+
'new_domain_html' => array (
180+
'datatype' => 'VARCHAR',
181+
'formtype' => 'TEXT',
182+
'default' => '',
183+
'value' => ''
184+
),
185+
##################################
186+
# ENDE Datatable fields
187+
##################################
188+
)
189+
);
165190

166191

167192
?>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ $wb['dblist_phpmyadmin_link_txt'] = 'Link zu phpMyAdmin in der Datenbankliste';
1212
$wb['mailboxlist_webmail_link_txt'] = 'Link zu Webmail in der Mailboxliste';
1313
$wb['webmail_url_txt'] = 'Webmail URL';
1414
$wb['phpmyadmin_url_txt'] = 'PHPMyAdmin URL';
15+
$wb['use_domain_module_txt'] = 'Neue Domains können nur über das Modul Domains angelegt werden';
16+
$wb['use_domain_module_hint'] = 'Wenn Sie dieses Modul verwenden, können Kunden beim Anlegen neuer E-Mail-Domains und neuer Websites lediglich eine Auswahl der vom Administrator für sie angelegter Domains treffen, sie können keine freie Eingabe ausführen.<br>Sollten Sie diesen Wert ändern, so müssen Sie sich danach ab- und wieder neu anmelden, um die Änderungen sichtbar zu machen.';
17+
$wb['new_domain_txt'] = 'HTML-Text zum Erstellen einer neuen Domäne';
1518
?>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ $wb['dblist_phpmyadmin_link_txt'] = 'Link to phpmyadmin in DB list';
1313
$wb['mailboxlist_webmail_link_txt'] = 'Link to webmail in Mailbox list';
1414
$wb['webmail_url_txt'] = 'Webmail URL';
1515
$wb['phpmyadmin_url_txt'] = 'PHPMyAdmin URL';
16-
16+
$wb['use_domain_module_txt'] = 'Use the domain-module to add new domains';
17+
$wb['use_domain_module_hint'] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They can not free edit the domain-field.You have to re-login after changing this value, to make the changes visible.';
18+
$wb['new_domain_txt'] = 'HTML to create a new domain';
1719
?>

interface/web/admin/system_config_edit.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
$app->load('tform_actions');
5050

5151
class page_action extends tform_actions {
52-
52+
53+
5354
function onShowEdit() {
5455
global $app, $conf;
5556

@@ -62,7 +63,11 @@ function onShowEdit() {
6263
$server_id = $this->id;
6364

6465
$this->dataRecord = $app->getconf->get_global_config($section);
65-
66+
if ($section == 'domains'){
67+
if (isset($this->dataRecord['use_domain_module'])){
68+
$_SESSION['use_domain_module_old_value'] = $this->dataRecord['use_domain_module'];
69+
}
70+
}
6671
}
6772

6873
$record = $app->tform->getHTML($this->dataRecord, $this->active_tab,'EDIT');
@@ -86,6 +91,23 @@ function onUpdateSave($sql) {
8691

8792
$sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1";
8893
$app->db->query($sql);
94+
95+
/*
96+
* If we should use the domain-module, we have to insert all existing domains into the table
97+
* (only the first time!)
98+
*/
99+
if (($section == 'domains') &&
100+
($_SESSION['use_domain_module_old_value'] == '') &&
101+
($server_config_array['domains']['use_domain_module'] == 'y')){
102+
$sql = "REPLACE INTO domain (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain ) " .
103+
"SELECT sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain " .
104+
"FROM mail_domain";
105+
$app->db->query($sql);
106+
$sql = "REPLACE INTO domain (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain ) " .
107+
"SELECT sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain " .
108+
"FROM web_domain";
109+
$app->db->query($sql);
110+
}
89111
}
90112

91113
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<h2><tmpl_var name="list_head_txt"></h2>
2+
<p><tmpl_var name="list_desc_txt"></p>
3+
4+
<div class="panel panel_system_config">
5+
6+
<div class="pnl_formsarea">
7+
<fieldset class="inlineLabels">
8+
<div class="ctrlHolder">
9+
<div style="float:left;width:100%">
10+
<p class="label" style="width:270px">{tmpl_var name='use_domain_module_txt'}</p>
11+
<div class="multiField">
12+
{tmpl_var name='use_domain_module'}
13+
</div>
14+
</div>
15+
<div style="float:left;width:500px;margin-top:20px">{tmpl_var name='use_domain_module_hint'}</div>
16+
</div>
17+
<div class="ctrlHolder">
18+
<p class="label">{tmpl_var name='new_domain_txt'}</p>
19+
<div class="multiField">
20+
<textarea name="new_domain_html" id="new_domain_html" style="width: 500px; height: 250px">
21+
{tmpl_var name='new_domain_html'}
22+
</textarea>
23+
</div>
24+
</div>
25+
</fieldset>
26+
27+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
28+
29+
<div class="buttonHolder buttons">
30+
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/system_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
31+
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
32+
</div>
33+
</div>
34+
35+
</div>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/*
3+
Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/******************************************
31+
* Begin Form configuration
32+
******************************************/
33+
34+
$list_def_file = "list/domain.list.php";
35+
$tform_def_file = "form/domain.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
44+
//* Check permissions for module
45+
$app->auth->check_module_permissions('domain');
46+
47+
// Loading classes
48+
$app->uses('tpl,tform,tform_actions');
49+
$app->load('tform_actions');
50+
51+
//* load language file
52+
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng';
53+
include($lng_file);
54+
55+
class page_action extends tform_actions {
56+
57+
function onBeforeDelete() {
58+
global $app; $conf;
59+
60+
/*
61+
* We can only delete domains if they are NOT in use
62+
*/
63+
$domain = $this->dataRecord['domain'];
64+
65+
$sql = "SELECT domain_id FROM mail_domain WHERE domain = '" . $app->db->quote($domain) . "'";
66+
$res = $app->db->queryOneRecord($sql);
67+
if (is_array($res)){
68+
$app->error($wb['error_domain_in mailuse']);
69+
}
70+
71+
$sql = "SELECT domain_id FROM web_domain WHERE domain = '" . $app->db->quote($domain) . "'";
72+
$res = $app->db->queryOneRecord($sql);
73+
if (is_array($res)){
74+
$app->error($wb['error_domain_in webuse']);
75+
}
76+
}
77+
}
78+
79+
$page = new page_action;
80+
$page->onDelete();
81+
82+
?>

0 commit comments

Comments
 (0)