forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-process-form.php
716 lines (646 loc) · 25.1 KB
/
upload-process-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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
<?php
/**
* Uploading files, step 2
*
* This file handles all the uploaded files, whether you are
* coming from the "Upload from computer" or "Find orphan files"
* pages. The only difference is from which POST array it takes
* the information to list the available files to process.
*
* It can display up tp 3 tables:
* One that will list all the files that were brought in from
* the first step. One with the confirmed uploaded and assigned
* files, and a possible third one with the ones that failed.
*
* @package ProjectSend
* @subpackage Upload
*/
$allowed_levels = array(9,8,7,0);
require_once('bootstrap.php');
$active_nav = 'files';
$page_title = __('Upload files', 'cftp_admin');
include_once ADMIN_TEMPLATES_DIR . DS . 'header.php';
define('CAN_INCLUDE_FILES', true);
?>
<div class="col-xs-12">
<?php
$uploaded_files = $_POST['files'];
/**
* A hidden field sends the list of failed files as a string,
* where each filename is separated by a comma.
* Here we change it into an array so we can list the files
* on a separate table.
*/
if(isset($_POST['upload_failed'])) {
$upload_failed_hidden_post = array_filter(explode(',',$_POST['upload_failed']));
}
/**
* Files that failed are removed from the uploaded files list.
*/
if(isset($upload_failed_hidden_post) && count($upload_failed_hidden_post) > 0) {
foreach ($upload_failed_hidden_post as $failed) {
$delete_key = array_search($failed, $uploaded_files);
unset($uploaded_files[$delete_key]);
}
}
/** Define the arrays */
$upload_failed = array();
$move_failed = array();
/**
* $empty_fields counts the amount of "name" fields that
* were not completed.
*/
$empty_fields = 0;
/** Fill the users array that will be used on the notifications process */
$users = array();
$statement = $dbh->prepare("SELECT id, name, level FROM " . TABLE_USERS . " ORDER BY name ASC");
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $statement->fetch() ) {
$users[$row["id"]] = $row["name"];
if ($row["level"] == '0') {
$clients[$row["id"]] = $row["name"];
}
}
/** Fill the groups array that will be used on the form */
$groups = array();
$statement = $dbh->prepare("SELECT id, name FROM " . TABLE_GROUPS . " ORDER BY name ASC");
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $statement->fetch() ) {
$groups[$row["id"]] = $row["name"];
}
/** Fill the categories array that will be used on the form */
$categories = array();
$get_categories = get_categories();
/**
* Make an array of file urls that are on the DB already.
*/
$statement = $dbh->prepare("SELECT DISTINCT original_url FROM " . TABLE_FILES);
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $statement->fetch() ) {
$urls_db_files[] = $row["original_url"];
}
/**
* A posted form will include information of the uploaded files
* (name, description and client).
*/
if (isset($_POST['submit'])) {
/**
* Get the ID of the current client that is uploading files.
*/
if (CURRENT_USER_LEVEL == 0) {
$client_my_id = CURRENT_USER_ID;
}
$n = 0;
foreach ($_POST['file'] as $file) {
$n++;
if(!empty($file['name'])) {
/**
* If the uploader is a client, set the "client" var to the current
* uploader username, since the "client" field is not posted.
*/
if (CURRENT_USER_LEVEL == 0) {
$file['assignments'] = 'c'.CURRENT_USER_USERNAME;
}
$this_upload = new \ProjectSend\FilesUpload();
if (!in_array($file['file'],$urls_db_files)) {
$file['file'] = $this_upload->safe_rename($file['file']);
}
$location = UPLOADED_FILES_DIR . DS . $file['file'];
if(file_exists($location)) {
$move_arguments = array(
'uploaded_name' => $location,
'filename' => $file['file'],
);
$upload_move = $this_upload->upload_move($move_arguments);
$new_filename = $upload_move['filename_disk'];
$original_filename = $upload_move['filename_original'];
if (!empty($new_filename)) {
$delete_key = array_search($file['original'], $uploaded_files);
unset($uploaded_files[$delete_key]);
/**
* Unassigned files are kept as orphans and can be related
* to clients or groups later.
*/
/** Add to the database for each client / group selected */
$add_arguments = array(
'file_disk' => $new_filename,
'file_original' => $original_filename,
'name' => $file['name'],
'description' => $file['description'],
'uploader' => CURRENT_USER_USERNAME,
'uploader_id' => CURRENT_USER_ID,
);
/** Set notifications to YES by default */
$send_notifications = true;
if (!empty($file['hidden'])) {
$add_arguments['hidden'] = $file['hidden'];
$send_notifications = false;
}
if (!empty($file['assignments'])) {
$add_arguments['assign_to'] = $file['assignments'];
$assignations_count = count($file['assignments']);
}
else {
$assignations_count = '0';
}
/** Uploader is a client */
if (CURRENT_USER_LEVEL == 0) {
$add_arguments['assign_to'] = array('c'.$client_my_id);
$add_arguments['hidden'] = '0';
$add_arguments['uploader_type'] = 'client';
$add_arguments['expires'] = '0';
$add_arguments['public'] = '0';
}
else {
$add_arguments['uploader_type'] = 'user';
if (!empty($file['expires'])) {
$add_arguments['expires'] = '1';
$add_arguments['expiry_date'] = $file['expiry_date'];
}
if (!empty($file['public'])) {
$add_arguments['public'] = '1';
}
}
if (!in_array($new_filename,$urls_db_files)) {
$add_arguments['add_to_db'] = true;
}
/**
* 1- Add the file to the database
*/
$process_file = $this_upload->upload_add_to_database($add_arguments);
if($process_file['database'] == true) {
$add_arguments['new_file_id'] = $process_file['new_file_id'];
$add_arguments['all_users'] = $users;
$add_arguments['all_groups'] = $groups;
/**
* 2- Add the assignments to the database
*/
$process_assignment = $this_upload->upload_add_assignment($add_arguments);
/**
* 3- Add the assignments to the database
*/
$categories_arguments = array(
'file_id' => $process_file['new_file_id'],
'categories' => !empty( $file['categories'] ) ? $file['categories'] : '',
);
$this_upload->upload_save_categories( $categories_arguments );
/**
* 4- Add the notifications to the database
*/
if ($send_notifications == true) {
$process_notifications = $this_upload->upload_add_notifications($add_arguments);
}
/**
* 5- Mark is as correctly uploaded / assigned
*/
$upload_finish[$n] = array(
'file_id' => $add_arguments['new_file_id'],
'file' => $file['file'],
'name' => htmlspecialchars($file['name']),
'description' => htmlspecialchars($file['description']),
'new_file_id' => $process_file['new_file_id'],
'assignations' => $assignations_count,
'public' => !empty( $add_arguments['public'] ) ? $add_arguments['public'] : 0,
'public_token' => !empty( $process_file['public_token'] ) ? $process_file['public_token'] : null,
);
if (!empty($file['hidden'])) {
$upload_finish[$n]['hidden'] = $file['hidden'];
}
}
}
}
}
else {
$empty_fields++;
}
}
}
/**
* Generate the table of files that were assigned to a client
* on this last POST. These files appear on this table only once,
* so if there is another submition of the form, only the new
* assigned files will be displayed.
*/
if(!empty($upload_finish)) {
?>
<h3><?php _e('Files uploaded correctly','cftp_admin'); ?></h3>
<table id="uploaded_files_tbl" class="footable" data-page-size="<?php echo FOOTABLE_PAGING_NUMBER; ?>">
<thead>
<tr>
<th data-sort-initial="true"><?php _e('Title','cftp_admin'); ?></th>
<th data-hide="phone"><?php _e('Description','cftp_admin'); ?></th>
<th data-hide="phone"><?php _e('File Name','cftp_admin'); ?></th>
<?php
if (CURRENT_USER_LEVEL != 0) {
?>
<th data-hide="phone"><?php _e("Status",'cftp_admin'); ?></th>
<th data-hide="phone"><?php _e('Assignations','cftp_admin'); ?></th>
<th data-hide="phone"><?php _e('Public','cftp_admin'); ?></th>
<?php
}
?>
<th data-hide="phone" data-sort-ignore="true"><?php _e("Actions",'cftp_admin'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach($upload_finish as $uploaded) {
?>
<tr>
<td><?php echo html_output($uploaded['name']); ?></td>
<td><?php echo htmlentities_allowed($uploaded['description']); ?></td>
<td><?php echo html_output($uploaded['file']); ?></td>
<?php
if (CURRENT_USER_LEVEL != 0) {
?>
<td class="<?php echo (!empty($uploaded['hidden'])) ? 'file_status_hidden' : 'file_status_visible'; ?>">
<?php
$status_hidden = __('Hidden','cftp_admin');
$status_visible = __('Visible','cftp_admin');
$class = (!empty($uploaded['hidden'])) ? 'danger' : 'success';
?>
<span class="label label-<?php echo $class; ?>">
<?php echo ( !empty( $hidden ) && $hidden == 1) ? $status_hidden : $status_visible; ?>
</span>
</td>
<td>
<?php $class = ($uploaded['assignations'] > 0) ? 'success' : 'danger'; ?>
<span class="label label-<?php echo $class; ?>">
<?php echo $uploaded['assignations']; ?>
</span>
</td>
<td class="col_visibility">
<?php
if ($uploaded['public'] == '1') {
?>
<a href="javascript:void(0);" class="btn btn-primary btn-sm public_link" data-type="file" data-id="<?php echo $uploaded['file_id']; ?>" data-token="<?php echo html_output($uploaded['public_token']); ?>">
<?php
}
else {
?>
<a href="javascript:void(0);" class="btn btn-default btn-sm disabled" rel="" title="">
<?php
}
$status_public = __('Public','cftp_admin');
$status_private = __('Private','cftp_admin');
echo ($uploaded['public'] == 1) ? $status_public : $status_private;
?>
</a>
</td>
<?php
}
?>
<td>
<a href="edit-file.php?file_id=<?php echo html_output($uploaded['new_file_id']); ?>" class="btn-primary btn btn-sm">
<i class="fa fa-pencil"></i><span class="button_label"><?php _e('Edit file','cftp_admin'); ?></span>
</a>
<?php
/*
* Show the "My files" button only to clients
*/
if (CURRENT_USER_LEVEL == 0) {
?>
<a href="<?php echo CLIENT_VIEW_FILE_LIST_URI; ?>" class="btn-primary btn btn-sm"><?php _e('View my files','cftp_admin'); ?></a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
/**
* Generate the table of files ready to be assigned to a client.
*/
if (!empty($uploaded_files)) {
?>
<h3><?php _e('Files ready to upload','cftp_admin'); ?></h3>
<p><?php _e('Please complete the following information to finish the uploading process. Remember that "Title" is a required field.','cftp_admin'); ?></p>
<?php
if (CURRENT_USER_LEVEL != 0) {
?>
<div class="message message_info"><strong><?php _e('Note','cftp_admin'); ?></strong>: <?php _e('You can skip assigning if you want. The files are retained and you may add them to clients or groups later.','cftp_admin'); ?></div>
<?php
}
/**
* First, do a server side validation for files that were submited
* via the form, but the name field was left empty.
*/
if(!empty($empty_fields)) {
$msg = 'Name and client are required fields for all uploaded files.';
echo system_message('danger',$msg);
}
?>
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function() {
clean_form(this);
$(this).find('input[name$="[name]"]').each(function() {
is_complete($(this)[0],'<?php echo $json_strings['validation']['no_title']; ?>');
});
// show the errors or continue if everything is ok
if (show_form_errors() == false) { return false; }
});
});
</script>
<form action="upload-process-form.php" name="save_files" id="save_files" method="post">
<?php
foreach($uploaded_files as $add_uploaded_field) {
?>
<input type="hidden" name="files[]" value="<?php echo $add_uploaded_field; ?>" />
<?php
}
?>
<div class="container-fluid">
<?php
$i = 1;
foreach ($uploaded_files as $file) {
clearstatcache();
$this_upload = new \ProjectSend\FilesUpload();
$file_original = $file;
$location = UPLOADED_FILES_DIR . DS . $file;
/**
* Check that the file is indeed present on the folder.
* If not, it is added to the failed files array.
*/
if(file_exists($location)) {
/** Generate a safe filename */
//$file = $this_upload->safe_rename($file);
/**
* Remove the extension from the file name and replace every
* underscore with a space to generate a valid upload name.
*/
$filename_no_ext = substr($file, 0, strrpos($file, '.'));
$file_title = str_replace('_',' ',$filename_no_ext);
if ($this_upload->is_filetype_allowed($file)) {
if (in_array($file,$urls_db_files)) {
$statement = $dbh->prepare("SELECT filename, description FROM " . TABLE_FILES . " WHERE url = :url");
$statement->bindParam(':url', $file);
$statement->execute();
while( $row = $statement->fetch() ) {
$file_title = $row["filename"];
$description = $row["description"];
}
}
?>
<div class="file_editor <?php if ($i%2) { echo 'f_e_odd'; } ?>">
<div class="row">
<div class="col-sm-12">
<div class="file_number">
<p><span class="glyphicon glyphicon-saved" aria-hidden="true"></span><?php echo html_output($file); ?></p>
</div>
</div>
</div>
<div class="row edit_files">
<div class="col-sm-12">
<div class="row edit_files_blocks">
<div class="<?php echo (CURRENT_USER_LEVEL != 0 || CLIENTS_CAN_SET_EXPIRATION_DATE == '1' ) ? 'col-sm-6 col-md-3' : 'col-sm-12 col-md-12'; ?> column">
<div class="file_data">
<div class="row">
<div class="col-sm-12">
<h3><?php _e('File information', 'cftp_admin');?></h3>
<input type="hidden" name="file[<?php echo $i; ?>][original]" value="<?php echo html_output($file_original); ?>" />
<input type="hidden" name="file[<?php echo $i; ?>][file]" value="<?php echo html_output($file); ?>" />
<div class="form-group">
<label><?php _e('Title', 'cftp_admin');?></label>
<input type="text" name="file[<?php echo $i; ?>][name]" value="<?php echo html_output($file_title); ?>" class="form-control file_title" placeholder="<?php _e('Enter here the required file title.', 'cftp_admin');?>" />
</div>
<div class="form-group">
<label><?php _e('Description', 'cftp_admin');?></label>
<textarea name="file[<?php echo $i; ?>][description]" class="<?php if ( FILES_DESCRIPTIONS_USE_CKEDITOR == 1 ) { echo 'ckeditor'; } ?> form-control" placeholder="<?php _e('Optionally, enter here a description for the file.', 'cftp_admin');?>"><?php echo (isset($description)) ? html_output($description) : ''; ?></textarea>
</div>
</div>
</div>
</div>
</div>
<?php
/** The following options are available to users or client if clients_can_set_expiration_date set. */
if (CURRENT_USER_LEVEL != 0 || CLIENTS_CAN_SET_EXPIRATION_DATE == '1' ) {
?>
<div class="col-sm-6 col-md-3 column_even column">
<div class="file_data">
<?php
/**
* Only show the expiration options if the current
* uploader is a system user or client if clients_can_set_expiration_date is set.
*/
?>
<h3><?php _e('Expiration date', 'cftp_admin');?></h3>
<div class="form-group">
<label for="file[<?php echo $i; ?>][expires_date]"><?php _e('Select a date', 'cftp_admin');?></label>
<div class="input-group date-container">
<input type="text" class="date-field form-control datapick-field" readonly id="file[<?php echo $i; ?>][expiry_date]" name="file[<?php echo $i; ?>][expiry_date]" value="<?php echo (!empty($expiry_date)) ? $expiry_date : date('d-m-Y'); ?>" />
<div class="input-group-addon">
<i class="glyphicon glyphicon-time"></i>
</div>
</div>
</div>
<div class="checkbox">
<label for="exp_checkbox_<?php echo $i; ?>">
<input type="checkbox" name="file[<?php echo $i; ?>][expires]" id="exp_checkbox_<?php echo $i; ?>" value="1" <?php if ($row['expiry_set']) { ?>checked="checked"<?php } ?> /> <?php _e('File expires', 'cftp_admin');?>
</label>
</div>
<?php
/** The following options are available to users only */
if (CURRENT_USER_LEVEL != 0) {
?>
<div class="divider"></div>
<h3><?php _e('Public downloading', 'cftp_admin');?></h3>
<div class="checkbox">
<label for="pub_checkbox_<?php echo $i; ?>">
<input type="checkbox" id="pub_checkbox_<?php echo $i; ?>" name="file[<?php echo $i; ?>][public]" value="1" /> <?php _e('Allow public downloading of this file.', 'cftp_admin');?>
</label>
</div>
<?php
} /** Close CURRENT_USER_LEVEL check */
?>
</div>
</div>
<?php
} /** Close CURRENT_USER_LEVEL check */
?>
<?php
/** The following options are available to users only */
if (CURRENT_USER_LEVEL != 0) {
?>
<div class="col-sm-6 col-md-3 assigns column">
<div class="file_data">
<?php
/**
* Only show the CLIENTS select field if the current
* uploader is a system user, and not a client.
*/
?>
<h3><?php _e('Assignations', 'cftp_admin');?></h3>
<label><?php _e('Assign this file to', 'cftp_admin');?>:</label>
<select multiple="multiple" name="file[<?php echo $i; ?>][assignments][]" class="form-control chosen-select" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<optgroup label="<?php _e('Clients', 'cftp_admin');?>">
<?php
/**
* The clients list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
foreach($clients as $client => $client_name) {
?>
<option value="<?php echo html_output('c'.$client); ?>"><?php echo html_output($client_name); ?></option>
<?php
}
?>
</optgroup>
<optgroup label="<?php _e('Groups', 'cftp_admin');?>">
<?php
/**
* The groups list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
foreach($groups as $group => $group_name) {
?>
<option value="<?php echo html_output('g'.$group); ?>"><?php echo html_output($group_name); ?></option>
<?php
}
?>
</optgroup>
</select>
<div class="list_mass_members">
<a href="#" class="btn btn-xs btn-primary add-all" data-type="assigns"><?php _e('Add all','cftp_admin'); ?></a>
<a href="#" class="btn btn-xs btn-primary remove-all" data-type="assigns"><?php _e('Remove all','cftp_admin'); ?></a>
<a href="#" class="btn btn-xs btn-danger copy-all" data-type="assigns"><?php _e('Copy selections to other files','cftp_admin'); ?></a>
</div>
<div class="divider"></div>
<div class="checkbox">
<label for="hid_checkbox_<?php echo $i; ?>">
<input type="checkbox" id="hid_checkbox_<?php echo $i; ?>" name="file[<?php echo $i; ?>][hidden]" value="1" /> <?php _e('Upload hidden (will not send notifications)', 'cftp_admin');?>
</label>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 categories column">
<div class="file_data">
<h3><?php _e('Categories', 'cftp_admin');?></h3>
<label><?php _e('Add to', 'cftp_admin');?>:</label>
<select multiple="multiple" name="file[<?php echo $i; ?>][categories][]" class="form-control chosen-select" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<?php
/**
* The categories list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
echo generate_categories_options( $get_categories['arranged'], 0 );
?>
</select>
<div class="list_mass_members">
<a href="#" class="btn btn-xs btn-primary add-all" data-type="categories"><?php _e('Add all','cftp_admin'); ?></a>
<a href="#" class="btn btn-xs btn-primary remove-all" data-type="categories"><?php _e('Remove all','cftp_admin'); ?></a>
<a href="#" class="btn btn-xs btn-danger copy-all" data-type="categories"><?php _e('Copy selections to other files','cftp_admin'); ?></a>
</div>
</div>
</div>
<?php
} /** Close CURRENT_USER_LEVEL check */
?>
</div>
</div>
</div>
</div>
<?php
$i++;
}
}
else {
$upload_failed[] = $file;
}
}
?>
</div> <!-- container -->
<?php
/**
* Take the list of failed files and store them as a text string
* that will be passed on a hidden field when posting the form.
*/
$upload_failed = array_filter($upload_failed);
$upload_failed_hidden = implode(',',$upload_failed);
?>
<input type="hidden" name="upload_failed" value="<?php echo $upload_failed_hidden; ?>" />
<div class="after_form_buttons">
<button type="submit" name="submit" class="btn btn-wide btn-primary" id="upload-continue"><?php _e('Save','cftp_admin'); ?></button>
</div>
</form>
<?php
}
/**
* There are no more files to assign.
* Send the notifications
*/
else {
include_once INCLUDES_DIR . DS . 'notifications.uploads.php';
}
/**
* Generate the table for the failed files.
*/
if(count($upload_failed) > 0) {
?>
<h3><?php _e('Files not uploaded','cftp_admin'); ?></h3>
<table id="failed_files_tbl" class="footable" data-page-size="<?php echo FOOTABLE_PAGING_NUMBER; ?>">
<thead>
<tr>
<th data-sort-initial="true"><?php _e('File Name','cftp_admin'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach($upload_failed as $failed) {
?>
<tr>
<td><?php echo $failed; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>
<script type="text/javascript">
$(document).ready(function() {
<?php
if(!empty($uploaded_files)) {
?>
$('.copy-all').click(function() {
if ( confirm( "<?php _e('Copy selection to all files?','cftp_admin'); ?>" ) ) {
var type = $(this).data('type');
var selector = $(this).closest('.' + type).find('select');
var selected = new Array();
$(selector).find('option:selected').each(function() {
selected.push($(this).val());
});
$('.' + type + ' .chosen-select').each(function() {
$(this).find('option').each(function() {
if ($.inArray($(this).val(), selected) === -1) {
$(this).removeAttr('selected');
}
else {
$(this).attr('selected', 'selected');
}
});
});
$('select').trigger('chosen:updated');
}
return false;
});
// Autoclick the continue button
//$('#upload-continue').click();
<?php
}
?>
});
</script>
<?php
include_once ADMIN_TEMPLATES_DIR . DS . 'footer.php';