root/trunk/gui/include/emailtpl-functions.php

Revision 1410, 6.1 kB (checked in by scitech, 4 days ago)

Fix regresion introduced on r1408

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @version     SVN: $Id$
8  * @link         http://isp-control.net
9  * @author         ispCP Team
10  *
11  * @license
12  *   This program is free software; you can redistribute it and/or modify it under
13  *   the terms of the MPL General Public License as published by the Free Software
14  *   Foundation; either version 1.1 of the License, or (at your option) any later
15  *   version.
16  *   You should have received a copy of the MPL Mozilla Public License along with
17  *   this program; if not, write to the Open Source Initiative (OSI)
18  *   http://opensource.org | osi@opensource.org
19  */
20
21 function get_email_tpl_data($admin_id, $tpl_name) {
22
23     $sql = Database::getInstance();
24
25     $query = <<<SQL_QUERY
26                  SELECT
27                 fname, lname, firm, email
28             FROM
29                 admin
30             WHERE
31                  admin_id = ?
32 SQL_QUERY;
33
34     $rs = exec_query($sql, $query, array($admin_id));
35
36     if ( (trim($rs->fields('fname')) != '') && (trim($rs->fields('lname')) != '') ) {
37
38         $data['sender_name'] = $rs->fields('fname') . ' ' . $rs->fields('lname');
39
40     } else if (trim($rs->fields('fname')) != '') {
41
42         $data['sender_name'] = $rs->fields('fname');
43
44     } else if (trim($rs->fields('lname')) != '') {
45
46         $data['sender_name'] = $rs->fields('lname');
47
48     } else {
49
50         $data['sender_name'] = '';
51
52     }
53
54     if ($rs->fields('firm') != '') {
55
56         if ($data['sender_name'] != '') {
57
58             $data['sender_name'] = $data['sender_name'] . ' ' . '[' . $rs->fields('firm') . ']';
59
60         } else {
61
62             $data['sender_name'] = $rs->fields('firm');
63
64         }
65
66     }
67
68     $data['sender_email'] = $rs->fields('email');
69
70     $query = <<<SQL_QUERY
71                         SELECT
72                   subject, message
73               FROM
74                   email_tpls
75               WHERE
76                   owner_id = ?
77               AND
78                   name = ?
79 SQL_QUERY;
80
81     $rs = exec_query($sql, $query, array($admin_id, $tpl_name));
82
83     if ($rs ->RowCount() == 1 ) {
84
85         $data['subject'] = $rs->fields['subject'];
86
87         $data['message'] = $rs->fields['message'];
88
89     } else {
90
91         $data['subject'] = '';
92
93         $data['message'] = '';
94
95     }
96
97     return $data;
98
99 }
100
101 function set_email_tpl_data($admin_id, $tpl_name, $data) {
102
103     $sql = Database::getInstance();
104
105     $query = <<<SQL_QUERY
106                       SELECT
107                 subject, message
108             FROM
109                 email_tpls
110             WHERE
111                 owner_id = ?
112                AND
113                    name = ?
114 SQL_QUERY;
115
116     $rs = exec_query($sql, $query, array($admin_id, $tpl_name));
117
118     if ($rs ->RowCount() == 0 ) {
119
120         $query = <<<SQL_QUERY
121                           INSERT INTO email_tpls
122                     (subject, message, owner_id, name)
123                     VALUES
124                     (?, ?, ?, ?)
125 SQL_QUERY;
126
127     } else {
128
129         $query = <<<SQL_QUERY
130                           UPDATE
131                               email_tpls
132                           SET
133                               subject = ?,
134                   message = ?
135                 WHERE
136                     owner_id = ?
137                 AND
138                     name = ?
139 SQL_QUERY;
140
141     }
142
143     exec_query($sql, $query, array($data['subject'], $data['message'], $admin_id, $tpl_name));
144
145 }
146
147 function get_welcome_email($admin_id) {
148
149     $data = get_email_tpl_data($admin_id, 'add-user-auto-msg');
150
151     if (!$data['subject']) {
152
153         $data['subject'] = tr('Welcome {USERNAME} to ispCP!', true);
154
155     }
156
157     if (!$data['message']) {
158
159         $data['message'] = tr('
160
161 Hello {NAME}!
162
163 A new ispCP account has been created for you.
164 Your account information:
165
166 User type: {USERTYPE}
167 User name: {USERNAME}
168 Password: {PASSWORD}
169
170 Remember to change your password often and the first time you login.
171
172 You can login right now at http://{BASE_SERVER_VHOST}
173
174 Statistics: http://{USERNAME}/stats/
175 User name: {USERNAME}
176 Password: {PASSWORD}
177
178 Best wishes with ispCP!
179 The ispCP Team.
180
181 ', true);
182
183     }
184
185     return $data;
186
187 }
188
189 function set_welcome_email($admin_id, $data) {
190
191     set_email_tpl_data($admin_id, 'add-user-auto-msg', $data);
192
193 }
194
195 function get_lostpassword_activation_email($admin_id) {
196
197     $data = get_email_tpl_data($admin_id, 'lostpw-msg-1');
198
199     if (!$data['subject']) {
200
201         $data['subject'] = tr('Please activate your new ispCP password!', true);
202
203     }
204
205     if (!$data['message']) {
206
207         $data['message'] = tr('
208
209 Hello {NAME}!
210 Use this link to activate your new ispCP password:
211
212 {LINK}
213
214 Good Luck with the ispCP System
215 The ispCP Team
216
217 ', true);
218
219     }
220
221     return $data;
222
223 }
224
225 function set_lostpassword_activation_email($admin_id, $data) {
226
227     set_email_tpl_data($admin_id, 'lostpw-msg-1', $data);
228
229 }
230
231 function get_lostpassword_password_email($admin_id) {
232
233     $data = get_email_tpl_data($admin_id, 'lostpw-msg-2');
234
235     if (!$data['subject']) {
236
237         $data['subject'] = tr('Your new ispCP login!', true);
238
239     }
240
241     if (!$data['message']) {
242
243         $data['message'] = tr('
244
245 Hello {NAME}!
246
247 Your user name is: {USERNAME}
248 Your password is: {PASSWORD}
249
250 You can login at http://{BASE_SERVER_VHOST}
251
252 Best wishes with ispCP!
253 The ispCP Team
254
255 ', true);
256
257     }
258
259     return $data;
260
261 }
262
263 function set_lostpassword_password_email($admin_id, $data) {
264
265     set_email_tpl_data($admin_id, 'lostpw-msg-2', $data);
266
267 }
268
269 function get_order_email($admin_id) {
270
271     $data = get_email_tpl_data($admin_id, 'after-order-msg');
272
273     if (!$data['subject']) {
274
275         $data['subject'] = tr('Confirmation for domain order {DOMAIN}!', true);
276
277     }
278
279     if (!$data['message']) {
280
281         $data['message'] = tr('
282
283 Dear {NAME},
284 This is an automatic confirmation for the order of the domain:
285
286 {DOMAIN}
287
288 Thank you for using ispCP services.
289 The ispCP Team
290
291 ', true);
292
293     }
294
295     return $data;
296
297 }
298
299 function set_order_email($admin_id, $data) {
300
301     set_email_tpl_data($admin_id, 'after-order-msg', $data);
302
303 }
304
305 function get_alias_order_email($admin_id) {
306
307     $data = get_email_tpl_data($admin_id, 'alias-order-msg');
308
309     if (!$data['subject']) {
310
311         $data['subject'] = tr('New alias order for {CUSTOMER}!', true);
312
313     }
314
315     if (!$data['message']) {
316
317         $data['message'] = tr('
318
319 Dear {RESELLER},
320 Your customer {CUSTOMER} is awaiting for the approval of his new alias:
321
322 {ALIAS}
323
324 Once logged in, you can activate his new alias at
325 http://{BASE_SERVER_VHOST}/reseller/domain-alias.php
326
327 Thank you for using ispCP services.
328 The ispCP Team
329
330 ', true);
331
332     }
333
334     return $data;
335
336 }
337
338 function set_alias_order_email($admin_id, $data) {
339
340     set_email_tpl_data($admin_id, 'alias-order-msg', $data);
341
342 }
343
344 ?>
Note: See TracBrowser for help on using the browser.