5 * Copyright 2004, Sung Kim/GForge, LLC
6 * Copyright 2009, Roland Mas
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'include/Error.class.php';
26 require_once $gfcommon.'survey/Survey.class.php';
28 class SurveyFactory extends Error {
47 * @param object The Group object to which this survey is associated.
48 * @param int The survey_id
50 function SurveyFactory(&$Group) {
52 if (!$Group || !is_object($Group)) {
53 $this->setError(_('No valid Group Object'));
57 if ($Group->isError()) {
58 $this->setError(_('Survey').':: '.$Group->getErrorMessage());
61 $this->Group =& $Group;
66 * getGroup - get the Group object this SurveyQuestionFactory is associated with.
68 * @return object The Group object.
70 function &getGroup() {
75 * getSurveyQuestion - get an array of Survey Question objects
76 * for this Group and Survey id if survey_id is given.
78 * @return array The array of Survey Question objects.
80 function &getSurveys() {
81 /* We alread have it */
83 return $this->surveys;
85 $result = db_query_params('SELECT * FROM surveys WHERE group_id=$1 ORDER BY survey_id DESC',
86 array ($this->Group->getID()));
89 $this->setError(_('No Survey is found').' '.db_error());
92 $this->surveys = array();
93 while ($arr = db_fetch_array($result)) {
94 $this->surveys[] = new Survey($this->Group, $arr['survey_id'], $arr);
96 db_free_result($result);
98 return $this->surveys;
105 // c-file-style: "bsd"