3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2013, Franck Villaume - TrivialDev
6 * This file is a part of Fusionforge.
8 * Fusionforge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Fusionforge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
22 require_once('Widget.class.php');
23 //require_once('common/survey/SurveySingleton.class.php');
24 require_once ('common/survey/SurveyFactory.class.php');
31 * This needs to be updated manually to display any given survey
32 * Default behavior: get first survey from group #1
34 class Widget_MySurveys extends Widget {
36 var $can_be_displayed;
38 function Widget_MySurveys() {
39 $this->Widget('mysurveys');
42 $user = session_get_user () ;
43 $projects = $user->getGroups() ;
44 sortProjectList ($projects) ;
46 foreach ($projects as $p) {
47 if ($p->usesSurvey()) {
48 $sf = new SurveyFactory($p);
49 foreach ($sf->getSurveys() as $s) {
57 $html_my_surveys = '';
58 if (count ($projects) < 1) {
59 $html_my_surveys .= '<div class="warning">'. _("There are no surveys in your projects.") ."</div>\n";
62 $request =& HTTPRequest::instance();
63 $html_my_surveys .= '<table style="width:100%">';
65 foreach ($projects as $project) {
67 $group_id = $project->getID() ;
68 $surveyfacto = new SurveyFactory($project);
69 $surveys = $surveyfacto->getSurveys();
70 $vItemId = new Valid_UInt('hide_item_id');
72 if($request->valid($vItemId)) {
73 $hide_item_id = $request->get('hide_item_id');
78 $vForum = new Valid_WhiteList('hide_survey', array(0, 1));
80 if($request->valid($vForum)) {
81 $hide_survey = $request->get('hide_survey');
86 list($hide_now,$count_diff,$hide_url) = my_hide_url('survey',$group_id,$hide_item_id,count($surveys),$hide_survey);
88 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="2">' : '').
89 $hide_url.'<a href="/survey/?group_id='.$group_id.'">'.
90 $project->getPublicName().'</a> ';
93 $count_new = max(0, $count_diff);
95 foreach ($surveys as $survey) {
98 $group_survey_id= $survey->getId();
99 $survey_title = $survey->getTitle();
100 $devsurvey_is_active = $survey->isActive();
101 if($devsurvey_is_active == 1 ) {
103 <tr '. $HTML->boxGetAltRowStyle($i) .'><td width="99%">'.
104 ' - <a href="/survey/survey.php?group_id='.$group_id.'&survey_id='.$group_survey_id.'">'.
105 $survey_title.'</a></td></tr>';
110 $html_hdr .= '['.count($surveys).($count_new ? ", <b>".sprintf(_('%d new'), $count_new)."</b>]" : ']').'</td></tr>';
111 $html_my_surveys .= $html_hdr.$html;
113 $html_my_surveys .= '</table>';
115 $this->content = $html_my_surveys;
118 function getTitle() {
119 return _("Quick Survey");
121 function getContent() {
122 return $this->content;
124 function getDescription() {
125 return _("List the surveys you have not answered.");