-
Notifications
You must be signed in to change notification settings - Fork 0
/
clients-form.php
executable file
·333 lines (304 loc) · 13 KB
/
clients-form.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?php
/**
* Contains the form that is used when adding or editing clients.
*
* @package ProjectSend
* @subpackage Clients
*
*/
?>
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function() {
clean_form(this);
is_complete(this.add_client_form_name,'<?php echo $validation_no_name; ?>');
is_complete(this.add_client_form_user,'<?php echo $validation_no_user; ?>');
is_complete(this.add_client_form_email,'<?php echo $validation_no_email; ?>');
is_length(this.add_client_form_user,<?php echo MIN_USER_CHARS; ?>,<?php echo MAX_USER_CHARS; ?>,'<?php echo $validation_length_user; ?>');
is_email(this.add_client_form_email,'<?php echo $validation_invalid_mail; ?>');
is_alpha_or_dot(this.add_client_form_user,'<?php echo $validation_alpha_user; ?>');
is_number(this.add_client_form_maxfilesize,'<?php echo $validation_file_size; ?>');
<?php
/**
* Password validation is optional only when editing a client.
*/
if ($clients_form_type == 'edit_client' || $clients_form_type == 'edit_client_self') {
?>
// Only check password if any of the 2 fields is completed
var password_1 = $("#add_client_form_pass").val();
//var password_2 = $("#add_client_form_pass2").val();
if ($.trim(password_1).length > 0/* || $.trim(password_2).length > 0*/) {
<?php
}
?>
is_complete(this.add_client_form_pass,'<?php echo $validation_no_pass; ?>');
//is_complete(this.add_client_form_pass2,'<?php echo $validation_no_pass2; ?>');
is_length(this.add_client_form_pass,<?php echo MIN_PASS_CHARS; ?>,<?php echo MAX_PASS_CHARS; ?>,'<?php echo $validation_length_pass; ?>');
is_password(this.add_client_form_pass,'<?php $chars = addslashes($validation_valid_chars); echo $validation_valid_pass." ".$chars; ?>');
//is_match(this.add_client_form_pass,this.add_client_form_pass2,'<?php echo $validation_match_pass; ?>');
<?php
/** Close the jquery IF statement. */
if ($clients_form_type == 'edit_client' || $clients_form_type == 'edit_client_self') {
?>
}
<?php
}
?>
// show the errors or continue if everything is ok
if (show_form_errors() == false) { return false; }
});
});
</script>
<?php
$current_level = get_current_user_level();
$name_placeholder = __("Will be visible on the client's file list",'cftp_admin');
switch ($clients_form_type) {
/** User is creating a new client */
case 'new_client':
$submit_value = __('Add client','cftp_admin');
$disable_user = false;
$require_pass = true;
$form_action = 'clients-add.php';
$info_box = true;
$extra_fields = true;
$group_field = true;
$group_label = __('Groups','cftp_admin');
$ignore_size = false;
break;
/** User is editing an existing client */
case 'edit_client':
$submit_value = __('Save client','cftp_admin');
$disable_user = true;
$require_pass = false;
$form_action = 'clients-edit.php?id='.$client_id;
$info_box = false;
$extra_fields = true;
$group_field = true;
$group_label = __('Groups','cftp_admin');
$ignore_size = false;
break;
/** A client is creating a new account for himself */
case 'new_client_self':
$submit_value = __('Register account','cftp_admin');
$disable_user = false;
$require_pass = true;
$form_action = 'register.php';
$info_box = true;
$extra_fields = false;
$name_placeholder = __("Your full name",'cftp_admin');
$group_field = false;
if ( CLIENTS_CAN_SELECT_GROUP == 'public' || CLIENTS_CAN_SELECT_GROUP == 'all' ) {
$group_field = true;
$group_label = __('Request access to groups','cftp_admin');
}
break;
/** A client is editing his profile */
case 'edit_client_self':
$submit_value = __('Update account','cftp_admin');
$disable_user = true;
$require_pass = false;
$form_action = 'clients-edit.php?id='.$client_id;
$info_box = false;
$extra_fields = false;
$group_field = false;
if ( CLIENTS_CAN_SELECT_GROUP == 'public' || CLIENTS_CAN_SELECT_GROUP == 'all' ) {
$group_field = true;
$group_label = __('Request access to groups','cftp_admin');
$override_groups_list = $found_requests[$client_id]['group_ids'];
}
$ignore_size = true;
break;
}
?>
<form action="<?php echo $form_action; ?>" name="addclient" method="post" class="form-horizontal">
<div class="form-group">
<label for="add_client_form_name" class="col-sm-4 control-label"><?php _e('Name','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_name" id="add_client_form_name" class="form-control required" value="<?php echo (isset($add_client_data_name)) ? html_output(stripslashes($add_client_data_name)) : ''; ?>" placeholder="<?php echo $name_placeholder; ?>" />
</div>
</div>
<div class="form-group">
<label for="add_client_form_user" class="col-sm-4 control-label"><?php _e('Log in username','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_user" id="add_client_form_user" class="form-control <?php if (!$disable_user) { echo 'required'; } ?>" maxlength="<?php echo MAX_USER_CHARS; ?>" value="<?php echo (isset($add_client_data_user)) ? html_output(stripslashes($add_client_data_user)) : ''; ?>" <?php if ($disable_user) { echo 'readonly'; }?> placeholder="<?php _e("Must be alphanumeric",'cftp_admin'); ?>" />
</div>
</div>
<div class="form-group">
<label for="add_client_form_pass" class="col-sm-4 control-label"><?php _e('Password','cftp_admin'); ?></label>
<div class="col-sm-8">
<div class="input-group">
<input name="add_client_form_pass" id="add_client_form_pass" class="form-control password_toggle <?php if ($require_pass) { echo 'required'; } ?>" type="password" maxlength="<?php echo MAX_PASS_CHARS; ?>" />
<div class="input-group-btn password_toggler">
<button type="button" class="btn pass_toggler_show"><i class="glyphicon glyphicon-eye-open"></i></button>
</div>
</div>
<button type="button" name="generate_password" id="generate_password" class="btn btn-default btn-sm btn_generate_password" data-ref="add_client_form_pass" data-min="<?php echo MAX_GENERATE_PASS_CHARS; ?>" data-max="<?php echo MAX_GENERATE_PASS_CHARS; ?>"><?php _e('Generate','cftp_admin'); ?></button>
<?php echo password_notes(); ?>
</div>
</div>
<div class="form-group">
<label for="add_client_form_email" class="col-sm-4 control-label"><?php _e('E-mail','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_email" id="add_client_form_email" class="form-control required" value="<?php echo (isset($add_client_data_email)) ? html_output(stripslashes($add_client_data_email)) : ''; ?>" placeholder="<?php _e("Must be valid and unique",'cftp_admin'); ?>" />
</div>
</div>
<div class="form-group">
<label for="add_client_form_address" class="col-sm-4 control-label"><?php _e('Address','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_address" id="add_client_form_address" class="form-control" value="<?php echo (isset($add_client_data_addr)) ? html_output(stripslashes($add_client_data_addr)) : ''; ?>" />
</div>
</div>
<div class="form-group">
<label for="add_client_form_phone" class="col-sm-4 control-label"><?php _e('Telephone','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_phone" id="add_client_form_phone" class="form-control" value="<?php echo (isset($add_client_data_phone)) ? html_output(stripslashes($add_client_data_phone)) : ''; ?>" />
</div>
</div>
<?php
if ($extra_fields == true) {
?>
<div class="form-group">
<label for="add_client_form_intcont" class="col-sm-4 control-label"><?php _e('Internal contact name','cftp_admin'); ?></label>
<div class="col-sm-8">
<input type="text" name="add_client_form_intcont" id="add_client_form_intcont" class="form-control" value="<?php echo (isset($add_client_data_intcont)) ? html_output(stripslashes($add_client_data_intcont)) : ''; ?>" />
</div>
</div>
<div class="form-group">
<label for="add_client_form_maxfilesize" class="col-sm-4 control-label"><?php _e('Max. upload filesize','cftp_admin'); ?></label>
<div class="col-sm-8">
<div class="input-group">
<input type="text" name="add_client_form_maxfilesize" id="add_client_form_maxfilesize" class="form-control" value="<?php echo (isset($add_client_data_maxfilesize)) ? html_output(stripslashes($add_client_data_maxfilesize)) : ''; ?>" />
<span class="input-group-addon">mb</span>
</div>
<p class="field_note"><?php _e("Set to 0 to use the default system limit",'cftp_admin'); ?> (<?php echo MAX_FILESIZE; ?> mb)</p>
</div>
</div>
<?php
}
?>
<?php
if ( $group_field == true ) {
/**
* Make a list of public groups in case clients can only request
* membership to those
*/
$memberships = new GroupActions;
$arguments = array();
/** Groups to search on based on the current user level */
if ( $current_level == 9 || $current_level == 8 ) {
/** An admin or client manager is creating a client account */
}
else {
/** Someone is registering an account for himself */
if ( CLIENTS_CAN_SELECT_GROUP == 'public' ) {
$arguments['public'] = true;
}
}
$sql_groups = $memberships->get_groups($arguments);
$selected_groups = ( !empty( $found_groups ) ) ? $found_groups : '';
$my_current_groups = array();
/** Dirty and awful quick test, mark as selected the current groups which have requests for a client that's editing his own account */
if ( isset( $override_groups_list ) ) {
$selected_groups = $override_groups_list;
if ( !empty( $found_groups ) ) {
foreach ( $sql_groups as $array_key => $sql_group ) {
if ( in_array( $sql_group['id'], $found_groups ) ) {
$my_current_groups[] = $sql_group;
unset($sql_groups[$array_key]);
}
}
}
}
if ( count( $sql_groups ) > 0) {
?>
<div class="form-group assigns">
<label for="add_client_group_request" class="col-sm-4 control-label"><?php echo $group_label; ?></label>
<div class="col-sm-8">
<select multiple="multiple" name="add_client_group_request[]" id="groups-select" class="form-control chosen-select" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<?php
foreach ( $sql_groups as $group ) {
?>
<option value="<?php echo $group['id']; ?>"
<?php
if ( !empty( $selected_groups ) && in_array( $group['id'], $selected_groups ) ) {
echo ' selected="selected"';
}
?>
><?php echo $group['name']; ?></option>
<?php
}
?>
</select>
<?php
if ( $current_level == 9 || $current_level == 8 ) {
?>
<div class="list_mass_members">
<a href="#" class="btn btn-default add-all" data-type="assigns"><?php _e('Add all','cftp_admin'); ?></a>
<a href="#" class="btn btn-default remove-all" data-type="assigns"><?php _e('Remove all','cftp_admin'); ?></a>
</div>
<?php
}
?>
</div>
</div>
<?php
}
}
?>
<?php
if ($extra_fields == true) {
?>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<label for="add_client_form_active">
<input type="checkbox" name="add_client_form_active" id="add_client_form_active" <?php echo (isset($add_client_data_active) && $add_client_data_active == 1) ? 'checked="checked"' : ''; ?>> <?php _e('Active (client can log in)','cftp_admin'); ?>
</label>
</div>
</div>
<?php
}
?>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<label for="add_client_form_notify_upload">
<input type="checkbox" name="add_client_form_notify_upload" id="add_client_form_notify_upload" <?php echo (isset($add_client_data_notify_upload) && $add_client_data_notify_upload == 1) ? 'checked="checked"' : ''; ?>> <?php _e('Notify new uploads by e-mail','cftp_admin'); ?>
</label>
</div>
</div>
<?php
if ( $clients_form_type == 'new_client' ) {
?>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<label for="add_client_form_notify_account">
<input type="checkbox" name="add_client_form_notify_account" id="add_client_form_notify_account" <?php echo (isset($add_client_data_notify_account) && $add_client_data_notify_account == 1) ? 'checked="checked"' : ''; ?>> <?php _e('Send welcome email','cftp_admin'); ?>
</label>
</div>
</div>
<?php
}
?>
<?php
if ( $clients_form_type == 'new_client_self' ) {
if ( defined('RECAPTCHA_AVAILABLE') ) {
?>
<div class="form-group">
<label class="col-sm-4 control-label"><?php _e('Verification','cftp_admin'); ?></label>
<div class="col-sm-8">
<div class="g-recaptcha" data-sitekey="<?php echo RECAPTCHA_SITE_KEY; ?>"></div>
</div>
</div>
<?php
}
}
?>
<div class="inside_form_buttons">
<button type="submit" name="submit" class="btn btn-wide btn-primary"><?php echo html_output($submit_value); ?></button>
</div>
<?php
if ($info_box == true) {
$msg = __('This account information will be e-mailed to the address supplied above','cftp_admin');
echo system_message('info',$msg);
}
?>
</form>