New: A box can use a "or" on module conditions

This commit is contained in:
Laurent Destailleur 2013-08-02 14:54:22 +02:00
parent a144b1307b
commit c18fed7e4c

View File

@ -127,17 +127,29 @@ class InfoBox
$box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id);
$box->note = (empty($obj->note) ? '' : $obj->note); $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; $enabled=$box->enabled;
if (isset($box->depends) && count($box->depends) > 0) if (isset($box->depends) && count($box->depends) > 0)
{ {
foreach($box->depends as $module) foreach($box->depends as $moduleelem)
{ {
//print $boxname.'-'.$module.'<br>'; $arrayelem=explode('|',$moduleelem);
$tmpmodule=preg_replace('/@[^@]+/','',$module); $tmpenabled=0; // $tmpenabled is used for the '|' test (OR)
if (empty($conf->$tmpmodule->enabled)) $enabled=0; 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; //print 'xx module='.$module.' enabled='.$enabled;
if ($enabled) $boxes[]=$box; if ($enabled) $boxes[]=$box;