diff --git a/ChangeLog b/ChangeLog index 4bfb6e73595..e85b76eaebc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,7 +16,7 @@ For developers: - New: Add path file of trigger into admin trigger list page. - New: More phpunit tests. - New: Payments and supplier payment pages tabs can now be extended from modules. - +- New: Opensurvey polls tab cards can now be extended from external modules. ***** ChangeLog for 3.5 compared to 3.4.* ***** diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index deeb34caa66..224798a2fd2 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -134,6 +134,7 @@ class modMyModule extends DolibarrModules // 'payment' to add a tab in payment view // 'payment_supplier' to add a tab in supplier payment view // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'opensurveypoll' to add a tab in opensurvey poll view $this->tabs = array(); // Dictionnaries diff --git a/htdocs/opensurvey/adminstuds.php b/htdocs/opensurvey/adminstuds.php index c6fc44e0025..6a0eda17148 100644 --- a/htdocs/opensurvey/adminstuds.php +++ b/htdocs/opensurvey/adminstuds.php @@ -173,17 +173,7 @@ $toutsujet=str_replace("°","'",$toutsujet); print '
'."\n"; print ''; -$head = array(); - -$head[0][0] = ''; -$head[0][1] = $langs->trans("Card"); -$head[0][2] = 'general'; -$h++; - -$head[1][0] = 'adminstuds_preview.php?sondage='.$object->id_sondage_admin; -$head[1][1] = $langs->trans("SurveyResults").'/'.$langs->trans("Preview"); -$head[1][2] = 'preview'; -$h++; +$head = opensurvey_prepare_head($object); print dol_get_fiche_head($head,'general',$langs->trans("Survey"),0,dol_buildpath('/opensurvey/img/object_opensurvey.png',1),1); diff --git a/htdocs/opensurvey/adminstuds_preview.php b/htdocs/opensurvey/adminstuds_preview.php index f0b29720bbb..de1658b80ea 100644 --- a/htdocs/opensurvey/adminstuds_preview.php +++ b/htdocs/opensurvey/adminstuds_preview.php @@ -406,17 +406,7 @@ $toutsujet=str_replace("°","'",$toutsujet); print ''."\n"; -$head = array(); - -$head[0][0] = 'adminstuds.php?sondage='.$object->id_sondage_admin; -$head[0][1] = $langs->trans("Card"); -$head[0][2] = 'general'; -$h++; - -$head[1][0] = 'adminstuds_preview.php?sondage='.$object->id_sondage_admin; -$head[1][1] = $langs->trans("SurveyResults").'/'.$langs->trans("Preview"); -$head[1][2] = 'preview'; -$h++; +$head = opensurvey_prepare_head($object); print dol_get_fiche_head($head,'preview',$langs->trans("Survey"),0,dol_buildpath('/opensurvey/img/object_opensurvey.png',1),1); diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 9dcc398fa3a..78cb13732dc 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Marcos García * * 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 @@ -21,7 +22,40 @@ * \brief Functions for module */ +/** + * Returns an array with the tabs for the "Opensurvey poll" section + * It loads tabs from modules looking for the entity Opensurveyso + * + * @param Opensurveysondage $object Current viewing poll + * @return array Tabs for the opensurvey section + */ +function opensurvey_prepare_head(Opensurveysondage $object) { + + global $langs, $conf; + + $h = 0; + $head = array(); + $head[0][0] = 'adminstuds.php?id='.$object->id_sondage_admin; + $head[0][1] = $langs->trans("Card"); + $head[0][2] = 'general'; + $h++; + + $head[1][0] = 'adminstuds_preview.php?id='.$object->id_sondage_admin; + $head[1][1] = $langs->trans("SurveyResults").'/'.$langs->trans("Preview"); + $head[1][2] = 'preview'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'opensurveypoll'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'opensurveypoll', 'remove'); + + return $head; +} /** * Show header for new member