I'm noticing that I can't delete messages in PM Lite and I'm wondering if there's a way to get rid of unwanted messages for users. The client who I'm working for loves the simplicity of the module, but they want just enough control to get rid of old messages. Thank you for your time.

my client:
http://www.socialstylists.com

CommentFileSizeAuthor
#2 458470-2.patch6.79 KBJamesAn

Comments

JamesAn’s picture

Currently, only users with the "administer pm_lite" permission can delete messages. A secondary problem is that if a message is deleted, it's deleted for the author and the recipient, since they view the same node.

I think message deletion is a basic operation, so I'd support it in PM Lite.

Off the top of my head, perhaps we can add in two hidden flags to indicate whether the author or the recipient has marked the message for deletion. If that flag is marked, than the respective user can no longer see the message. The message stays in the node table and is still viewable for the other party.

If both users mark the message for deletion, it is safe to delete the message. Maybe we can have hook into cron to check for this condition to delete the message entirely, if the admin wants to delete such messages.

Is there a better/cleaner/simpler approach?

JamesAn’s picture

Status: Active » Needs review
StatusFileSize
new6.79 KB

Implementing the delete operation was a little more complicated than I expected as I didn't realize that messages could have multiple recipients.

I've converted the db field, status, to hold two more status flags: deletion flags for both author and recipient. The 3 status flags are extracted and inserted through bit masks.

Since there are multiple {pm_lite} entries for a message with multiple recipients (one entry per recipient), it raises an issue of data duplication. There are multiple entries where the deletion flag for the author could be stored. This patch raises the flag in one of these multiple entries (with the SQL phrase "LIMIT 1"). The flag will still be found, since pm_lite_table() loops through all these entries to construct the sent page.

I've done some basic testing, but someone else would probably catch things much better.