Fix: check if multicompany object exists

This commit is contained in:
Regis Houssin 2018-07-03 14:11:00 +02:00
parent f93f5bd6e0
commit 0bb7f84f87

View File

@ -88,7 +88,7 @@ $user = new User($db);
$user->fetch(5); $user->fetch(5);
$user->getrights(); $user->getrights();
if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled)) { if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabled) && is_object($mc)) {
$sql = "SELECT entity"; $sql = "SELECT entity";
$sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service = '".$db->escape($service)."' and tokenstring = '%".$db->escape($event->account)."%'"; $sql.= " WHERE service = '".$db->escape($service)."' and tokenstring = '%".$db->escape($event->account)."%'";
@ -102,10 +102,12 @@ if (! empty($conf->multicompany->enabled) && ! empty($conf->stripeconnect->enabl
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$key=$obj->entity; $key=$obj->entity;
} }
else {$key=1; else {
$key=1;
} }
} }
else {$key=1; else {
$key=1;
} }
$ret=$mc->switchEntity($key); $ret=$mc->switchEntity($key);
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");