diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php
index db980561127..7eb4f8333c3 100644
--- a/htdocs/core/lib/signature.lib.php
+++ b/htdocs/core/lib/signature.lib.php
@@ -20,11 +20,12 @@
/**
* Return string with full online Url to accept and sign a quote
*
- * @param string $type Type of URL ('proposal', ...)
- * @param string $ref Ref of object
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @param CommonObject $obj object (needed to make multicompany good links)
* @return string Url string
*/
-function showOnlineSignatureUrl($type, $ref)
+function showOnlineSignatureUrl($type, $ref, CommonObject $obj = null)
{
global $langs;
@@ -34,7 +35,7 @@ function showOnlineSignatureUrl($type, $ref)
$servicename = 'Online';
$out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
';
- $url = getOnlineSignatureUrl(0, $type, $ref);
+ $url = getOnlineSignatureUrl(0, $type, $ref, $obj);
$out .= '
';
if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
$out .= $url;
@@ -51,16 +52,27 @@ function showOnlineSignatureUrl($type, $ref)
/**
* Return string with full Url
*
- * @param int $mode 0=True url, 1=Url formated with colors
- * @param string $type Type of URL ('proposal', ...)
- * @param string $ref Ref of object
- * @param string $localorexternal 0=Url for browser, 1=Url for external access
+ * @param int $mode 0=True url, 1=Url formated with colors
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @param string $localorexternal 0=Url for browser, 1=Url for external access
+ * @param CommonObject $obj object (needed to make multicompany good links)
* @return string Url string
*/
-function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
+function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, CommonObject $obj = null)
{
global $conf, $dolibarr_main_url_root;
- global $object;
+
+ if(null === $obj) {
+ //to be compatible with 15.0 -> 19.0
+ global $object;
+ if (empty($object)) {
+ $obj = new CommonObject();
+ } else {
+ dol_syslog(__METHOD__." using global object is deprecated, please give obj as argument", LOG_WARNING);
+ $obj = $object;
+ }
+ }
$ref = str_replace(' ', '', $ref);
$out = '';
@@ -91,7 +103,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $object->entity), '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $obj->entity), '0');
}
/*
if ($mode == 1) {
@@ -121,7 +133,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
// For multicompany
if (!empty($out) && !empty($conf->multicompany->enabled)) {
- $out .= "&entity=".$object->entity; // Check the entity of object because we may have the same reference in several entities
+ $out .= "&entity=".$obj->entity; // Check the entity of object because we may have the same reference in several entities
}
return $out;