Skip to content

Commit 573922b

Browse files
committed
Cleaned up code - some adjustments to selected files
The following adjustments were made: - Files should end with a newline (PHP:S113) - Field names should comply with a naming convention (PHP_S116) - Sections of code should not be commented out (PHP:S125) - Mergeable "if" statements should be combined (PHP:S1066) - Boolean literals should not be redundant (PHP:S1125) - Use empty() to check whether the array is empty or not (PHP:S1155) - Unused function parameters should be removed (PHP:S1172) - Unused local variables should be removed (PHP:S1481) - "elseif" keyword should be used in place of "else if" keywords (PHP:S1793) - Unused assignments should be removed (PHP:S1854)
1 parent efd8f4c commit 573922b

15 files changed

Lines changed: 2966 additions & 3082 deletions

lib/execute/editExecution.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
/**
3-
* TestLink Open Source Project - http://testlink.sourceforge.net/
4-
* This script is distributed under the GNU General Public License 2 or later.
3+
* TestLink Open Source Project - http://testlink.sourceforge.net/
4+
* This script is distributed under the GNU General Public License 2 or later.
55
*
66
* @filesource editExecution.php
77
*
88
* Edit an execution notes and custom fields
9-
*
9+
*
1010
**/
1111
require_once '../../config.inc.php';
1212
require_once 'common.php';
@@ -29,15 +29,15 @@
2929

3030
case 'doUpdate':
3131
doUpdate($db,$args,$tcase_mgr,$_REQUEST);
32-
break;
32+
break;
3333
}
3434
$map = get_execution($db,$args->exec_id);
3535
$owebeditor->Value = $map[0]['notes'];
3636

37-
// order on script is critic
37+
// order on script is critic
3838
$gui = initializeGui($args,$tcase_mgr);
3939
$cols = intval(isset($editorCfg['cols']) ? $editorCfg['cols'] : 60);
40-
$rows = intval(isset($editorCfg['rows']) ? $editorCfg['rows'] : 10);
40+
$rows = intval(isset($editorCfg['rows']) ? $editorCfg['rows'] : 10);
4141
$gui->notes = $owebeditor->CreateHTML($rows,$cols);
4242
$gui->editorType = $editorCfg['type'];
4343

@@ -77,7 +77,7 @@ function init_args()
7777
$args->basehref = $_SESSION['basehref'];
7878
$args->user = $_SESSION['currentUser'];
7979

80-
return $args;
80+
return $args;
8181
}
8282

8383
/**
@@ -103,7 +103,7 @@ function initializeGui(&$argsObj,&$tcaseMgr)
103103

104104
/**
105105
* Checks the user rights for viewing the page
106-
*
106+
*
107107
* @param $db resource the database connection handle
108108
* @param $user tlUser the object of the current user
109109
*
@@ -112,4 +112,4 @@ function initializeGui(&$argsObj,&$tcaseMgr)
112112
function checkRights(&$db,&$user)
113113
{
114114
return $user->hasRight($db,"testplan_execute") && $user->hasRight($db,"exec_edit_notes");
115-
}
115+
}

lib/execute/execDashboard.php

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
/**
3-
* TestLink Open Source Project - http://testlink.sourceforge.net/
3+
* TestLink Open Source Project - http://testlink.sourceforge.net/
44
*
55
* @filesource execDashboard.php
6-
*
6+
*
77
*
88
**/
99
require_once '../../config.inc.php';
@@ -21,28 +21,28 @@
2121
$tree_mgr = new tree($db);
2222
$attachmentRepository = tlAttachmentRepository::create($db);
2323

24-
list($args,$tplan_mgr) = init_args($db,$cfg);
24+
list($args,$tplan_mgr) = init_args($db);
2525
$gui = initializeGui($db,$args,$cfg,$tplan_mgr);
2626

2727
$smarty->assign('gui',$gui);
2828
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
2929

3030

3131
/*
32-
function:
32+
function:
3333
3434
args:
3535
36-
returns:
36+
returns:
3737
*/
38-
function init_args(&$dbHandler,$cfgObj) {
38+
function init_args(&$dbHandler) {
3939

4040
$args = new stdClass();
4141
$_REQUEST = strings_stripSlashes($_REQUEST);
4242
$tplan_mgr = new testplan($dbHandler);
4343

4444

45-
// Settings we put on session to create some sort of persistent scope,
45+
// Settings we put on session to create some sort of persistent scope,
4646
// because we have had issues when passing this info using GET mode (size limits)
4747
//
4848
// we get info about build_id, platform_id, etc ...
@@ -58,26 +58,26 @@ function init_args(&$dbHandler,$cfgObj) {
5858
if($args->tproject_id <= 0) {
5959
$tree_mgr = new tree($dbHandler);
6060
$dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id);
61-
$args->tproject_id = $dm['parent_id'];
61+
$args->tproject_id = $dm['parent_id'];
6262
}
6363

6464
if(is_null($args->build_id) || ($args->build_id == 0) ) {
6565
// Go for the build
6666
// this info can be present in session, then we will try different ways
67-
// ATTENTION:
67+
// ATTENTION:
6868
// give a look to tlTestCaseFilterControl.class.php method init_setting_build()
6969
//
7070
$key = $args->tplan_id . '_stored_setting_build';
7171
$args->build_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
7272
if( is_null($args->build_id) ) {
7373
$args->build_id = $tplan_mgr->get_max_build_id($args->tplan_id,1,1);
74-
}
75-
}
74+
}
75+
}
7676

