diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 89f3700c4f7..888debef0e0 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -172,7 +172,6 @@ $elementList['user']=$langs->trans('MailToUser');
$elementList['all'] =$langs->trans('VisibleEverywhere');
$elementList['none']=$langs->trans('VisibleNowhere');
-
$parameters=array('elementList'=>$elementList);
$reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook == 0) {
@@ -726,10 +725,10 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
- print '
';
-
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
{
+ print '
';
+
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@@ -787,10 +786,21 @@ if ($resql)
print ' | ';
}
}
+
+ print "
\n";
}
else
{
- $tmpaction = 'view';
+ $keyforobj='type_template';
+ if (! in_array($obj->$keyforobj, array_keys($elementList)))
+ {
+ $i++;
+ continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
+ }
+
+ print '';
+
+ $tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@@ -876,7 +886,6 @@ if ($resql)
}
print '';
-
/*
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
@@ -904,8 +913,9 @@ if ($resql)
}
}*/
+
+ print "
\n";
}
- print "\n";
$i++;