amdp3-metaforums/Application/Views/thread.php

130 lines
5.8 KiB
PHP
Raw Permalink Normal View History

2019-11-20 05:19:02 +00:00
<?php if($thread->isLocked()) { ?>
<div class="lock-message">
This thread has been locked for <?php echo $thread->lock()->duration ?>. See the last post for reason why.
2019-11-21 16:28:57 +00:00
<?php if($auth->isLoggedIn() && $auth->user()->didIModerateThis($thread->category_id) ) { ?>
2019-11-20 05:19:02 +00:00
<a href="/thread/unlock?id=<?php echo $thread->id ?>">Unlock this thread</a>
<?php } ?>
</div>
<?php } ?>
2019-11-19 03:36:39 +00:00
<div id="forum">
<h1 class="text-2xl">Thread in: <?php echo $thread->category()->category_name ?></h1>
<p class="text-4xl"><?php echo $thread->title ?></p>
<p>Posted on <?php echo $thread->created_at ?> by <?php echo $thread->author_model->username ?></p>
<p><?php echo $thread->elapsed_created ?></p>
<div id="forum-posts">
<?php foreach($thread->posts() as $post) { ?>
<div class="forum-post" id="forum-post-<?php echo $post->id ?>">
<div class="forum-post-title">
<p class="text-lg flex-grow"><?php echo $post->title ?></p>
<p class="text-lg"><?php echo $post->elapsed_created; ?></p>
</div>
<div class="forum-post-content">
<div class="forum-post-user">
<a href="/profile?id=<?php echo $post->user()->id ?>">
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-center">
<img src="/<?php echo $post->user()->avatar_path != "" ? $post->user()->avatar_path : "noava.jpg" ?>">
2019-11-19 03:36:39 +00:00
<p><?php echo $post->user()->username ?></p>
</div>
</a>
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-center">
<p><?php echo $post->user()->status ?></p>
2019-11-19 03:36:39 +00:00
</div>
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-start">
2019-11-19 03:36:39 +00:00
<p><?php echo $post->user()->role_string ?></p>
</div>
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-start">
2019-11-19 03:36:39 +00:00
<p><?php echo $post->user()->post_count ?> posts</p>
</div>
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-start">
<p><?php echo $post->user()->elapsed_login ?></p>
2019-11-19 03:36:39 +00:00
</div>
2019-11-20 05:19:02 +00:00
<div class="forum-post-user-detail items-start">
2019-11-19 03:36:39 +00:00
<?php if($post->user()->isBanned($thread->category()->id)) { ?>
<p>Banned</p>
<?php } else if($post->user()->isSilenced($thread->category()->id)) { ?>
<p>Silenced</p>
<?php } else {?>
<p>Active</p>
<?php } ?>
</div>
</div>
<div class="forum-post-text">
<?php echo $post->post ?>
</div>
</div>
<div class="forum-post-footer">
2019-11-20 05:19:02 +00:00
<div class="forum-post-footer-left">
<?php echo $post->favorites; ?> favorites
2019-11-19 03:36:39 +00:00
</div>
2019-11-20 05:19:02 +00:00
<div class="forum-post-footer-mid">
</div>
<div class="forum-post-footer-right">
<?php if($auth->isLoggedIn()) { ?>
<?php if($post->user_id == $auth->user()->id) { ?>
<a class="forum-post-footer-action" @click="reply(<?php echo $post->id ?>)">Reply</a>
<a class="forum-post-footer-action" @click="edit(<?php echo $post->id ?>)">Edit</a>
2019-11-23 08:58:59 +00:00
<a class="forum-post-footer-action danger" @click="delete_post(<?php echo $post->id ?>)">Delete</a>
2019-11-20 05:19:02 +00:00
<?php } else { ?>
2019-11-23 08:58:59 +00:00
<a class="forum-post-footer-action" @click="favorite(<?php echo $post->id ?>)"><?php echo $post->is_favorited() ? 'Unfavorite' : 'Favorite' ?></a>
2019-11-20 05:19:02 +00:00
<a class="forum-post-footer-action" @click="reply(<?php echo $post->id ?>)">Reply</a>
<?php if(!$auth->user()->didIModerateThis($thread->category()->id) && $auth->user()->is_confirmed ) { ?>
2019-11-23 08:58:59 +00:00
<a class="forum-post-footer-action danger" @click="report(<?php echo $post->id ?>)">Report Abuse</a>
2019-11-20 05:19:02 +00:00
<?php } ?>
<?php } ?>
2019-11-21 16:28:57 +00:00
<?php if($auth->user()->didIModerateThis($thread->category()->id) || $auth->user()->is_admin ) { ?>
2019-11-23 08:58:59 +00:00
<a class="forum-post-footer-action danger" @click="moderate(<?php echo $post->id ?>)">Moderate</a>
2019-11-20 05:19:02 +00:00
<?php } ?>
2019-11-19 03:36:39 +00:00
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<script>
var threadapp = new Vue({
el: "#forum",
2019-11-20 05:19:02 +00:00
data: {
favorite_num: [],
},
2019-11-19 03:36:39 +00:00
methods: {
reply(post_id) {
$.ajax("<?php echo $root ?>/thread/editor?thread=<?php echo $thread->id ?>&reply="+post_id).done(function(data) {
$("#editor").html(data);
});
2019-11-21 16:28:57 +00:00
window.location.hash = "#editor";
2019-11-19 03:36:39 +00:00
},
edit(post_id) {
$.ajax("<?php echo $root ?>/thread/editor?thread=<?php echo $thread->id ?>&edit="+post_id).done(function(data) {
$("#editor").html(data);
});
2019-11-21 16:28:57 +00:00
window.location.hash = "#editor";
2019-11-19 03:36:39 +00:00
},
2019-11-20 05:19:02 +00:00
delete_post(post_id) {
$.ajax("<?php echo $root ?>/thread/editor?thread=<?php echo $thread->id ?>&delete="+post_id).done(function(data) {
$("#editor").html(data);
});
2019-11-21 16:28:57 +00:00
window.location.hash = "#editor";
2019-11-20 05:19:02 +00:00
},
favorite(post_id) {
$.ajax("<?php echo $root ?>/api/favorite?id="+post_id).done(function(data) {
console.log(data);
location.reload();
}.bind(this));
},
report(post_id) {
$.ajax("<?php echo $root ?>/thread/editor?thread=<?php echo $thread->id ?>&report="+post_id).done(function(data) {
$("#editor").html(data);
});
2019-11-21 16:28:57 +00:00
window.location.hash = "#editor";
2019-11-20 05:19:02 +00:00
},
moderate(post_id) {
$.ajax("<?php echo $root ?>/thread/moderating_editor?id="+post_id).done(function(data) {
$("#editor").html(data);
});
2019-11-21 16:28:57 +00:00
window.location.hash = "#editor";
2019-11-20 05:19:02 +00:00
}
2019-11-19 03:36:39 +00:00
},
});
</script>