How does the user resolution work

ulf1 - May 27, 2009 - 15:41
Project:Listhandler
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hello,

I have a question about how subscribed users are being detected, and how it is suppose to work.

-Assume you have a mailing list M within mailman where user A is not!! subscribed.
-Also assume you have a forum F connected to M through modules "listhandler" and "mailhandler" and mailman_manager.

Now the question is, what is the expected behavior if user A logs in to drupal and posts a topic or replies in forum M.

What happens on my system is that the forum posting still goes to the mailing list M (and because user A is not subscribed, the email causes an error response).
Is this correct or how is it suppose to work?

I have to add that I wrote and use smartlist_manager instead of mailman manager. So maybe there is something going on that I do not know about yet.

Thanks,
Ulf

#1

ulf1 - May 27, 2009 - 15:43

syntax error. It should be

"Now the question is, what is the expected behavior if user A logs in to drupal and posts a topic or replies in forum F ?"

#2

samuelet - May 28, 2009 - 08:26

Listhandler can't know if a user is subscribed or not to a list, so any post will be sent as mail to the email list (then the list manager , in the next stage, will manage it).
The only workaround i know is to assign a role to subscribed users and give the write permission them only on the forum F with some access module (forum_access or tac_lite).
This could require unmanageable manual syncronizations if your user subscriptions are managed directly by the list manager (via web interface or command line or whatelse).
It could be easyer if you are able to manage them inside drupal only, abstracting the list manager subscription process, but i don't know any modules to achieve this except for the mailman modules mailman_manager and User Mailman Register.

#3

ulf1 - May 28, 2009 - 18:49

Thanks for your detailed answer.

I created the smartlist_manager module which works internally similar to the mailman_manager module.

To get this working, I am thinking about something like a callback function that the list manager calls. Only if the function returns "true" the email will be forwarded to the list manager with the users email. If it returns false, it uses the "anon" email account.
Then mailman manager and smartlist_manager can implement the method to determine if a user is part of the mailing list or not. And of course the function should be able to handle admin and anonymous forum posts.

What do you think about this idea?
I am willing to provide some code/patch to make that work.

Cheers,
Ulf

#4

philipnet - May 28, 2009 - 19:32
Component:Documentation» Code
Category:support request» feature request

I think that idea sounds workable.

If you can provide some code and an idea of your setup (so that I can test it!) I'm willing to commit it.

Regards.

Phil.

#5

samuelet - May 29, 2009 - 09:42

Well, it could be sufficent to know if a user is subscribed to a list before sending the post.
mailman_manager can do with _mailman_manager_get_subscriptions.
but it's not full reliable in this, i.e #351067: Unsubscribing via email not reflected in Mailman_Manager.
user_mailman_register is good for this as it can retrive the real status with _user_mailman_register_get_subscriptions.
Don't know about smartlist_manager.

Just an idea, pheraps the implementation could be done with hooks:
Before a user send a forum message, Listhandler could invoke an hook (using the forum id as argument) which retrives the forum post validation from external modules like those above mentioned.
Modules could make validation providing a configuration to assign mailing lists to forum (better in the listhandler configuration itself with form alteration) and the listhandler hook, which will check for user subscription status for the list assigned to the forum id passed by listhandler sending true/false to allow/deny the post.

#6

ulf1 - May 31, 2009 - 21:31

I was also thinking down the line. with two differences:

I used the mailing list adress instead the forum id to pass to the hook, because the mailing list address is known to the mailman_manager and the listhandler. That way I do not need to alter the list handler configuration.

Secondly, the code allows posts to the forum, but before sending the post to the mailing list it verifies the user and if it does not exist it still sends the email, but uses the anonymous account.
Of course it would be perfect when there would be a configuration setting in listhandler to decide when the check is being done in list handler and what the outcome would be. I did not go down that path though, and the following solution works for me.

Besides the listhandler patch that I attached, here the code that I added to my smartlist_manager module to do the actual check if the user is subscribed to the mailing list. It could be added to mailman_manager as well:

//copied from listhandler module
define('ERR_LISTHANDLER_WRONG_HOOK', -98);

/**
* implementation of hook_listhandler_user
* @param $op is the kind of operation
* @param $usr is the user object being passed in (could be anonymous)
* @param $mailinglist string is the mailinglist we refering to.
*/
function smartlist_manager_listhandler_user($op, $usr, $mailinglist)
{
  switch ($op)
  {
    case 'exists':
      if (!$usr->uid) {
        return false; //anonymous user
      }
      else
      {
        $lists = _smartlist_manager_get_lists();

        if (count($lists) == 0)
          return ERR_LISTHANDLER_WRONG_HOOK;

        foreach ($lists as $list) {
          if ($list['name'] == $mailinglist)
          {
            $subscrip = _smartlist_manager_get_subscriptions($usr->uid, $list['lid']);
            if ($subscrip['lstatus'] == 0)
              return false; //the user that posted the topic is not part of the mailing list.
            else
              return true;
          }
        }
        //could not find any matching mailing list.
        return ERR_LISTHANDLER_WRONG_HOOK;
      }
      break;
  }

  return ERR_LISTHANDLER_WRONG_HOOK;
}

AttachmentSize
listhandler_1.patch 4.27 KB
 
 

Drupal is a registered trademark of Dries Buytaert.