Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: subscriptions using anonymous user #534

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dnn.CommunityForums/CustomControls/UserControls/TopicView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,9 +1373,9 @@ private string ParseContent(DataRow dr, string tempate, int rowcount)
sbOutput.Replace("[ACTIONS:DELETE]", string.Empty);
}

if ((ForumUser.IsAdmin || ForumUser.IsSuperUser || _bModUser) && (authorId != UserId) && (!author.IsSuperUser) && (!author.IsAdmin))
if ((ForumUser.IsAdmin || ForumUser.IsSuperUser || _bModUser) && (authorId != -1) && (authorId != UserId) && (author != null) && (!author.IsSuperUser) && (!author.IsAdmin))
{
var banParams = new List<string> { ParamKeys.ViewType + "=modban", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + replyId, ParamKeys.UserId + "=" + authorId };
var banParams = new List<string> { ParamKeys.ViewType + "=modban", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + replyId, ParamKeys.AuthorId + "=" + authorId };
if (_useListActions)
{
sbOutput.Replace("[ACTIONS:BAN]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", banParams) + "';\" title=\"[RESX:Ban]\"><i class=\"fa fa-ban fa-fw fa-blue\"></i>&nbsp;[RESX:Ban]</li>");
Expand Down
34 changes: 17 additions & 17 deletions Dnn.CommunityForums/class/ForumBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ForumBase : SettingsBase
private int? _topicId; // = -1;
private int? _replyId;
private int? _quoteId;
private int? _userId;
private int? _authorid;
private bool? _jumpToLastPost;
private string _defaultView = Views.ForumView;
private int _defaultForumViewTemplateId = -1;
Expand Down Expand Up @@ -364,43 +364,43 @@ public int ForumId
_forumId = value;
}
}
public int UserId
public int AuthorId
{
get
{
// If the id has already been set, return it.
if (_userId.HasValue)
return _userId.Value;
if (_authorid.HasValue)
return _authorid.Value;

// Set out default value
_userId = -1;
_authorid = -1;

// If there is an id in the query string, parse it
var queryUserId = Request.QueryString[ParamKeys.UserId];
if (!string.IsNullOrWhiteSpace(queryUserId))
var queryAuthorId = Request.QueryString[ParamKeys.AuthorId];
if (!string.IsNullOrWhiteSpace(queryAuthorId))
{
// Try to parse the id, if it doesn't work, return the default value.
int parsedUserId;
_userId = int.TryParse(queryUserId, out parsedUserId) ? parsedUserId : 0;
int parsedAuthorId;
_authorid = int.TryParse(queryAuthorId, out parsedAuthorId) ? parsedAuthorId : 0;
}

// If we don't have a user id at this point, try and pull it from "userid" in the query string
if (_userId < 1)
// If we don't have a user id at this point, try and pull it from "authorid" in the query string
if (_authorid < 1)
{
queryUserId = Request.QueryString["userid"];
if (!string.IsNullOrWhiteSpace(queryUserId))
queryAuthorId = Request.QueryString["authorid"];
if (!string.IsNullOrWhiteSpace(queryAuthorId))
{
// Try to parse the id, if it doesn't work, return the default value.
int parsedUserId;
_userId = int.TryParse(queryUserId, out parsedUserId) ? parsedUserId : 0;
int parsedAuthorId;
_authorid = int.TryParse(queryAuthorId, out parsedAuthorId) ? parsedAuthorId : 0;
}
}

return _userId.Value;
return _authorid.Value;
}
set
{
_userId = value;
_authorid = value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/class/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public class ParamKeys
public const string ConfirmActionId = "afca";
public const string Tags = "aftg";
public const string FirstNewPost = "afnp";
public const string UserId = "afu";
public const string AuthorId = "authorid";
}

public class Views
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/class/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ internal static string ParseTokenConfig(int moduleId, string template, string gr
template = template.Replace("[PARAMKEYS:VIEWTYPE]", ParamKeys.ViewType);
template = template.Replace("[PARAMKEYS:QUOTEID]", ParamKeys.QuoteId);
template = template.Replace("[PARAMKEYS:REPLYID]", ParamKeys.ReplyId);
template = template.Replace("[PARAMKEYS:USERID]", ParamKeys.UserId);
template = template.Replace("[PARAMKEYS:AUTHORID]", ParamKeys.AuthorId);
template = template.Replace("[VIEWS:TOPICS]", Views.Topics);
template = template.Replace("[VIEWS:TOPIC]", Views.Topic);
template = template.Replace("[PAGEID]", config.PageId.ToString());
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/config/tokens.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<value><![CDATA[<af:imagebutton runat='server' cssclass='ambuttonsm' PostBack='false' PageId='[PAGEID]' Params='[PARAMKEYS:VIEWTYPE]=modreport,[PARAMKEYS:FORUMID]=[FORUMID],[PARAMKEYS:TOPICID]=[TOPICID],[PARAMKEYS:REPLYID]=[POSTID]' text='[RESX:Alert]' SpriteCSS='aficon aficonalert aficonleft' AuthRoles='[REPLYROLES]' UserRoles='[USERROLES]' />]]></value>
</token>
<token group="*" name="[ACTIONS:BAN]">
<value><![CDATA[[AF:SECURITY:USER]<af:imagebutton runat='server' cssclass='ambuttonsm' PostBack='false' PageId='[PAGEID]' Params='[PARAMKEYS:VIEWTYPE]=modban,[PARAMKEYS:FORUMID]=[FORUMID],[PARAMKEYS:TOPICID]=[TOPICID],[PARAMKEYS:REPLYID]=[POSTID],[PARAMKEYS:USERID]=[USERID]' text='[RESX:Ban]' SpriteCSS='aficon aficonalert aficonleft' NotAuthText='' AuthRoles='[MODUSER]' /[/AF:SECURITY:USER]>]]></value>
<value><![CDATA[[AF:SECURITY:USER]<af:imagebutton runat='server' cssclass='ambuttonsm' PostBack='false' PageId='[PAGEID]' Params='[PARAMKEYS:VIEWTYPE]=modban,[PARAMKEYS:FORUMID]=[FORUMID],[PARAMKEYS:TOPICID]=[TOPICID],[PARAMKEYS:REPLYID]=[POSTID],[PARAMKEYS:AUTHORID]=[AUTHORID]' text='[RESX:Ban]' SpriteCSS='aficon aficonalert aficonleft' NotAuthText='' AuthRoles='[MODUSER]' /[/AF:SECURITY:USER]>]]></value>
</token>
<token group="*" name="[ACTIONS:MOVE]">
<value><![CDATA[[AF:SECURITY:MOVE]<af:link runat="server" PageId="[PAGEID]" title="[RESX:MoveTopic]" Params="[PARAMKEYS:VIEWTYPE]=modmovetopic,[PARAMKEYS:FORUMID]=[FORUMID],[PARAMKEYS:TOPICID]=[POSTID]" text="<img src='[THEMEPATH]topic_move.gif' border='0' style='vertical-align:middle;' />" AuthRoles="[MODMOVE]" cssclass="afactionbtn" />[/AF:SECURITY:MOVE]]]></value>
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/controls/af_modban.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void btnBan_Click(object sender, System.EventArgs e)
}
else
{
DotNetNuke.Modules.ActiveForums.Controllers.UserController.BanUser(PortalId: PortalId, ModuleId: ForumModuleId, UserId: UserId);
DotNetNuke.Modules.ActiveForums.Controllers.UserController.BanUser(PortalId: PortalId, ModuleId: ForumModuleId, UserId: AuthorId);
Response.Redirect(NavigateUrl(TabId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, (ReplyId > 0 ? ParamKeys.TopicId + "=" + TopicId : string.Empty), ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.UserBanned + (SocialGroupId > 0 ? "&" + ParamKeys.GroupIdName + "=" + SocialGroupId : string.Empty) }));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/controls/af_quickreply.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ private void SaveQuickReply()
notification.Subject = subject;
notification.Body = body;
notification.IncludeDismissAction = false;
notification.SenderUserID = UserInfo.UserID;
notification.SenderUserID = UserId;
notification.Context = notificationKey;

NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);
Expand Down