Skip to content

Commit

Permalink
Opensurvey polls tab cards can now be extended from external modules
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgdf committed Jan 2, 2014
1 parent 048ea80 commit 5f3d2ae
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Expand Up @@ -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.* *****
Expand Down
1 change: 1 addition & 0 deletions dev/skeletons/modMyModule.class.php
Expand Up @@ -134,6 +134,7 @@ function __construct($db)
// '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
Expand Down
12 changes: 1 addition & 11 deletions htdocs/opensurvey/adminstuds.php
Expand Up @@ -173,17 +173,7 @@
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);

Expand Down
12 changes: 1 addition & 11 deletions htdocs/opensurvey/adminstuds_preview.php
Expand Up @@ -406,17 +406,7 @@

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);

Expand Down
36 changes: 35 additions & 1 deletion 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
Expand All @@ -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
Expand Down

0 comments on commit 5f3d2ae

Please sign in to comment.