5 * Copyright 2011, Alcatel-Lucent
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
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 along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * Standard Alcatel-Lucent disclaimer for contributing to open source
26 * "The Roadmap ("Contribution") has not been tested and/or
27 * validated for release as or in products, combinations with products or
28 * other commercial use. Any use of the Contribution is entirely made at
29 * the user's own responsibility and the user can not rely on any features,
30 * functionalities or performances Alcatel-Lucent has attributed to the
33 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
45 require_once $gfcommon.'include/Error.class.php';
46 require_once $gfcommon.'tracker/Roadmap.class.php';
48 class RoadmapFactory extends Error {
57 function __construct($group) {
60 if (is_object($group)) {
61 if ($group->isError()) {
62 $this->setError('in RoadmapFactory, '.$group->getErrorMessage());
65 $this->group = $group;
66 $this->group_id = $group->getID();
69 $this->setError('No Valid Group');
76 public function getRoadmaps($enable_only=false) {
77 if ($this->roadmaps) {
78 return $this->roadmaps;
83 $enable_filter = 'AND enable=1';
86 $result = db_query_params ('SELECT * FROM roadmap WHERE group_id=$1 '.$enable_filter.' ORDER BY name',
87 array ($this->group_id));
88 if (! $result /* || ! db_numrows($result) */) {
89 $this->setError('in getRoadmaps, '.db_error());
92 $this->roadmaps = array();
93 while($entry = db_fetch_array($result)) {
94 $roadmap = new Roadmap($this->group, $entry['roadmap_id'], $entry);
95 if($roadmap->isError()) {
96 $this->setError($roadmap->getErrorMessage());
98 $this->roadmaps[] = $roadmap;
102 return $this->roadmaps;
105 public function getRoadmapByID($roadmap_id, $enable_only=false) {
106 $roadmaps = $this->getRoadmaps($enable_only);
107 foreach ($roadmaps as $roadmap) {
108 if($roadmap->isError()) {
109 $this->setError($roadmap->getErrorMessage());
111 if ($roadmap->getID() == $roadmap_id) {
120 public function getRoadmapByName($name, $enable_only=false) {
121 $roadmaps = $this->getRoadmaps($enable_only);
122 foreach ($roadmaps as $roadmap) {
123 if($roadmap->isError()) {
124 $this->setError($roadmap->getErrorMessage());
126 if ($roadmap->getName() == $name) {
135 public function getDefault() {
136 $roadmaps = $this->getRoadmaps();
137 foreach ($roadmaps as $roadmap) {
138 if($roadmap->isError()) {
139 $this->setError($roadmap->getErrorMessage());
141 if ($roadmap->isDefault()) {
142 return $roadmap->getID();