/
lnl.php
196 lines (168 loc) · 6.12 KB
/
lnl.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
* TestLink Open Source Project - http://testlink.sourceforge.net/
* This script is distributed under the GNU General Public License 2 or later.
*
* Direct links for external access to reports
*
*
* How this feature works:
*
* @package TestLink
* @author franciscom
* @copyright 2012,2015 TestLink community
* @link http://www.testlink.org/
* @since 1.9.14
*
* @internal revisions
*
*/
// some session and settings stuff from original index.php
require_once('config.inc.php');
require_once('./cfg/reports.cfg.php');
require_once('common.php');
$args = init_args();
switch($args->light)
{
case 'red':
// can not find user or item
break;
case 'green':
$reportCfg = config_get('reports_list');
$what2launch = null;
$cfg = isset($reportCfg[$args->type]) ? $reportCfg[$args->type] : null;
switch($args->type)
{
case 'file':
$what2launch = "lib/attachments/attachmentdownload.php" .
"?id={$args->id}&apikey=$args->apikey";
break;
case 'metricsdashboard':
$param = "&tproject_id={$args->tproject_id}";
$what2launch = "lib/results/metricsDashboard.php?apikey=$args->apikey{$param}";
break;
case 'test_report':
$param = "&type={$args->type}&level=testproject" .
"&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&header=y&summary=y&toc=y&body=y&passfail=y&cfields=y&metrics=y&author=y" .
"&requirement=y&keyword=y¬es=y&headerNumbering=y&format=" . FORMAT_HTML;
$what2launch = "lib/results/printDocument.php?apikey=$args->apikey{$param}";
break;
case 'test_plan':
$param = "&type={$args->type}&level=testproject" .
"&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&header=y&summary=y&toc=y&body=y&passfail=y&cfields=y&metrics=y&author=y" .
"&requirement=y&keyword=y¬es=y&headerNumbering=y&format=" . FORMAT_HTML;
$what2launch = "lib/results/printDocument.php?apikey=$args->apikey{$param}";
break;
case 'testspec':
$param = "&type={$args->type}&level=testproject&id={$args->tproject_id}" .
"&tproject_id={$args->tproject_id}" .
"&header=y&summary=y&toc=y&body=y&cfields=y&author=y".
"&requirement=y&keyword=y&headerNumbering=y&format=" . FORMAT_HTML;
$what2launch = $cfg['url'] . "?apikey=$args->apikey{$param}";
break;
case 'metrics_tp_general':
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&format=" . FORMAT_HTML;
$what2launch = $cfg['url'] . "?apikey=$args->apikey{$param}";
break;
case 'list_tc_failed':
case 'list_tc_blocked':
case 'list_tc_not_run':
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&format={$args->format}";
$what2launch = $cfg['url'] ."&apikey=$args->apikey{$param}";
break;
case 'results_matrix';
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&format={$args->format}";
$what2launch = $cfg['url'] ."?apikey=$args->apikey{$param}";
break;
case 'results_by_tester_per_build';
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}&format=" . FORMAT_HTML;
$what2launch = $cfg['url'] ."?apikey=$args->apikey{$param}";
break;
case 'charts_basic':
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}&format=" . FORMAT_HTML;
$what2launch = $cfg['url'] ."?apikey=$args->apikey{$param}";
break;
default:
$needle = 'list_tc_';
$nl = strlen($needle);
if(strpos($key,$needle) !== FALSE)
{
$param = "&tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}" .
"&format={$args->format}";
$what2launch = $cfg['url'] ."&apikey=$args->apikey{$param}";
}
else
{
echo 'ABORTING - UNKNOWN TYPE:' . $args->type;
die();
}
break;
}
if(!is_null($what2launch))
{
// 20150312 - changed to be able to get XLS file using wget
// redirect(TL_BASE_HREF . $what2launch);
header('Location:' . TL_BASE_HREF . $what2launch);
exit();
}
break;
default:
// ??
break;
}
/**
*
*/
function init_args()
{
$_REQUEST = strings_stripSlashes($_REQUEST);
$args = new stdClass();
try
{
// ATTENTION - give a look to $tlCfg->reports_list
// format domain: see reports.cfg.php FORMAT_*
$typeSize = 30;
$iParams = array("apikey" => array(tlInputParameter::STRING_N,32,64),
"tproject_id" => array(tlInputParameter::INT_N),
"tplan_id" => array(tlInputParameter::INT_N),
"level" => array(tlInputParameter::STRING_N,0,16),
"type" => array(tlInputParameter::STRING_N,0,$typeSize),
'id' => array(tlInputParameter::INT_N),
'format' => array(tlInputParameter::STRING_N,0,1));
}
catch (Exception $e)
{
echo $e->getMessage();
exit();
}
R_PARAMS($iParams,$args);
$args->format = intval($args->format);
$args->format = ($args->format <= 0) ? FORMAT_HTML : $args->format;
$args->envCheckMode = $args->type == 'file' ? 'hippie' : 'paranoic';
$args->light = 'red';
$opt = array('setPaths' => true,'clearSession' => true);
if(strlen($args->apikey) == 32)
{
$args->debug = 'USER-APIKEY';
setUpEnvForRemoteAccess($dbHandler,$args->apikey,null,$opt);
$user = tlUser::getByAPIKey($dbHandler,$args->apikey);
$args->light = (count($user) == 1) ? 'green' : 'red';
}
else
{
$args->debug = 'OBJECT-APIKEY';
$kerberos = new stdClass();
$kerberos->args = $args;
$kerberos->method = null;
if( setUpEnvForAnonymousAccess($dbHandler,$args->apikey,$kerberos,$opt) )
{
$args->light = 'green';
}
}
return $args;
}