1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
<?php
/**
* FusionForge trackers
*
* Copyright 2002, GForge, LLC
* Copyright 2009, Roland Mas
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation; either version 2 of the Licence, or (at your option)
* any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FusionForge; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'include/User.class.php';
require_once $gfcommon.'tracker/Artifact.class.php';
require_once $gfcommon.'tracker/ArtifactFromID.class.php';
class ArtifactsForUser extends Error {
var $User;
var $Group;
var $ArtifactType;
var $Artifact;
/**
* __construct - Creates a new ArtifactsForUser object
*
* @param object $user the User object for which to collect artifacts
*/
function __construct(&$user) {
$this->User =& $user;
}
/**
* getArtifactsFromSQLwithParams - Gets an array of Artifacts
*
* @param string $sql The sql that returns artifact_id
* @param array $params Array of values associated to sql query
* @return Artifact[] The array of Artifacts
*/
function &getArtifactsFromSQLwithParams ($sql, $params) {
$artifacts = array();
$result = db_query_params ($sql, $params);
$rows=db_numrows($result);
if ($rows<=0) {
return $artifacts;
}
for ($i=0; $i < $rows; $i++) {
$artifact_id = db_result($result,$i,'artifact_id');
$arr = db_fetch_array($result);
$afi = new ArtifactFromID($artifact_id,$arr);
if ($afi->isError()) {
$this->setError($afi->getErrorMessage());
} elseif($afi->Artifact->ArtifactType->Group->getStatus() == 'A') {
$artifacts[] =& $afi->Artifact;
}
}
return $artifacts;
}
/**
* getAssignedArtifactsByGroup - Get the users's assigned artifacts
* @return Artifact[] The array of Artifacts
*/
function &getAssignedArtifactsByGroup() {
return $this->getArtifactsFromSQLwithParams('SELECT * FROM artifact_vw av WHERE av.assigned_to=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id DESC',
array($this->User->getID())) ;
}
/**
* getSubmittedArtifactsByGroup
*
* @return Artifact[] The array of Artifacts
*/
function &getSubmittedArtifactsByGroup() {
return $this->getArtifactsFromSQLwithParams('SELECT * FROM artifact_vw av WHERE av.submitted_by=$1 AND av.status_id=1 ORDER BY av.group_artifact_id, av.artifact_id DESC',
array($this->User->getID())) ;
}
/**
* getMonitoredArtifacts
*
* @return Artifact[] The array of Artifacts
*/
function & getMonitoredArtifacts() {
$artifacts = array();
$result=db_query_params ('SELECT groups.group_name,groups.group_id,
artifact_group_list.group_artifact_id,
artifact_group_list.name
FROM groups,artifact_group_list,artifact_type_monitor
WHERE groups.group_id=artifact_group_list.group_id
AND groups.status =$1
AND artifact_group_list.group_artifact_id=artifact_type_monitor.group_artifact_id
AND artifact_type_monitor.user_id=$2
ORDER BY group_name ASC',
array('A',
$this->User->getID()));
$rows=db_numrows($result);
if ($rows < 1) {
return $artifacts;
}
for ($i=0; $i<$rows; $i++) {
$group_id = db_result($result,$i,'group_id');
$group_artifact_id = db_result($result,$i,'group_artifact_id');
$group = group_get_object($group_id);
$artifact = new ArtifactType($group,$group_artifact_id);
if ($artifact->isError()) {
$this->setError($artifact->getErrorMessage());
} else {
$artifacts[] = $artifact;
}
}
return $artifacts;
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|