-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathltx.php
More file actions
318 lines (271 loc) · 8.05 KB
/
ltx.php
File metadata and controls
318 lines (271 loc) · 8.05 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<?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 testlink items with frames for navigation and tree.
*
* IMPORTANT - LIMITATIONS:
* User has to login before clicking the link!
* If user is not logged in he is redirected to login page.
* After login main page is shown, Clicking the link again then it works!
*
*
* @package TestLink
* @author Francisco Mancardi
* @copyright 2015, TestLink community
* @link http://www.testlink.org/
*
* @internal revisions
* @since 1.9.14
*/
// use output buffer to prevent headers/data from being sent before
// cookies are set, else it will fail
ob_start();
// some session and settings stuff from original index.php
require_once('lib/functions/configCheck.php');
checkConfiguration();
require_once('config.inc.php');
require_once('common.php');
testlinkInitPage($db, true);
$smarty = new TLSmarty();
// display outer or inner frame?
if (!isset($_GET['load']))
{
// display outer frame, pass parameters to next script call for inner frame
// ATTENTION:
// Because we are going to recreate an URL with paramenters on the URL, we need
// to use urlencode() on data we have got.
//
$args = init_args($db);
$args->tproject_id = 0;
if( $args->status_ok )
{
$user = $_SESSION['currentUser'];
if($args->tplan_id != '')
{
$hasRight = checkTestPlan($db,$user,$args);
if( $hasRight )
{
$gui = new stdClass();
$gui->titleframe = 'lib/general/navBar.php?caller=linkto';
if( $args->tproject_id > 0)
{
$gui->titleframe .= '&testproject=' . $args->tproject_id;
}
$gui->title = lang_get('main_page_title');
$gui->mainframe = 'ltx.php?' . buildLink($args);
$smarty->assign('gui', $gui);
$smarty->display('main.tpl');
}
}
}
}
else
{
//
// inner frame, parameters passed
// figure out what to display
//
// key: item, value: url to tree management page
$itemCode = array('exec' => 'lib/execute/execNavigator.php');
$op = array('status_ok' => true, 'msg' => '');
// First check for keys in _GET that MUST EXIST
// key: key on _GET, value: labelID defined on strings.txt
$mandatoryKeys = array('item' => 'item_not_set',
'build_id' => 'build_id_not_set');
foreach($mandatoryKeys as $key => $labelID)
{
$op['status_ok'] = isset($_GET[$key]);
if( !$op['status_ok'])
{
$op['msg'] = lang_get($labelID);
break;
}
}
if( $op['status_ok'] )
{
$op['status_ok'] = isset($_GET['feature_id']);
if( !$op['status_ok'] )
{
$keySet = array('tplan_id' => 'testplan_not_set',
'tcversion_id' => 'tcversion_id',
'platform_id' => 'platform_id_not_set');
foreach($keySet as $key => $labelID)
{
$op['status_ok'] = isset($_GET[$key]);
if( !$op['status_ok'])
{
$op['msg'] = lang_get($labelID);
break;
}
}
}
}
$args = init_args($db);
if($op['status_ok'])
{
// Set Environment
$tplan_mgr = new testplan($db);
$info = $tplan_mgr->get_by_id($args->tplan_id,array('output' => 'minimun'));
if(is_null($info))
{
die('ltx - tplan info does not exist');
}
$tproject_mgr = new testproject($db);
$tproject_mgr->setSessionProject($info['tproject_id']);
$op['status_ok'] = true;
}
if($op['status_ok'])
{
// Build name of function to call for doing the job.
$pfn = 'process_' . $args->item;
$ctx = array();
$ctx['setting_testplan'] = $args->tplan_id;
$ctx['setting_build'] = $args->build_id;
$ctx['setting_platform'] = $args->platform_id;
$ctx['tcversion_id'] = $args->tcversion_id;
$ctx['tcase_id'] = 0;
$jump_to = $pfn($db,$ctx);
$op['status_ok'] = !is_null($jump_to['url']);
$op['msg'] = $jump_to['msg'];
}
if($op['status_ok'])
{
$treeframe = $itemCode[$args->item] .
'?loadExecDashboard=0' .
'&setting_testplan=' . $args->tplan_id .
'&setting_build=' . $args->build_id .
'&setting_platform=' . $args->platform_id;
$smarty->assign('title', lang_get('main_page_title'));
$smarty->assign('treewidth', TL_FRMWORKAREA_LEFT_FRAME_WIDTH);
$smarty->assign('workframe', $jump_to['url']);
$smarty->assign('treeframe', $treeframe);
$smarty->display('frmInner.tpl');
}
else
{
echo $op['msg'];
ob_end_flush();
exit();
}
}
ob_end_flush();
/**
*
*
*/
function checkTestPlan(&$db,&$user,&$args)
{
$hasRight = false;
// $tproject_mgr = new testproject($db);
$tplan_mgr = new testplan($db);
$item_info = $tplan_mgr->get_by_id($args->tplan_id,array( 'output' => 'minimun'));
if(($op['status_ok'] = !is_null($item_info)))
{
$args->tproject_id = intval($item_info['tproject_id']);
switch($args->item)
{
case 'exec':
$hasRight = $user->hasRight($db,'testplan_execute',
$args->tproject_id,$args->tplan_id);
break;
default:
// need to fail!!
break;
}
}
return $hasRight;
}
/**
*
*/
function init_args(&$dbHandler)
{
$args = new stdClass();
$args->tplan_id = intval(isset($_GET['tplan_id']) ? $_GET['tplan_id'] : null);
$args->tcversion_id = intval(isset($_GET['tcversion_id']) ? $_GET['tcversion_id'] : null);
$args->platform_id = intval(isset($_GET['platform_id']) ? $_GET['platform_id'] : null);
$args->build_id = intval(isset($_GET['build_id']) ? $_GET['build_id'] : null);
$args->anchor = isset($_GET['anchor']) ? $_GET['anchor'] : null;
$args->item = isset($_GET['item']) ? $_GET['item'] : null;
$args->feature_id = isset($_GET['feature_id']) ? $_GET['feature_id'] : null;
$args->status_ok = ($args->build_id >0);
if($args->status_ok)
{
if( $args->feature_id >0 )
{
// get missing data
$tb = DB_TABLE_PREFIX . 'testplan_tcversions';
$sql = "SELECT testplan_id,platform_id,tcversion_id " .
"FROM {$tb} WHERE id=" . $args->feature_id;
$rs = $dbHandler->get_recordset($sql);
$args->tplan_id = $rs[0]['testplan_id'];
$args->tcversion_id = $rs[0]['tcversion_id'];
$args->platform_id = $rs[0]['platform_id'];
}
else
{
$args->status_ok = ($args->tplan_id > 0) && ($args->tcversion_id >0);
}
}
return $args;
}
/**
*
*/
function buildLink(&$argsObj)
{
$lk = isset($_GET['item']) ? "item=" . $_GET['item'] : '';
if($argsObj->feature_id >0)
{
$lk .= "&feature_id=" . $argsObj->feature_id;
}
else
{
$lk .= "&tplan_id=" . $argsObj->tplan_id . "&platform_id=" . $argsObj->platform_id;
"&tcversion_id=" . $argsObj->tcversion_id;
}
$lk .= "&build_id=" . $argsObj->build_id;
$lk .= '&load' . (isset($_GET['anchor']) ? '&anchor=' . $_GET['anchor'] : "");
return $lk;
}
/**
*
*
*/
function process_exec(&$dbHandler,$context)
{
$ret = array();
$ret['url'] = null;
$ret['msg'] = 'ko';
$treeMgr = new tree($dbHandler);
$info = $treeMgr->get_node_hierarchy_info($context['tcversion_id']);
$ret['url'] = "lib/execute/execSetResults.php?level=testcase" .
"&version_id=" . $context['tcversion_id'] .
"&id=" . $info['parent_id'] .
"&setting_testplan=" . $context['setting_testplan'] .
"&setting_build=" . $context['setting_build'] .
"&setting_platform=" . $context['setting_platform'];
$ret['msg'] = 'ok';
return $ret;
}
/**
*
*
*/
function buildCookie(&$dbHandler,$itemID,$tprojectID,$cookiePrefix)
{
$tree_mgr = new tree($dbHandler);
$path = $tree_mgr->get_path($itemID);
$parents = array();
$parents[] = $tprojectID;
foreach($path as $node)
{
$parents[] = $node['id'];
}
array_pop($parents);
$cookieInfo['path'] = 'a:s%3A/' . implode("/", $parents);
$cookieInfo['value'] = $cookiePrefix . $tprojectID . '_ext-comp-1001' ;
return $cookieInfo;
}