Browse Source

Opensurvey polls tab cards can now be extended from external modules

Marcos García de La Fuente 11 years ago
parent
commit
5f3d2aea51

+ 1 - 1
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.* *****

+ 1 - 0
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

+ 1 - 11
htdocs/opensurvey/adminstuds.php

@@ -173,17 +173,7 @@ $toutsujet=str_replace("°","'",$toutsujet);
 print '<form name="updatesurvey" action="'.$_SERVER["PHP_SELF"].'?id='.$numsondageadmin.'" method="POST">'."\n";
 print '<input type="hidden" name="action" value="update">';
 
-$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);
 

+ 1 - 11
htdocs/opensurvey/adminstuds_preview.php

@@ -406,17 +406,7 @@ $toutsujet=str_replace("°","'",$toutsujet);
 
 print '<form name="formulaire4" action="#" method="POST" onkeypress="javascript:process_keypress(event)">'."\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);
 

+ 35 - 1
htdocs/opensurvey/fonctions.php

@@ -1,5 +1,6 @@
 <?php
 /* Copyright (C) 2013 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2014 Marcos García			<marcosgdf@gmail.com>
  *
 * 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