mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
More fixes, specifically with forum
This commit is contained in:
parent
1abd027bdb
commit
7e54c9b3fa
6 changed files with 136 additions and 296 deletions
|
@ -224,37 +224,26 @@ public static string UserNameFromEmailRaw(string userId)
|
||||||
|
|
||||||
public static bool CanSee(string userName, string fId)
|
public static bool CanSee(string userName, string fId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(fId))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var db = new ApplicationDbContext();
|
var db = new ApplicationDbContext();
|
||||||
|
var user = db.Users.FirstOrDefault(x => x.UserName == userName);
|
||||||
var usr = db.Users.Include(x => x.Roles).FirstOrDefault(u => u.UserName == userName);
|
var frm = db.ForumCategories.FirstOrDefault(x => x.Id == fId);
|
||||||
|
if (frm == null) return false;
|
||||||
var userRoles = new List<Role>();
|
if (user == null) {
|
||||||
foreach (var usrRole in usr.Roles)
|
return frm.VisibleToGuests;
|
||||||
{
|
|
||||||
userRoles.Add(db.Roles.FirstOrDefault(r => r.Id == usrRole.RoleId) as Role);
|
|
||||||
}
|
}
|
||||||
db.Dispose();
|
else
|
||||||
var userRole = userRoles.OrderByDescending(m => m.Priority).First();
|
|
||||||
|
|
||||||
db = new ApplicationDbContext();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var forums = db.ForumCategories;
|
|
||||||
var forum = forums.First(x => x.Id == fId);
|
|
||||||
var perms = forum.Permissions.FirstOrDefault(x => x.RoleId == userRole.Id);
|
|
||||||
if (perms == null)
|
|
||||||
{
|
{
|
||||||
UpdateACLDefinitions(fId);
|
if (user.HighestRole.IsAdmin)
|
||||||
return true;
|
return frm.AdminPermission > 0;
|
||||||
|
if (user.HighestRole.IsDeveloper)
|
||||||
|
return frm.DeveloperPermission > 0;
|
||||||
|
if (user.HighestRole.IsModerator)
|
||||||
|
return frm.ModeratorPermission > 0;
|
||||||
|
if (user.HighestRole.IsMember)
|
||||||
|
return frm.MemberPermission > 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
return (int)perms.Permissions >= (int)PermissionPreset.CanRead;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool UserEmailConfirmed(string username)
|
public static bool UserEmailConfirmed(string username)
|
||||||
|
@ -278,39 +267,26 @@ public static Role LowestPriorityRole()
|
||||||
|
|
||||||
public static bool CanReply(string userName, string fId)
|
public static bool CanReply(string userName, string fId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(fId))
|
|
||||||
return false;
|
|
||||||
if (HttpContext.Current.User.Identity.IsGuest())
|
|
||||||
return false; //obviously if this role has a global restraint for this ACL def we shouldn't let them post in ANY forum.
|
|
||||||
|
|
||||||
var db = new ApplicationDbContext();
|
var db = new ApplicationDbContext();
|
||||||
|
var user = db.Users.FirstOrDefault(x => x.UserName == userName);
|
||||||
var usr = db.Users.Include(x => x.Roles).FirstOrDefault(u => u.UserName == userName);
|
var frm = db.ForumCategories.FirstOrDefault(x => x.Id == fId);
|
||||||
|
if (frm == null) return false;
|
||||||
var userRoles = new List<Role>();
|
if (user == null)
|
||||||
foreach (var usrRole in usr.Roles)
|
|
||||||
{
|
{
|
||||||
userRoles.Add(db.Roles.FirstOrDefault(r => r.Id == usrRole.RoleId) as Role);
|
return false;
|
||||||
}
|
}
|
||||||
db.Dispose();
|
else
|
||||||
var userRole = userRoles.OrderByDescending(m => m.Priority).First();
|
|
||||||
|
|
||||||
db = new ApplicationDbContext();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var forums = db.ForumCategories;
|
|
||||||
var forum = forums.First(x => x.Id == fId);
|
|
||||||
var perms = forum.Permissions.FirstOrDefault(x => x.RoleId == userRole.Id);
|
|
||||||
if (perms == null)
|
|
||||||
{
|
{
|
||||||
UpdateACLDefinitions(fId);
|
if (user.HighestRole.IsAdmin)
|
||||||
return true;
|
return frm.AdminPermission > 1;
|
||||||
|
if (user.HighestRole.IsDeveloper)
|
||||||
|
return frm.DeveloperPermission > 1;
|
||||||
|
if (user.HighestRole.IsModerator)
|
||||||
|
return frm.ModeratorPermission > 1;
|
||||||
|
if (user.HighestRole.IsMember)
|
||||||
|
return frm.MemberPermission > 1;
|
||||||
}
|
}
|
||||||
return perms.Permissions >= PermissionPreset.CanReply;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationUser GetUserInfo(string id)
|
public static ApplicationUser GetUserInfo(string id)
|
||||||
|
@ -320,69 +296,26 @@ public static ApplicationUser GetUserInfo(string id)
|
||||||
|
|
||||||
public static bool CanPost(string userName, string fId)
|
public static bool CanPost(string userName, string fId)
|
||||||
{
|
{
|
||||||
|
var db = new ApplicationDbContext();
|
||||||
|
var user = db.Users.FirstOrDefault(x => x.UserName == userName);
|
||||||
if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(fId))
|
var frm = db.ForumCategories.FirstOrDefault(x => x.Id == fId);
|
||||||
|
if (frm == null) return false;
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
if (HttpContext.Current.User.Identity.IsGuest())
|
|
||||||
return false; //obviously if this role has a global restraint for this ACL def we shouldn't let them post in ANY forum.
|
|
||||||
|
|
||||||
var db = new ApplicationDbContext();
|
|
||||||
|
|
||||||
var usr = db.Users.Include(x => x.Roles).FirstOrDefault(u => u.UserName == userName);
|
|
||||||
|
|
||||||
var userRoles = new List<Role>();
|
|
||||||
foreach (var usrRole in usr.Roles)
|
|
||||||
{
|
|
||||||
userRoles.Add(db.Roles.FirstOrDefault(r => r.Id == usrRole.RoleId) as Role);
|
|
||||||
}
|
}
|
||||||
db.Dispose();
|
else
|
||||||
var userRole = userRoles.OrderByDescending(m => m.Priority).First();
|
|
||||||
|
|
||||||
db = new ApplicationDbContext();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var forums = db.ForumCategories;
|
|
||||||
var forum = forums.First(x => x.Id == fId);
|
|
||||||
var perms = forum.Permissions.FirstOrDefault(x=>x.RoleId==userRole.Id);
|
|
||||||
if (perms == null)
|
|
||||||
{
|
{
|
||||||
UpdateACLDefinitions(fId);
|
if (user.HighestRole.IsAdmin)
|
||||||
return true;
|
return frm.AdminPermission > 2;
|
||||||
|
if (user.HighestRole.IsDeveloper)
|
||||||
|
return frm.DeveloperPermission > 2;
|
||||||
|
if (user.HighestRole.IsModerator)
|
||||||
|
return frm.ModeratorPermission > 2;
|
||||||
|
if (user.HighestRole.IsMember)
|
||||||
|
return frm.MemberPermission > 2;
|
||||||
}
|
}
|
||||||
return perms.Permissions >= PermissionPreset.CanPost;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
public static void UpdateACLDefinitions(string fid)
|
|
||||||
{
|
|
||||||
var db = new ApplicationDbContext();
|
|
||||||
var forum = db.ForumCategories.FirstOrDefault(x => x.Id == fid);
|
|
||||||
if (forum == null)
|
|
||||||
return;
|
|
||||||
int recordsAdded = 0;
|
|
||||||
|
|
||||||
if (forum.Permissions.Length < db.Roles.Count())
|
|
||||||
{
|
|
||||||
var roles = db.Roles.ToArray();
|
|
||||||
foreach(var role in roles)
|
|
||||||
{
|
|
||||||
if (db.ForumPermissions.FirstOrDefault(x => x.CategoryId == fid && x.RoleId == role.Id) == null)
|
|
||||||
{
|
|
||||||
var perm = new ForumPermission();
|
|
||||||
perm.Id = Guid.NewGuid().ToString();
|
|
||||||
perm.CategoryId = forum.Id;
|
|
||||||
perm.RoleId = role.Id;
|
|
||||||
perm.Permissions = PermissionPreset.CanPost;
|
|
||||||
db.ForumPermissions.Add(perm);
|
|
||||||
recordsAdded++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, $"Automatic forum ACL update occurred - Forum: {forum.Name}, records added: {recordsAdded}."));
|
|
||||||
db.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CanManageRole(string userId, string roleId)
|
public static bool CanManageRole(string userId, string roleId)
|
||||||
|
|
|
@ -7,27 +7,6 @@
|
||||||
|
|
||||||
namespace Project_Unite.Models
|
namespace Project_Unite.Models
|
||||||
{
|
{
|
||||||
public class AdminAccessControlViewModel
|
|
||||||
{
|
|
||||||
public AdminAccessControlViewModel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminAccessControlViewModel(Dictionary<string, ForumPermission[]> modelList)
|
|
||||||
{
|
|
||||||
ACLList = new List<ForumPermission>();
|
|
||||||
foreach(var v in modelList.Values)
|
|
||||||
{
|
|
||||||
ACLList.AddRange(v);
|
|
||||||
}
|
|
||||||
IDs = modelList.Keys.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<string> IDs { get; set; }
|
|
||||||
public List<ForumPermission> ACLList { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CreateUserModel
|
public class CreateUserModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -39,28 +39,12 @@ public ForumTopic[] Topics
|
||||||
|
|
||||||
public virtual string Parent { get; set; }
|
public virtual string Parent { get; set; }
|
||||||
|
|
||||||
public ForumPermission[] Permissions { get
|
public int AdminPermission { get; set; }
|
||||||
{
|
public int DeveloperPermission { get; set; }
|
||||||
var db = new ApplicationDbContext();
|
public int ModeratorPermission { get; set; }
|
||||||
return db.ForumPermissions.Where(x => x.CategoryId == this.Id).ToArray();
|
public int MemberPermission { get; set; }
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ForumPermission
|
public bool VisibleToGuests { get; set; }
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string CategoryId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string RoleId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
[EnumDataType(typeof(PermissionPreset))]
|
|
||||||
public PermissionPreset Permissions { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ForumPost
|
public class ForumPost
|
||||||
|
@ -124,8 +108,32 @@ public Like[] Dislikes
|
||||||
|
|
||||||
public bool IsLocked { get; set; }
|
public bool IsLocked { get; set; }
|
||||||
|
|
||||||
|
public int Priority
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int priority = 0;
|
||||||
|
if (IsSticky)
|
||||||
|
priority = 1;
|
||||||
|
if (IsAnnounce)
|
||||||
|
priority = 2;
|
||||||
|
if (IsSticky && IsAnnounce)
|
||||||
|
priority = 3;
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime StartedAt { get; set; }
|
public DateTime StartedAt { get; set; }
|
||||||
public string Subject { get; set; }
|
public string Subject { get; set; }
|
||||||
|
public bool ShouldShow
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsUnlisted == true)
|
||||||
|
return HttpContext.Current.User?.Identity?.IsModerator() == true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string AuthorId { get; set; }
|
public string AuthorId { get; set; }
|
||||||
public bool IsSticky { get; set; }
|
public bool IsSticky { get; set; }
|
||||||
public bool IsAnnounce { get; set; }
|
public bool IsAnnounce { get; set; }
|
||||||
|
|
|
@ -241,7 +241,6 @@ public static ApplicationDbContext Create()
|
||||||
public DbSet<UserPost> UserPosts { get; set; }
|
public DbSet<UserPost> UserPosts { get; set; }
|
||||||
public DbSet<ForumPostEdit> ForumPostEdits { get; set; }
|
public DbSet<ForumPostEdit> ForumPostEdits { get; set; }
|
||||||
public DbSet<Like> Likes { get; set; }
|
public DbSet<Like> Likes { get; set; }
|
||||||
public DbSet<ForumPermission> ForumPermissions { get; set; }
|
|
||||||
public DbSet<BannedIP> BannedIPs { get; set; }
|
public DbSet<BannedIP> BannedIPs { get; set; }
|
||||||
public DbSet<AuditLog> AuditLogs { get; set; }
|
public DbSet<AuditLog> AuditLogs { get; set; }
|
||||||
public System.Data.Entity.DbSet<Project_Unite.Models.Role> IdentityRoles { get; set; }
|
public System.Data.Entity.DbSet<Project_Unite.Models.Role> IdentityRoles { get; set; }
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Forums";
|
ViewBag.Title = "Forums";
|
||||||
|
bool noForums = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>Welcome to the forums.</h2>
|
<h2>Welcome to the forums.</h2>
|
||||||
|
|
||||||
@foreach (var cat in Model)
|
@foreach (var cat in Model)
|
||||||
{
|
{
|
||||||
|
if (ACL.CanSee(User?.Identity?.Name, cat.Id))
|
||||||
|
{
|
||||||
|
noForums = false;
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>@cat.Name</th>
|
<th>@cat.Name</th>
|
||||||
|
@ -16,16 +20,21 @@
|
||||||
<th>Most Recent Post</th>
|
<th>Most Recent Post</th>
|
||||||
</tr>
|
</tr>
|
||||||
@foreach (var subcat in cat.Children)
|
@foreach (var subcat in cat.Children)
|
||||||
{
|
{
|
||||||
|
if (ACL.CanSee(User?.Identity?.Name, subcat.Id))
|
||||||
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@Html.ActionLink(subcat.Name, "ViewForum", "Forum", new { id = subcat.Id }, null) <br/>
|
<td>@Html.ActionLink(subcat.Name, "ViewForum", "Forum", new { id = subcat.Id }, null) <br/>
|
||||||
<p>@subcat.Description</p>
|
<p>@subcat.Description</p>
|
||||||
@if(subcat.Children.Length > 0)
|
@if (subcat.Children.Length > 0)
|
||||||
{
|
{
|
||||||
<p><strong>Subforums: </strong>
|
<p><strong>Subforums: </strong>
|
||||||
@foreach(var subfrm in subcat.Children)
|
@foreach (var subfrm in subcat.Children)
|
||||||
{
|
{
|
||||||
|
if (ACL.CanSee(User?.Identity?.Name, subfrm.Id))
|
||||||
|
{
|
||||||
<em> @Html.ActionLink(subfrm.Name, "ViewForum", "Forum", new { id = subfrm.Id }, null) </em>
|
<em> @Html.ActionLink(subfrm.Name, "ViewForum", "Forum", new { id = subfrm.Id }, null) </em>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
@ -34,6 +43,17 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</table>
|
</table>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@if(noForums == true)
|
||||||
|
{
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
<div class="panel-body">
|
||||||
|
<p><span class="glyphicon glyphicon-ban-circle"></span> <strong>No forums to show!</strong> There are no forums that you have read access to. If you are a guest, please @Html.ActionLink("log in", "Login", "Account"). If not, please contact an admin.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
|
@ -5,160 +5,61 @@
|
||||||
|
|
||||||
<h2>@Model.Name</h2>
|
<h2>@Model.Name</h2>
|
||||||
|
|
||||||
@if (Model.Parent == "root")
|
<ul class="nav nav-tabs">
|
||||||
{
|
<li><a href="#" onclick="window.history.back()"><span class="glyphicon glyphicon-arrow-left"></span> Back</a></li>
|
||||||
@Html.ActionLink("Back", "Index", "Forum", null, new { @class = "btn btn-default" })
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@Html.ActionLink("Back", "ViewForum", "Forum", new { id=Model.Parent}, new { @class = "btn btn-default" })
|
|
||||||
}
|
|
||||||
|
|
||||||
@if(ACL.CanPost(User.Identity.Name, Model.Id))
|
@if(ACL.CanPost(User.Identity.Name, Model.Id))
|
||||||
{
|
{
|
||||||
@Html.ActionLink("New topic", "CreateTopic", "Forum", new { id=Model.Id}, new { @class = "btn btn-default" })
|
<li>@Html.ActionLink("New topic", "CreateTopic", "Forum", new { id=Model.Id}, null)</li>
|
||||||
}
|
}
|
||||||
|
</ul>
|
||||||
<p>@Model.Description</p>
|
<p>@Model.Description</p>
|
||||||
|
|
||||||
@if (Model.Children.Length > 0)
|
@if (Model.Children.Length > 0)
|
||||||
{
|
{
|
||||||
<table class="table">
|
<div class="row">
|
||||||
<tr>
|
<div class="col-xs-6">Subforums</div>
|
||||||
<th>Subforums</th>
|
<div class="col-xs-2">Topics</div>
|
||||||
<th>Topics</th>
|
<div class="col-xs-2">Posts</div>
|
||||||
<th>Posts</th>
|
<div class="col-xs-2">Most Recent Post</div>
|
||||||
<th>Most Recent Post</th>
|
</div>
|
||||||
</tr>
|
foreach (var cat in Model.Children)
|
||||||
@foreach (var cat in Model.Children)
|
|
||||||
{
|
{
|
||||||
<tr>
|
<div class="row">
|
||||||
<td>@Html.ActionLink(cat.Name, "ViewForum", "Forum", new { id = cat.Id }, null)
|
<div class="col-xs-6">@Html.ActionLink(cat.Name, "ViewForum", "Forum", new { id = cat.Id }, null)
|
||||||
<p>@cat.Description</p>
|
<p>@cat.Description</p>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
<div class="col-xs-2">
|
||||||
@cat.Topics.Length
|
@cat.Topics.Length
|
||||||
</td>
|
</div>
|
||||||
<td></td>
|
<div class="col-xs-2"></div>
|
||||||
<td></td>
|
<div class="col-xs-2"></div>
|
||||||
</tr>
|
</div>
|
||||||
}
|
}
|
||||||
</table>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
@if (Model.Topics.Length > 0)
|
@if (Model.Topics.Length > 0)
|
||||||
{
|
{
|
||||||
<table class="table">
|
<div class="row">
|
||||||
<tr>
|
<div class="col-xs-6">Topics</div>
|
||||||
<th>Topics</th>
|
<div class="col-xs-2">Posts</div>
|
||||||
<th>Posts</th>
|
<div class="col-xs-4">Most recent post</div>
|
||||||
<th>Most recent post</th>
|
</div>
|
||||||
</tr>
|
var topics = Model.Topics.Where(x => x.ShouldShow == true).OrderByDescending(x=>x.StartedAt).ThenByDescending(x=>x.Priority);
|
||||||
@{
|
foreach(var topic in topics)
|
||||||
var stickies = Model.Topics.Where(x => x.IsSticky == true);
|
|
||||||
var stickiesSorted = stickies.OrderByDescending(x => x.StartedAt);
|
|
||||||
var topicsSorted = Model.Topics.Where(x => x.IsSticky != true).OrderByDescending(x => x.StartedAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@foreach (var topic in stickiesSorted)
|
|
||||||
{
|
|
||||||
bool showTopic = true;
|
|
||||||
if (topic.IsUnlisted == true)
|
|
||||||
{
|
{
|
||||||
if(!ACL.Granted(User.Identity.Name, "CanSeeUnlistedTopics"))
|
<div class="row">
|
||||||
{
|
<div class="col-xs-6">
|
||||||
showTopic = false;
|
@Html.ActionLink(topic.Subject, "ViewTopic", "Forum", new { id = topic.Discriminator }, null)
|
||||||
}
|
<br/>
|
||||||
|
<p><strong>Started by </strong> @Html.UserLink(topic.AuthorId) <strong>at </strong> @topic.StartedAt • <span class="glyphicon glyphicon-thumbs-up"></span> @topic.Likes.Length • <span class="glyphicon glyphicon-thumbs-down"></span> @topic.Dislikes.Length</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-2">
|
||||||
|
<strong>@topic.Posts.Length</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTopic == true)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td><span class="glyphicon glyphicon-star"></span>
|
|
||||||
@if(topic.IsUnlisted == true)
|
|
||||||
{
|
|
||||||
<span class="glyphicon glyphicon-eye-close"></span>
|
|
||||||
}
|
|
||||||
@if (topic.IsLocked == true)
|
|
||||||
{
|
|
||||||
<span class="glyphicon glyphicon-lock"></span>
|
|
||||||
}
|
|
||||||
|
|
||||||
@Html.ActionLink(topic.Subject, "ViewTopic", "Forum", new { id = topic.Discriminator }, null)
|
|
||||||
<p>Started by @Html.UserLink(topic.AuthorId) on @topic.StartedAt</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@topic.Posts.Length
|
|
||||||
</td>
|
|
||||||
<td style="text-align:center">
|
|
||||||
@if (topic.Posts.Length > 0)
|
|
||||||
{
|
|
||||||
var mostRecent = topic.Posts.OrderByDescending(x => x.PostedAt).First();
|
|
||||||
<strong>Re: @topic.Subject</strong>
|
|
||||||
<em>by @Html.UserLink(mostRecent.AuthorId)</em>
|
|
||||||
<p><em>at @mostRecent.PostedAt</em></p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<em>No posts.</em>
|
|
||||||
}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@foreach (var topic in topicsSorted)
|
|
||||||
{
|
|
||||||
|
|
||||||
bool showTopic = true;
|
|
||||||
if (topic.IsUnlisted == true)
|
|
||||||
{
|
|
||||||
if (!ACL.Granted(User.Identity.Name, "CanSeeUnlistedTopics"))
|
|
||||||
{
|
|
||||||
showTopic = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showTopic == true)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@if(topic.IsUnlisted == true)
|
|
||||||
{
|
|
||||||
<span class="glyphicon glyphicon-eye-close"></span>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (topic.IsLocked == true)
|
|
||||||
{
|
|
||||||
<span class="glyphicon glyphicon-lock"></span>
|
|
||||||
}
|
|
||||||
@Html.ActionLink(topic.Subject, "ViewTopic", "Forum", new { id = topic.Discriminator }, null)
|
|
||||||
<p>Started by @Html.UserLink(topic.AuthorId) on @topic.StartedAt</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@topic.Posts.Length
|
|
||||||
</td>
|
|
||||||
<td style="text-align:center">
|
|
||||||
@if (topic.Posts.Length > 0)
|
|
||||||
{
|
|
||||||
var mostRecent = topic.Posts.OrderByDescending(x => x.PostedAt).First();
|
|
||||||
<strong>Re: @topic.Subject</strong>
|
|
||||||
<em>by @Html.UserLink(mostRecent.AuthorId)</em>
|
|
||||||
<p><em>at @mostRecent.PostedAt</em></p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<em>No posts.</em>
|
|
||||||
}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</table>
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue