3 * Copyright 2005 (c) GForge Group, LLC
5 * This file is part of FusionForge. FusionForge is free software;
6 * you can redistribute it and/or modify it under the terms of the
7 * GNU General Public License as published by the Free Software
8 * Foundation; either version 2 of the Licence, or (at your option)
11 * FusionForge is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
25 $headers = getIntFromRequest('headers');
26 $sep = getStringFromRequest('sep', ',');
28 $date = date('Y-m-d');
31 header('Content-type: text/csv');
32 header('Content-disposition: filename="trackers-'.$date.'.csv"');
34 session_require_perm ('tracker', $ath->getID(), 'read') ;
36 $af = new ArtifactFactory($ath);
37 if (!$af || !is_object($af)) {
38 exit_error(_('Could Not Get Factory'),'tracker');
39 } elseif ($af->isError()) {
40 exit_error($af->getErrorMessage(),'tracker');
43 $offset = getStringFromRequest('offset');
44 $_sort_col = getStringFromRequest('_sort_col');
45 $_sort_ord = getStringFromRequest('_sort_ord');
46 $max_rows = getIntFromRequest('max_rows');
47 $set = getStringFromRequest('set');
48 $_assigned_to = getStringFromRequest('_assigned_to');
49 $_status = getStringFromRequest('_status');
50 $_changed_from = getStringFromRequest('_changed_from');
52 $af->setup($offset,$_sort_col,$_sort_ord,$max_rows,$set,$_assigned_to,$_status,$_changed_from);
54 $at_arr = $af->getArtifacts();
57 echo 'artifact_id'.$sep.
62 'submitter_name'.$sep.
63 'assigned_to_id'.$sep.
64 'assigned_to_name'.$sep.
67 'last_modified_date'.$sep.
72 // Show the extra fields
74 $ef = $ath->getExtraFields();
75 $keys=array_keys($ef);
76 for ($i=0; $i<count($keys); $i++) {
77 echo $sep.'"'.$ef[$keys[$i]]['field_name'].'"';
82 for ($i=0; $i<count($at_arr); $i++) {
84 $open_date = $at_arr[$i]->getOpenDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getOpenDate()) : '';
85 $update_date = $at_arr[$i]->getLastModifiedDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getLastModifiedDate()) : '';
86 $close_date = $at_arr[$i]->getCloseDate()? date(_('Y-m-d H:i'),$at_arr[$i]->getCloseDate()): '';
88 echo $at_arr[$i]->getID().$sep.
89 $at_arr[$i]->getStatusID().$sep.
90 '"'.$at_arr[$i]->getStatusName().'"'.$sep.
91 $at_arr[$i]->getPriority().$sep.
92 $at_arr[$i]->getSubmittedBy().$sep.
93 '"'.$at_arr[$i]->getSubmittedRealName().'"'.$sep.
94 $at_arr[$i]->getAssignedTo().$sep.
95 '"'.$at_arr[$i]->getAssignedRealName().'"'.$sep.
96 '"'.$open_date.'"'.$sep.
97 '"'.$close_date.'"'.$sep.
98 '"'.$update_date.'"'.$sep.
99 '"'.fix4csv($at_arr[$i]->getSummary()).'"'.$sep.
100 '"'.fix4csv($at_arr[$i]->getDetails()).'"';
103 // Show the extra fields
105 $efd = $at_arr[$i]->getExtraFieldDataText();
106 foreach ( $efd as $efd_pair ) {
107 $value = $efd_pair["value"];
108 echo $sep.'"'. fix4csv($value) .'"';
113 function fix4csv ($value) {
114 $value = util_unconvert_htmlspecialchars( $value );
115 $value = str_replace("\r\n", "\n", $value);
116 $value = str_replace('"', '""', $value);