Fix Fatal error with bad triggers
This commit is contained in:
parent
68512e0281
commit
6ec5dd02b6
@ -328,48 +328,59 @@ class Interfaces
|
||||
continue;
|
||||
}
|
||||
|
||||
$objMod = new $modName($db);
|
||||
try {
|
||||
$objMod = new $modName($db);
|
||||
|
||||
// Define disabledbyname and disabledbymodule
|
||||
$disabledbyname = 0;
|
||||
$disabledbymodule = 1;
|
||||
$module = '';
|
||||
if (is_subclass_of($objMod, 'DolibarrTriggers'))
|
||||
{
|
||||
// Define disabledbyname and disabledbymodule
|
||||
$disabledbyname = 0;
|
||||
$disabledbymodule = 1;
|
||||
$module = '';
|
||||
|
||||
// Check if trigger file is disabled by name
|
||||
if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1;
|
||||
// Check if trigger file is for a particular module
|
||||
if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg))
|
||||
{
|
||||
$module = preg_replace('/^mod/i', '', $reg[2]);
|
||||
$constparam = 'MAIN_MODULE_'.strtoupper($module);
|
||||
if (strtolower($module) == 'all') $disabledbymodule = 0;
|
||||
elseif (empty($conf->global->$constparam)) $disabledbymodule = 2;
|
||||
$triggers[$j]['module'] = strtolower($module);
|
||||
// Check if trigger file is disabled by name
|
||||
if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1;
|
||||
// Check if trigger file is for a particular module
|
||||
if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg))
|
||||
{
|
||||
$module = preg_replace('/^mod/i', '', $reg[2]);
|
||||
$constparam = 'MAIN_MODULE_'.strtoupper($module);
|
||||
if (strtolower($module) == 'all') $disabledbymodule = 0;
|
||||
elseif (empty($conf->global->$constparam)) $disabledbymodule = 2;
|
||||
$triggers[$j]['module'] = strtolower($module);
|
||||
}
|
||||
|
||||
// We set info of modules
|
||||
$triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "') : img_object('', 'generic', 'class="valignmiddle pictomodule "');
|
||||
$triggers[$j]['file'] = $files[$key];
|
||||
$triggers[$j]['fullpath'] = $fullpath[$key];
|
||||
$triggers[$j]['relpath'] = $relpath[$key];
|
||||
$triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
|
||||
$triggers[$j]['version'] = $objMod->getVersion();
|
||||
$triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
|
||||
if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = '';
|
||||
|
||||
$text = '<b>'.$langs->trans("Description").':</b><br>';
|
||||
$text .= $objMod->getDesc().'<br>';
|
||||
$text .= '<br><b>'.$langs->trans("Status").':</b><br>';
|
||||
if ($disabledbyname == 1)
|
||||
{
|
||||
$text .= $langs->trans("TriggerDisabledByName").'<br>';
|
||||
if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>';
|
||||
if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>';
|
||||
if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
print 'Error: Trigger '.$modName.' does not extends DolibarrTriggers<br>';
|
||||
}
|
||||
}
|
||||
|
||||
// We set info of modules
|
||||
$triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "') : img_object('', 'generic', 'class="valignmiddle pictomodule "');
|
||||
$triggers[$j]['file'] = $files[$key];
|
||||
$triggers[$j]['fullpath'] = $fullpath[$key];
|
||||
$triggers[$j]['relpath'] = $relpath[$key];
|
||||
$triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
|
||||
$triggers[$j]['version'] = $objMod->getVersion();
|
||||
$triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
|
||||
if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = '';
|
||||
|
||||
$text = '<b>'.$langs->trans("Description").':</b><br>';
|
||||
$text .= $objMod->getDesc().'<br>';
|
||||
$text .= '<br><b>'.$langs->trans("Status").':</b><br>';
|
||||
if ($disabledbyname == 1)
|
||||
{
|
||||
$text .= $langs->trans("TriggerDisabledByName").'<br>';
|
||||
if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>';
|
||||
if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>';
|
||||
if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
|
||||
catch(Exception $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
|
||||
$triggers[$j]['info'] = $text;
|
||||
|
||||
@ -2295,9 +2295,11 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
{
|
||||
print img_object($alttext, 'generic', 'class="inline-block valignmiddle"');
|
||||
}
|
||||
print '<span class="info-box-icon-version" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';
|
||||
print $this->getVersion(1);
|
||||
print '</span>';
|
||||
if ($this->isCoreOrExternalModule() == 'external') {
|
||||
print '<span class="info-box-icon-version" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';
|
||||
print $this->getVersion(1);
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
/*print '<span class="info-box-icon-action">';
|
||||
print '<div class="valignmiddle inline-block">';
|
||||
@ -2313,7 +2315,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
|
||||
print '</div>
|
||||
<div class="info-box-content info-box-text-module">
|
||||
<span class="info-box-title">'.$this->getName().'</span>
|
||||
<span class="info-box-title marginbottomonly">'.$this->getName().'</span>
|
||||
<span class="info-box-desc twolinesmax opacitymedium" title="'.dol_escape_htmltag($this->getDesc()).'">'.nl2br($this->getDesc()).'</span>';
|
||||
|
||||
/*print '<span class="info-box-icon-version" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';
|
||||
|
||||
@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||
/**
|
||||
* Class of triggers for stripe module
|
||||
*/
|
||||
class InterfaceStripe
|
||||
class InterfaceStripe extends DolibarrTriggers
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
|
||||
@ -8,7 +8,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
|
||||
*/
|
||||
|
||||
.info-box-module-external span.info-box-icon-version {
|
||||
background: #999;
|
||||
background: #bbb;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
@ -74,7 +74,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
font-size: 25px;
|
||||
line-height: 80px;
|
||||
line-height: 100px;
|
||||
}
|
||||
.info-box-module .info-box-icon {
|
||||
height: 106px;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user