7777
if(is_null($args->platform_id) || ($args->platform_id <= 0) ) {
7878
// Go for the platform (if any exists)
7979
// this info can be present in session, then we will try different ways
80-
// ATTENTION:
80+
// ATTENTION:
8181
// give a look to tlTestCaseFilterControl.class.php method init_setting_platform()
8282
//
8383
$itemSet = $tplan_mgr->getPlatforms($args->tplan_id);
@@ -86,17 +86,17 @@ function init_args(&$dbHandler,$cfgObj) {
8686
$args->platform_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
8787
if( is_null($args->platform_id) || ($args->platform_id <= 0) ) {
8888
$args->platform_id = $itemSet[0]['id'];
89-
}
90-
}
91-
}
89+
}
90+
}
91+
}
9292
return array($args,$tplan_mgr);
9393
}
9494

9595

9696

9797
/*
98-
function: initializeRights
99-
create object with rights useful for this feature
98+
function: initializeRights
99+
create object with rights useful for this feature
100100
101101
args:
102102
dbHandler: reference to db object
@@ -108,12 +108,11 @@ function: initializeRights
108108
has_rights() can works in a mode (that i consider a dirty one)
109109
using SESSION to achieve global coupling.
110110
111-
returns:
111+
returns:
112112
113113
*/
114114
function initializeRights(&$dbHandler,&$userObj,$tproject_id,$tplan_id)
115115
{
116-
$exec_cfg = config_get('exec_cfg');
117116
$grants = new stdClass();
118117

119118
$grants->execute = $userObj->hasRight($dbHandler,"testplan_execute",$tproject_id,$tplan_id);
@@ -123,7 +122,7 @@ function initializeRights(&$dbHandler,&$userObj,$tproject_id,$tplan_id)
123122
// If is TRUE we will need also to analize, test case by test case
124123
// these settings:
125124
// $tlCfg->exec_cfg->exec_mode->tester
126-
// $tlCfg->exec_cfg->simple_tester_roles
125+
// $tlCfg->exec_cfg->simple_tester_roles
127126
//
128127
// Why ?
129128
// Because if a tester can execute ONLY test cases assigned to him, this also
@@ -141,8 +140,7 @@ function initializeRights(&$dbHandler,&$userObj,$tproject_id,$tplan_id)
141140
// Important:
142141
// Execution right must be present to consider this configuration option.
143142
// $grants->edit_exec_notes = $grants->execute && $exec_cfg->edit_notes;
144-
$grants->edit_exec_notes = $grants->execute &&
145-
$userObj->hasRight($dbHandler,"exec_edit_notes",$tproject_id,$tplan_id);
143+
$grants->edit_exec_notes = $grants->execute && $userObj->hasRight($dbHandler,"exec_edit_notes",$tproject_id,$tplan_id);
146144

147145

148146
$grants->edit_testcase = $userObj->hasRight($dbHandler,"mgt_modify_tc",$tproject_id,$tplan_id);
@@ -156,7 +154,7 @@ function: initializeGui
156154
157155
args :
158156
159-
returns:
157+
returns:
160158
161159
*/
162160
function initializeGui(&$dbHandler,&$argsObj,&$cfgObj,&$tplanMgr) {
@@ -182,10 +180,10 @@ function initializeGui(&$dbHandler,&$argsObj,&$cfgObj,&$tplanMgr) {
182180
$cfgBuild = getWebEditorCfg('build');
183181
$gui->buildEditorType = $cfgBuild['type'];
184182

185-
// Just for the records:
183+
// Just for the records:
186184
// doing this here, we avoid to do on processTestSuite() and processTestCase(),
187185
// but absolutely this will not improve in ANY WAY perfomance, because we do not loop
188-
// over these two functions.
186+
// over these two functions.
189187
$tprojectMgr = new testproject($dbHandler);
190188
$gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
191189
$build_info = $buildMgr->get_by_id($argsObj->build_id);
@@ -198,8 +196,8 @@ function initializeGui(&$dbHandler,&$argsObj,&$cfgObj,&$tplanMgr) {
198196
$gui->testplan_notes = $rs['notes'];
199197
$gui->testplan_name = $rs['name'];
200198

201-
// Important note:
202-
// custom fields for test plan can be edited ONLY on design, that's reason why we are using
199+
// Important note:
200+
// custom fields for test plan can be edited ONLY on design, that's reason why we are using
203201
// scope = 'design' instead of 'execution'
204202
$gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id,'design',
205203
array('show_on_execution' => 1));
@@ -213,7 +211,7 @@ function initializeGui(&$dbHandler,&$argsObj,&$cfgObj,&$tplanMgr) {
213211

214212
$gui->platform_info['id']=0;
215213
$gui->platform_info['name']='';
216-
if(!is_null($argsObj->platform_id) && $argsObj->platform_id > 0 ) {
214+
if(!is_null($argsObj->platform_id) && $argsObj->platform_id > 0 ) {
217215
$gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
218216
}
219217

@@ -233,41 +231,41 @@ function initializeGui(&$dbHandler,&$argsObj,&$cfgObj,&$tplanMgr) {
233231

234232

235233
/**
236-
* get info from ...
234+
* get info from ...
237235
*
238236
*/
239237
function getContextFromGlobalScope(&$argsObj)
240238
{
241-
$mode = 'execution_mode';
239+
//$mode = 'execution_mode';
242240
$settings = array('build_id' => 'setting_build', 'platform_id' => 'setting_platform');
243241
$isNumeric = array('build_id' => 0, 'platform_id' => 0);
244242

245243
$argsObj->form_token = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0;
246-
$sf = isset($_SESSION['execution_mode']) && isset($_SESSION['execution_mode'][$argsObj->form_token]) ?
244+
$sf = isset($_SESSION['execution_mode']) && isset($_SESSION['execution_mode'][$argsObj->form_token]) ?
247245
$_SESSION['execution_mode'][$argsObj->form_token] : null;
248246

249247
if(is_null($sf))
250248
{
251249
foreach($settings as $key => $sfKey)
252250
{
253251
$argsObj->$key = null;
254-
}
252+
}
255253
return;
256-
}
254+
}
257255

258256
foreach($settings as $key => $sfKey)
259257
{
260258
$argsObj->$key = isset($sf[$sfKey]) ? $sf[$sfKey] : null;
261-
if (is_null($argsObj->$key))
259+
if (is_null($argsObj->$key))
262260
{
263-
// let's this page be functional withouth a form token too
261+
// let's this page be functional withouth a form token too
264262
// (when called from testcases assigned to me)
265263
$argsObj->$key = isset($_REQUEST[$sfKey]) ? $_REQUEST[$sfKey] : null;
266264
}
267265
if(isset($isNumeric[$key]))
268266
{
269-
$argsObj->$key = intval($argsObj->$key);
270-
}
267+
$argsObj->$key = intval($argsObj->$key);
268+
}
271269
}
272270

273271
}

lib/execute/execNavigator.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,28 @@
5050

5151

5252
/**
53-
*
53+
*
5454
*
5555
*/
5656
function initializeGui(&$dbH,&$control) {
5757
$gui = new stdClass();
5858

5959
// This logic is managed from execSetResults.php
6060
$gui->loadExecDashboard = true;
61-
if( isset($_SESSION['loadExecDashboard'][$control->form_token]) ||
62-
$control->args->loadExecDashboard == 0
63-
) {
64-
$gui->loadExecDashboard = false;
65-
unset($_SESSION['loadExecDashboard'][$control->form_token]);
66-
}
61+
if( isset($_SESSION['loadExecDashboard'][$control->form_token]) || $control->args->loadExecDashboard == 0 ) {
62+
$gui->loadExecDashboard = false;
63+
unset($_SESSION['loadExecDashboard'][$control->form_token]);
64+
}
6765

6866
$gui->menuUrl = 'lib/execute/execSetResults.php';
6967
$gui->args = $control->get_argument_string();
70-
if($control->args->loadExecDashboard == false) {
68+
if(!$control->args->loadExecDashboard) {
7169
$gui->src_workframe = '';
7270
} else {
7371
$gui->src_workframe = $control->args->basehref . $gui->menuUrl .
74-
"?edit=testproject&id={$control->args->testproject_id}" .
72+
"?edit=testproject&id={$control->args->testproject_id}" .
7573
$gui->args;
76-
}
74+
}
7775

7876
$control->draw_export_testplan_button = true;
7977
$control->draw_import_xml_results_button = true;
@@ -95,11 +93,11 @@ function initializeGui(&$dbH,&$control) {
9593
$gui->features['export'] = true;
9694
$gui->features['import'] = true;
9795
$gui->execAccess = true;
98-
}
96+
}
9997

10098
if($grants['exec_ro_access']) {
10199
$gui->execAccess = true;
102-
}
100+
}
103101

104102

105103
$control->draw_export_testplan_button = $gui->features['export'];
@@ -122,7 +120,7 @@ function checkAccessToExec(&$dbH,&$ct) {
122120
{
123121
throw new Exception("Can not find Test Project For Test Plan - ABORT", 1);
124122

125-
}
123+
}
126124
$rs = current($rs);
127125
$tproject_id = $rs['testproject_id'];
128126

@@ -135,8 +133,8 @@ function checkAccessToExec(&$dbH,&$ct) {
135133
if( $user->hasRight($dbH,$r2c,$tproject_id,$tplan_id,true) || $user->globalRoleID == TL_ROLES_ADMIN )
136134
{
137135
$grants[$r2c] = true;
138-
}
139-
}
136+
}
137+
}
140138

141139
return $grants;
142-
}
140+
}

0 commit comments

Comments
 (0)