Hi, I use DA for a multisite homepage - and it works great!! Thank you for this software.

Yesterday I started with the integration of a new component. "mass contact". Mass contact sents mails to user groups defined by roles.
Now I recognized, that using mass contact, mails are really sent to ALL users of a role - not limited by the DA settings.
Is there any way or hints, how to insert the DA rights to roles? I don't want to create 100dred of extra roles (each role for each domain).

Kind regards

Kai

Comments

vistree’s picture

Hi,
I found out now, how recipients are build by mass contact. Now I have to extend the sql query with a domain access part. I need to know how to limit the result by the users which are member of the "current domain" - the domain, the sender is logged in.
Can anyone help me to find the correct tables?

Kind regards

Kai

    global $user;

    // Create the recipient list.
    $recipientouta = array();
    $roles = explode(',', $contact->recipients);
    foreach ($roles as $r) {
      if ($r == 2) { // all users
        $recipients = db_query("SELECT name, mail, uid FROM {users} WHERE status <> %d AND uid > %d", 0, 0);
        while ($obj = db_fetch_object($recipients)) {
          $rname = $obj->name;
          $rmail = $obj->mail;
          $ruid = $obj->uid;
          if ($rname != $user->name && !$uidooa[$ruid]) {
//          if (!$uidooa[$ruid]) {
            $recipientouta[$rname] = $rmail;
          }
        }
        break;
      }
      else {
        // Get from users_roles, then role -> user.
        $uids = db_query("SELECT ur.uid FROM {users_roles} ur LEFT JOIN {users} u ON ur.uid = u.uid WHERE ur.rid = %d AND u.status <> %d", $r, 0);
        while ($obj = db_fetch_object($uids))  {
          $ruid = $obj->uid;
          $userobj = db_fetch_object(db_query("SELECT name, mail FROM {users} WHERE uid = %d", $ruid));
          $rname = $userobj->name;
          $rmail = $userobj->mail;
          if (isset($uidooa[$ruid])) {
            if ($rname != $user->name && !$uidooa[$ruid]) {
//            if (!$uidooa[$ruid]) {
              $recipientouta[$rname] = $rmail;
            }
          }
          else {
            if ($rname != $user->name) {
              $recipientouta[$rname] = $rmail;
            }
          }
        }
      }
    }
agentrickard’s picture

Users are tracked as "members" of the domain that they registered from, unless this setting is overridden (either manually or through the User defaults settings tab).

You want the {domain_editor} table, which maps UID to DOMAIN_ID.

vistree’s picture

Hi agentrickard,
yes, this is exactly the table I need ;-) Now I just need to know, how to get the ID of the current domain the user is looged in. Is there a token-value or php-value I can use?

Kind regards

Kai

agentrickard’s picture

Users are not 'logged in' to a domain. You can read the value of the current domain in the $_domain global variable.

See the README.txt, section 7, which explains all this, including the database schema.

vistree’s picture

Status: Active » Fixed

Thank you - I will check the readme.

Kind regards

Kai

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.