-
Notifications
You must be signed in to change notification settings - Fork 0
/
announcement.php
706 lines (652 loc) · 53.2 KB
/
announcement.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
<?php
require "php/db.php";
include_once 'php/functions.php';
if (array_key_exists('logged_user', $_SESSION)) {
$data = $_POST;
$errors = array();
$update_ann_errors = array();
$user_status = $_SESSION['logged_user']->user_status;
$user_id = $_SESSION['logged_user']->id;
$announcement = get_announcement_by_id($_GET['id']);
if ($announcement) {
$visible = true;
if ($announcement['announcement_status_id'] == 3) {
if (!($user_status <= 2 or $announcement['user_id'] == $user_id or $announcement['help_user_id'] == $user_id))
$visible = false;
}
if ($announcement['announcement_status_id'] == 2) {
if (!($user_status <= 2 or $announcement['user_id'] == $user_id))
$visible = false;
}
[$ann_comments, $com_comments] = get_comments_by_announcement_id($_GET['id']);
$user = $_SESSION['logged_user'];
if (isset($data['do_comment'])) {
if (trim($data['comment_to_ann']) == '') {
$errors[] = 'Ваш коментар не може бути порожнім';
}
if (empty($errors)) {
$comment = R::dispense('comments');
$comment->message = nl2br($data['comment_to_ann']);
$comment->date = time();
$comment->user_id = $user['id'];
$comment->announcement_id = $announcement['id'];
R::store($comment);
header("location: announcement.php?id=" . $announcement['id']);
}
}
foreach ($ann_comments as $ann_comment) {
if (isset($data['do_comment_to_comment' . $ann_comment['id']])) {
if (trim($data['comment_to_com' . $ann_comment['id']]) == '') {
$errors[] = 'Ваш коментар не може бути порожнім';
}
if (empty($errors)) {
$comment = R::dispense('comments');
$comment->parent_comment_id = $ann_comment['id'];
$comment->message = nl2br($data['comment_to_com' . $ann_comment['id']]);
$comment->date = time();
$comment->user_id = $user['id'];
$comment->announcement_id = $announcement['id'];
R::store($comment);
header("location: announcement.php?id=" . $announcement['id']);
}
}
if (isset($data['do_delete_comment' . $ann_comment['id']])) {
foreach ($com_comments as $com_comment) {
if ($com_comment['parent_comment_id'] == $ann_comment['id']) {
R::trash($com_comment);
}
}
R::trash($ann_comment);
header("location: announcement.php?id=" . $announcement['id']);
}
if (isset($data['do_ban_comment' . $ann_comment['id']])) {
$ann_comment['complaint'] = $user['id'];
R::store($ann_comment);
header("location: announcement.php?id=" . $announcement['id']);
}
}
foreach ($com_comments as $com_comment) {
if (isset($data['do_delete_comment' . $com_comment['id']])) {
R::trash($com_comment);
header("location: announcement.php?id=" . $announcement['id']);
}
if (isset($data['do_ban_comment' . $com_comment['id']])) {
$com_comment['complaint'] = $user['id'];
R::store($com_comment);
header("location: announcement.php?id=" . $announcement['id']);
}
}
if (isset($data['do_delete_ann'])) {
$path = 'uploads/' . $announcement['id'] . '/';
delete_files($path);
R::trash($announcement);
header("location: index.php");
}
if (isset($data['do_ban_ann'])) {
$announcement['complaint'] = $user['id'];
R::store($announcement);
header("location: announcement.php?id=" . $announcement['id']);
}
if (isset($data['do_update_ann'])) {
if (trim($data['title']) == '') {
$update_ann_errors[] = 'Вкажіть загловок оголошення';
}
if ($data['deadline'] == '') {
$update_ann_errors[] = 'Встановіть дедлайн оголошення';
}
if (strtotime($data['deadline']) < time()) {
$update_ann_errors[] = 'Дедлайн не може бути попередньою датою';
}
if (trim($data['details']) == '') {
$update_ann_errors[] = 'Вкажіть деталі оголошення';
}
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$location = get_upload_path($announcement->id);
// Create directory if it does not exist
if (!is_dir($location)) {
mkdir($location, 0755);
}
$uploadName = basename($_FILES['userfile']['name']);
$uploadFile = $location . $uploadName;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) {
$announcement['file'] = $uploadName;
} else {
$update_ann_errors[] = "Не вдалось завантажити файл";
}
}
if (empty($update_ann_errors)) {
$announcement['title'] = $data['title'];
$announcement['details'] = nl2br($data['details']);
$announcement['deadline'] = strtotime($data['deadline']);
$announcement['announcement_status_id'] = 2;
R::store($announcement);
header('location: announcement.php?id=' . $announcement['id']);
}
}
if (isset($data['do_unpin_file'])) {
$path = 'uploads/' . $announcement['id'] . '/';
delete_files($path);
$announcement['file'] = null;
R::store($announcement);
header('location: announcement.php?id=' . $announcement['id']);
}
if (isset($data['do_cancel_ann'])) {
header('location: announcement.php?id=' . $announcement['id']);
}
if (isset($data['do_help'])) {
$announcement['help_user_id'] = $_SESSION['logged_user']->id;
$mail = R::findOne('users', 'id = ' . $announcement['user_id'])['email'];
mail($mail, 'Someone want to help', 'Please, check your "' . $announcement['title'] . '"', 'From: stephub.com@gmail.com');
R::store($announcement);
header('location: announcement.php?id=' . $announcement['id']);
}
if (isset($data['do_apply_help'])) {
$announcement['announcement_status_id'] = 3;
$user_mail = $_SESSION['logged_user']['email'];
$help_user = R::findOne('users', 'id = ' . $announcement['help_user_id']);
mail($help_user['email'], 'Help', 'Please, contact with ' . $_SESSION['logged_user']['telegram_username'], 'From: stephub.com@gmail.com');
mail($user_mail, 'Help', 'Please, contact with ' . $help_user['telegram_username'], 'From: stephub.com@gmail.com');
R::store($announcement);
header('location: announcement.php?id=' . $announcement['id']);
}
if (isset($data['do_cancel_help'])) {
$announcement['announcement_status_id'] = 1;
$help_user = R::findOne('users', 'id = ' . $announcement['help_user_id']);
mail($help_user['email'], 'Help', 'Owner of "' . $announcement['title'] . '" has canceled your application', 'From: stephub.com@gmail.com');
$announcement['help_user_id'] = null;
$announcement['date'] = time();
R::store($announcement);
header('location: announcement.php?id=' . $announcement['id']);
}
}
} else {
header("location: index.php");
}
?>
<!DOCTYPE html>
<html lang="ua">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>
<?php if ($announcement) {
echo $announcement['title'];
} else {
echo "Не знайдено оголошення";
} ?> | StepHub</title>
<link rel="shortcut icon" href="favicon.ico">
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Material Design Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Font Awesome Icons -->
<link href="vendor/fontawesome-free-5.9.0-web/css/all.css" rel="stylesheet">
<!--load all styles -->
<link href="css/main.css" rel="stylesheet">
<link href="css/announcement.css" rel="stylesheet">
</head>
<body>
<!-- Preloader -->
<?php include_once 'templates/preloader.html'; ?>
<!-- Back to top button -->
<a id="back-to-top-button"></a>
<!-- Navigation -->
<?php include_once 'templates/navbar.php'; ?>
<!-- Errors -->
<?php include_once "templates/errors.php"; ?>
<!-- Page Content -->
<div class="container pt-sm-5 pt-md-5">
<?php if ($announcement) : ?>
<?php if ($visible) : ?>
<div class="row">
<div class="col-md-9 px-0 px-md-3">
<!-- Announcement -->
<?php if (isset($data['do_edit_ann'])) : ?>
<!-- Edit Announcement -->
<div class="card announcement shadow-sm border-xs-0">
<form id="form_edit_ann" action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0" enctype="multipart/form-data">
<div class="card-header diagonal-gradient-gray-light my-color-dark border-bottom-0 border-xs-0 px-2 px-md-3">
<div class="container">
<div class="row pb-2 pt-sm-2">
<input type="text" name="title" value="<?= $announcement['title'] ?>" class="form-control form-control-lg my-bg-light my-color-dark" placeholder="Заголовок">
</div>
<div class="row pt-2 px-2">
<p class="card-text text-muted small mr-2 d-none d-md-inline"><i class="far fa-calendar mr-2"></i><?= show_date($announcement['date']) ?></p>
<p class="card-text text-muted small ml-2 mr-4 d-none d-md-inline"><i class="far fa-clock mr-2"></i><?= show_time($announcement['date']) ?></p>
<p class="card-text text-muted small ml-2"><i class="far fa-calendar-times mr-2"></i></p>
<p class="card-text text-muted small mb-2 mr-0"><input type="date" name="deadline" value="<?= date("Y-m-d", $announcement['deadline']) ?>" class="form-control form-control-sm my-bg-light text-muted"></p>
</div>
</div>
</div>
<div class="card-body p-2 p-md-3">
<textarea name="details" cols="30" rows="10" class="form-control"><?= $announcement['details'] ?></textarea>
</div>
<?php if (isset($announcement['file'])) : ?>
<div class="card-footer p-2 p-md-3">
<div class="container">
<div class="row">
<button class="btn btn-xs-block my-btn-red order-12 order-md-1" type="submit" name="do_unpin_file"><i class="material-icons mr-2">cancel</i>Відкріпити файл</button>
<p class="small ml-2 my-auto order-1 order-md-12"><i class="material-icons md-18 mr-1">insert_drive_file</i><?= $announcement['file'] ?></p>
</div>
</div>
</div>
<?php else : ?>
<div class="card-footer p-2 p-md-3">
<div class="container">
<div class="row">
<!-- Upload file -->
<label for="fileUpload" class="file-upload btn btn-xs-block my-btn-blue mb-0 clickable order-12 order-md-1">
<i class="material-icons mr-2">attach_file</i>Прикріпити файл
<input id="fileUpload" type="file" name="userfile">
</label>
<label for="fileUpload" class="fileUploadName small my-auto ml-0 ml-md-3 mx-auto order-1 order-md-12"></label>
</div>
</div>
</div>
<?php endif; ?>
</form>
</div><!-- /Edit Announcement -->
<?php else : ?>
<!-- Show Announcement -->
<div class="card announcement shadow-sm <?php if ($announcement['complaint'] and ($user['user_status'] == 1 or $user['user_status'] == 2)) {
echo 'border-danger';
} ?>">
<div class="card-header announcement-block-header my-color-dark diagonal-gradient-gray-light px-2 px-md-3 <?php if ($announcement['complaint'] and ($user['user_status'] == 1 or $user['user_status'] == 2)) {
echo 'diagonal-gradient-red-light';
} ?>">
<div class="container">
<div class="row pt-2 pb-2">
<div class="col-md-10">
<h3 class="card-title"><?= $announcement['title'] ?></h3>
</div>
<div class="col-md-2 pr-0">
<?php if ($user['id'] != $announcement['user_id']) : ?>
<?php if ($announcement['complaint'] and ($user['user_status'] == 1 or $user['user_status'] == 2)) : ?>
<button class="btn float-right comment-option-admin" data-toggle="modal" data-target="#removeAnnModal"><i class="fas fa-trash"></i></button>
<?php else : ?>
<button class="btn float-right announcement-option" data-toggle="modal" data-target="#banAnnModal"><i class="fas fa-ban"></i></button>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<div class="row pt-2 px-2">
<p class="card-text text-muted small mx-2"><i class="far fa-calendar mr-2"></i><?= show_date($announcement['date']) ?></p>
<p class="card-text text-muted small mx-2 mr-4"><i class="far fa-clock mr-2"></i><?= show_time($announcement['date']) ?></p>
<p class="card-text text-muted small mx-2"><i class="far fa-calendar-times mr-2"></i><?= show_date($announcement['deadline']) ?></p>
</div>
</div>
</div>
<div class="card-body px-3 px-md-4 pt-4 announcement-block-body">
<p class="lead d-none d-md-inline"><?= $announcement['details'] ?></p>
<p class="d-inline d-md-none"><?= $announcement['details'] ?></p>
</div>
<?php if (isset($announcement['file'])) : ?>
<div class="card-footer p-2 p-md-3">
<div class="container">
<div class="row">
<a href="uploads/<?= $announcement['id'] ?>/<?= $announcement['file'] ?>" class="btn btn-xs-block btn-secondary order-12 order-md-1" download><i class="material-icons mr-2">get_app</i>Завантажити</a>
<p class="announcementFileLabel small ml-2 my-auto order-1 order-md-12"><i class="announcementFileIcon mr-1 fas"></i><?= $announcement['file'] ?></p>
</div>
</div>
</div>
<?php endif; ?>
</div><!-- /Show Announcement -->
<?php endif; ?>
<!-- /Announcement -->
</div>
<?php if ($user['id'] == $announcement['user_id']) : ?>
<!-- Owner Menu -->
<div class="col-md-3 px-0 px-md-3">
<div class="card border-xs-0 shadow-sm">
<div class="card-body px-3 py-4 py-md-3">
<?php if (isset($data['do_edit_ann'])) : ?>
<h5 class="card-title">Редагувати</h5>
<button class="btn btn-secondary btn-block mt-3" form="form_edit_ann" name="do_cancel_ann" type="submit"><i class="fas fa-redo mr-2"></i>Відмінити</button>
<button class="btn btn-success btn-block mt-3" form="form_edit_ann" name="do_update_ann" type="submit"><i class="fas fa-save mr-2"></i>Зберегти</button>
<?php else : ?>
<h5 class="card-title">Ваше оголошення</h5>
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group">
<?php if ($announcement['help_user_id']) : ?>
<?php if ($announcement['announcement_status_id'] == 1) : ?>
<button class="btn btn-success btn-block mt-3" name="do_apply_help" type="submit"><i class="fas fa-hands-helping mr-2"></i>Прийняти допомогу</button>
<?php elseif ($announcement['announcement_status_id'] == 3) : ?>
<button class="btn btn-warning btn-block mt-3" name="do_cancel_help" type="submit"><i class="fas fa-hands-helping mr-2"></i>Відмовити допомогу</button>
<?php endif; ?>
<?php endif; ?>
<button class="btn btn-secondary btn-block mt-md-3" name="do_edit_ann" type="submit"><i class="fas fa-edit mr-2"></i>Редагувати</button>
</form>
<button class="btn my-btn-red btn-block mt-md-3" data-toggle="modal" data-target="#removeAnnModal"><i class="fas fa-trash mr-2"></i>Видалити</button>
<?php endif; ?>
</div>
</div>
</div><!-- /Owner Menu -->
<?php elseif (!$announcement['help_user_id']) : ?>
<!-- Others Menu -->
<div class="col-md-3 px-0 px-md-3">
<div class="card border-xs-0 shadow-sm">
<div class="card-body px-3 py-4 py-md-3">
<h5 class="card-title">Можеш допомогти?</h5>
<form id="help" action="announcement.php?id=<?= $announcement['id'] ?>" method="post">
<button type="submit" form="help" name="do_help" class="btn btn-success btn-block"><i class="fas fa-hands-helping mr-2"></i>Допомогти</button>
</form>
</div>
</div>
</div><!-- Others Menu -->
<?php endif; ?>
</div>
<div class="row">
<div class="col-md-9 px-0 px-md-3">
<!-- Comments -->
<div class="card shadow-sm mt-4 mt-sm-5 border-xs-0">
<div class="card-header p-2 p-sm-3 pt-4 pt-sm-3">
<!-- Leave New Comment -->
<form class="form" action="announcement.php?id=<?= $_GET['id'] ?>" method="POST">
<label class="sr-only" for="comment_field">Написати коментар</label>
<textarea type="text" name="comment_to_ann" rows="3" class="form-control mb-2 mr-sm-2" id="comment_field" placeholder="Написати коментар"></textarea>
<button type="submit" name="do_comment" class="btn my-btn-blue mt-sm-1"><i class="fas fa-comment mr-2"></i>Коментувати</button>
</form><!-- /Leave New Comment -->
</div>
<div class="card-body bg-light pt-2 px-2 px-sm-3">
<?php if (count($ann_comments) > 0) : ?>
<?php foreach ($ann_comments as $a) : ?>
<!-- Comment 1st lvl -->
<div class="anchor" id="comment<?= $a['id'] ?>">
<div class="card mt-3 bg-white shadow-sm <?= ($a['complaint'] and ($user['user_status'] < 3)) ? 'border-danger' : "" ?>">
<div class="card-header py-1 border-bottom-0 diagonal-gradient-gray <?= ($a['complaint'] and ($user['user_status'] < 2)) ? 'diagonal-gradient-red-light' : "" ?>">
<div class="row">
<p class="card-text text-muted small mx-2 mb-0"><i class="far fa-calendar mr-2"></i><?= show_date($a['date']) ?></p>
<p class="card-text text-muted small mx-2 mb-0"><i class="far fa-clock mr-2"></i><?= show_time($a['date']) ?></p>
<?php if ($user['id'] == $a['user_id']) : ?>
<span class="badge badge-primary my-bg-blue ml-2 my-auto"><i class="fas fa-user mr-lg-2"></i><span class="d-none d-lg-inline">Ваш коментар</span></span>
<?php elseif ($announcement['user_id'] == $a['user_id']) : ?>
<span class="badge badge-success ml-2 my-auto"><i class="far fa-star mr-lg-2"></i><span class="d-none d-lg-inline">Автор оголошення</span></span>
<?php endif; ?>
<?php if (get_user_by_id($a['user_id'])['user_status'] == 1) : ?>
<span class="badge badge-secondary ml-2 my-auto"><i class="fas fa-shield-alt mr-lg-2"></i><span class="d-none d-lg-inline">Адміністратор</span></span>
<?php elseif (get_user_by_id($a['user_id'])['user_status'] == 2) : ?>
<span class="badge badge-secondary ml-2 my-auto"><i class="far fa-shield-al mr-lg-2"></i><span class="d-none d-lg-inline">Модератор</span></span>
<?php endif; ?>
<!-- Button -->
<?php if ($user['user_status'] < 2) : ?>
<?php if ($a['complaint']) : ?>
<button data-toggle="modal" data-target="#removeComm1Modal" class="btn btn-sm float-right comment-option-admin p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php else : ?>
<button data-toggle="modal" data-target="#removeComm1Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php endif; ?>
<?php else : ?>
<?php if ($user['id'] == $a['user_id']) : ?>
<button data-toggle="modal" data-target="#removeComm1Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php else : ?>
<?php if ($a['complaint'] or get_user_by_id($a['user_id'])['user_status'] < 3) : ?>
<button class="btn btn-sm float-right text-muted p-0" disabled><i class="fas fa-ban"></i></button>
<?php else : ?>
<button data-toggle="modal" data-target="#banComm1Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-ban"></i></button>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<!-- Modal Remove Comment 1 -->
<div class="modal fade" id="removeComm1Modal" tabindex="-1" role="dialog" aria-labelledby="removeComm1ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="removeComm1ModalLabel">Видалити коментар</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Після видалення коментаря його буде неможливо переглянути та повернути. Ви дійсно хочете видалити оголошення?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_delete_comment<?= $a['id'] ?>" type="submit">Видалити</button>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Ban Comment 1 -->
<div class="modal fade" id="banComm1Modal" tabindex="-1" role="dialog" aria-labelledby="banComm1ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="banComm1ModalLabel">Поскаржитись на коментар</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Якщо коментар порушує правила користування сервісом, то його буде видалено назавжди. Відправити запит на розглядання цього оголошення модераторами?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_ban_comment<?= $a['id'] ?>" type="submit">Поскаржитись</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body pb-1 px-1 pt-2">
<p class="card-text mb-2 mx-2"> <?= $a['message'] ?></p>
<span class="badge btn mb-0" type="button" data-toggle="collapse" data-target="#collapse<?= $a['id'] ?>" aria-expanded="true" aria-controls="collapse<?= $a['id'] ?>"><i class="fas fa-reply mr-2"></i>Відповісти</span>
</div>
<div class="accordion" id="idReply<?= $a['id'] ?>">
<div class="" id="heading<?= $a['id'] ?>"></div>
<div id="collapse<?= $a['id'] ?>" class="collapse" aria-labelledby="heading<?= $a['id'] ?>" data-parent="#idReply<?= $a['id'] ?>">
<div class="card-footer px-2 pb-1">
<form class="form-inline" action="announcement.php?id=<?= $_GET['id'] ?>" method="POST">
<div class="container">
<div class="row">
<div class="col-md-10 px-0">
<label class="sr-only" for="comment_field">Написати коментар</label>
<textarea class="form-control-sm w-100 mr-sm-2" style="min-width: 100%" type="text" name="comment_to_com<?= $a['id'] ?>" rows="1" id="comment_field" placeholder="Написати коментар"></textarea>
</div>
<div class="col-md-auto ml-auto pl-0 pr-1">
<button type="submit" name="do_comment_to_comment<?= $a['id'] ?>" class="btn btn-sm my-btn-blue w-100"><i class="fa fa-paper-plane mr-2"></i>Відправити</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div><!-- /Comment 1st lvl -->
<?php foreach ($com_comments as $c) : ?>
<?php if ($c['parent_comment_id'] == $a['id']) : ?>
<!-- Comment 2nd lvl -->
<div class="row justify-content-end anchor" id="comment<?= $c['id'] ?>">
<div class="col-1 col-md-2"></div>
<div class="col-11 col-md-10">
<div class="card mt-2 bg-white shadow-sm <?= ($c['complaint'] and ($user['user_status'] < 3)) ? 'border-danger' : "" ?>">
<div class="card-header pb-0 pt-1 border-bottom-0 diagonal-gradient-gray <?= ($c['complaint'] and ($user['user_status'] < 3)) ? 'diagonal-gradient-red-light' : "" ?>">
<div class="row">
<p class="card-text text-muted small mx-2 mb-0"><i class="far fa-calendar mr-2"></i><?= show_date($c['date']) ?></p>
<p class="card-text text-muted small mx-2 mb-0"><i class="far fa-clock mr-2"></i><?= show_time($c['date']) ?></p>
<?php if ($user['id'] == $c['user_id']) : ?>
<span class="badge badge-primary my-bg-blue ml-2 my-auto"><i class="fas fa-user mr-lg-2"></i><span class="d-none d-lg-inline">Ваш коментар</span></span>
<?php elseif ($announcement['user_id'] == $c['user_id']) : ?>
<span class="badge badge-success ml-2 my-auto"><i class="far fa-star mr-lg-2"></i><span class="d-none d-lg-inline">Автор оголошення</span></span>
<?php endif; ?>
<?php if (get_user_by_id($c['user_id'])['user_status'] == 1) : ?>
<span class="badge badge-secondary ml-2 my-auto"><i class="fas fa-shield-alt mr-lg-2"></i><span class="d-none d-lg-inline">Адміністратор</span></span>
<?php elseif (get_user_by_id($c['user_id'])['user_status'] == 2) : ?>
<span class="badge badge-secondary ml-2 my-auto"><i class="far fa-shield-al mr-lg-2"></i><span class="d-none d-lg-inline">Модератор</span></span>
<?php endif; ?>
<!-- Button -->
<?php if ($user['user_status'] < 2) : ?>
<?php if ($c['complaint']) : ?>
<button data-toggle="modal" data-target="#removeComm2Modal" class="btn btn-sm float-right comment-option-admin p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php else : ?>
<button data-toggle="modal" data-target="#removeComm2Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php endif; ?>
<?php else : ?>
<?php if ($user['id'] == $c['user_id']) : ?>
<button data-toggle="modal" data-target="#removeComm2Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-trash"></i></button>
<?php else : ?>
<?php if ($c['complaint'] or get_user_by_id($c['user_id'])['user_status'] < 3) : ?>
<button class="btn btn-sm float-right text-muted p-0" disabled><i class="fas fa-ban"></i></button>
<?php else : ?>
<button data-toggle="modal" data-target="#banComm2Modal" class="btn btn-sm float-right comment-option p-0 ml-auto"><i class="fas fa-ban"></i></button>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<!-- Modal Remove Comment 2 -->
<div class="modal fade" id="removeComm2Modal" tabindex="-1" role="dialog" aria-labelledby="removeComm2ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="removeComm2ModalLabel">Видалити коментар</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Після видалення коментаря його буде неможливо переглянути та повернути. Ви дійсно хочете видалити оголошення?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_delete_comment<?= $c['id'] ?>" type="submit">Видалити</button>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Ban Comment 2 -->
<div class="modal fade" id="banComm2Modal" tabindex="-1" role="dialog" aria-labelledby="banComm2ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="banComm2ModalLabel">Поскаржитись на коментар</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Якщо коментар порушує правила користування сервісом, то його буде видалено назавжди. Відправити запит на розглядання цього оголошення модераторами?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_ban_comment<?= $c['id'] ?>" type="submit">Поскаржитись</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body p-2 shadow-sm">
<p class="card-text"><?= $c['message'] ?></p>
</div>
</div>
</div>
</div><!-- /Comment 2nd lvl -->
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php else : ?>
<!-- Comments Not Found -->
<div class="card mt-3 bg-white" id="commentsNotFound">
<div class="card-body">
<p class="card-text text-center text-muted mb-2 mx-2"><i class="fas fa-exclamation-circle mr-3"></i>Коментарів цього оголошення не знайдено</p>
</div>
</div><!-- /Comments Not Found -->
<?php endif; ?>
</div>
</div><!-- /Comments -->
</div>
</div>
<?php else : ?>
<!-- Frozen Announcement -->
<div class="card not-found-parent diagonal-gradient-gray-light shadow-sm border-xs-0">
<div class="card-body text-center p-0 p-md-3">
<div class="card not-found-child diagonal-gradient-gray-light border-xs-0">
<div class="card-body text-center my-color-dark py-5">
<h1><span class="material-icons md-48">info</span></h1>
<h3 class="mb-5"><i class="fas fa-exclamation-circle"></i>У вас нема можливості переглядати це оголошення</h3>
<a href="index.php" class="btn my-btn-outline-dark">Повернутись на головну</a>
</div>
</div>
</div>
</div><!-- /Frozen Announcement -->
<?php endif; ?>
<?php else : ?>
<!-- Not Found Announcement -->
<div class="card not-found-parent diagonal-gradient-gray-light shadow-sm border-xs-0">
<div class="card-body text-center p-0 p-md-3">
<div class="card not-found-child diagonal-gradient-gray-light border-xs-0">
<div class="card-body text-center my-color-dark py-5">
<h1><span class="material-icons md-48">info</span></h1>
<h3 class="mb-5">Вибачте, сторінку оголошення не знайдено</h3>
<a href="index.php" class="btn my-btn-outline-dark">Повернутись на головну</a>
</div>
</div>
</div>
</div><!-- /Not Found Announcement -->
<?php endif; ?>
</div>
<!-- Footer -->
<?php include_once 'templates/footer.php'; ?>
<!-- Modal Remove Announcement -->
<div class="modal fade" id="removeAnnModal" tabindex="-1" role="dialog" aria-labelledby="removeAnnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="removeAnnModalLabel">Видалити оголошення</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Після видалення оголошення його буде неможливо переглянути та повернути. Ви дійсно хочете видалити оголошення?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_delete_ann" type="submit">Видалити</button>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Ban Announcement -->
<div class="modal fade" id="banAnnModal" tabindex="-1" role="dialog" aria-labelledby="banAnnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="banAnnModalLabel">Поскаржитись на оголошення</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Якщо оголошення порушує правила користування сервісом, то його буде видалено назавжди. Відправити запит на розглядання цього оголошення модераторами?
</div>
<div class="modal-footer">
<form action="announcement.php?id=<?= $announcement['id'] ?>" method="post" class="form-group mb-0">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Скасувати</button>
<button class="btn my-btn-red" name="do_ban_ann" type="submit">Поскаржитись</button>
</form>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Main sctipt -->
<script src="js/script.js"></script>
<!-- Back to top button -->
<script src="js/top.js"></script>
<!-- Upload file sctipt -->
<script src="js/file.js"></script>
</body>
</html>