Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Zvonimir
ISPConfig 3
Commits
12ae7f4b
Commit
12ae7f4b
authored
Dec 16, 2008
by
vogelor
Browse files
It is now possible to add additional templates to the client (and delete them)
parent
88a927c0
Changes
8
Hide whitespace changes
Inline
Side-by-side
interface/web/client/client_edit.php
View file @
12ae7f4b
...
...
@@ -50,7 +50,39 @@ $app->uses('tpl,tform,tform_actions');
$app
->
load
(
'tform_actions'
);
class
page_action
extends
tform_actions
{
function
onShowEnd
()
{
global
$app
;
$sql
=
"SELECT template_id,template_name FROM client_template WHERE template_type = 'a'"
;
$tpls
=
$app
->
db
->
queryAllRecords
(
$sql
);
$option
=
''
;
$tpl
=
array
();
foreach
(
$tpls
as
$item
){
$option
.
=
'<option value="'
.
$item
[
'template_id'
]
.
'|'
.
$item
[
'template_name'
]
.
'">'
.
$item
[
'template_name'
]
.
'</option>'
;
$tpl
[
$item
[
'template_id'
]]
=
$item
[
'template_name'
];
}
$app
->
tpl
->
setVar
(
'tpl_add_select'
,
$option
);
$sql
=
"SELECT template_additional FROM client WHERE client_id = "
.
$this
->
id
;
$result
=
$app
->
db
->
queryOneRecord
(
$sql
);
$tplAdd
=
explode
(
"/"
,
$result
[
'template_additional'
]);
$text
=
''
;
foreach
(
$tplAdd
as
$item
){
if
(
trim
(
$item
)
!=
''
){
if
(
$text
!=
''
)
$text
.
=
'<br>'
;
$text
.
=
$tpl
[
$item
];
}
}
$app
->
tpl
->
setVar
(
'template_additional_list'
,
$text
);
parent
::
onShowEnd
();
}
/*
This function is called automatically right after
the data was successful inserted in the database.
...
...
@@ -87,6 +119,8 @@ class page_action extends tform_actions {
/* If there is a client-template, process it */
applyClientTemplates
(
$this
->
id
);
parent
::
onAfterInsert
();
}
...
...
@@ -127,6 +161,8 @@ class page_action extends tform_actions {
/*
* If there is a client-template, process it */
applyClientTemplates
(
$this
->
id
);
parent
::
onAfterUpdate
();
}
}
...
...
interface/web/client/client_template_edit.php
View file @
12ae7f4b
...
...
@@ -62,10 +62,16 @@ class page_action extends tform_actions {
/*
* the template has changed. apply the new data to all clients
*/
$sql
=
"SELECT client_id FROM client WHERE template_master = "
.
$this
->
id
;
if
(
$this
->
dataRecord
[
"template_type"
]
==
'm'
){
$sql
=
"SELECT client_id FROM client WHERE template_master = "
.
$this
->
id
;
}
else
{
$sql
=
"SELECT client_id FROM client WHERE template_additional LIKE '%/"
.
$this
->
id
.
'/%"'
;
}
$clients
=
$app
->
db
->
queryAllRecords
(
$sql
);
foreach
(
$clients
as
$client
){
applyClientTemplates
(
$client
[
'client_id'
]);
if
(
is_array
(
$clients
)){
foreach
(
$clients
as
$client
){
applyClientTemplates
(
$client
[
'client_id'
]);
}
}
}
}
...
...
interface/web/client/form/client.tform.php
View file @
12ae7f4b
...
...
@@ -308,6 +308,10 @@ $form["tabs"]['limits'] = array (
),
'value'
=>
array
(
'0'
=>
'custom'
)
),
'template_additional'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
),
'default_mailserver'
=>
array
(
'datatype'
=>
'INTEGER'
,
'formtype'
=>
'SELECT'
,
...
...
interface/web/client/form/client_template.tform.php
View file @
12ae7f4b
...
...
@@ -107,7 +107,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_maildomain_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -121,7 +121,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailbox_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -135,7 +135,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailalias_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -149,7 +149,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailforward_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -163,7 +163,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailcatchall_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -191,7 +191,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailfilter_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -205,7 +205,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailfetchmail_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -219,7 +219,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_mailquota_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -233,7 +233,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_spamfilter_wblist_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -247,7 +247,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_spamfilter_user_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -261,7 +261,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_spamfilter_policy_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -275,7 +275,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_web_domain_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -289,7 +289,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_web_aliasdomain_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -303,7 +303,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_web_subdomain_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -317,7 +317,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_ftp_user_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -331,7 +331,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_shell_user_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -345,7 +345,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_dns_zone_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -359,7 +359,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_dns_record_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
@@ -387,7 +387,7 @@ $form["tabs"]['limits'] = array (
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'ISINT'
,
'errmsg'
=>
'limit_database_error_notint'
),
),
'default'
=>
'
-1
'
,
'default'
=>
'
0
'
,
'value'
=>
''
,
'separator'
=>
''
,
'width'
=>
'10'
,
...
...
interface/web/client/templates/client_edit_limits.htm
View file @
12ae7f4b
...
...
@@ -9,6 +9,17 @@
<select
id=
"template_master"
name=
"template_master"
>
{tmpl_var name='template_master'}
</select>
</span>
</fieldset>
<fieldset
id=
"wf_area_client"
><legend>
Additional-Templates
</legend>
<span
class=
"wf_oneField"
>
<select
id=
"tpl_add_select"
name=
"tpl_add_select"
>
{tmpl_var name='tpl_add_select'}
</select>
</span>
<span
id=
"template_additional_list"
>
{tmpl_var name='template_additional_list'}
</span>
<input
type=
"hidden"
id=
"template_additional"
name=
"template_additional"
value=
"{tmpl_var name='template_additional'}"
>
<div
class=
"wf_actions buttons"
>
<button
class=
"positive iconstxt icoAdd"
type=
"button"
value=
"Add additional template"
onClick=
"addAdditionalTemplate();"
><span>
Add additional template
</span></button>
<button
class=
"negative iconstxt icoDelete"
type=
"button"
value=
"Delete additional template"
onClick=
"delAdditionalTemplate();"
><span>
Delete additional template
</span></button>
</div>
</fieldset>
<fieldset
id=
"wf_area_client"
><legend>
Limits
</legend>
<span
class=
"wf_oneField"
>
<label
for=
"default_mailserver"
class=
"wf_preField"
>
{tmpl_var name='default_mailserver_txt'}
</label>
...
...
interface/web/client/tools.inc.php
View file @
12ae7f4b
...
...
@@ -32,9 +32,10 @@ function applyClientTemplates($clientId){
/*
* Get the master-template for the client
*/
$sql
=
"SELECT template_master FROM client WHERE client_id = "
.
intval
(
$clientId
);
$sql
=
"SELECT template_master
, template_additional
FROM client WHERE client_id = "
.
intval
(
$clientId
);
$record
=
$app
->
db
->
queryOneRecord
(
$sql
);
$masterTemplateId
=
$record
[
'template_master'
];
$additionalTemplateStr
=
$record
[
'template_additional'
];
/*
* if the master-Template is custom there is NO changing
...
...
@@ -42,13 +43,34 @@ function applyClientTemplates($clientId){
if
(
$masterTemplateId
>
0
){
$sql
=
"SELECT * FROM client_template WHERE template_id = "
.
intval
(
$masterTemplateId
);
$limits
=
$app
->
db
->
queryOneRecord
(
$sql
);
}
else
{
$limits
=
$this
->
dataRecord
;
}
/*
*
TODO:
Process the additional tempaltes here (add them to the limits
* Process the additional tempaltes here (add them to the limits
* if != -1)
* (like $limits['limit_database'] += $limitAdditional)
*/
$addTpl
=
explode
(
'/'
,
$additionalTemplateStr
);
foreach
(
$addTpl
as
$item
){
if
(
trim
(
$item
)
!=
''
){
$sql
=
"SELECT * FROM client_template WHERE template_id = "
.
intval
(
$item
);
$addLimits
=
$app
->
db
->
queryOneRecord
(
$sql
);
/* maybe the template is deleted in the meantime */
if
(
is_array
(
$addLimits
)){
foreach
(
$addLimits
as
$k
=>
$v
){
if
(
$limits
[
$k
]
>
-
1
){
if
(
$v
==
-
1
)
{
$limits
[
$k
]
=
-
1
;
}
else
{
$limits
[
$k
]
+=
$v
;
}
}
}
}
}
}
/*
* Write all back to the database
...
...
interface/web/js/scrigo.js.php
View file @
12ae7f4b
...
...
@@ -408,3 +408,35 @@ function pass_contains(pass, check) {
}
return false;
}
function addAdditionalTemplate(){
var tpl_add = document.getElementById('template_additional').value;
var tpl_list = document.getElementById('template_additional_list').innerHTML;
var addTemplate = document.getElementById('tpl_add_select').value.split('|',2);
var addTplId = addTemplate[0];
var addTplText = addTemplate[1];
var newVal = tpl_add + '/' + addTplId + '/';
newVal = newVal.replace('//', '/');
var newList = tpl_list + '
<br>
' + addTplText;
newList = newList.replace('
<br><br>
', '
<br>
');
document.getElementById('template_additional').value = newVal;
document.getElementById('template_additional_list').innerHTML = newList;
alert('additional template ' + addTplText + ' added to customer');
}
function delAdditionalTemplate(){
var tpl_add = document.getElementById('template_additional').value;
var tpl_list = document.getElementById('template_additional_list').innerHTML;
var addTemplate = document.getElementById('tpl_add_select').value.split('|',2);
var addTplId = addTemplate[0];
var addTplText = addTemplate[1];
var newVal = tpl_add;
newVal = newVal.replace(addTplId, '');
newVal = newVal.replace('//', '/');
var newList = tpl_list.replace(addTplText, '');
newList = newList.replace('
<br><br>
', '
<br>
');
document.getElementById('template_additional').value = newVal;
document.getElementById('template_additional_list').innerHTML = newList;
alert('additional template ' + addTplText + ' deleted from customer');
}
interface/web/themes/default/css/screen/content_ispc.css
View file @
12ae7f4b
...
...
@@ -287,6 +287,7 @@
.iconstxt.icoNegative
{
background-image
:
url("../../icons/x16/cross_circle_frame.png")
;
}
.iconstxt.icoAdd
{
background-image
:
url(../../icons/x16/plus_circle_frame.png)
;
}
.iconstxt.icoKey
{
background-image
:
url("../../icons/x16/key.png")
;
}
.iconstxt.icoDelete
{
background-image
:
url("../../icons/x16/minus_circle_frame.png")
;
}
/* Button with icon and without text */
.icons16
span
{
display
:
none
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment