﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>InstantASP Community Forums » Old Forums » InstantForum.NET 4.x » Bug Reports  » Sending an Attachment in a Private Message</title><generator>InstantForum.NET 2010 RC2</generator><description>InstantASP Community Forums</description><link>http://community.instantasp.co.uk/</link><webMaster>InstantASP Community Forums</webMaster><lastBuildDate>Sat, 13 Mar 2010 00:49:17 GMT</lastBuildDate><ttl>20</ttl><item><title>Sending an Attachment in a Private Message</title><link>http://community.instantasp.co.uk/FindPost0.aspx</link><description>If you try to Add an attachment when creating a private message you are greeted with a yellow screen of death exit error message.&lt;/P&gt;&lt;P&gt;The bug is in the vb code located in a file &lt;STRONG&gt;InstantASP.InstantForum/InstantASP.InstantForum.UI/Dialogs/InsertAttachments.vb&lt;/STRONG&gt; in procedure named Initialize: &lt;/P&gt;&lt;P&gt;[quote]Private Sub Initialize()&lt;BR&gt;  ' ensure this page is not locally cached&lt;BR&gt;  System.Web.HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache)&lt;BR&gt;  System.Web.HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(False)&lt;BR&gt;  ' ensure user is authenticated&lt;BR&gt;  InstantASP.InstantForum.Security.Handler.HasPermission(CurrentContext.CurrentRequest.Task, _&lt;BR&gt;  CurrentContext.CurrentPermissions, CurrentContext.CurrentForum.Moderators.SelectModerator( _&lt;BR&gt;  CurrentContext.CurrentUser.UserID), CurrentContext.CurrentForum)[/quote]&lt;/P&gt;&lt;P&gt; Since we are sending a private message from the control panel there is no forum context here, hence the error. The correct way to authenticate a user is displayed bellow:&lt;/P&gt; &lt;P&gt;[quote]  ' ensure user is authenticated&lt;BR&gt;  If Not CurrentContext.CurrentForum Is Nothing Then&lt;BR&gt;    InstantASP.InstantForum.Security.Handler.HasPermission(CurrentContext.CurrentRequest.Task, _&lt;BR&gt;    CurrentContext.CurrentPermissions, CurrentContext.CurrentForum.Moderators.SelectModerator( _&lt;BR&gt;    CurrentContext.CurrentUser.UserID), CurrentContext.CurrentForum)&lt;BR&gt;  Else&lt;BR&gt;    InstantASP.InstantForum.Security.Handler.HasPermission(CurrentContext.CurrentRequest.Task, _&lt;BR&gt;    CurrentContext.CurrentPermissions)&lt;BR&gt;  End If[/quote]&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 21 Nov 2006 10:02:02 GMT</pubDate><dc:creator>rooobce</dc:creator></item><item><title>RE: Sending an Attachment in a Private Message</title><link>http://community.instantasp.co.uk/FindPost0.aspx</link><description>And for the previous modification to really work, you have to completely rewrite the stored procedure  &lt;STRONG&gt;if_sp_SelectAttachment&lt;/STRONG&gt;, which now should look like:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;[quote]set ANSI_NULLS ON&lt;BR&gt;set QUOTED_IDENTIFIER ON&lt;BR&gt;GO&lt;BR&gt;ALTER PROCEDURE [dbo].[if_sp_SelectAttachment] &lt;BR&gt;@intAttachmentID int,&lt;BR&gt;@intUserID int&lt;BR&gt;AS&lt;BR&gt;SET NOCOUNT ON &lt;BR&gt;/* Get the forum this attachment is within */&lt;BR&gt;DECLARE @intForumID int&lt;BR&gt;DECLARE @SQL nvarchar(4000)&lt;BR&gt;IF EXISTS( SELECT AttachmentID FROM InstantForum_AttachmentsPosts WHERE AttachmentID = @intAttachmentID AND IsPrivateMessage = 1 )&lt;BR&gt;BEGIN&lt;BR&gt;SET @intForumID = 0&lt;BR&gt;SELECT TOP 1&lt;BR&gt;InstantForum_Attachments.AttachmentID, &lt;BR&gt;InstantForum_Attachments.UserID, &lt;BR&gt;InstantForum_Attachments.AttachmentBLOB,&lt;BR&gt;InstantForum_Attachments.[Filename], &lt;BR&gt;InstantForum_Attachments.[Views], &lt;BR&gt;InstantForum_Attachments.ContentLength, &lt;BR&gt;InstantForum_Attachments.ContentType&lt;BR&gt;FROM InstantForum_Attachments &lt;BR&gt;JOIN InstantForum_AttachmentsPosts ON InstantForum_AttachmentsPosts.AttachmentID = InstantForum_Attachments.AttachmentID&lt;BR&gt;JOIN InstantForum_PrivateMessages ON InstantForum_PrivateMessages.PrivateMessageID = InstantForum_AttachmentsPosts.PostID&lt;BR&gt;WHERE InstantForum_Attachments.AttachmentID = @intAttachmentID&lt;BR&gt;AND InstantForum_AttachmentsPosts.IsPrivateMessage = 1 &lt;BR&gt;AND InstantForum_PrivateMessages.RecipientID = @intUserID&lt;BR&gt;END&lt;BR&gt;ELSE&lt;BR&gt;BEGIN&lt;BR&gt;SET @intForumID = (&lt;BR&gt;SELECT ForumID &lt;BR&gt;FROM InstantForum_Topics &lt;BR&gt;WHERE PostID = (&lt;BR&gt;SELECT PostID &lt;BR&gt;FROM InstantForum_AttachmentsPosts &lt;BR&gt;WHERE AttachmentID = @intAttachmentID&lt;BR&gt;)&lt;BR&gt;)&lt;BR&gt;SELECT &lt;BR&gt;InstantForum_Attachments.AttachmentID, &lt;BR&gt;InstantForum_Attachments.UserID, &lt;BR&gt;InstantForum_Attachments.AttachmentBLOB,&lt;BR&gt;InstantForum_Attachments.[Filename], &lt;BR&gt;InstantForum_Attachments.[Views], &lt;BR&gt;InstantForum_Attachments.ContentLength, &lt;BR&gt;InstantForum_Attachments.ContentType &lt;BR&gt;FROM InstantForum_Attachments &lt;BR&gt;WHERE InstantForum_Attachments.AttachmentID = @intAttachmentID&lt;BR&gt;AND EXISTS (&lt;BR&gt;SELECT InstantForum_ForumsRoles.ForumRoleID &lt;BR&gt;FROM InstantForum_ForumsRoles &lt;BR&gt;WHERE InstantForum_ForumsRoles.ForumID = @intForumID &lt;BR&gt;AND InstantForum_ForumsRoles.RoleID IN (&lt;BR&gt;SELECT InstantASP_Roles.RoleID &lt;BR&gt;FROM InstantASP_UsersRoles &lt;BR&gt;INNER JOIN InstantASP_Roles ON InstantASP_UsersRoles.RoleID = InstantASP_Roles.RoleID &lt;BR&gt;WHERE InstantASP_UsersRoles.UserID = @intUserID &lt;BR&gt;)&lt;BR&gt;)&lt;BR&gt;END[/quote]&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;</description><pubDate>Tue, 21 Nov 2006 10:02:02 GMT</pubDate><dc:creator>rooobce</dc:creator></item></channel></rss>