Fix: add condition in remove tab

Fix: dont add a remove tab
Fix: uniform code
This commit is contained in:
Regis Houssin 2011-12-20 18:47:35 +08:00
parent 8032f25487
commit 2548a817cb
2 changed files with 69 additions and 74 deletions

View File

@ -89,24 +89,22 @@ function societe_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'thirdparty'); complete_head_from_modules($conf,$langs,$object,$head,$h,'thirdparty');
// Notes
if ($user->societe_id == 0) if ($user->societe_id == 0)
{ {
// Notes
$head[$h][0] = DOL_URL_ROOT.'/societe/socnote.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/socnote.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
}
// Attached files // Attached files
if ($user->societe_id == 0)
{
$head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Documents"); $head[$h][1] = $langs->trans("Documents");
$head[$h][2] = 'document'; $head[$h][2] = 'document';
$h++; $h++;
}
// Notifications // Notifications
if (! empty($conf->notification->enabled) && $user->societe_id == 0) if (! empty($conf->notification->enabled))
{ {
$head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Notifications"); $head[$h][1] = $langs->trans("Notifications");
@ -115,8 +113,6 @@ function societe_prepare_head($object)
} }
// Log // Log
if ($user->societe_id == 0)
{
$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info'; $head[$h][2] = 'info';

View File

@ -4313,12 +4313,11 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
{ {
$values=explode(':',$value); $values=explode(':',$value);
if ($mode == 'add') if ($mode == 'add' && ! preg_match('/^\-/',$values[1]))
{ {
if (count($values) == 6) // new declaration with permissions if (count($values) == 6) // new declaration with permissions
{ {
if ($values[0] != $type) continue; if ($values[0] != $type) continue;
//print 'ee'.$values[4];
if (verifCond($values[4])) if (verifCond($values[4]))
{ {
if ($values[3]) $langs->load($values[3]); if ($values[3]) $langs->load($values[3]);
@ -4353,9 +4352,9 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
$tabname=str_replace('-','',$values[1]); $tabname=str_replace('-','',$values[1]);
foreach($head as $key => $val) foreach($head as $key => $val)
{ {
if ($head[$key][2]==$tabname) $condition = (! empty($values[3]) ? verifCond($values[3]) : 1);
if ($head[$key][2]==$tabname && $condition)
{ {
//print 'on vire '.$tabname.' key='.$key;
unset($head[$key]); unset($head[$key]);
break; break;
} }