Skip to content

Commit 7d5c2b5

Browse files
committed
Cleaned up code - some adjustments to selected files
The following adjustments were made: - Files should end with a newline (PHP:S113) - Sections of code should not be commented out (PHP:S125) - Unused "private" fields should be removed (PHP:S1068) - Redundant pairs of parentheses should be removed (PHP:1110) - Empty statements should be removed (PHP:S1116) - Lines should not end with trailing whitespaces (PHP:S1131) - Unused function parameters should be removed (PHP:S1172) - Unused local variables should be removed (PHP:S1481) - The "var" keyword should not be used (PHP:S1765) - Method arguments with default values should be last (PHP:S1788) - "elseif" keyword should be used in place of "else if" keywords (PHP:S1793) - Unused assignments should be removed (PHP:S1854) - Array values should not be replaced unconditionally (PHP:S4143) - "default" clauses should be first or last (PHP:S4524)
1 parent 9a53ae4 commit 7d5c2b5

24 files changed

Lines changed: 1378 additions & 1599 deletions

lib/ajax/getrequirementnodes.php

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
2-
/**
2+
/**
33
* TestLink Open Source Project - http://testlink.sourceforge.net/
4-
*
4+
*
55
* @filesource getrequirementnodes.php
66
* @author Francisco Mancardi
7-
*
8-
* **** IMPORTANT *****
7+
*
8+
* **** IMPORTANT *****
99
* Created using Ext JS example code
1010
*
1111
* Is the tree loader, will be called via AJAX.
12-
* Ext JS automatically will pass $_REQUEST['node']
12+
* Ext JS automatically will pass $_REQUEST['node']
1313
* Other arguments will be added by TL php code that needs the tree.
14-
*
14+
*
1515
* This tree is used to navigate ...
1616
*
1717
* @internal revision
18-
*
18+
*
1919
*/
2020
require_once '../../config.inc.php';
2121
require_once 'common.php';
@@ -37,8 +37,8 @@
3737
3838
*/
3939
function display_children($dbHandler,$root_node,$parent,$filter_node,
40-
$show_children=ON,$operation='manage',$mode='reqspec')
41-
{
40+
$show_children=ON,$operation='manage',$mode='reqspec')
41+
{
4242
$tables = tlObjectWithDB::getDBTables(array('requirements','nodes_hierarchy','node_types','req_specs'));
4343
$cfg = config_get('req_cfg');
4444
$forbidden_parent['testproject'] = 'none';
@@ -47,7 +47,7 @@ function display_children($dbHandler,$root_node,$parent,$filter_node,
4747
if($cfg->child_requirements_mgmt)
4848
{
4949
$forbidden_parent['requirement_spec'] = 'none';
50-
}
50+
}
5151

5252
$fn = array();
5353
$fn['print']['reqspec'] = array('testproject' => 'TPROJECT_PTP_RS',
@@ -73,54 +73,53 @@ function display_children($dbHandler,$root_node,$parent,$filter_node,
7373

7474
default:
7575
$js_function=$fn['manage'][$mode];
76-
break;
76+
break;
7777
}
7878

7979
$nodes = null;
8080
$filter_node_type = $show_children ? '' : ",'requirement'";
81-
$sql = " SELECT NHA.*, NT.description AS node_type, RSPEC.doc_id " .
81+
$sql = " SELECT NHA.*, NT.description AS node_type, RSPEC.doc_id " .
8282
" FROM {$tables['nodes_hierarchy']} NHA JOIN {$tables['node_types']} NT " .
8383
" ON NHA.node_type_id=NT.id " .
84-
" AND NT.description NOT IN " .
84+
" AND NT.description NOT IN " .
8585
" ('testcase','testsuite','testcase_version','testplan','requirement_spec_revision' {$filter_node_type}) " .
8686
" LEFT OUTER JOIN {$tables['req_specs']} RSPEC " .
87-
" ON RSPEC.id = NHA.id " .
87+
" ON RSPEC.id = NHA.id " .
8888
" WHERE NHA.parent_id = " . intval($parent);
8989

9090
if(!is_null($filter_node) && $filter_node > 0 && $parent == $root_node)
9191
{
92-
$sql .= " AND NHA.id = " . intval($filter_node);
92+
$sql .= " AND NHA.id = " . intval($filter_node);
9393
}
94-
$sql .= " ORDER BY NHA.node_order ";
94+
$sql .= " ORDER BY NHA.node_order ";
9595

9696
$nodeSet = $dbHandler->get_recordset($sql);
97-
if(!is_null($nodeSet))
97+
if(!is_null($nodeSet))
9898
{
9999
$sql = " SELECT DISTINCT req_doc_id AS doc_id,NHA.id" .
100100
" FROM {$tables['requirements']} REQ JOIN {$tables['nodes_hierarchy']} NHA ON NHA.id = REQ.id " .
101-
" JOIN {$tables['nodes_hierarchy']} NHB ON NHA.parent_id = NHB.id " .
101+
" JOIN {$tables['nodes_hierarchy']} NHB ON NHA.parent_id = NHB.id " .
102102
" JOIN {$tables['node_types']} NT ON NT.id = NHA.node_type_id " .
103103
" WHERE NHB.id = " . intval($parent) . " AND NT.description = 'requirement'";
104104
$requirements = $dbHandler->fetchRowsIntoMap($sql,'id');
105105

106106
$treeMgr = new tree($dbHandler);
107107
$ntypes = $treeMgr->get_available_node_types();
108-
$peerTypes = array('target' => $ntypes['requirement'], 'container' => $ntypes['requirement_spec']);
108+
$peerTypes = array('target' => $ntypes['requirement'], 'container' => $ntypes['requirement_spec']);
109109
foreach($nodeSet as $key => $row)
110110
{
111-
$path['text'] = htmlspecialchars($row['name']);
112-
$path['id'] = $row['id'];
111+
$path['text'] = htmlspecialchars($row['name']);
112+
$path['id'] = $row['id'];
113113

114114
// this attribute/property is used on custom code on drag and drop
115-
$path['position'] = $row['node_order'];
115+
$path['position'] = $row['node_order'];
116116
$path['leaf'] = false;
117117
$path['cls'] = 'folder';
118118

119119
// Important:
120120
// We can add custom keys, and will be able to access it using
121-
// public property 'attributes' of object of Class Ext.tree.TreeNode
122-
//
123-
$path['testlink_node_type'] = $row['node_type'];
121+
// public property 'attributes' of object of Class Ext.tree.TreeNode
122+
$path['testlink_node_type'] = $row['node_type'];
124123
$path['testlink_node_name'] = $path['text']; // already htmlspecialchars() done
125124

126125
$path['forbidden_parent'] = 'none';
@@ -141,7 +140,7 @@ function display_children($dbHandler,$root_node,$parent,$filter_node,
141140
if(!is_null($req_list))
142141
{
143142
$item_qty = count($req_list);
144-
$path['text'] .= " ({$item_qty})";
143+
$path['text'] .= " ({$item_qty})";
145144
}
146145
break;
147146

@@ -153,8 +152,8 @@ function display_children($dbHandler,$root_node,$parent,$filter_node,
153152
break;
154153
}
155154

156-
$nodes[] = $path;
157-
} // foreach
155+
$nodes[] = $path;
156+
}
158157
}
159-
return $nodes;
160-
}
158+
return $nodes;
159+
}

