0

 EDITED

The excellent Privatemsg module provides a wealth of functionality but some sites might not need/want this degree of complexity. Rather than starting with something complex and disabling/removing features, I would like to think about ways to build something relatively simple from basics.

Using the basic infrastructure of D7 what are the ways one could create a simple messaging system that allows user A to message user B, and both of these corresponding users to delete this message individually (i.e. user A deletes message 1, but user B does not; therefore user B can still see message 1)?

How might message threads (i.e. successive related messages) be managed and displayed?

How well would the solution scale (e.g. 1,000,000 messages, 100,000 threads, etc.).

Thank you.

5
  • @berdir can you help here please? Jan 24, 2016 at 22:44
  • I'm voting to close this question as off-topic because it's a follow-up on specific comments in the Drupal issue queue. Please continue the conversation there. Jan 26, 2016 at 8:51
  • @marcvangend Sorry, but I argue you've misunderstood the purpose of this question. I referenced Drupal.org in my 1st paragraph only to keep my question here as brief as possible, to provide helpful context. My 2nd paragraph contains the question, which I think is clearly not a "follow-up" to that Drupal.org thread: the latter is about D8 Privatemsg while I am asking for ways to accomplish simple messaging using D7's basic infrastructure without Privatemsg. Niall (below) has kindly suggested Entity References as 1 way to build the functionality I asked about.If you want I will edit my OP.
    – penname
    Jan 26, 2016 at 12:54
  • @marcvangend Have edited. I admit my initial post may not have been clear enough in its intention - sorry about that. Hopefully the edit is satisfactory. Private messaging in Drupal is apparently dominated by the (impressive) Privatemsg module. Therefore I think this question is helpful for the community. Not everyone wants to take a feature-rich OTB solution and start disabling/removing features/bending it to their use case. If only 25% of what Privatemsg can do is needed, what are the ways this could be built from scratch using D7's basic infrastructure.
    – penname
    Jan 26, 2016 at 13:16
  • "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." I find this unnecessarily heavy-handed of the moderators. This is a helpful question about how to leverage the intrinsic infrastructure of Drupal to accomplish a defined task, and "opinions" from experienced developers would be valuable to all interested - not "spam". Shame to see moderators like this.
    – penname
    Feb 7, 2016 at 22:09

1 Answer 1

3

By default, giving a role the permission to delete messages will not delete the message for the other user. I just tested this and it works as you require.

As for only allowing messages between certain users, you can prepopulate the "To" field with /messages/new/[nid]. So on the user page or in views or whatever, you can create this link using tokens or replacements. Then disable the field with a custom module. Savvy users could change the [nid] in the url or even the html in the page so this depends on how secure it needs to be. They'd need to know another user's nid to be able to do this but they can only know that if they can already view the user.

function CUSTOMMODULENAME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'privatemsg_new') {
    $form['recipient']['#disabled'] = '1';
 }
}
2
  • Thank you for this - I appreciate it. I should have said more clearly in the OP, I know how to do all this with Privatemsg. What I was wondering is if you wanted to achieve the basic functionality (described above) without using Privatemsg what are the ways you might go about this. I think it's a helpful line of enquiry because some might want basic message functionality without using Privatemsg, which as Berdir explains is a large and feature-packed module. Rather than starting with something complex and disabling/removing features, what are the ways to build just the basics? Thanks
    – penname
    Jan 25, 2016 at 18:10
  • 2
    Entity references. Have a content type with an entity reference field for each user. You can prepopulate this field with two or more users. Then have a view that displays these nodes and the users chat in the comments. If you are using rules, you can control access to the nodes or if not, a small custom module. Jan 26, 2016 at 3:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.