blob: 37e8cf8665fe8f279b61557fe5c561e288b66817 (
plain)
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
|
<?php
use mystic\forum\orm\UserPermissions;
$canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false;
$canEdit = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::EDIT_OWN_TOPIC))
|| ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_TOPIC));
$canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC))
|| ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC));
?>
<?php if ($canEdit): ?>
<div class="modal fade" tabindex="-1" role="dialog" id="diag-edit-post">
<form class="modal-dialog" role="document" action="?_action=updatepost" method="post">
<input type="hidden" id="i_edit_post" name="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Edit post</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="sr-only" for="i_edit_message">Message:</label>
<textarea class="form-control" name="message" id="i_edit_message" rows="12" style="resize: vertical; max-height: 500px"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button>
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button>
</div>
</div>
</form>
</div>
<?php endif; ?>
<div class="page-header margin-top-0 clearfix">
<div id="displayHeading">
<div role="heading" class="h1 seamless-inline">
<?= htmlentities($topic->title) ?>
<div class="pull-right text-normal">
<?php if ($canEdit): ?>
<button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit title</button>
<?php endif; ?>
<?php if ($canReply): ?>
<button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button>
<?php endif; ?>
<?php if ($canDelete): ?>
<form action="?_action=deletetopic" method="post" class="seamless-inline">
<input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>">
<button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete topic</button>
</form>
<?php endif; ?>
</div>
</div><br>
Started by
<?php if ($topicAuthor !== null): ?>
<a href="?_action=viewuser&user=<?= htmlentities(urlencode($topicAuthor->id)) ?>"><?= htmlentities($topicAuthor->displayName) ?></a>
<?php else: ?>
<em>(deleted)</em>
<?php endif; ?>
on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span>
</div>
<?php if ($canEdit): ?>
<form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline" style="display: block">
<input type="hidden" name="topic" value="<?= htmlentities(urlencode($topic->id)) ?>">
<div class="row">
<div class="col-md-8">
<input type="text" class="form-control" name="title" id="i_edit_title" data-original-value="<?= htmlentities($topic->title) ?>" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%; font-size: 36px; height: 56px">
</div>
<div class="col-md-4 text-right">
<button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button>
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button>
</div>
</div>
</form>
<?php endif; ?>
</div>
<script>
<?php if ($canEdit): ?>
$(function() {
$("#btn-edit-title").click(function() {
$("#displayHeading").hide();
$("#editHeading").show();
$("#i_edit_title").val($("#i_edit_title").attr("data-original-value")).focus();
});
$("#topicTitleEditCancel").click(function() {
$("#displayHeading").show();
$("#editHeading").hide();
});
});
<?php endif; ?>
<?php if ($canReply): ?>
$(function() {
function focusReplyBox() {
var msgInput = $("#i_message");
msgInput[0].scrollIntoView();
msgInput.focus();
}
$("#btn-reply").click(function() {
focusReplyBox();
});
$("._reply-post").click(function() {
var text = $("#post-" + $(this).attr("data-post-id")).attr("data-text");
var val = $("#i_message").val();
var lines = text.split("\n");
for (var i = 0; i < lines.length; ++i)
val += "\n> " + lines[i];
val += "\n\n";
$("#i_message").val(val.replace(/^\n+/, ""));
focusReplyBox();
});
});
<?php endif; ?>
<?php if ($canEdit): ?>
$(function() {
$("._edit-post").click(function() {
var $post = $("#post-" + $(this).attr("data-post-id"));
var $postContent = $post.find(".post-content");
$("#i_edit_message").css("height", "").val($post.attr("data-text"));
$("#i_edit_post").val($(this).attr("data-post-id"));
$("#diag-edit-post").modal();
});
$("#diag-edit-post").on("shown.bs.modal", function() {
$("#i_edit_message").focus();
});
});
<?php endif; ?>
</script>
|