-
Notifications
You must be signed in to change notification settings - Fork 2
/
commentremove.php
80 lines (65 loc) · 1.97 KB
/
commentremove.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
<?php
require_once "../config.php";
require_once "util/tdiscus.php";
require_once "util/threads.php";
use \Tsugi\Util\U;
use \Tsugi\Core\LTIX;
use \Tsugi\Core\Settings;
use \Tdiscus\Tdiscus;
use \Tdiscus\Threads;
// No parameter means we require CONTEXT, USER, and LINK
$LAUNCH = LTIX::requireData();
$THREADS = new Threads();
$TDISCUS = new Tdiscus();
$rest_path = U::rest_path();
$old_comment = null;
$thread_id = null;
if ( isset($rest_path->action) && is_numeric($rest_path->action) ) {
$comment_id = intval($rest_path->action);
$old_comment = $THREADS->commentLoadForUpdate($comment_id);
if ( is_array($old_comment) ) $thread_id = $old_comment['thread_id'];
}
if ( !$old_comment || !$thread_id) {
$_SESSION['error'] = __('Could not load comment');
header( 'Location: '.addSession($TOOL_ROOT) ) ;
return;
}
$come_back = $TOOL_ROOT . '/commentremove/' . $comment_id;
$all_done = $TOOL_ROOT.'/thread/'.$thread_id;
if ( count($_POST) > 0 ) {
$retval = $THREADS->commentDelete($comment_id, $thread_id);
if ( is_string($retval) ) {
$_SESSION['error'] = $retval;
header( 'Location: '.addSession($come_back) ) ;
return;
}
$_SESSION['success'] = __('Comment deleted');
header( 'Location: '.addSession($all_done) ) ;
return;
}
$OUTPUT->header();
$TDISCUS->header();
$OUTPUT->bodyStart();
$OUTPUT->topNav(false);
$OUTPUT->flashMessages();
echo("<h1>".__('Delete Comment')."</h1>\n");
?>
<div id="delete-comment-div" title="<?= __("Delete comment") ?>" >
<form id="delete-comment-form" method="post">
<p><?= __("Comment:") ?> <br/>
<?php
echo('<b>'.htmlentities($old_comment['comment']).'</b></br>');
?>
</p>
<p>
<input type="submit" id="delete-comment-submit" value="<?= __('Delete') ?>" >
<input type="submit" id="delete-comment-cancel" value="<?= __('Cancel') ?>"
onclick='window.location.href="<?= addSession($all_done) ?>";return false;'
>
</p>
</form>
</div>
<?php
$OUTPUT->footerStart();
$TDISCUS->footer();
$OUTPUT->footerEnd();