fix #26104 : remove global object

This commit is contained in:
Eric Seigne
2023-10-04 00:10:19 +02:00
parent a071adbe0f
commit 563cdcefb3

View File

@@ -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').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'</span><br>';
$url = getOnlineSignatureUrl(0, $type, $ref);
$url = getOnlineSignatureUrl(0, $type, $ref, $obj);
$out .= '<div class="urllink">';
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;