mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-02-03 13:17:33 +00:00
188 lines
No EOL
7.8 KiB
Text
188 lines
No EOL
7.8 KiB
Text
@using Project_Unite.Controllers;
|
|
@model Project_Unite.Models.ForumTopic
|
|
@using Microsoft.AspNet.Identity
|
|
@{
|
|
ViewBag.Title = Model.Subject;
|
|
var db = new Project_Unite.Models.ApplicationDbContext();
|
|
var posts = db.ForumPosts.Where(x => x.Parent == Model.Id);
|
|
foreach(var post in posts.ToArray())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(post.Subject))
|
|
{
|
|
post.Subject = Model.Subject;
|
|
}
|
|
}
|
|
db.SaveChanges();
|
|
}
|
|
|
|
<ul class="nav nav-tabs">
|
|
<li><a href="#" onclick="window.history.back()"><span class="glyphicon glyphicon-arrow-left"></span> Back</a></li>
|
|
@if (Request.IsAuthenticated)
|
|
{
|
|
if (ACL.CanReply(User.Identity.Name, Model.Parent))
|
|
{
|
|
if (Model.IsLocked == false)
|
|
{
|
|
<li><a href="@Url.Action("PostReply", "Forum", new { id = Model.Discriminator, fid=Model.Parent })"><span class="glyphicon glyphicon-comment"></span> Post reply</a></li>
|
|
}
|
|
else
|
|
{
|
|
<li><a href="#"><span class="glyphicon glyphicon-lock"></span> Locked.</a></li>
|
|
}
|
|
}
|
|
if (Request.IsAuthenticated)
|
|
{
|
|
if(User.Identity.GetUserId() != Model.AuthorId)
|
|
{
|
|
<li><a href="@Url.Action("Like", "Forum", new { id = Model.Discriminator })"><span class="glyphicon glyphicon-thumbs-up"></span> @Model.Likes.Length</a></li>
|
|
<li><a href="@Url.Action("Dislike", "Forum", new { id = Model.Discriminator })"><span class="glyphicon glyphicon-thumbs-down"></span> @Model.Dislikes.Length</a></li>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<li><span class="glyphicon glyphicon-thumbs-up"></span> @Model.Likes.Length</li>
|
|
<li><span class="glyphicon glyphicon-thumbs-down"></span> @Model.Dislikes.Length</li>
|
|
|
|
}
|
|
if (User.Identity.IsModerator())
|
|
{
|
|
<li class="dropdown"><a data-toggle="dropdown" href="#" class="dropdown-toggle">Quick mod <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li class="dropdown-header">Topic status</li>
|
|
<li><a href="@Url.Action("StickyTopic", "Moderator", new { id = Model.Discriminator })">
|
|
@if (Model.IsSticky)
|
|
{
|
|
<span class="glyphicon glyphicon-ok"></span>
|
|
}
|
|
Sticky
|
|
</a></li>
|
|
<li>
|
|
<a href="@Url.Action("AnnounceTopic", "Moderator", new { id = Model.Discriminator })">
|
|
@if (Model.IsAnnounce)
|
|
{
|
|
<span class="glyphicon glyphicon-star"></span>
|
|
}
|
|
Announcement
|
|
</a>
|
|
</li>
|
|
@if (User.Identity.IsAdmin())
|
|
{
|
|
<li>
|
|
<a href="@Url.Action("GlobalTopic", "Moderator", new { id = Model.Discriminator })">
|
|
@if (Model.IsGlobal)
|
|
{
|
|
<span class="glyphicon glyphicon-globe"></span>
|
|
}
|
|
Global
|
|
</a>
|
|
</li>
|
|
|
|
}
|
|
<li class="dropdown-header">Posting</li>
|
|
@if (Model.IsLocked)
|
|
{
|
|
<li><a href="@Url.Action("UnlockTopic", "Moderator", new { id = Model.Discriminator })">Unlock</a></li>
|
|
}
|
|
else
|
|
{
|
|
<li><a href="@Url.Action("LockTopic", "Moderator", new { id = Model.Discriminator })">Lock</a></li>
|
|
}
|
|
</ul>
|
|
</li>
|
|
}
|
|
}
|
|
</ul>
|
|
|
|
|
|
@if(Model.IsUnlisted == true)
|
|
{
|
|
<div class="panel panel-warning">
|
|
<div class="panel-body">
|
|
<p><span class="glyphicon glyphicon-eye-close"></span> <strong>This topic is unlisted.</strong> Only those with the topic link as well as moderators may see this topic. Please respect its privacy.</p>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<h2>@Model.Subject</h2>
|
|
|
|
<p>Started by <strong>@Html.UserLink(Model.AuthorId)</strong> at <strong>@Model.StartedAt</strong></p>
|
|
|
|
@foreach (Project_Unite.Models.ForumPost post in PaginationExtensions.GetItemsOnPage<Project_Unite.Models.ForumPost>(Model.Posts.OrderBy(x => x.PostedAt).ToArray(), ViewBag.Page, ViewBag.PageSize))
|
|
{
|
|
if (Request.IsAuthenticated)
|
|
{
|
|
if (ACL.IsUnread(User.Identity.GetUserId(), post.Id))
|
|
{
|
|
ACL.MarkRead(User.Identity.GetUserId(), post.Id);
|
|
}
|
|
}
|
|
|
|
<div class="row panel panel-default">
|
|
<div class="panel-body">
|
|
<div class="col-xs-2"> <!--Mini profile data-->
|
|
<img class="avatar" src="@ACL.GetUserInfo(post.AuthorId).AvatarUrl" width="128" height="128" /><br/>
|
|
<strong>@Html.UserLink(post.AuthorId)</strong><br/>
|
|
@{
|
|
var user = ACL.GetUserInfo(post.AuthorId);
|
|
<p><strong>@user.Codepoints</strong> Codepoints</p>
|
|
<p><strong><u>@user.HighestRole.Name</u></strong></p>
|
|
<p>
|
|
@if (User?.Identity?.IsModerator()==true)
|
|
{
|
|
@Html.ActionLink("User info", "UserDetails", "Moderator", new { id = ACL.UserNameRaw(post.AuthorId) }, new { @class = "btn btn-default" })
|
|
}
|
|
</p>
|
|
}
|
|
</div>
|
|
<div class="col-xs-10" id="forum_post_body"><!--Post body, subject, author, time-->
|
|
<h4>@Model.Subject</h4>
|
|
<p>@Html.UserLink(post.AuthorId) at @post.PostedAt</p>
|
|
<p>@Html.Markdown(post.Body)</p>
|
|
|
|
@if (post.EditHistory.Length > 0)
|
|
{
|
|
<div class="panel panel-primary">
|
|
<div class="panel-body">
|
|
<h4>Latest edit</h4>
|
|
@{
|
|
var edit = post.EditHistory.OrderByDescending(x => x.EditedAt).First();
|
|
}
|
|
<p>By @Html.UserLink(edit.UserId) at @edit.EditedAt</p>
|
|
<p><strong>Reason: </strong>@Html.Markdown(edit.EditReason)</p>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@if (Request.IsAuthenticated)
|
|
{
|
|
if(User.Identity.IsModerator() || post.AuthorId == User.Identity.GetUserId())
|
|
{
|
|
<ul class="nav nav-tabs">
|
|
<li><a href="@Url.Action("EditPost", "Forum", new { id = post.Id })"><span class="glyphicon glyphicon-pencil"></span> Edit</a></li>
|
|
<li><a href="@Url.Action("DeletePost", "Forum", new { id = post.Id })"><span class="glyphicon glyphicon-trash"></span> Delete</a></li>
|
|
</ul>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<p>Pages:
|
|
<ul class="pagination">
|
|
<li>@Html.ActionLink("First", "ViewTopic", "Forum", new { id = Model.Discriminator, page = 1 }, null)</li>
|
|
|
|
@for(int i = 1; i <= ViewBag.PageCount; i++)
|
|
{
|
|
if (i == ViewBag.Page + 1)
|
|
{
|
|
<li class="active">@Html.ActionLink(i.ToString(), "ViewTopic", "Forum", new { id = Model.Discriminator, page = i }, null)</li>
|
|
}
|
|
else
|
|
{
|
|
<li>@Html.ActionLink(i.ToString(), "ViewTopic", "Forum", new { id = Model.Discriminator, page = i }, null)</li>
|
|
}
|
|
}
|
|
<li>@Html.ActionLink("Last", "ViewTopic", "Forum", new { id = Model.Discriminator, page = ViewBag.PageCount }, null)</li>
|
|
</ul>
|
|
</p> |