New: A box can use a "or" on module conditions
This commit is contained in:
parent
a144b1307b
commit
c18fed7e4c
@ -127,18 +127,30 @@ class InfoBox
|
||||
$box->box_id = (empty($obj->box_id) ? '' : $obj->box_id);
|
||||
$box->note = (empty($obj->note) ? '' : $obj->note);
|
||||
|
||||
// Filter on box->enabled (used for example by box_comptes) and box->depends
|
||||
// Filter on box->enabled (used for example by box_comptes)
|
||||
// Filter also on box->depends. Example: array("product|service") or array("contrat", "service")
|
||||
$enabled=$box->enabled;
|
||||
if (isset($box->depends) && count($box->depends) > 0)
|
||||
{
|
||||
foreach($box->depends as $module)
|
||||
foreach($box->depends as $moduleelem)
|
||||
{
|
||||
//print $boxname.'-'.$module.'<br>';
|
||||
$tmpmodule=preg_replace('/@[^@]+/','',$module);
|
||||
if (empty($conf->$tmpmodule->enabled)) $enabled=0;
|
||||
$arrayelem=explode('|',$moduleelem);
|
||||
$tmpenabled=0; // $tmpenabled is used for the '|' test (OR)
|
||||
foreach($arrayelem as $module)
|
||||
{
|
||||
$tmpmodule=preg_replace('/@[^@]+/','',$module);
|
||||
if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1;
|
||||
//print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
|
||||
}
|
||||
if (empty($tmpenabled)) // We found at least one module required that disabled
|
||||
{
|
||||
$enabled=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//print '=>'.$boxname.'-enabled='.$enabled.'<br>';
|
||||
|
||||
//print 'xx module='.$module.' enabled='.$enabled;
|
||||
if ($enabled) $boxes[]=$box;
|
||||
else unset($box);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user