Joomlatools Support Center

Patch - Get user data from Community Builder

Hi.

This patch is getting info from Community Builder database fields, in this case the "Company" (and also email, but from Joomla Users database) of each user; this way, we can assign users to groups by Company, because when you have +10000 users, it is very hard to sort them only by ID/name...

---

I've modified:

/administrator/components/com_docman/includes/groups.php

From:

    // get selected members
    if ($row->groups_members) {
        $database->setQuery("SELECT id,name,username, block "
                . "\n FROM jos_users "
                . "\n WHERE id IN (" . $row->groups_members . ")"
                . "\n ORDER BY block ASC, name ASC"
            );
        $usersInGroup = $database->loadObjectList();

        foreach($usersInGroup as $user) {
            $musers[] = JHTML::_('select.option',$user->id,
                    $user->id . "-" . $user->name . " (" . $user->username . ")"
                    . ($user->block ? ' - ['._DML_USER_BLOCKED.']':'')
                    );
        }

    }
    // get non selected members
    $query = "SELECT id,name,username, block FROM jos_users ";
    if ($row->groups_members) {
        $query .= "\n WHERE id NOT IN (" . $row->groups_members . ")" ;
    }
    $query .= "\n ORDER BY block ASC, name ASC";
    $database->setQuery($query);
    $usersToAdd = $database->loadObjectList();
    foreach($usersToAdd as $user) {
        $toAddUsers[] = JHTML::_('select.option',$user->id,
                        $user->id . "-" . $user->name . " (" . $user->username . ")"
                        . ($user->block ? ' - ['._DML_USER_BLOCKED.']':'')
                        );
    }

To:

    // get selected members
    if ($row->groups_members) {
    $database->setQuery("SELECT a.id,a.name,a.username,a.block,a.email,b.id,b.cb_company"
        . "\n FROM jos_users a,jos_comprofiler b"
        . "\n WHERE a.id=b.id AND a.id IN (" . $row->groups_members . ")"
        . "\n ORDER BY a.block ASC, b.cb_company ASC, a.name ASC"
            );
        $usersInGroup = $database->loadObjectList();

        foreach($usersInGroup as $user) {
            $musers[] = JHTML::_('select.option',$user->id,
          $user->cb_company . " - " . $user->name . " (" . $user->email . ")"
                    . ($user->block ? ' - ['._DML_USER_BLOCKED.']':'')
                    );
        }

    }
  
    // get non selected members
$query = "SELECT a.id,a.name,a.username,a.block,a.email,b.id,b.cb_company FROM jos_users a,jos_comprofiler b WHERE a.id=b.id ";
if ($row->groups_members) {
    $query .= "\n AND a.id NOT IN (" . $row->groups_members . ")" ;
}
$query .= "\n ORDER BY a.block ASC, b.cb_company ASC, a.name ASC";
$database->setQuery($query);
$usersToAdd = $database->loadObjectList();
foreach($usersToAdd as $user) {
    $toAddUsers[] = JHTML::_('select.option',$user->id,
                    $user->cb_company . "-" . $user->name . " (" . $user->username . ")"
                    . ($user->block ? ' - ['._DML_USER_BLOCKED.']':'')
                    );
}

Answer

Posted 7 years ago by Carlos Ferreira

It is getting infos from Community Builder database fields, in this case the "Company" (and also email, but from Joomla Users database) of each user; this way, we can assign users to groups by Company, because when you have +10000 users, it is very hard to sort them only by ID/name...

There are 3 more comments in this ticket.
Subscribe or login to join the discussion!

Carlos Ferreira
27.12.12
Answered

System Information

n/a
n/a
n/a
n/a