Skip to content

Commit 92bc670

Browse files
committed
- Added a mailserver configuration form.
- Fixed several bugs.
1 parent 098b2f0 commit 92bc670

18 files changed

+603
-34
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ public function getTables($database_name = '')
341341
if($database_name == ''){
342342
$database_name = $this->dbName;
343343
}
344-
$result = mysql_list_tables($database_name);
344+
$result = @mysql_list_tables($database_name);
345345
$tb_names = array();
346-
for ($i = 0; $i < mysql_num_rows($result); $i++) {
347-
$tb_names[$i] = mysql_tablename($result, $i);
346+
for ($i = 0; $i < @mysql_num_rows($result); $i++) {
347+
$tb_names[$i] = @mysql_tablename($result, $i);
348348
}
349349
return $tb_names;
350350
}

interface/lib/classes/ini_parser.inc.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
class ini_parser{
4040

4141
private $config;
42-
42+
43+
//* Converts a ini string to array
4344
public function parse_ini_string($ini) {
4445
$ini = str_replace("\r\n", "\n", $ini);
4546
$lines = explode("\n", $ini);
@@ -56,19 +57,27 @@ public function parse_ini_string($ini) {
5657
}
5758
return $this->config;
5859
}
59-
60-
public function get_ini_string($file) {
60+
61+
62+
//* Converts a config array to a string
63+
public function get_ini_string($config_array = '') {
64+
if($config_array == '') $config_array = $this->config;
6165
$content = '';
62-
foreach($this->config as $section => $data) {
66+
foreach($config_array as $section => $data) {
6367
$content .= "[$section]\n";
6468
foreach($data as $item => $value) {
65-
if($value != ''){
69+
if($item != ''){
6670
$content .= "$item=$value\n";
6771
}
6872
}
73+
$content .= "\n";
6974
}
7075
return $content;
7176
}
77+
78+
79+
80+
7281
}
7382

7483
?>

interface/lib/classes/listform_actions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function prepareDataRow($rec)
9797
foreach($app->listform->listDef['item'] as $field) {
9898
$key = $field['field'];
9999
if(isset($field['formtype']) && $field['formtype'] == 'SELECT') {
100-
$rec[$key] = $field['value'][$rec[$key]];
100+
$rec[$key] = @$field['value'][$rec[$key]];
101101
}
102102
}
103103

interface/lib/classes/tform_actions.inc.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,17 @@ function onUpdate() {
9898
global $app, $conf;
9999

100100
$this->onBeforeUpdate();
101-
101+
102102
$ext_where = '';
103103
$sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'UPDATE',$this->id,$ext_where);
104104
if($app->tform->errorMessage == '') {
105105

106106
if($app->tform->formDef['db_history'] == 'yes') {
107107
$old_data_record = $app->tform->getDataRecord($this->id);
108108
}
109-
110-
if(!empty($sql)) {
111-
$app->db->query($sql);
112-
if($app->db->errorMessage != '') die($app->db->errorMessage);
113-
}
109+
110+
// Save record in database
111+
$this->onUpdateSave($sql);
114112

115113
// loading plugins
116114
$next_tab = $app->tform->getCurrentTab();
@@ -160,6 +158,19 @@ function onUpdate() {
160158
$this->onError();
161159
}
162160
}
161+
162+
/*
163+
Save record in database
164+
*/
165+
166+
function onUpdateSave($sql) {
167+
global $app;
168+
if(!empty($sql)) {
169+
$app->db->query($sql);
170+
if($app->db->errorMessage != '') die($app->db->errorMessage);
171+
}
172+
}
173+
163174

164175
/**
165176
* Function called on data insert
@@ -173,9 +184,8 @@ function onInsert() {
173184
$ext_where = '';
174185
$sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'INSERT',$this->id,$ext_where);
175186
if($app->tform->errorMessage == '') {
176-
$app->db->query($sql);
177-
if($app->db->errorMessage != '') die($app->db->errorMessage);
178-
$this->id = $app->db->insertID();
187+
188+
$this->id = $this->onInsertSave($sql);
179189

180190
// loading plugins
181191
$next_tab = $app->tform->getCurrentTab();
@@ -221,6 +231,17 @@ function onInsert() {
221231
$this->onError();
222232
}
223233
}
234+
235+
/*
236+
Save record in database
237+
*/
238+
239+
function onInsertSave($sql) {
240+
global $app, $conf;
241+
$app->db->query($sql);
242+
if($app->db->errorMessage != '') die($app->db->errorMessage);
243+
return $app->db->insertID();
244+
}
224245

225246
function onBeforeUpdate() {
226247
global $app, $conf;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
$form["action"] = "groups_edit.php";
6666
$form["db_table"] = "sys_group";
6767
$form["db_table_idx"] = "groupid";
68+
$form["db_history"] = "no";
6869
$form["tab_default"] = "groups";
6970
$form["list_default"] = "groups_list.php";
7071
$form["auth"] = 'no';

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
$form['action'] = 'users_edit.php';
6767
$form['db_table'] = 'sys_user';
6868
$form['db_table_idx'] = 'userid';
69+
$form["db_history"] = "no";
6970
$form['tab_default'] = 'users';
7071
$form['list_default'] = 'users_list.php';
7172
$form['auth'] = 'yes';
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
34+
*/
35+
36+
$form["title"] = "Spamfilter Config";
37+
$form["description"] = "";
38+
$form["name"] = "spamfilter_config";
39+
$form["action"] = "spamfilter_config_edit.php";
40+
$form["db_table"] = "server";
41+
$form["db_table_idx"] = "server_id";
42+
$form["db_history"] = "yes";
43+
$form["tab_default"] = "mail";
44+
$form["list_default"] = "spamfilter_config_list.php";
45+
$form["auth"] = 'yes'; // yes / no
46+
47+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
48+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
49+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
50+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
52+
53+
$form["tabs"]['mail'] = array (
54+
'title' => "Mailserver",
55+
'width' => 100,
56+
'template' => "templates/spamfilter_config_mail_edit.htm",
57+
'fields' => array (
58+
##################################
59+
# Begin Datatable fields
60+
##################################
61+
'module' => array (
62+
'datatype' => 'VARCHAR',
63+
'formtype' => 'SELECT',
64+
'default' => '',
65+
'value' => array('postfix_mysql' => 'postfix_mysql')
66+
),
67+
'maildir_path' => array (
68+
'datatype' => 'VARCHAR',
69+
'formtype' => 'TEXT',
70+
'default' => '/home/vmail/[domain]/[localpart]/',
71+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
72+
'errmsg'=> 'maildir_path_error_empty'),
73+
),
74+
'value' => '',
75+
'width' => '40',
76+
'maxlength' => '255'
77+
),
78+
'homedir_path' => array (
79+
'datatype' => 'VARCHAR',
80+
'formtype' => 'TEXT',
81+
'default' => '/home/vmail/',
82+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
83+
'errmsg'=> 'homedir_path_error_empty'),
84+
),
85+
'value' => '',
86+
'width' => '40',
87+
'maxlength' => '255'
88+
),
89+
'mailuser_uid' => array (
90+
'datatype' => 'INTEGER',
91+
'formtype' => 'TEXT',
92+
'default' => '5000',
93+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
94+
'errmsg'=> 'mailuser_uid_error_empty'),
95+
),
96+
'value' => '',
97+
'width' => '10',
98+
'maxlength' => '255'
99+
),
100+
'mailuser_gid' => array (
101+
'datatype' => 'INTEGER',
102+
'formtype' => 'TEXT',
103+
'default' => '5000',
104+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
105+
'errmsg'=> 'mailuser_gid_error_empty'),
106+
),
107+
'value' => '',
108+
'width' => '10',
109+
'maxlength' => '255'
110+
),
111+
'mailuser_name' => array (
112+
'datatype' => 'VARCHAR',
113+
'formtype' => 'TEXT',
114+
'default' => 'vmail',
115+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
116+
'errmsg'=> 'mailuser_name_error_empty'),
117+
),
118+
'value' => '',
119+
'width' => '10',
120+
'maxlength' => '255'
121+
),
122+
'mailuser_group' => array (
123+
'datatype' => 'VARCHAR',
124+
'formtype' => 'TEXT',
125+
'default' => 'vmail',
126+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
127+
'errmsg'=> 'mailuser_group_error_empty'),
128+
),
129+
'value' => '',
130+
'width' => '10',
131+
'maxlength' => '255'
132+
),
133+
'relayhost' => array (
134+
'datatype' => 'VARCHAR',
135+
'formtype' => 'TEXT',
136+
'default' => '',
137+
'value' => '',
138+
'width' => '40',
139+
'maxlength' => '255'
140+
),
141+
'relayhost_user' => array (
142+
'datatype' => 'VARCHAR',
143+
'formtype' => 'TEXT',
144+
'default' => '',
145+
'value' => '',
146+
'width' => '40',
147+
'maxlength' => '255'
148+
),
149+
'relayhost_password' => array (
150+
'datatype' => 'VARCHAR',
151+
'formtype' => 'TEXT',
152+
'default' => '',
153+
'value' => '',
154+
'width' => '40',
155+
'maxlength' => '255'
156+
),
157+
'mailbox_size_limit' => array (
158+
'datatype' => 'INTEGER',
159+
'formtype' => 'TEXT',
160+
'default' => '0',
161+
'value' => '',
162+
'width' => '10',
163+
'maxlength' => '15'
164+
),
165+
'message_size_limit' => array (
166+
'datatype' => 'INTEGER',
167+
'formtype' => 'TEXT',
168+
'default' => '0',
169+
'value' => '',
170+
'width' => '10',
171+
'maxlength' => '15'
172+
),
173+
##################################
174+
# ENDE Datatable fields
175+
##################################
176+
)
177+
);
178+
179+
180+
?>
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
<?php
2-
$wb["list_head_txt"] = 'Spamfilter';
3-
$wb["active_txt"] = 'Active';
4-
$wb["server_id_txt"] = 'Server';
5-
$wb["email_txt"] = 'Email';
6-
$wb["page_txt"] = 'Page';
7-
$wb["page_of_txt"] = 'of';
8-
$wb["page_next_txt"] = 'Next';
9-
$wb["page_back_txt"] = 'Back';
10-
$wb["delete_txt"] = 'Delete';
11-
$wb["filter_txt"] = 'Filter';
12-
$wb["add_new_record_txt"] = 'Add new Spamfilter record';
1+
<?php
2+
$wb["list_head_txt"] = 'Spamfilter';
3+
$wb["active_txt"] = 'Active';
4+
$wb["server_id_txt"] = 'Server';
5+
$wb["server_name_txt"] = 'server_name';
6+
$wb["page_txt"] = 'Page';
7+
$wb["page_of_txt"] = 'of';
8+
$wb["page_next_txt"] = 'Next';
9+
$wb["page_back_txt"] = 'Back';
10+
$wb["delete_txt"] = 'Delete';
11+
$wb["filter_txt"] = 'Filter';
12+
$wb["email_txt"] = 'Email';
13+
$wb["add_new_record_txt"] = 'Add new Spamfilter record';
1314
?>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
$wb["module_txt"] = 'Server Module';
3+
$wb["maildir_path_txt"] = 'Maildir Path';
4+
$wb["homedir_path_txt"] = 'Homedir Path';
5+
$wb["mailuser_uid_txt"] = 'Mailuser UID';
6+
$wb["mailuser_gid_txt"] = 'Mailuser GID';
7+
$wb["mailuser_name_txt"] = 'Mailuser Name';
8+
$wb["mailuser_group_txt"] = 'Mailuser Group';
9+
$wb["relayhost_txt"] = 'Relayhost';
10+
$wb["relayhost_user_txt"] = 'Relayhost User';
11+
$wb["relayhost_password_txt"] = 'Relayhost Password';
12+
$wb["mailbox_size_limit_txt"] = 'Mailbox Size Limit';
13+
$wb["message_size_limit_txt"] = 'Message Size Limit';
14+
$wb["btn_save_txt"] = 'Save';
15+
$wb["btn_cancel_txt"] = 'Cancel';
16+
?>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$wb["list_head_txt"] = 'Server Configuration';
3+
$wb["server_name_txt"] = 'Server';
4+
$wb["page_txt"] = 'Page';
5+
$wb["page_of_txt"] = 'of';
6+
$wb["page_next_txt"] = 'Next';
7+
$wb["page_back_txt"] = 'Back';
8+
$wb["delete_txt"] = 'Delete';
9+
$wb["filter_txt"] = 'Filter';
10+
$wb["server_id_txt"] = 'server_id';
11+
?>

0 commit comments

Comments
 (0)