To start with; a bit of a description of what I wanted the Mass PM feature to do:
- display the Group Name in the From field (inbox) when a person receives a PM sent to a Group
- display the Group Name in the To field (sentbox, outbox) for the person sending the group PM
- only display one instance of the “sent†message in the sender’s “Outboxâ€
- o see below for more detail
- anyone can send Group PMs
- but only Admin can select (Niels pulldown menu) the Group to send to
- o in my app a button to send PM to a group is listed on “home page†for that group
o when selected the To field is filled in with Group Name and is uneditable.
What I did:
DB Changes:
- added group_msgs table
- o group_msg_id number for each group PM
o the group_id it was sent to
o msgtxt id (I don’t use this yet)
- - Niels’ mod has multiple copies of group msg text saved – this is not really required
- o link to group_msgs table
- when a new group msg is created I add entry to group_msg table and take that number and add it along with msg entry in privmsgs table
- o if a privmsg has a group_msg_id = 0 it is a normal (non-group) PM
Changes in privmsg.php:
- check group_msg_id value in privmsg table to NOT make a copy of sender msg a in the posters sent box
- in sql for Outbox – don’t select group msgs
- in main loop for building folder – insert code to check if one of group msg items was already counted; if it was; skip the rest for that group_msg_id
Changes in groupmsg.php
- when I go to insert a msg – get a new group_msg_id and insert that as well
- neat trick
- o Niels originally “sent†a copy of group msg to the sender (since he is in the group as well)
o at first I took that out since I didn’t think it made any sense – but then I decided to use it to solve a problem I had with everything to this point
- to fix this – the copy of msg that is to be sent to sender – I stamp it as going to SENDBOX immediately – this gives me a copy that will persist as readers read their PM
That’s about it.
You can check out my modd’ed mod at my site (www.thesportsconnection.ca) although you will have to register to access (for now; registration is free). If you check it out and it doesn’t seem obvious – “groups†in my world are related to a specific sport.
Other bits:
If you were to check out my code at some point you will see some code specific to location filtering. My site has the concept of “local†groups. Basically my site is related to Sports. There are over 70 sports listed. Each of these sports is a Group (or Community). But my site also covers all of the US and Canada and I have location info for all my registered members. When someone sends a Group PM (lets say to the Baseball Community) it only goes to those people registered in the Baseball Community that are “local†or “close†to the sender.
Basically, without this I would need to maintain about a million “groups†(each city X each sport) – that of course would be silly. So I only have 70 or so groups; but filter everything by an added “location string†to my SQL queries. Very cool.
Cheers,
Peter Lindstrom
CEO - The Sports Connection
Ottawa, ON
Email: peter@thesportsconnection.ca
Web: http://www.thesportsconnection.ca

