Fix: compatibility with multicompany and transverse mode
This commit is contained in:
parent
714fe81abf
commit
05b7dfd97b
@ -146,11 +146,14 @@ class UserGroup extends CommonObject
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($result))
|
||||
{
|
||||
$newgroup=new UserGroup($this->db);
|
||||
$newgroup->fetch($obj->rowid);
|
||||
$newgroup->usergroup_entity = $obj->usergroup_entity;
|
||||
if (! array_key_exists($obj->rowid, $ret))
|
||||
{
|
||||
$newgroup=new UserGroup($this->db);
|
||||
$newgroup->fetch($obj->rowid);
|
||||
$ret[$obj->rowid]=$newgroup;
|
||||
}
|
||||
|
||||
$ret[]=$newgroup;
|
||||
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
@ -181,7 +184,7 @@ class UserGroup extends CommonObject
|
||||
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE ug.fk_user = u.rowid";
|
||||
$sql.= " AND ug.fk_usergroup = ".$this->id;
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$sql.= " AND u.entity IS NOT NULL";
|
||||
}
|
||||
@ -189,17 +192,21 @@ class UserGroup extends CommonObject
|
||||
{
|
||||
$sql.= " AND u.entity IN (0,".$conf->entity.")";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::listUsersForGroup sql=".$sql,LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($result))
|
||||
{
|
||||
$newuser=new User($this->db);
|
||||
$newuser->fetch($obj->rowid);
|
||||
$newuser->usergroup_entity = $obj->usergroup_entity;
|
||||
if (! array_key_exists($obj->rowid, $ret))
|
||||
{
|
||||
$newuser=new User($this->db);
|
||||
$newuser->fetch($obj->rowid);
|
||||
$ret[$obj->rowid]=$newuser;
|
||||
}
|
||||
|
||||
$ret[]=$newuser;
|
||||
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
@ -1394,8 +1394,17 @@ else
|
||||
print '</td>';
|
||||
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">'.$mc->label."</td>";
|
||||
print '<td class="valeur">';
|
||||
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">';
|
||||
if ($caneditgroup)
|
||||
|
||||
@ -354,7 +354,7 @@ else
|
||||
|
||||
if (! empty($object->members))
|
||||
{
|
||||
if( !($conf->multicompany->enabled && $conf->multicompany->transverse_mode))
|
||||
if (! ($conf->multicompany->enabled && $conf->multicompany->transverse_mode))
|
||||
{
|
||||
foreach($object->members as $useringroup)
|
||||
{
|
||||
@ -404,7 +404,7 @@ else
|
||||
print '<td class="liste_titre">'.$langs->trans("Login").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Firstname").'</td>';
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
||||
{
|
||||
print '<td class="liste_titre">'.$langs->trans("Entity").'</td>';
|
||||
}
|
||||
@ -428,10 +428,20 @@ else
|
||||
print '</td>';
|
||||
print '<td>'.$useringroup->lastname.'</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">'.$mc->label."</td>";
|
||||
print '<td class="valeur">';
|
||||
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="right">';
|
||||
|
||||
@ -55,10 +55,10 @@ llxHeader();
|
||||
|
||||
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.= " 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)))
|
||||
{
|
||||
$sql.= " WHERE g.entity IS NOT NULL";
|
||||
}
|
||||
@ -100,13 +100,13 @@ if ($resql)
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.'</a>';
|
||||
if (!$obj->entity)
|
||||
if (! $obj->entity)
|
||||
{
|
||||
print img_picto($langs->trans("GlobalGroup"),'redstar');
|
||||
}
|
||||
print "</td>";
|
||||
//multicompany
|
||||
if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
{
|
||||
$mc->getInfo($obj->entity);
|
||||
print '<td align="center">'.$mc->label.'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user