3 * GForge Survey Facility: Get Survey
5 * Copyright 2004 GForge, LLC
8 * This file is part of GForge.
10 * GForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * GForge 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
21 * along with GForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 require_once('common/include/Error.class.php');
31 require_once('common/survey/Survey.class.php');
33 class SurveyFactory extends Error {
52 * @param object The Group object to which this survey is associated.
53 * @param int The survey_id
55 function SurveyFactory(&$Group) {
57 if (!$Group || !is_object($Group)) {
58 $this->setError(_('No valid Group Object'));
62 if ($Group->isError()) {
63 $this->setError(_('Survey').':: '.$Group->getErrorMessage());
66 $this->Group =& $Group;
72 * getGroup - get the Group object this SurveyQuestionFactory is associated with.
74 * @return object The Group object.
76 function &getGroup() {
81 * getSurveyQuestion - get an array of Survey Question objects
82 * for this Group and Survey id if survey_id is given.
84 * @return array The array of Survey Question objects.
86 function &getSurveys() {
87 /* We alread have it */
89 return $this->surveys;
92 $group_id = $this->Group->GetID();
94 $sql="SELECT * FROM surveys WHERE group_id='$group_id' order by survey_id DESC";
95 $result = db_query ($sql);
98 $this->setError(_('No Survey is found').db_error());
101 while ($arr = db_fetch_array($result)) {
102 $this->surveys[] = new Survey($this->Group, $arr['survey_id'], $arr);
104 db_free_result($result);
106 return $this->surveys;
113 // c-file-style: "bsd"