diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index e201f1ab5bd..76902714a9e 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -1038,7 +1038,7 @@ class Ticketsup extends CommonObject { global $langs; - if (count($this->cache_types_tickets)) { + if (! empty($this->cache_types_tickets) && count($this->cache_types_tickets)) { return 0; } // Cache deja charge @@ -1078,7 +1078,7 @@ class Ticketsup extends CommonObject { global $langs; - if (count($this->cache_category_tickets)) { + if (! empty($this->cache_category_ticket) && count($this->cache_category_tickets)) { return 0; } // Cache deja charge @@ -1118,7 +1118,7 @@ class Ticketsup extends CommonObject { global $langs; - if (count($this->cache_severity_tickets)) { + if (! empty($this->cache_severity_tickets) && count($this->cache_severity_tickets)) { return 0; } // Cache deja charge diff --git a/htdocs/ticketsup/index.php b/htdocs/ticketsup/index.php index 8881b8c3ad2..b98a81f204e 100644 --- a/htdocs/ticketsup/index.php +++ b/htdocs/ticketsup/index.php @@ -215,7 +215,7 @@ print '' . $langs->trans("Statistics") . ' ' . img_ print ''; // don't display graph if no series -if (count($dataseries) >1) { +if (! empty($dataseries) && count($dataseries) > 1) { $data = array(); foreach ($dataseries as $key => $value) { $data[] = array($value['label'], $value['data']); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f3c8f03329f..bf9ff370e11 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2744,7 +2744,11 @@ class User extends CommonObject */ 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(); @@ -2754,23 +2758,11 @@ class User extends CommonObject // 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.= " FROM ".MAIN_DB_PREFIX."user as u"; - // TODO add hook - if (! empty($conf->multicompany->enabled)) { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (! empty($user->admin) && empty($user->entity)) { - if ($conf->entity == 1) { - $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').")"; - } + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $sql.=$hookmanager->resPrint; } else { $sql.= " WHERE u.entity IN (".getEntity('user').")"; } diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 0a4cb253c0f..ac14f6b0243 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -46,6 +46,10 @@ if ($user->societe_id > 0) $socid = $user->societe_id; $companystatic = new Societe($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 @@ -101,23 +105,11 @@ $sql.= ", s.code_client"; $sql.= ", s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; -// TODO add hook -if (! empty($conf->multicompany->enabled)) { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (! empty($user->admin) && empty($user->entity)) { - if ($conf->entity == 1) { - $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').")"; - } +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook +if ($reshook > 0) { + $sql.=$hookmanager->resPrint; } else { $sql.= " WHERE u.entity IN (".getEntity('user').")"; } @@ -225,7 +217,7 @@ if ($canreadperms) $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) + if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 704c04d2593..4d83903d0aa 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -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)"; $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"; -// TODO add hook -if (! empty($conf->multicompany->enabled)) { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (! empty($user->admin) && empty($user->entity)) { - if ($conf->entity == 1) { - $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').")"; - } +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook +if ($reshook > 0) { + $sql.=$hookmanager->resPrint; } else { $sql.= " WHERE u.entity IN (".getEntity('user').")"; }