-
Notifications
You must be signed in to change notification settings - Fork 0
/
email-templates.php
293 lines (271 loc) · 11.4 KB
/
email-templates.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
/**
* Allows the administrator to customize the emails
* sent by the system.
*
* @package ProjectSend
* @subpackage Options
*/
$easytabs = 1;
$allowed_levels = array(9);
require_once('sys.includes.php');
$page_title = __('E-mail templates','cftp_admin');
$active_nav = 'options';
include('header.php');
$database->MySQLDB();
if ($_POST) {
/** Checkboxes */
$checkboxes = array(
'email_header_footer_customize',
'email_new_file_by_user_customize',
'email_new_file_by_client_customize',
'email_new_client_by_user_customize',
'email_new_client_by_self_customize',
'email_new_user_customize',
'email_pass_reset_customize',
);
foreach ($checkboxes as $checkbox) {
$_POST[$checkbox] = (empty($_POST[$checkbox]) || !isset($_POST[$checkbox])) ? 0 : 1;
}
/**
* Escape all the posted values on a single function.
* Defined on functions.php
*/
$_POST = mysql_real_escape_array($_POST);
$keys = array_keys($_POST);
$options_total = count($keys);
$updated = 0;
for ($j = 0; $j < $options_total; $j++) {
$q = 'UPDATE tbl_options SET value="'.$_POST[$keys[$j]].'" WHERE name="'.$keys[$j].'"';
$sql = mysql_query($q, $database->connection);
$updated++;
}
if ($updated > 0){
$query_state = '1';
}
else {
$query_state = '2';
}
/** Redirect so the options are reflected immediatly */
while (ob_get_level()) ob_end_clean();
$location = BASE_URI . 'email-templates.php?status=' . $query_state;
header("Location: $location");
die();
}
?>
<div id="main">
<h2><?php echo $page_title; ?></h2>
<?php
if (isset($_GET['status'])) {
switch ($_GET['status']) {
case '1':
$msg = __('Options updated succesfuly.','cftp_admin');
echo system_message('ok',$msg);
break;
case '2':
$msg = __('There was an error. Please try again.','cftp_admin');
echo system_message('error',$msg);
break;
}
}
?>
<script type="text/javascript">
$(document).ready(function() {
$('#tab-container').easytabs({
updateHash: false
});
});
</script>
<?php
$href_string = ' ' . __('(to be used as href on a link tag)','cftp_admin');
$options_groups = array(
1 => array(
'tab' => 'file_by_user',
'name' => __('New file by user','cftp_admin'),
'checkbox' => 'email_new_file_by_user_customize',
'textarea' => 'email_new_file_by_user_text',
'description' => __('This email will be sent to a client whenever a new file has been assigned to his account.','cftp_admin'),
'option_check' => EMAILS_FILE_BY_USER_USE_CUSTOM,
'option_text' => EMAILS_FILE_BY_USER_TEXT,
'tags' => array(
'%FILES%' => __('Shows the list of files','cftp_admin'),
'%URI% ' => __('The login link','cftp_admin') . $href_string,
),
),
2 => array(
'tab' => 'file_by_client',
'name' => __('New file by client','cftp_admin'),
'checkbox' => 'email_new_file_by_client_customize',
'textarea' => 'email_new_file_by_client_text',
'description' => __('This email will be sent to the system administrator whenever a client uploads a new file.','cftp_admin'),
'option_check' => EMAILS_FILE_BY_CLIENT_USE_CUSTOM,
'option_text' => EMAILS_FILE_BY_CLIENT_TEXT,
'tags' => array(
'%FILES%' => __('Shows the list of files','cftp_admin'),
'%URI% ' => __('The login link','cftp_admin') . $href_string,
),
),
3 => array(
'tab' => 'client_by_user',
'name' => __('New client (welcome)','cftp_admin'),
'checkbox' => 'email_new_client_by_user_customize',
'textarea' => 'email_new_client_by_user_text',
'description' => __('This email will be sent to the new client after an administrator has created his new account. It would be best to include the log in details (username and password).','cftp_admin'),
'option_check' => EMAILS_CLIENT_BY_USER_USE_CUSTOM,
'option_text' => EMAILS_CLIENT_BY_USER_TEXT,
'tags' => array(
'%USERNAME%' => __('The new username for this account','cftp_admin'),
'%PASSWORD%' => __('The new password for this account','cftp_admin'),
'%URI% ' => __('The login link','cftp_admin') . $href_string,
),
),
4 => array(
'tab' => 'client_by_self',
'name' => __('New client (self-registered)','cftp_admin'),
'checkbox' => 'email_new_client_by_self_customize',
'textarea' => 'email_new_client_by_self_text',
'description' => __('This email will be sent to the system administrator after a new client has created a new account for himself.','cftp_admin'),
'option_check' => EMAILS_CLIENT_BY_SELF_USE_CUSTOM,
'option_text' => EMAILS_CLIENT_BY_SELF_TEXT,
'tags' => array(
'%FULLNAME%' => __('The full name the client registered with','cftp_admin'),
'%USERNAME%' => __('The new username for this account','cftp_admin'),
'%URI% ' => __('The login link','cftp_admin') . $href_string,
),
),
5 => array(
'tab' => 'new_user_welcome',
'name' => __('New user (welcome)','cftp_admin'),
'checkbox' => 'email_new_user_customize',
'textarea' => 'email_new_user_text',
'description' => __('This email will be sent to the new system user after an administrator has created his new account. It would be best to include the log in details (username and password).','cftp_admin'),
'option_check' => EMAILS_NEW_USER_USE_CUSTOM,
'option_text' => EMAILS_NEW_USER_TEXT,
'tags' => array(
'%USERNAME%' => __('The new username for this account','cftp_admin'),
'%PASSWORD%' => __('The new password for this account','cftp_admin'),
'%URI% ' => __('The login link','cftp_admin') . $href_string,
),
),
6 => array(
'tab' => 'password_reset',
'name' => __('Password reset','cftp_admin'),
'checkbox' => 'email_pass_reset_customize',
'textarea' => 'email_pass_reset_text',
'description' => __('This email will be sent to a user or client when they try to reset their password.','cftp_admin'),
'option_check' => EMAILS_PASS_RESET_USE_CUSTOM,
'option_text' => EMAILS_PASS_RESET_TEXT,
'tags' => array(
'%USERNAME%' => __('The username for this account','cftp_admin'),
'%TOKEN%' => __('The text string unique to this request. Must be included somewhere.','cftp_admin'),
'%URI% ' => __('The link to continue the process','cftp_admin') . $href_string,
),
),
);
?>
<form action="email-templates.php" name="templatesform" method="post">
<div id="outer_tabs_wrapper">
<div id="tab-container" class="tab-container">
<ul class="etabs">
<li class="tab">
<a href="#tab_header_footer">
<?php _e('Header / Footer','cftp_admin'); ?>
</a>
</li>
<?php
foreach ($options_groups as $group) {
?>
<li class="tab">
<a href="#tab_<?php echo $group['tab']; ?>">
<?php echo $group['name']; ?>
</a>
</li>
<?php
}
?>
</ul>
<div class="panel-container">
<div id="tab_header_footer">
<div class="options_box whitebox">
<ul class="form_fields">
<li>
<h3><?php _e('Header / Footer','cftp_admin'); ?></h3>
<p class="text-warning"><?php _e('Here you set up the header and footer of every email, or use the default ones available with the system. Use this to customize each part and include, for example, your own logo and markup.','cftp_admin'); ?></p>
</li>
<li>
<label for="email_header_footer_customize"><?php _e('Use custom header / footer','cftp_admin'); ?></label>
<input type="checkbox" value="1" name="email_header_footer_customize" class="checkbox_options" <?php echo (EMAILS_HEADER_FOOTER_CUSTOM == 1) ? 'checked="checked"' : ''; ?> />
</li>
<li>
<label for="email_header_text"><?php _e('Header','cftp_admin'); ?></label>
<textarea name="email_header_text" id="email_header_text"><?php echo EMAILS_HEADER_TEXT; ?></textarea>
</li>
<li>
<p class="field_note"><?php _e('You can use HTML tags here.','cftp_admin'); ?></p>
</li>
<li>
<label for="email_footer_text"><?php _e('Footer','cftp_admin'); ?></label>
<textarea name="email_footer_text" id="email_footer_text"><?php echo EMAILS_FOOTER_TEXT; ?></textarea>
</li>
<li>
<p class="field_note"><?php _e('You can use HTML tags here.','cftp_admin'); ?></p>
</li>
</ul>
</div>
</div>
<?php
foreach ($options_groups as $group) {
?>
<div id="tab_<?php echo $group['tab']; ?>">
<div class="options_box whitebox">
<ul class="form_fields">
<li>
<h3><?php echo $group['name']; ?></h3>
<p class="text-warning"><?php echo $group['description']; ?></p>
</li>
<li>
<label for="<?php echo $group['checkbox']; ?>"><?php _e('Use custom template','cftp_admin'); ?></label>
<input type="checkbox" value="1" name="<?php echo $group['checkbox']; ?>" class="checkbox_options" <?php echo ($group['option_check'] == 1) ? 'checked="checked"' : ''; ?> />
</li>
<li>
<label for="<?php echo $group['textarea']; ?>"><?php _e('Template text','cftp_admin'); ?></label>
<textarea name="<?php echo $group['textarea']; ?>" id="<?php echo $group['textarea']; ?>"><?php echo $group['option_text']; ?></textarea>
</li>
<li>
<p class="field_note"><?php _e('You can use HTML tags here.','cftp_admin'); ?></p>
</li>
<li class="email_available_tags">
<p><strong><?php _e("The following tags can be used on this e-mails' body.",'cftp_admin'); ?></strong></p>
<?php
if (!empty($group['tags'])) {
?>
<ul>
<?php
foreach ($group['tags'] as $tag => $description) {
?>
<li><i class="icon-ok"></i> <strong><?php echo $tag; ?></strong>: <?php echo $description; ?></li>
<?php
}
?>
</ul>
<?php
}
?>
</li>
</ul>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
<div class="after_form_buttons">
<button type="submit" name="submit" class="btn btn-wide btn-primary empty"><?php _e('Update all options','cftp_admin'); ?></button>
</div>
</form>
</div>
<div class="clear"></div>
</div>
<?php include('footer.php'); ?>