Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2018-03-24 18:28:23 +01:00
commit a1b44651e5
5 changed files with 29 additions and 57 deletions

View File

@ -1038,7 +1038,7 @@ class Ticketsup extends CommonObject
{ {
global $langs; global $langs;
if (count($this->cache_types_tickets)) { if (! empty($this->cache_types_tickets) && count($this->cache_types_tickets)) {
return 0; return 0;
} }
// Cache deja charge // Cache deja charge
@ -1078,7 +1078,7 @@ class Ticketsup extends CommonObject
{ {
global $langs; global $langs;
if (count($this->cache_category_tickets)) { if (! empty($this->cache_category_ticket) && count($this->cache_category_tickets)) {
return 0; return 0;
} }
// Cache deja charge // Cache deja charge
@ -1118,7 +1118,7 @@ class Ticketsup extends CommonObject
{ {
global $langs; global $langs;
if (count($this->cache_severity_tickets)) { if (! empty($this->cache_severity_tickets) && count($this->cache_severity_tickets)) {
return 0; return 0;
} }
// Cache deja charge // Cache deja charge

View File

@ -215,7 +215,7 @@ print '<tr class="liste_titre"><th >' . $langs->trans("Statistics") . ' ' . img_
print '<tr><td>'; print '<tr><td>';
// don't display graph if no series // don't display graph if no series
if (count($dataseries) >1) { if (! empty($dataseries) && count($dataseries) > 1) {
$data = array(); $data = array();
foreach ($dataseries as $key => $value) { foreach ($dataseries as $key => $value) {
$data[] = array($value['label'], $value['data']); $data[] = array($value['label'], $value['data']);

View File

@ -2745,6 +2745,10 @@ class User extends CommonObject
function get_full_tree($deleteafterid=0, $filter='') function get_full_tree($deleteafterid=0, $filter='')
{ {
global $conf, $user; global $conf, $user;
global $hookmanager;
// Actions hooked (by external module)
$hookmanager->initHooks(array('userdao'));
$this->users = array(); $this->users = array();
@ -2754,23 +2758,11 @@ class User extends CommonObject
// Init $this->users array // Init $this->users array
$sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
// TODO add hook // Add fields from hooks
if (! empty($conf->multicompany->enabled)) { $parameters=array();
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook
if (! empty($user->admin) && empty($user->entity)) { if ($reshook > 0) {
if ($conf->entity == 1) { $sql.=$hookmanager->resPrint;
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else { } else {
$sql.= " WHERE u.entity IN (".getEntity('user').")"; $sql.= " WHERE u.entity IN (".getEntity('user').")";
} }

View File

@ -46,6 +46,10 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
$companystatic = new Societe($db); $companystatic = new Societe($db);
$fuserstatic = new User($db); $fuserstatic = new User($db);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$contextpage=array('userhome');
$hookmanager->initHooks($contextpage);
/* /*
* View * View
@ -101,23 +105,11 @@ $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
// TODO add hook // Add fields from hooks
if (! empty($conf->multicompany->enabled)) { $parameters=array();
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook
if (! empty($user->admin) && empty($user->entity)) { if ($reshook > 0) {
if ($conf->entity == 1) { $sql.=$hookmanager->resPrint;
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else { } else {
$sql.= " WHERE u.entity IN (".getEntity('user').")"; $sql.= " WHERE u.entity IN (".getEntity('user').")";
} }

View File

@ -191,23 +191,11 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
// TODO add hook // Add fields from hooks
if (! empty($conf->multicompany->enabled)) { $parameters=array();
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook
if (! empty($user->admin) && empty($user->entity)) { if ($reshook > 0) {
if ($conf->entity == 1) { $sql.=$hookmanager->resPrint;
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else { } else {
$sql.= " WHERE u.entity IN (".getEntity('user').")"; $sql.= " WHERE u.entity IN (".getEntity('user').")";
} }