lib/ajax/requirements/getreqmonitors.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2-
/**
2+
/**
33
* TestLink Open Source Project - http://testlink.sourceforge.net/
4-
*
4+
*
55
* @filesource getreqmonitors.php
66
* @author Francisco Mancardi
7-
*
7+
*
88
* @internal revisions
99
*/
1010
require_once '../../../config.inc.php';
@@ -24,4 +24,4 @@
2424
$ou = new stdClass();
2525
$ou->data = $mon;
2626
}
27-
echo json_encode($ou);
27+
echo json_encode($ou);

lib/functions/print.inc.php

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@
3737
* @internal revisions
3838
*
3939
*/
40-
function renderReqForPrinting(&$db,$node, &$options, $tocPrefix, $reqLevel, $tprojectID)
40+
function renderReqForPrinting(&$db,$node, &$options, $reqLevel, $tprojectID)
4141
{
42-
4342
static $tableColspan;
4443
static $firstColWidth;
4544
static $labels;
4645
static $title_separator;
4746
static $req_mgr;
48-
static $tplan_mgr;
4947
static $req_cfg;
50-
static $req_spec_cfg;
5148
static $decodeReq;
5249
static $force = null;
5350
static $basehref;
@@ -57,7 +54,6 @@ function renderReqForPrinting(&$db,$node, &$options, $tocPrefix, $reqLevel, $tpr
5754
if (!$req_mgr) {
5855
$basehref = $_SESSION['basehref'];
5956
$req_cfg = config_get('req_cfg');
60-
$req_spec_cfg = config_get('req_spec_cfg');
6157
$firstColWidth = '20%';
6258
$tableColspan = 2;
6359
$labels = array('requirement' => 'requirement', 'status' => 'status',
@@ -81,7 +77,6 @@ function renderReqForPrinting(&$db,$node, &$options, $tocPrefix, $reqLevel, $tpr
8177

8278
$title_separator = config_get('gui_title_separator_1');
8379
$req_mgr = new requirement_mgr($db);
84-
$tplan_mgr = new testplan($db);
8580

8681
$repoDir = config_get('repositoryPath');
8782
}
@@ -106,7 +101,6 @@ function renderReqForPrinting(&$db,$node, &$options, $tocPrefix, $reqLevel, $tpr
106101
$req = $dummy[0];
107102

108103
// update with values got from req, this is needed if user did not provide it
109-
$versionID = $req['version_id'];
110104
$revision = $req['revision'];
111105

112106
$name = htmlspecialchars($req["req_doc_id"] . $title_separator . $req['title']);
@@ -510,15 +504,11 @@ function renderReqSpecTreeForPrinting(&$db, &$node, &$options,$tocPrefix, $rsCnt
510504

511505
static $tree_mgr;
512506
static $map_id_descr;
513-
static $tplan_mgr;
514-
static $repoDir;
515507
$code = null;
516508

517509
if(!$tree_mgr) {
518-
$tplan_mgr = new testplan($db);
519510
$tree_mgr = new tree($db);
520511
$map_id_descr = $tree_mgr->node_types;
521-
$repoDir = config_get('repositoryPath');
522512
}
523513
$verbose_node_type = $map_id_descr[$node['node_type_id']];
524514

@@ -536,8 +526,7 @@ function renderReqSpecTreeForPrinting(&$db, &$node, &$options,$tocPrefix, $rsCnt
536526

537527
case 'requirement':
538528
$tocPrefix .= (!is_null($tocPrefix) ? "." : '') . $rsCnt;
539-
$code .= renderReqForPrinting($db, $node, $options,
540-
$tocPrefix, $rstLevel, $tprojectID);
529+
$code .= renderReqForPrinting($db, $node, $options, $rstLevel, $tprojectID);
541530
break;
542531
}
543532

@@ -661,13 +650,7 @@ function renderFirstPage($doc_info)
661650

662651
if ($docCfg->company_logo != '' )
663652
{
664-
// allow to configure height via config file
665-
$height = '';
666-
if (isset($docCfg->company_logo_height) && $docCfg->company_logo_height != '')
667-
{
668-
$height = "height=\"{$docCfg->company_logo_height}\"";
669-
}
670-
653+
// allow to configure height via config file
671654
$safePName = $_SESSION['basehref'] . TL_THEME_IMG_DIR . $docCfg->company_logo;
672655
list($iWidth, $iHeight, $iType, $iAttr) = getimagesize($safePName);
673656
$output .= '<p style="text-align: center;"><img alt="TestLink logo" ' .
@@ -776,16 +759,12 @@ function renderTestSpecTreeForPrinting(&$db,&$node,&$options,$env,$context,$tocP
776759
{
777760
static $tree_mgr;
778761
static $id_descr;
779-
static $tplan_mgr;
780-
static $repoDir;
781762

782763
$code = null;
783764

784765
if(!$tree_mgr) {
785-
$tplan_mgr = new testplan($db);
786766
$tree_mgr = new tree($db);
787767
$id_descr = $tree_mgr->node_types;
788-
$repoDir = config_get('repositoryPath');
789768

790769
$k2i = array('tproject_id' => 0, 'tplan_id' => 0, 'platform_id' => 0, 'build_id' => 0, 'prefix' => null);
791770
$context = array_merge($k2i,$context);
@@ -882,26 +861,20 @@ function gendocGetUserName(&$db, $userId)
882861
* @internal revisions
883862
*/
884863
function renderTestCaseForPrinting(&$db,&$node,&$options,$env,$context,$indentLevel) {
885-
886-
887864
static $st;
888865
static $statusL10N;
889866
static $labels;
890867
static $tcase_prefix;
891-
static $userMap = array();
892868
static $cfg;
893869
static $force = null;
894870

895871
$code = null;
896872
$tcInfo = null;
897-
// $tcResultInfo = null;
898873
$tcase_pieces = null;
899874

900875
$id = $node['id'];
901-
// $tcversion_id = isset($node['tcversion_id']) ? $node['tcversion_id'] : null;
902876

903877
$level = $indentLevel;
904-
// $prefix = isset($context['prefix']) ? $context['prefix'] : null;
905878
$tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
906879
$tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
907880
$platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0;
@@ -985,7 +958,6 @@ function renderTestCaseForPrinting(&$db,&$node,&$options,$env,$context,$indentLe
985958
//
986959
// ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided
987960
//
988-
//
989961
// Get Linked test case version
990962
$linkedItem = $st->tplan_mgr->getLinkInfo($tplan_id,$id,$platform_id);
991963

@@ -1166,10 +1138,10 @@ function renderTestCaseForPrinting(&$db,&$node,&$options,$env,$context,$indentLe
11661138
// function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false)
11671139
// $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
11681140
// $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
1169-
$canManageAttachments = false;
1170-
if(isset($context['user']) && !is_null($context['user'])) {
1171-
$canManageAttachments = $context['user']->hasRight($db,'testplan_execute',$tprojectID,$tplan_id);
1172-
}
1141+
// $canManageAttachments = false;
1142+
// if(isset($context['user']) && !is_null($context['user'])) {
1143+
// $canManageAttachments = $context['user']->hasRight($db,'testplan_execute',$tprojectID,$tplan_id);
1144+
// }
11731145

11741146
// Multiple Test Case Steps Feature
11751147
foreach($tcase_pieces as $key) {
@@ -1654,7 +1626,6 @@ function renderTestSuiteNodeForPrinting(&$db,&$node,$env,&$options,$context,$toc
16541626
static $title_separator;
16551627
static $cfieldFormatting;
16561628
static $getOpt;
1657-
static $reporDir;
16581629

16591630
$designCfg = getWebEditorCfg('design');
16601631
$designType = $designCfg['type'];
@@ -1751,7 +1722,6 @@ function renderTestSuiteNodeForPrinting(&$db,&$node,$env,&$options,$context,$toc
17511722
$context['tproject_id'],
17521723
$cfieldFormatting);
17531724
if($cfields[$key] != "") {
1754-
$add_br = true;
17551725
$code .= '<p>' . $cfields[$key] . '</p>';
17561726
}
17571727
}
@@ -1788,7 +1758,6 @@ function renderTestDuration($statistics,$platform_id=0) {
17881758
static $ecfg;
17891759

17901760
$output = '';
1791-
$hasOutput = false;
17921761

17931762
if(!$ecfg) {
17941763
$ecfg = config_get('exec_cfg');
@@ -2275,6 +2244,5 @@ function initStaticRenderTestCaseForPrinting(&$dbH,$tcaseID,$ctx,$cfg) {
22752244
'value_css_style' =>
22762245
' colspan = "' . ($cfg['tableColspan']-1) . '" ' );
22772246

2278-
22792247
return $things;
22802248
}

0 commit comments

Comments
 (0)