Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The privatemsg_roles module does not implement the privatemsg hook to block messages (hook_privatemsg_block_message). This means that you cannot check whether a user can send messages to the role group in the same way you can other recipient types (by using module_invoke_all on that hook).
Comment | File | Size | Author |
---|---|---|---|
#2 | privatemsg-1296372-2-roles_block_hook.patch | 974 bytes | arithmetric |
#1 | privatemsg-1296372-1-roles_block_hook.patch | 946 bytes | arithmetric |
Comments
Comment #1
arithmetric CreditAttribution: arithmetric commentedAttached is a patch for the privatemsg module that adds this hook to privatemsg_roles.
Comment #2
arithmetric CreditAttribution: arithmetric commentedUpdating the patch to clean up the PHP warnings in the test.
Comment #3
BerdirThere is a API function to check recipient type access: http://api.worldempire.ch/api/privatemsg/privatemsg.module/function/priv....
There is however now API function which does all necessary checks to verify if A can write B a message. There is http://api.worldempire.ch/api/privatemsg/privatemsg.module/function/priv... but it's not going to work for roles correctly.
My suggestion would be to extract a generic privatemsg_can_write($author, $recipient) (maybe a better name, maybe multiple recipients) function and use that in privatemsg_get_link(). There are probably also other places where we could use this. Because your patch means that any recipient type would need to implement this hook which is IMHO unecessary code duplication.
Comment #4
arithmetric CreditAttribution: arithmetric commentedFair enough... So in the generic function, we'd need a combination of privatemsg_recipient_access() for the recipient type access checks and an invocation of hook_privatemsg_block_message() for any modules that implement it?
Comment #5
BerdirYes exactly. And additionally a privatemsg_user_access('write privatemsg', $author) might make sense, similar to what privatemsg_get_link() does too. We loose a bit of performance when calling the function multiple times like it could happen in privatemsg_get_link() but it should be minimal and usually the function is only used for a single recipient anyway.
Comment #7
oadaeh CreditAttribution: oadaeh as a volunteer commentedThis issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-1.x branch (bug fixes only) or the 7.x-2.x branch.
Thank you.