lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-07-23T06:39:38Z
Hi guys,

Just a quick question:

I use the pmmessage_info procedure to extract the number of read and unread PMS for a user and place it on the users home page.
I noticed that when I (as the user in question) delete PMs from my inbox via the forum that they are still in the database, and more specific still appear in the number of PMs.

Could someone please tell me what I am doing wrong, and what the correct process for a user to delete PMs actually is?

Thanks

Sponsor
jshepler
2009-07-23T14:37:45Z
lucauwf76 wrote:

Hi guys,

Just a quick question:

I use the pmmessage_info procedure to extract the number of read and unread PMS for a user and place it on the users home page.
I noticed that when I (as the user in question) delete PMs from my inbox via the forum that they are still in the database, and more specific still appear in the number of PMs.

Could someone please tell me what I am doing wrong, and what the correct process for a user to delete PMs actually is?

Thanks



Private Messages are stored once in the database but are associated with multiple users (user that sent it and the user(s) that received it). When a user deletes a PM, only their reference is removed. The PM remains in the database until no more users are associated with it.

The "pmessage_info" proc returns the count of all PMs in the database - not for any specific user. You might try the user_pmcount proc instead although it doesn't return the same info. You would probably be better off querying the database directly for what you need.
not jsheLPer
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-07-23T17:41:10Z
Thanks JS, that makes sense.
Doesn't YAF already make use of something existing to retrieve this data for when a user goes to their PMS?

I'd settle for a method of finding out if a user simply has unread/new pms. I'm using the 1.9.3beta (I need to upgrade : /) binary, so I'd much prefer to use a yaf integrated solution for this to keep my own application separated from querying the yaf database directly.

Thanks.
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-07-23T19:05:32Z
Without detracting too much from my post above, which I would still like an answer to if you'd please oblige, I upgraded to the latest version today and did some testing.

Your statement above doesn't seem to be true.
If I send a PM from account A to account B the PM is placed in account A's Sent Items (Unread), and account B's Inbox (Unread).
That is, the state of the PM in account B is represented in the Sent Items of account A.
If account B then deletes the PM it is removed from the sent items of Account A! (And internally deleted from yaf_PMessage and yaf_UserPMessage).

That doesn't seem correct to me (I'd expect behaviour as you suggested tbh) - but I tested it several times with the same result.
This means ofc that there's no way of anyone reliably storing sent PMs, but it does give you a good indication of the recipients interaction with it.
jshepler
2009-07-23T23:50:22Z
lucauwf76 wrote:

Without detracting too much from my post above, which I would still like an answer to if you'd please oblige, I upgraded to the latest version today and did some testing.

Your statement above doesn't seem to be true.
If I send a PM from account A to account B the PM is placed in account A's Sent Items (Unread), and account B's Inbox (Unread).
That is, the state of the PM in account B is represented in the Sent Items of account A.
If account B then deletes the PM it is removed from the sent items of Account A! (And internally deleted from yaf_PMessage and yaf_UserPMessage).

That doesn't seem correct to me (I'd expect behaviour as you suggested tbh) - but I tested it several times with the same result.
This means ofc that there's no way of anyone reliably storing sent PMs, but it does give you a good indication of the recipients interaction with it.



This bug was fixed after release - http://forum.yetanotherf...te-his-received-one.aspx 

not jsheLPer
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-07-24T03:05:33Z
Ah, OK. I'm probably being dumb here - but where is the fix? Mek's last post says:
Mek wrote:

Already Sorted it mate.
I've created a new delete flag, and it won't actually delete the message until all instances of the messaege are set to delete.



But there's nothing else. Is it due for the next release?
Also, is there a way without querying the DB directly to know if a user has Unread messages?
Thanks again.
Mek
  •  Mek
  • 100% (Exalted)
  • YAF Developer
2009-07-24T08:20:15Z
My post above that one very cryptically states comitted to SVN and then the number. This means the codes been comitted to our central repository, so unless you're familiar with SVN it'll be included in the next release.

UserPostedImage 

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
jshepler
2009-07-24T09:40:55Z
lucauwf76 wrote:

Ah, OK. I'm probably being dumb here - but where is the fix?



You can get Mek's fix by either getting latest SVN or wait for next release. Or you can use the fix I posted in that thread. I haven't tested it but it's a pretty simple thing to check if the post is still being referenced before deleting it.

lucauwf76 wrote:

Also, is there a way without querying the DB directly to know if a user has Unread messages?



Not that I'm aware of.

not jsheLPer
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-07-24T09:49:46Z
OK, thanks guys. I'll try to replace the stored procedure JS and give it a run tonight.
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-08-09T07:19:05Z
Sorry, it's been a while since I got the opportunity to try this.
Anyway, I modified my stored procedure as follows, but it still did not behave correctly, if the user the PM was sent to deletes the pm it is still deleted from the user who sent it sent box.

I may have done something wrong, any ideas?

Quote:


ALTER PROCEDURE [dbo].[yaf_pmessage_delete](@UserPMessageID int, @FromOutbox bit = 0) as
BEGIN
DECLARE @PMessageID int

SET @PMessageID = (SELECT TOP 1 PMessageID FROM [dbo].[yaf_UserPMessage] where [UserPMessageID] = @UserPMessageID);

IF @FromOutbox = 1
BEGIN
-- set IsInOutbox bit which will remove it from the senders outbox
UPDATE [dbo].[yaf_UserPMessage] SET [Flags] = ([Flags] ^ 2) WHERE UserPMessageID = @UserPMessageID AND IsInOutbox = 1
END
ELSE
BEGIN
DELETE FROM [dbo].[yaf_UserPMessage] WHERE [UserPMessageID] = @UserPMessageID

IF NOT EXISTS (SELECT * FROM [dbo].[yaf_UserPMessage] WHERE [PMessageID] = @PMessageID)
BEGIN
DELETE FROM [dbo].[yaf_PMessage] WHERE [PMessageID] = @PMessageID
END
END
END

logan
  •  logan
  • 100% (Exalted)
  • YAF Leader
2009-08-09T21:45:52Z
The new code from the svn is like this:
There are other modifications that need to be made for it to work correctly.

http://yafdotnet.svn.sou.../yafdotnet/?pathrev=2388 

Look for the code changes.


ALTER PROCEDURE [dbo].[yaf_pmessage_delete](@UserPMessageID int, @FromOutbox bit = 0) as
BEGIN
	DECLARE @PMessageID int

	SET @PMessageID = (SELECT TOP 1 PMessageID FROM [dbo].[yaf_UserPMessage] where [UserPMessageID] = @UserPMessageID);

	-- set IsInOutbox bit which will remove it from the senders outbox
	UPDATE [dbo].[yaf_UserPMessage] SET [Flags] = ([Flags] ^ 😎 WHERE UserPMessageID = @UserPMessageID
	
	DECLARE @MsgCount int
	SET @MsgCount = (SELECT COUNT (UserPMessageID) FROM [dbo].[yaf_UserPMessage]  WHERE  ([Flags] & 8)=0) ;
	
	IF @MsgCount =0 
	BEGIN
		DELETE FROM [dbo].[yaf_UserPMessage] WHERE [PMessageID] = @PMessageID
		DELETE FROM [dbo].[yaf_PMessage] WHERE [PMessageID] = @PMessageID
	END

END

test
lucauwf76
  •  lucauwf76
  • 65% (Friendly)
  • YAF Forumling Topic Starter
2009-08-11T04:39:15Z
Thanks, but I'm using the binary and not the source code so I was looking to implement a fix in the stored procedure.
If I move to using the source I'll take a look.
Users browsing this topic

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved