3 * GForge Tracker Facility
5 * Copyright 2002 GForge, LLC
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
27 require_once $gfcommon.'include/Error.class.php';
28 require_once $gfcommon.'tracker/ArtifactType.class.php';
30 class ArtifactTypeFactory extends Error {
40 * The ArtifactTypes array.
42 * @var array ArtifactTypes.
49 * @var string dataType
56 * @param object The Group object to which this ArtifactTypeFactory is associated
57 * @return boolean success.
59 function ArtifactTypeFactory(&$Group) {
61 if (!$Group || !is_object($Group)) {
62 $this->setError('ArtifactTypeFactory:: No Valid Group Object');
65 if ($Group->isError()) {
66 $this->setError('ArtifactTypeFactory:: '.$Group->getErrorMessage());
69 $this->Group =& $Group;
75 * getGroup - get the Group object this ArtifactType is associated with.
77 * @return object The Group object.
79 function &getGroup() {
84 * getArtifactTypes - return an array of ArtifactType objects.
86 * @return array The array of ArtifactType objects.
88 function &getArtifactTypes() {
89 if ($this->ArtifactTypes) {
90 return $this->ArtifactTypes;
92 if (session_loggedin()) {
93 $perm =& $this->Group->getPermission( session_get_user() );
94 if (!$perm || !is_object($perm) || !$perm->isMember()) {
99 if ($perm->isArtifactAdmin()) {
102 $exists=" AND group_artifact_id IN (SELECT role_setting.ref_id
103 FROM role_setting, user_group
104 WHERE role_setting.value::integer >= 0
105 AND role_setting.section_name = 'tracker'
106 AND role_setting.ref_id=artifact_group_list_vw.group_artifact_id
108 AND user_group.role_id = role_setting.role_id
109 AND user_group.user_id='".user_getid()."') ";
117 $sql="SELECT * FROM artifact_group_list_vw
118 WHERE group_id='". $this->Group->getID() ."'
119 AND is_public $public_flag
121 ORDER BY group_artifact_id ASC";
123 $result = db_query ($sql);
125 $rows = db_numrows($result);
127 if (!$result || $rows < 1) {
128 $this->setError('None Found '.db_error());
129 $this->ArtifactTypes=NULL;
131 while ($arr =& db_fetch_array($result)) {
132 $artifactType = new ArtifactType($this->Group, $arr['group_artifact_id'], $arr);
133 if($artifactType->isError()) {
134 $this->setError($artifactType->getErrorMessage());
136 $this->ArtifactTypes[] = $artifactType;
140 return $this->ArtifactTypes;
144 * getPublicFlag - a utility method to load up the current user's permissions
146 * @return string The public_flag field to plug into a SQL string
148 function &getPublicFlag() {