Fix: compatibility with multicompany and transverse mode
This commit is contained in:
parent
8b832f475f
commit
3686fad393
@ -145,12 +145,15 @@ class UserGroup extends CommonObject
|
|||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($result))
|
while ($obj = $this->db->fetch_object($result))
|
||||||
|
{
|
||||||
|
if (! array_key_exists($obj->rowid, $ret))
|
||||||
{
|
{
|
||||||
$newgroup=new UserGroup($this->db);
|
$newgroup=new UserGroup($this->db);
|
||||||
$newgroup->fetch($obj->rowid);
|
$newgroup->fetch($obj->rowid);
|
||||||
$newgroup->usergroup_entity = $obj->usergroup_entity;
|
$ret[$obj->rowid]=$newgroup;
|
||||||
|
}
|
||||||
|
|
||||||
$ret[]=$newgroup;
|
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
@ -189,17 +192,21 @@ class UserGroup extends CommonObject
|
|||||||
{
|
{
|
||||||
$sql.= " AND u.entity IN (0,".$conf->entity.")";
|
$sql.= " AND u.entity IN (0,".$conf->entity.")";
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::listUsersForGroup sql=".$sql,LOG_DEBUG);
|
dol_syslog(get_class($this)."::listUsersForGroup sql=".$sql,LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($result))
|
while ($obj = $this->db->fetch_object($result))
|
||||||
|
{
|
||||||
|
if (! array_key_exists($obj->rowid, $ret))
|
||||||
{
|
{
|
||||||
$newuser=new User($this->db);
|
$newuser=new User($this->db);
|
||||||
$newuser->fetch($obj->rowid);
|
$newuser->fetch($obj->rowid);
|
||||||
$newuser->usergroup_entity = $obj->usergroup_entity;
|
$ret[$obj->rowid]=$newuser;
|
||||||
|
}
|
||||||
|
|
||||||
$ret[]=$newuser;
|
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|||||||
@ -1394,8 +1394,17 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||||
{
|
{
|
||||||
$mc->getInfo($group->usergroup_entity);
|
print '<td class="valeur">';
|
||||||
print '<td class="valeur">'.$mc->label."</td>";
|
if (! empty($group->usergroup_entity))
|
||||||
|
{
|
||||||
|
$nb=0;
|
||||||
|
foreach($group->usergroup_entity as $group_entity)
|
||||||
|
{
|
||||||
|
$mc->getInfo($group_entity);
|
||||||
|
print ($nb > 0 ? ', ' : '').$mc->label;
|
||||||
|
$nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
if ($caneditgroup)
|
if ($caneditgroup)
|
||||||
|
|||||||
@ -430,8 +430,18 @@ else
|
|||||||
print '<td>'.$useringroup->firstname.'</td>';
|
print '<td>'.$useringroup->firstname.'</td>';
|
||||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
if (! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
||||||
{
|
{
|
||||||
$mc->getInfo($useringroup->usergroup_entity);
|
print '<td class="valeur">';
|
||||||
print '<td class="valeur">'.$mc->label."</td>";
|
if (! empty($useringroup->usergroup_entity))
|
||||||
|
{
|
||||||
|
$nb=0;
|
||||||
|
foreach($useringroup->usergroup_entity as $group_entity)
|
||||||
|
{
|
||||||
|
$mc->getInfo($group_entity);
|
||||||
|
print ($nb > 0 ? ', ' : '').$mc->label;
|
||||||
|
$nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
}
|
}
|
||||||
print '<td align="center">'.$useringroup->getLibStatut(3).'</td>';
|
print '<td align="center">'.$useringroup->getLibStatut(3).'</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
|||||||
@ -55,7 +55,7 @@ llxHeader();
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("ListOfGroups"));
|
print_fiche_titre($langs->trans("ListOfGroups"));
|
||||||
|
|
||||||
$sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(ugu.rowid) as nb";
|
$sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
|
||||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user