Skip to content

Commit a2e8063

Browse files
committed
More on published property of forum topic and forum post
1 parent aedfad7 commit a2e8063

9 files changed

Lines changed: 216 additions & 232 deletions

File tree

src/Libraries/SmartStore.Data/Migrations/201809261026134_ForumGroupAcl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public override void Up()
99
{
1010
DropIndex("dbo.Forums_Topic", new[] { "ForumId" });
1111
DropIndex("dbo.Forums_Forum", new[] { "ForumGroupId" });
12-
AddColumn("dbo.Forums_Post", "Published", c => c.Boolean(nullable: false));
13-
AddColumn("dbo.Forums_Topic", "Published", c => c.Boolean(nullable: false));
12+
AddColumn("dbo.Forums_Post", "Published", c => c.Boolean(nullable: false, defaultValue: true));
13+
AddColumn("dbo.Forums_Topic", "Published", c => c.Boolean(nullable: false, defaultValue: true));
1414
AddColumn("dbo.Forums_Group", "SubjectToAcl", c => c.Boolean(nullable: false));
1515
CreateIndex("dbo.Forums_Post", "CreatedOnUtc");
1616
CreateIndex("dbo.Forums_Post", "Published");

src/Libraries/SmartStore.Services/Forums/ForumService.cs

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -841,33 +841,26 @@ public virtual bool IsCustomerAllowedToCreateTopic(Customer customer, Forum foru
841841

842842
public virtual bool IsCustomerAllowedToEditTopic(Customer customer, ForumTopic topic)
843843
{
844-
if (topic == null || customer == null || customer.IsGuest())
844+
if (customer != null && topic != null)
845845
{
846-
return false;
847-
}
848-
849-
if (customer.IsForumModerator())
850-
{
851-
return true;
852-
}
846+
if (customer.IsForumModerator())
847+
{
848+
return true;
849+
}
853850

854-
if (_forumSettings.AllowCustomersToEditPosts && topic.Published)
855-
{
856-
var ownTopic = customer.Id == topic.CustomerId;
857-
return ownTopic;
851+
if (_forumSettings.AllowCustomersToEditPosts && topic.Published)
852+
{
853+
var ownTopic = customer.Id == topic.CustomerId;
854+
return ownTopic;
855+
}
858856
}
859857

860858
return false;
861859
}
862860

863861
public virtual bool IsCustomerAllowedToMoveTopic(Customer customer, ForumTopic topic)
864862
{
865-
if (topic == null || customer == null || customer.IsGuest())
866-
{
867-
return false;
868-
}
869-
870-
if (customer.IsForumModerator())
863+
if (customer != null && customer.IsForumModerator())
871864
{
872865
return true;
873866
}
@@ -877,20 +870,18 @@ public virtual bool IsCustomerAllowedToMoveTopic(Customer customer, ForumTopic t
877870

878871
public virtual bool IsCustomerAllowedToDeleteTopic(Customer customer, ForumTopic topic)
879872
{
880-
if (topic == null || customer == null || customer.IsGuest())
873+
if (topic != null && customer != null)
881874
{
882-
return false;
883-
}
884-
885-
if (customer.IsForumModerator())
886-
{
887-
return true;
888-
}
875+
if (customer.IsForumModerator())
876+
{
877+
return true;
878+
}
889879

890-
if (_forumSettings.AllowCustomersToDeletePosts && topic.Published)
891-
{
892-
var ownTopic = customer.Id == topic.CustomerId;
893-
return ownTopic;
880+
if (_forumSettings.AllowCustomersToDeletePosts && topic.Published)
881+
{
882+
var ownTopic = customer.Id == topic.CustomerId;
883+
return ownTopic;
884+
}
894885
}
895886

896887
return false;
@@ -903,7 +894,7 @@ public virtual bool IsCustomerAllowedToCreatePost(Customer customer, ForumTopic
903894
return false;
904895
}
905896

906-
if (customer.IsGuest() && !_forumSettings.AllowGuestsToCreatePosts)
897+
if (!_forumSettings.AllowGuestsToCreatePosts && customer.IsGuest())
907898
{
908899
return false;
909900
}
@@ -913,58 +904,39 @@ public virtual bool IsCustomerAllowedToCreatePost(Customer customer, ForumTopic
913904

914905
public virtual bool IsCustomerAllowedToEditPost(Customer customer, ForumPost post)
915906
{
916-
if (post == null || customer == null || customer.IsGuest())
917-
{
918-
return false;
919-
}
920-
921-
if (customer.IsForumModerator())
907+
if (post != null && customer != null)
922908
{
923-
return true;
924-
}
909+
if (customer.IsForumModerator())
910+
{
911+
return true;
912+
}
925913

926-
if (_forumSettings.AllowCustomersToEditPosts && post.Published)
927-
{
928-
var ownPost = customer.Id == post.CustomerId;
929-
return ownPost;
914+
if (_forumSettings.AllowCustomersToEditPosts && post.Published)
915+
{
916+
var ownPost = customer.Id == post.CustomerId;
917+
return ownPost;
918+
}
930919
}
931920

932921
return false;
933922
}
934923

935924
public virtual bool IsCustomerAllowedToDeletePost(Customer customer, ForumPost post)
936925
{
937-
if (post == null || customer == null || customer.IsGuest())
926+
if (post != null && customer != null)
938927
{
939-
return false;
940-
}
941-
942-
if (customer.IsForumModerator())
943-
{
944-
return true;
945-
}
946-
947-
if (_forumSettings.AllowCustomersToDeletePosts && post.Published)
948-
{
949-
var ownPost = customer.Id == post.CustomerId;
950-
return ownPost;
951-
}
952-
953-
return false;
954-
}
928+
if (customer.IsForumModerator())
929+
{
930+
return true;
931+
}
955932

956-
public virtual bool IsCustomerAllowedToSetTopicPriority(Customer customer)
957-
{
958-
if (customer == null || customer.IsGuest())
959-
{
960-
return false;
933+
if (_forumSettings.AllowCustomersToDeletePosts && post.Published)
934+
{
935+
var ownPost = customer.Id == post.CustomerId;
936+
return ownPost;
937+
}
961938
}
962939

963-
if (customer.IsForumModerator())
964-
{
965-
return true;
966-
}
967-
968940
return false;
969941
}
970942

src/Libraries/SmartStore.Services/Forums/IForumService.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,6 @@ IPagedList<ForumSubscription> GetAllSubscriptions(int customerId, int forumId,
348348
/// <returns>True if allowed, otherwise false</returns>
349349
bool IsCustomerAllowedToDeletePost(Customer customer, ForumPost post);
350350

351-
/// <summary>
352-
/// Check whether customer is allowed to set topic priority
353-
/// </summary>
354-
/// <param name="customer">Customer</param>
355-
/// <returns>True if allowed, otherwise false</returns>
356-
bool IsCustomerAllowedToSetTopicPriority(Customer customer);
357-
358351
/// <summary>
359352
/// Check whether customer is allowed to watch topics
360353
/// </summary>

0 commit comments

Comments
 (0)