3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once('Widget.class.php');
22 //require_once('common/survey/SurveySingleton.class.php');
23 require_once ('common/survey/SurveyFactory.class.php');
29 * This needs to be updated manually to display any given survey
30 * Default behavior: get first survey from group #1
32 class Widget_MySurveys extends Widget {
34 var $can_be_displayed;
36 function Widget_MySurveys() {
37 $this->Widget('mysurveys');
40 $user = session_get_user () ;
41 $projects = $user->getGroups() ;
42 sortProjectList ($projects) ;
44 foreach ($projects as $p) {
45 $sf = new SurveyFactory($p);
46 foreach ($sf->getSurveys() as $s) {
53 $html_my_surveys = '';
54 if (count ($projects) < 1) {
55 $html_my_surveys .= _("<p>There are no surveys in your groups.</p>");
57 $request =& HTTPRequest::instance();
58 $html_my_surveys .= '<table style="width:100%">';
60 foreach ($projects as $project) {
62 $group_id = $project->getID() ;
63 $surveyfacto = new SurveyFactory($project);
64 $surveys = $surveyfacto->getSurveys();
65 $vItemId = new Valid_UInt('hide_item_id');
67 if($request->valid($vItemId)) {
68 $hide_item_id = $request->get('hide_item_id');
73 $vForum = new Valid_WhiteList('hide_survey', array(0, 1));
75 if($request->valid($vForum)) {
76 $hide_survey = $request->get('hide_survey');
81 list($hide_now,$count_diff,$hide_url) = my_hide_url('survey',$group_id,$hide_item_id,count($surveys),$hide_survey);
83 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="2">' : '').
84 $hide_url.'<a href="/survey/?group_id='.$group_id.'">'.
85 $project->getPublicName().'</a> ';
88 $count_new = max(0, $count_diff);
90 foreach ($surveys as $survey) {
94 $class="bgcolor-white";
97 $class="bgcolor-grey";
100 $group_survey_id= $survey->getId();
101 $survey_title = $survey->getTitle();
102 $devsurvey_is_active = $survey->isActive();
103 if($devsurvey_is_active == 1 ) {
105 <tr class="'. $class .'"><td width="99%">'.
106 ' - <a href="/survey/survey.php?group_id='.$group_id.'&survey_id='.$group_survey_id.'">'.
107 $survey_title.'</a></td></tr>';
112 $html_hdr .= '['.count($surveys).($count_new ? ", <b>".sprintf(_('%s new'), array($count_new))."</b>]" : ']').'</td></tr>';
113 $html_my_surveys .= $html_hdr.$html;
115 $html_my_surveys .= '</table>';
117 $this->content = $html_my_surveys;
120 function getTitle() {
121 return _("Quick Survey");
123 function getContent() {
124 return $this->content;
126 function getDescription() {
127 return _("List the surveys you have not answered.");