/
frmWorkArea.php
271 lines (233 loc) · 8.07 KB
/
frmWorkArea.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
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
<?php
/**
* TestLink Open Source Project - http://testlink.sourceforge.net/
* This script is distributed under the GNU General Public License 2 or later.
*
* @filesource frmWorkArea.php
* @author Martin Havlat
*
* @internal revisions
* @since 1.9.10
*
*
**/
require_once('../../config.inc.php');
require_once("common.php");
testlinkInitPage($db);
$args = init_args();
// --------------------------------------------------------------------------------------
// Important Notes for Developers
// --------------------------------------------------------------------------------------
//
// if key found in this map, at User Interface level, screen will be divided
// vertically in two frames.
// Normally on left will exists a tree menu.
// On right frame an html named $key.html will be launched.
// Example:
// if key = printTc, an html page printTc.html must exists on help directory
//
// (aa_tfp -> Associative Array TreeFramePath)
// key : feature
// value: page to lauch
//
$req_cfg = config_get('req_cfg');
// 20131214
// more info here
// array(0) => left pane
// array(1) => right pane
$aa_tfp = array(
'editTc' => array('lib/testcases/listTestCases.php?feature=edit_tc',
'lib/testcases/archiveData.php?edit=testproject&id='),
'assignReqs' => 'lib/testcases/listTestCases.php?feature=assignReqs',
'searchTc' => 'lib/testcases/tcSearchForm.php',
'searchReq' => 'lib/requirements/reqSearchForm.php',
'searchReqSpec' => 'lib/requirements/reqSpecSearchForm.php',
'printTestSpec' => 'lib/results/printDocOptions.php?type=testspec',
'printReqSpec' => 'lib/results/printDocOptions.php?type=reqspec',
'keywordsAssign' => 'lib/testcases/listTestCases.php?feature=keywordsAssign',
'planAddTC' => array('lib/plan/planAddTCNavigator.php?loadRightPaneAddTC=0',
'lib/results/printDocOptions.php?activity=addTC'),
'planRemoveTC' => 'lib/plan/planTCNavigator.php?feature=removeTC&help_topic=planRemoveTC',
'planUpdateTC' => 'lib/plan/planTCNavigator.php?feature=planUpdateTC',
'show_ve' => 'lib/plan/planTCNavigator.php?feature=show_ve',
'newest_tcversions' => '../../lib/plan/newest_tcversions.php',
'test_urgency' => 'lib/plan/planTCNavigator.php?feature=test_urgency',
'tc_exec_assignment' => 'lib/plan/planTCNavigator.php?feature=tc_exec_assignment',
'executeTest' => array('lib/execute/execNavigator.php?setting_testplan=', 'lib/execute/execDashboard.php?id='),
'showMetrics' => 'lib/results/resultsNavigator.php',
'reqSpecMgmt' => array('lib/requirements/reqSpecListTree.php','lib/project/project_req_spec_mgmt.php?id=')
);
$full_screen = array('newest_tcversions' => 1);
//cleanup session var
$_SESSION['currentSrsId'] = null;
/** feature to display */
$showFeature = $args->feature;
if (isset($aa_tfp[$showFeature]) === FALSE)
{
// argument is wrong
tLog("Wrong page argument feature = ".$showFeature, 'ERROR');
exit();
}
// features that need to run the validate build function
if (in_array($showFeature,array('executeTest','showMetrics','tc_exec_assignment')))
{
// Check if for test project selected at least a test plan exist (BUGID 623)
if( isset($_SESSION['testplanID']) || !is_null($args->tplan_id))
{
// Filter on build attributes: ACTIVE,OPEN
switch($showFeature)
{
case 'executeTest':
$hasToBe['active'] = true;
$hasToBe['open'] = true;
$featureHint = lang_get('href_execute_test');
break;
case 'tc_exec_assignment':
$txcfg = config_get('tree_filter_cfg');
$cfg = $txcfg->testcases->plan_mode;
$hasToBe['active'] = $cfg->setting_build_inactive_out;
$hasToBe['open'] = $cfg->setting_build_close_out ;
$featureHint = lang_get('href_tc_exec_assignment');
break;
default:
$hasToBe['active'] = null;
$hasToBe['open'] = null;
$featureHint = lang_get('href_rep_and_metrics');
break;
}
$tplanIDCard = new stdClass();
$tplanIDCard->id = intval($_SESSION['testplanID']);
$tplanIDCard->name = $_SESSION['testplanName'];
$tplanMgr = new testplan($db);
if(!is_null($args->tplan_id))
{
$tplanIDCard->id = intval($args->tplan_id);
$dummy = $tplanMgr->tree_manager->get_node_hierarchy_info($tplanIDCard->id);
$tplanIDCard->name = $dummy['name'];
}
$ctx = new stdClass();
$ctx->tplanIDCard = $tplanIDCard;
$ctx->featureTitle = $featureHint;
validateBuildAvailability($db,$tplanMgr,$ctx,$hasToBe);
}
else
{
redirect('../plan/planView.php');
exit();
}
}
/// 1. get path from global var
/// 2. the URL made easier after setting some rules for help/instruction files
/// naming convention.
/// </enhancement>
$smarty = new TLSmarty();
// try to add context in order to avoid using global coupling via $_SESSION
// this will be useful to open different test projects on different browser TAB
if( is_array($aa_tfp[$showFeature]) )
{
$leftPane = $aa_tfp[$showFeature][0];
$rightPane = $aa_tfp[$showFeature][1];
if($rightPane[strlen($rightPane)-1] == '=')
{
$rightPane .= intval($_SESSION['testprojectID']);
}
if($showFeature == 'executeTest')
{
$leftPane .= $args->tplan_id;
}
// new dBug($leftPane);
}
else
{
$leftPane = $aa_tfp[$showFeature];
$rightPane = 'lib/general/staticPage.php?key=' . $showFeature;
}
if( intval($args->tproject_id) > 0 || intval($args->tproject_id) > 0)
{
$leftPane .= (strpos($leftPane,"?") === false) ? "?" : "&";
$leftPane .= "tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}";
// for execDashboard is OK, need to understand if will be ok for other features
// or is going to create issues.
$rightPane .= (strpos($rightPane,"?") === false) ? "?" : "&";
$rightPane .= "tproject_id={$args->tproject_id}&tplan_id={$args->tplan_id}";
}
if(isset($full_screen[$showFeature]))
{
redirect($leftPane);
}
else
{
$smarty->assign('treewidth', TL_FRMWORKAREA_LEFT_FRAME_WIDTH);
$smarty->assign('treeframe', $leftPane);
$smarty->assign('workframe', $rightPane);
$smarty->display('frmInner.tpl');
}
/**
* validate that some build exists (for Test Plan related features).
* If no valid build is found give feedback to user and exit.
*
* check if user can create builds, then put a link on the message page
* to create link feature
*
*
*
*
**/
function validateBuildAvailability(&$db,&$tplanMgr,$context,$attrFilter)
{
$tpID = $context->tplanIDCard->id;
$tpName = $context->tplanIDCard->name;
if (!$tplanMgr->getNumberOfBuilds($tpID, $attrFilter['active'], $attrFilter['open']))
{
$msx = null;
if($attrFilter['active'])
{
$msx[] = lang_get('active');
}
if($attrFilter['open'])
{
$msx[] = lang_get('open');
}
$mzx = '';
if(count($msx) > 0)
{
$mzx = "(" . implode(' & ',$msx) . ")";
}
$message = "<p>" . $context->featureTitle .
"<p>" . sprintf(lang_get('no_good_build'),$mzx) .
"<b> " . htmlspecialchars($tpName) . "</b>";
$link_to_op = '';
$hint_text = '';
if(has_rights($db,"testplan_create_build") == 'yes')
{
// final url will be composed adding to $basehref
// (one TL variable available on smarty templates) to $link_to_op
$link_to_op = "lib/plan/buildEdit.php?do_action=create";
$hint_text = lang_get('create_a_build');
}
else
{
$message .= '</p><p>' . lang_get('no_build_warning_part2') . '</p>';
}
// show info and exit
$smarty = new TLSmarty;
$smarty->assign('content', $message);
$smarty->assign('link_to_op', $link_to_op);
$smarty->assign('hint_text', $hint_text);
$smarty->display('workAreaSimple.tpl');
exit();
}
}
/**
*
*/
function init_args()
{
$_REQUEST=strings_stripSlashes($_REQUEST);
$args = new stdClass();
$iParams = array("feature" => array(tlInputParameter::STRING_N),
"tproject_id" => array(tlInputParameter::INT_N),
"tplan_id" => array(tlInputParameter::INT_N));
R_PARAMS($iParams,$args);
return $args;
}