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');
30 header('Content-type: text/csv');
31 header('Content-disposition: filename="trackers-'.$date.'.csv"');
33 session_require_perm ('tracker', $ath->getID(), 'read') ;
35 $af = new ArtifactFactory($ath);
36 if (!$af || !is_object($af)) {
37 exit_error('Error','Could Not Get Factory');
38 } elseif ($af->isError()) {
39 exit_error('Error',$af->getErrorMessage());
42 $offset = getStringFromRequest('offset');
43 $_sort_col = getStringFromRequest('_sort_col');
44 $_sort_ord = getStringFromRequest('_sort_ord');
45 $max_rows = getIntFromRequest('max_rows');
46 $set = getStringFromRequest('set');
47 $_assigned_to = getStringFromRequest('_assigned_to');
48 $_status = getStringFromRequest('_status');
49 $_changed_from = getStringFromRequest('_changed_from');
51 $af->setup($offset,$_sort_col,$_sort_ord,$max_rows,$set,$_assigned_to,$_status,$_changed_from);
53 $at_arr = $af->getArtifacts();
56 echo 'artifact_id'.$sep.
61 'submitter_name'.$sep.
62 'assigned_to_id'.$sep.
63 'assigned_to_name'.$sep.
66 'last_modified_date'.$sep.
71 // Show the extra fields
73 $ef = $ath->getExtraFields();
74 $keys=array_keys($ef);
75 for ($i=0; $i<count($keys); $i++) {
76 echo $sep.'"'.$ef[$keys[$i]]['field_name'].'"';
81 for ($i=0; $i<count($at_arr); $i++) {
83 $open_date = $at_arr[$i]->getOpenDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getOpenDate()) : '';
84 $update_date = $at_arr[$i]->getLastModifiedDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getLastModifiedDate()) : '';
85 $close_date = $at_arr[$i]->getCloseDate()? date(_('Y-m-d H:i'),$at_arr[$i]->getCloseDate()): '';
87 echo $at_arr[$i]->getID().$sep.
88 $at_arr[$i]->getStatusID().$sep.
89 '"'.$at_arr[$i]->getStatusName().'"'.$sep.
90 $at_arr[$i]->getPriority().$sep.
91 $at_arr[$i]->getSubmittedBy().$sep.
92 '"'.$at_arr[$i]->getSubmittedRealName().'"'.$sep.
93 $at_arr[$i]->getAssignedTo().$sep.
94 '"'.$at_arr[$i]->getAssignedRealName().'"'.$sep.
95 '"'.$open_date.'"'.$sep.
96 '"'.$close_date.'"'.$sep.
97 '"'.$update_date.'"'.$sep.
98 '"'.fix4csv($at_arr[$i]->getSummary()).'"'.$sep.
99 '"'.fix4csv($at_arr[$i]->getDetails()).'"';
102 // Show the extra fields
104 $efd = $at_arr[$i]->getExtraFieldDataText();
105 foreach ( $efd as $efd_pair ) {
106 $value = $efd_pair["value"];
107 echo $sep.'"'. fix4csv($value) .'"';
112 function fix4csv ($value) {
113 $value = util_unconvert_htmlspecialchars( $value );
114 $value = str_replace("\r\n", "\n", $value);
115 $value = str_replace('"', '""', $value);