From cf92f704d8a6cc634369560ee25e7c6a89313318 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 13 Jul 2015 09:54:26 +0200 Subject: [PATCH] Fix: avoid error if $mc object not exists TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! --- htdocs/user/card.php | 3 ++- htdocs/user/home.php | 29 +++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 102d275b968..6332aab4794 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2195,7 +2195,8 @@ else } // Multicompany - if (! empty($conf->multicompany->enabled)) + // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! + if (! empty($conf->multicompany->enabled) && is_object($mc)) { if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { diff --git a/htdocs/user/home.php b/htdocs/user/home.php index cb700b9701e..d14c9b8fb21 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -180,21 +180,18 @@ if ($resql) $entity=$obj->entity; $entitystring=''; // TODO Set of entitystring should be done with a hook - if (is_object($mc)) - { - if (! empty($conf->multicompany->enabled)) - { - if (empty($entity)) - { - $entitystring=$langs->trans("AllEntities"); - } - else - { - $mc->getInfo($entity); - $entitystring=$mc->label; - } - } - } + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($entity)) + { + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; + } + } print ($entitystring?' ('.$entitystring.')':''); print ''; @@ -259,7 +256,7 @@ if ($canreadperms) print img_picto($langs->trans("GlobalGroup"),'redstar'); } print ""; - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); print '';