From 9dfd4275b508b3ea47c9bc1af45f4ef80b419a31 Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis@dolibarr.fr> Date: Mon, 14 Mar 2011 16:14:15 +0000 Subject: [PATCH] New: add possibility to defined permissions in external tab --- dev/skeletons/modMyModule.class.php | 4 ++-- htdocs/lib/functions.lib.php | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index d9994e31839..c10618f340f 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -102,8 +102,8 @@ class modMyModule extends DolibarrModules $this->const = array(); // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:Title2:@mymodule:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname // where objecttype can be // 'thirdparty' to add a tab in third party view diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 5fd2fe63834..429a7510da7 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -3752,7 +3752,19 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= $values=explode(':',$value); if ($mode == 'add') { - if (sizeof($values) == 5) // new declaration + if (sizeof($values) == 6) // new declaration with permissions + { + if ($values[0] != $type) continue; + if (verifCond($values[4])) + { + if ($values[3]) $langs->load($values[3]); + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[5]),1); + $head[$h][1] = $langs->trans($values[2]); + $head[$h][2] = str_replace('+','',$values[1]); + $h++; + } + } + if (sizeof($values) == 5) // new declaration { if ($values[0] != $type) continue; if ($values[3]) $langs->load($values[3]); -- GitLab