mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
Fix code comment and missing showLinkToObjectBlock hook declaration as
an addreplace hook.
This commit is contained in:
@@ -2554,9 +2554,9 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if (! empty($this->linkedObjectsIds))
|
if (! empty($this->linkedObjectsIds))
|
||||||
{
|
{
|
||||||
foreach($this->linkedObjectsIds as $objecttype => $objectids)
|
foreach($this->linkedObjectsIds as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...)
|
||||||
{
|
{
|
||||||
// Parse element/subelement (ex: project_task)
|
// Parse element/subelement (ex: project_task, cabinetmed_consultation, ...)
|
||||||
$module = $element = $subelement = $objecttype;
|
$module = $element = $subelement = $objecttype;
|
||||||
if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier'
|
if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier'
|
||||||
&& preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
&& preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||||
@@ -2621,7 +2621,7 @@ abstract class CommonObject
|
|||||||
if ($conf->$module->enabled && (($element != $this->element) || $alsosametype))
|
if ($conf->$module->enabled && (($element != $this->element) || $alsosametype))
|
||||||
{
|
{
|
||||||
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||||
//print '/'.$classpath.'/'.$classfile.'.class.php';
|
//print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname);
|
||||||
if (class_exists($classname))
|
if (class_exists($classname))
|
||||||
{
|
{
|
||||||
foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element
|
foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class HookManager
|
|||||||
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||||
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||||
* All types can also return some values into an array ->results.
|
* All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller.
|
||||||
* $this->error or this->errors are also defined by class called by this function if error.
|
* $this->error or this->errors are also defined by class called by this function if error.
|
||||||
*/
|
*/
|
||||||
function executeHooks($method, $parameters=false, &$object='', &$action='')
|
function executeHooks($method, $parameters=false, &$object='', &$action='')
|
||||||
@@ -172,11 +172,11 @@ class HookManager
|
|||||||
'printObjectSubLine',
|
'printObjectSubLine',
|
||||||
'createDictionaryFieldList',
|
'createDictionaryFieldList',
|
||||||
'editDictionaryFieldlist',
|
'editDictionaryFieldlist',
|
||||||
'getFormMail'
|
'getFormMail',
|
||||||
|
'showLinkToObjectBlock'
|
||||||
)
|
)
|
||||||
)) $hooktype='addreplace';
|
)) $hooktype='addreplace';
|
||||||
// Deprecated hook types ('returnvalue')
|
|
||||||
//if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks.
|
|
||||||
if ($method == 'insertExtraFields')
|
if ($method == 'insertExtraFields')
|
||||||
{
|
{
|
||||||
$hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
|
$hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
|
||||||
|
|||||||
@@ -5391,6 +5391,7 @@ class Form
|
|||||||
global $noMoreLinkedObjectBlockAfter;
|
global $noMoreLinkedObjectBlockAfter;
|
||||||
$noMoreLinkedObjectBlockAfter=1;
|
$noMoreLinkedObjectBlockAfter=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
|
$res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
@@ -5440,6 +5441,26 @@ class Form
|
|||||||
'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc = ".$object->thirdparty->id)
|
'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc = ".$object->thirdparty->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
global $action;
|
||||||
|
|
||||||
|
// Can complet the possiblelink array
|
||||||
|
$hookmanager->initHooks(array('commonobject'));
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('showLinkToObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (is_array($hookmanager->resArray) && count($hookmanager->resArray))
|
||||||
|
{
|
||||||
|
$possiblelinks=array_merge($possiblelinks, $hookmanager->resArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook > 0)
|
||||||
|
{
|
||||||
|
if (is_array($hookmanager->resArray) && count($hookmanager->resArray))
|
||||||
|
{
|
||||||
|
$possiblelinks=$hookmanager->resArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach($possiblelinks as $key => $possiblelink)
|
foreach($possiblelinks as $key => $possiblelink)
|
||||||
{
|
{
|
||||||
@@ -5451,6 +5472,7 @@ class Form
|
|||||||
{
|
{
|
||||||
print '<div id="'.$key.'list"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
|
print '<div id="'.$key.'list"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
|
||||||
$sql = $possiblelink['sql'];
|
$sql = $possiblelink['sql'];
|
||||||
|
|
||||||
$resqllist = $this->db->query($sql);
|
$resqllist = $this->db->query($sql);
|
||||||
if ($resqllist)
|
if ($resqllist)
|
||||||
{
|
{
|
||||||
@@ -5466,7 +5488,7 @@ class Form
|
|||||||
print '<td class="nowrap"></td>';
|
print '<td class="nowrap"></td>';
|
||||||
print '<td align="center">' . $langs->trans("Ref") . '</td>';
|
print '<td align="center">' . $langs->trans("Ref") . '</td>';
|
||||||
print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
|
print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
|
||||||
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
|
print '<td align="right">' . $langs->trans("AmountHTShort") . '</td>';
|
||||||
print '<td align="left">' . $langs->trans("Company") . '</td>';
|
print '<td align="left">' . $langs->trans("Company") . '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@@ -5480,7 +5502,7 @@ class Form
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td align="center">' . $objp->ref . '</td>';
|
print '<td align="center">' . $objp->ref . '</td>';
|
||||||
print '<td>' . $objp->ref_client . '</td>';
|
print '<td>' . $objp->ref_client . '</td>';
|
||||||
print '<td>' . price($objp->total_ht) . '</td>';
|
print '<td align="right">' . price($objp->total_ht) . '</td>';
|
||||||
print '<td>' . $objp->name . '</td>';
|
print '<td>' . $objp->name . '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user