-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexport_issues.php
44 lines (31 loc) · 1.25 KB
/
export_issues.php
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
<?php
session_start();
include_once 'directory.php';
$resourceID = $_GET['resourceID'];
$archivedFlag = (!empty($_GET['archived']) && $_GET['archived'] == 1) ? true:false;
$resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID)));
$util = new Utility();
$organizationArray = $resource->getOrganizationArray();
$exportIssues = array();
if (count($organizationArray) > 0) {
$issuedOrgs = array();
foreach ($organizationArray as $orgData) {
if (!in_array($orgData['organizationID'],$issuedOrgs)) {
// todo: create issues repo so we don't have to initialize an organization object from the wrong module
$organization = new Organization(new NamedArguments(array('primaryKey' => $orgData['organizationID'])));
$exportIssues = array_merge($exportIssues,$organization->getExportableIssues($archivedFlag));
$issuedOrgs[] = $orgData['organizationID'];
}
}
}
$exportIssues = array_merge($exportIssues,$resource->getExportableIssues($archivedFlag));
header("Pragma: public");
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=\"issues.csv\"");
$out = fopen('php://output', 'w');
fputcsv($out,array_keys($exportIssues[0]));
foreach ($exportIssues as $issue) {
fputcsv($out, $issue);
}
fclose($out);
?>