Debug v18
This commit is contained in:
parent
5dbc1f5529
commit
404a70a2a9
@ -100,6 +100,7 @@ class UserGroup extends CommonObject
|
||||
public $members = array(); // Array of users
|
||||
|
||||
public $nb_rights; // Number of rights granted to the user
|
||||
public $nb_users; // Number of users in the group
|
||||
|
||||
private $_tab_loaded = array(); // Array of cache of already loaded permissions
|
||||
|
||||
@ -151,7 +152,7 @@ class UserGroup extends CommonObject
|
||||
* @param boolean $load_members Load all members of the group
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($id = '', $groupname = '', $load_members = true)
|
||||
public function fetch($id = '', $groupname = '', $load_members = false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -166,7 +167,7 @@ class UserGroup extends CommonObject
|
||||
|
||||
if ($result) {
|
||||
if ($load_members) {
|
||||
$this->members = $this->listUsersForGroup();
|
||||
$this->members = $this->listUsersForGroup(); // This make a lot of subrequests
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -237,7 +238,7 @@ class UserGroup extends CommonObject
|
||||
|
||||
$ret = array();
|
||||
|
||||
$sql = "SELECT u.rowid";
|
||||
$sql = "SELECT u.rowid, u.login, u.lastname, u.firstname, u.photo, u.fk_soc, u.entity, u.employee, u.email";
|
||||
if (!empty($this->id)) {
|
||||
$sql .= ", ug.entity as usergroup_entity";
|
||||
}
|
||||
@ -263,12 +264,23 @@ class UserGroup extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
if (!array_key_exists($obj->rowid, $ret)) {
|
||||
if ($mode != 1) {
|
||||
$newuser = new User($this->db);
|
||||
$newuser->fetch($obj->rowid);
|
||||
//$newuser->fetch($obj->rowid); // We are inside a loop, no subrequests inside a loop
|
||||
$newuser->id = $obj->rowid;
|
||||
$newuser->login = $obj->login;
|
||||
$newuser->photo = $obj->photo;
|
||||
$newuser->lastname = $obj->lastname;
|
||||
$newuser->firstname = $obj->firstname;
|
||||
$newuser->email = $obj->email;
|
||||
$newuser->socid = $obj->fk_soc;
|
||||
$newuser->entity = $obj->entity;
|
||||
$newuser->employee = $obj->employee;
|
||||
|
||||
$ret[$obj->rowid] = $newuser;
|
||||
} else {
|
||||
$ret[$obj->rowid] = $obj->rowid;
|
||||
@ -936,10 +948,10 @@ class UserGroup extends CommonObject
|
||||
$return .= '<div class="info-box-content">';
|
||||
$return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
|
||||
if (property_exists($this, 'members')) {
|
||||
$return .= '<br><span class="info-box-status opacitymedium">'.(!empty($this->members)? $this->members : 0).' '.$langs->trans('Users').'</span>';
|
||||
$return .= '<br><span class="info-box-status opacitymedium">'.(empty($this->nb_users) ? 0 : $this->nb_users).' '.$langs->trans('Users').'</span>';
|
||||
}
|
||||
if (property_exists($this, 'nb_rights')) {
|
||||
$return .= '<br><div class="info-box-status margintoponly opacitymedium">'.$langs->trans('NbOfPermissions').' : '.$this->nb_rights.'</div>';
|
||||
$return .= '<br><div class="info-box-status margintoponly opacitymedium">'.$langs->trans('NbOfPermissions').' : '.(empty($this->nb_rights) ? 0 : $this->nb_rights).'</div>';
|
||||
}
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
|
||||
@ -247,6 +247,7 @@ if (empty($reshook)) {
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$title = $object->name.' - '.$langs->trans("Card");
|
||||
if ($action == 'create') {
|
||||
$title = $langs->trans("NewGroup");
|
||||
@ -309,8 +310,6 @@ if ($action == 'create') {
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($id) {
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
$head = group_prepare_head($object);
|
||||
$title = $langs->trans("Group");
|
||||
|
||||
@ -447,6 +446,8 @@ if ($action == 'create') {
|
||||
print '<td class="liste_titre right" width="5"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$object->fetch($object->id, '', true); // true to force load of all users, member of the group
|
||||
|
||||
if (!empty($object->members)) {
|
||||
foreach ($object->members as $useringroup) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -380,8 +380,8 @@ while ($i < $imaxinloop) {
|
||||
|
||||
$object->name = $obj->name;
|
||||
$object->note = $obj->note;
|
||||
$object->members = $obj->nb;
|
||||
$object->nb_rights = $obj->nbpermissions;
|
||||
$object->nb_users = $obj->nb;
|
||||
|
||||
if ($mode == 'kanban') {
|
||||
if ($i == 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user