commit | author | age
|
fedbca
|
1 |
<?php |
TB |
2 |
/* |
|
3 |
Copyright (c) 2014 Till Brehm, ISPConfig UG |
|
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 |
/****************************************** |
|
32 |
* Begin Form configuration |
|
33 |
******************************************/ |
|
34 |
|
|
35 |
$tform_def_file = "form/message_template.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('client'); |
|
46 |
|
|
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
|
52 |
|
|
53 |
function onSubmit() { |
|
54 |
global $app, $conf; |
|
55 |
|
|
56 |
// Check for duplicates |
|
57 |
if($this->dataRecord['template_type'] == 'welcome') { |
|
58 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
cc7a82
|
59 |
$sql = "SELECT count(client_message_template_id) as number FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?"; |
fedbca
|
60 |
if($this->id > 0) { |
cc7a82
|
61 |
$sql .= " AND client_message_template_id != ?"; |
fedbca
|
62 |
} |
cc7a82
|
63 |
$tmp = $app->db->queryOneRecord($sql, $client_group_id, $this->id); |
fedbca
|
64 |
if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng('duplicate_welcome_error'); |
TB |
65 |
} |
|
66 |
|
|
67 |
parent::onSubmit(); |
|
68 |
} |
|
69 |
|
|
70 |
function onShowEnd() { |
|
71 |
global $app, $conf; |
|
72 |
|
|
73 |
//message variables |
|
74 |
$message_variables = ''; |
|
75 |
$sql = "SHOW COLUMNS FROM client WHERE Field NOT IN ('client_id', 'sys_userid', 'sys_groupid', 'sys_perm_user', 'sys_perm_group', 'sys_perm_other', 'parent_client_id', 'id_rsa', 'ssh_rsa', 'created_at', 'default_mailserver', 'default_webserver', 'web_php_options', 'ssh_chroot', 'default_dnsserver', 'default_dbserver', 'template_master', 'template_additional', 'force_suexec', 'default_slave_dnsserver', 'usertheme', 'locked', 'canceled', 'can_use_api', 'tmp_data', 'customer_no_template', 'customer_no_start', 'customer_no_counter', 'added_date', 'added_by') AND Field NOT LIKE 'limit_%'"; |
|
76 |
$field_names = $app->db->queryAllRecords($sql); |
|
77 |
if(!empty($field_names) && is_array($field_names)){ |
|
78 |
foreach($field_names as $field_name){ |
|
79 |
if($field_name['Field'] != ''){ |
|
80 |
if($field_name['Field'] == 'gender'){ |
|
81 |
$message_variables .= '<a href="javascript:void(0);" class="addPlaceholder">{salutation}</a> '; |
|
82 |
} else { |
|
83 |
$message_variables .= '<a href="javascript:void(0);" class="addPlaceholder">{'.$field_name['Field'].'}</a> '; |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
$app->tpl->setVar('message_variables', trim($message_variables)); |
|
89 |
|
|
90 |
parent::onShowEnd(); |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
$page = new page_action; |
|
96 |
$page->onLoad(); |
|
97 |
|
|
98 |
?> |