From adab5f7722ad1a0e0db2c342bf60e4a41940e7f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 17 Sep 2010 05:18:01 +0000 Subject: [PATCH] Add: external module tab --- dev/skeletons/modMyModule.class.php | 3 ++ htdocs/lib/contact.lib.php | 34 ++++++++++++---- htdocs/lib/usergroups.lib.php | 61 +++++++++++++++++++++++------ 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index a82114ac134..f8df2762e2b 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -111,6 +111,9 @@ class modMyModule extends DolibarrModules // 'propal' to add a tab in propal view // 'member' to add a tab in fundation member view // 'contract' to add a tab in contract view + // 'user' to add a tab in user view + // 'group' to add a tab in group view + // 'contact' to add a tab in contact view // Boxes diff --git a/htdocs/lib/contact.lib.php b/htdocs/lib/contact.lib.php index 8bc6530b165..0d7c342e7a3 100644 --- a/htdocs/lib/contact.lib.php +++ b/htdocs/lib/contact.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2006-2010 Laurent Destailleur + * Copyright (C) 2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,17 +29,17 @@ /** * Enter description here... * - * @param $contrat + * @param $object * @return array */ -function contact_prepare_head($contrat) +function contact_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; + $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'general'; $h++; @@ -47,26 +48,43 @@ function contact_prepare_head($contrat) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$_GET["id"]; + $head[$h][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; + $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id; $head[$h][1] = $langs->trans("PersonalInformations"); $head[$h][2] = 'perso'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; + $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$object->id; $head[$h][1] = $langs->trans("ExportImport"); $head[$h][2] = 'exportimport'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; + $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__'); + if (is_array($conf->tabs_modules['contact'])) + { + $i=0; + foreach ($conf->tabs_modules['contact'] as $value) + { + $values=explode(':',$value); + if ($values[2]) $langs->load($values[2]); + $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][1] = $langs->trans($values[1]); + $head[$h][2] = 'tab'.$values[1]; + $h++; + } + } return $head; } diff --git a/htdocs/lib/usergroups.lib.php b/htdocs/lib/usergroups.lib.php index 97ac9d09db8..f72a193d990 100644 --- a/htdocs/lib/usergroups.lib.php +++ b/htdocs/lib/usergroups.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2006-2010 Laurent Destailleur + * Copyright (C) 2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +24,7 @@ * \brief Ensemble de fonctions de base pour la gestion des utilisaterus et groupes * \version $Id$ */ -function user_prepare_head($user) +function user_prepare_head($object) { global $langs, $conf; $langs->load("users"); @@ -31,7 +32,7 @@ function user_prepare_head($user) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("UserCard"); $head[$h][2] = 'user'; $h++; @@ -39,52 +40,69 @@ function user_prepare_head($user) if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; $head[$h][1] = $langs->trans("UserRights"); $head[$h][2] = 'rights'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; $head[$h][1] = $langs->trans("UserGUISetup"); $head[$h][2] = 'guisetup'; $h++; if ($conf->clicktodial->enabled) { - $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id; $head[$h][1] = $langs->trans("ClickToDial"); $head[$h][2] = 'clicktodial'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$user->id; + $head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__'); + if (is_array($conf->tabs_modules['user'])) + { + $i=0; + foreach ($conf->tabs_modules['user'] as $value) + { + $values=explode(':',$value); + if ($values[2]) $langs->load($values[2]); + $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][1] = $langs->trans($values[1]); + $head[$h][2] = 'tab'.$values[1]; + $h++; + } + } return $head; } -function group_prepare_head($group) +function group_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id; + $head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("GroupCard"); $head[$h][2] = 'group'; $h++; @@ -92,16 +110,33 @@ function group_prepare_head($group) if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$group->id; + $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$group->id; + $head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$object->id; $head[$h][1] = $langs->trans("GroupRights"); $head[$h][2] = 'rights'; $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__'); + if (is_array($conf->tabs_modules['group'])) + { + $i=0; + foreach ($conf->tabs_modules['group'] as $value) + { + $values=explode(':',$value); + if ($values[2]) $langs->load($values[2]); + $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][1] = $langs->trans($values[1]); + $head[$h][2] = 'tab'.$values[1]; + $h++; + } + } return $head; }