Skip to content

Commit be39e0f

Browse files
author
atisne
committed
Merge remote-tracking branch 'upstream/testlink_1_9' into feature-API_manage_ITS
2 parents a28e9b5 + 936236d commit be39e0f

10 files changed

Lines changed: 276 additions & 298 deletions

File tree

gui/templates/dashio/main.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<link href="gui/templates/dashio/css/style.css" rel="stylesheet">
2121
<link href="gui/templates/dashio/css/style-responsive.css" rel="stylesheet">
2222
<script src="gui/templates/dashio/lib/chart-master/Chart.js"></script>
23-
<link rel="stylesheet" type="text/css" href="{$basehref}gui/themes/default/css/frame.css">
23+
<link rel="stylesheet" type="text/css" href="{$basehref}{$tlCfg->theme_dir}/css/frame.css">
2424

2525
</head>
2626

gui/templates/tl-classic/frmInner.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<base href="{$basehref}" />
1616
<title>TestLink Inner Frame</title>
1717
<style media="all" type="text/css">@import "{$css}";</style>
18-
<link rel="stylesheet" type="text/css" href="{$basehref}gui/themes/default/css/frame.css">
18+
<link rel="stylesheet" type="text/css" href="{$basehref}{$tlCfg->theme_dir}/css/frame.css">
1919
<script type="text/javascript" src="{$basehref}third_party/jquery/{$smarty.const.TL_JQUERY}" language="javascript"></script>
2020
<script type="text/javascript" src="{$basehref}third_party/chosen/chosen.jquery.js"></script>
2121
{include file="bootstrap.inc.tpl"}

gui/templates/tl-classic/main.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<link rel="icon" href="{$basehref}{$smarty.const.TL_THEME_IMG_DIR}favicon.ico" type="image/x-icon" />
1616

1717
<!-- for the iframes -->
18-
<link rel="stylesheet" type="text/css" href="{$basehref}gui/themes/default/css/frame.css">
18+
<link rel="stylesheet" type="text/css" href="{$basehref}{$tlCfg->theme_dir}/css/frame.css">
1919

2020

2121
</head>

lib/api/rest/v2/tlRestApi.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,10 @@ public function createTestPlan() {
593593
$item = json_decode($request->getBody());
594594

595595
$op = array('status' => 'ok', 'message' => 'ok');
596-
$op['id'] = $this->tplanMgr->createFromObject($item,array('doChecks' => true));
596+
$opeOpt = array('setSessionProject' => false,
597+
'doChecks' => true);
598+
$op['id'] = $this->tplanMgr->createFromObject($item,$opeOpt);
599+
597600
} catch (Exception $e) {
598601
$this->app->status(500);
599602
$op['message'] = __METHOD__ . ' >> ' . $e->getMessage();

lib/functions/testplan.class.php

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class testplan extends tlObjectWithAttachments
4343
var $assignment_mgr;
4444
var $cfield_mgr;
4545
var $tcase_mgr;
46+
var $tproject_mgr;
4647

4748
var $assignment_types;
4849
var $assignment_status;
@@ -89,6 +90,8 @@ function __construct(&$db)
8990
$this->cfield_mgr = new cfield_mgr($this->db);
9091
$this->tcase_mgr = New testcase($this->db);
9192
$this->platform_mgr = new tlPlatform($this->db);
93+
$this->tproject_mgr = new testproject($this->db);
94+
9295

9396
$this->resultsCfg = config_get('results');
9497
$this->tcaseCfg = config_get('testcase_cfg');
@@ -165,14 +168,24 @@ function createFromObject($item,$opt=null) {
165168

166169
// what checks need to be done ?
167170
// 1. test project exist
168-
$pinfo = $this->tree_manager->get_node_hierarchy_info($item->testProjectID);
169-
if(is_null($pinfo) || $this->node_types_id_descr[$pinfo['node_type_id']] != 'testproject') {
171+
$pinfo = null;
172+
if( is_numeric($item->testProjectID) ) {
173+
$pinfo = $this->tproject_mgr->get_by_id(intval($item->testProjectID));
174+
}
175+
176+
if( null == $pinfo || count($pinfo) == 0 ) {
177+
$pinfo = $this->tproject_mgr->get_by_prefix($item->testProjectID);
178+
}
179+
180+
if( is_null($pinfo) || count($pinfo) == 0 ) {
170181
throw new Exception('Test project ID does not exist');
171182
}
172183

184+
$tproject_id = intval($pinfo['id']);
185+
173186
// 2. there is NO other test plan on test project with same name
174187
$name = trim($item->name);
175-
$op = $this->checkNameExistence($name,$item->testProjectID);
188+
$op = $this->checkNameExistence($name,$tproject_id);
176189
if(!$op['status_ok']) {
177190
throw new Exception('Test plan name is already in use on Test project');
178191
}
@@ -186,12 +199,13 @@ function createFromObject($item,$opt=null) {
186199

187200
$api_key = md5(rand()) . md5(rand());
188201

189-
$id = $this->tree_manager->new_node($item->testProjectID,$this->node_types_descr_id['testplan'],$name);
202+
$id = $this->tree_manager->new_node($tproject_id,$this->node_types_descr_id['testplan'],$name);
190203
$sql = "/* $debugMsg */ " .
191204
" INSERT INTO {$this->tables['testplans']} (id,notes,api_key,testproject_id,active,is_public) " .
192205
" VALUES ( {$id} " . ", '" . $this->db->prepare_string($item->notes) . "'," .
193206
"'" . $this->db->prepare_string($api_key) . "'," .
194-
$item->testProjectID . "," . $active_status . "," . $public_status . ")";
207+
$tproject_id . "," .
208+
$active_status . "," . $public_status . ")";
195209
$result = $this->db->exec_query($sql);
196210
return $result ? $id : 0;
197211
}
@@ -3953,38 +3967,38 @@ private function exportTestSuiteDataToXML($container,$tproject_id,$tplan_id,$pla
39533967
}
39543968
// testcase::LATEST_VERSION,
39553969
$tcaseExportOptions['EXEC_ORDER'] = $linkedItems[$cNode['id']][$platform_id]['node_order'];
3956-
3957-
$filter_lv = array( 'exec_status' => 'ALL', 'active_status' => 'ALL','tplan_id' => $tplan_id, 'platform_id' => $platform_id );
3958-
$output_lv = array( 'output' => 'simple' );
3959-
// get tc versions linked in current testplan for current platform
3960-
$info = $tcaseMgr->get_linked_versions($cNode['id'],$filter_lv,$output_lv);
3961-
if( !is_null($info) )
3962-
{
3963-
$tcversID = key($info);
3964-
}
3965-
3966-
// get users assigned to tc version in current testplan for the current build
3967-
$versionAssignInfo = $tcaseMgr->get_version_exec_assignment($tcversID, $tplan_id, $build_id );
3968-
$userList = array();
3969-
// extract user names
3970-
if(!is_null($versionAssignInfo))
3971-
{
3972-
foreach($versionAssignInfo[$tcversID][$platform_id] as $vaInfo)
3973-
{
3974-
$assignedTesterId = intval($vaInfo['user_id']);
3975-
if($assignedTesterId)
3976-
{
3977-
$user = tlUser::getByID($this->db,$assignedTesterId);
3978-
if ($user)
3979-
{
3980-
$userList[] = $user->getDisplayName();
3981-
}
3982-
}
3983-
}
3984-
}
3985-
(count($userList) > 0) ? $tcaseExportOptions['ASSIGNED_USER'] = $userList : $tcaseExportOptions['ASSIGNED_USER'] = null;
3986-
3987-
$xmlTC .= $tcaseMgr->exportTestCaseDataToXML($cNode['id'],$cNode['tcversion_id'],
3970+
3971+
$filter_lv = array( 'exec_status' => 'ALL', 'active_status' => 'ALL','tplan_id' => $tplan_id, 'platform_id' => $platform_id );
3972+
$output_lv = array( 'output' => 'simple' );
3973+
// get tc versions linked in current testplan for current platform
3974+
$info = $tcaseMgr->get_linked_versions($cNode['id'],$filter_lv,$output_lv);
3975+
if( !is_null($info) )
3976+
{
3977+
$tcversID = key($info);
3978+
}
3979+
3980+
// get users assigned to tc version in current testplan for the current build
3981+
$versionAssignInfo = $tcaseMgr->get_version_exec_assignment($tcversID, $tplan_id, $build_id );
3982+
$userList = array();
3983+
// extract user names
3984+
if(!is_null($versionAssignInfo))
3985+
{
3986+
foreach($versionAssignInfo[$tcversID][$platform_id] as $vaInfo)
3987+
{
3988+
$assignedTesterId = intval($vaInfo['user_id']);
3989+
if($assignedTesterId)
3990+
{
3991+
$user = tlUser::getByID($this->db,$assignedTesterId);
3992+
if ($user)
3993+
{
3994+
$userList[] = $user->getDisplayName();
3995+
}
3996+
}
3997+
}
3998+
}
3999+
(count($userList) > 0) ? $tcaseExportOptions['ASSIGNED_USER'] = $userList : $tcaseExportOptions['ASSIGNED_USER'] = null;
4000+
4001+
$xmlTC .= $tcaseMgr->exportTestCaseDataToXML($cNode['id'],$cNode['tcversion_id'],
39884002
$tproject_id,testcase::NOXMLHEADER,
39894003
$tcaseExportOptions);
39904004
break;

lib/functions/testproject.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ protected function getTestProject($condition = null, $opt=null)
330330
$doParse = true;
331331
$tprojCols = ' testprojects.* ';
332332

333-
switch($my['options']['output'])
334-
{
333+
switch($my['options']['output']) {
335334
case 'existsByID':
336335
$doParse = false;
337336
$sql = "/* debugMsg */ SELECT testprojects.id ".

lib/functions/tlTestCaseFilterByRequirementControl.class.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @filesource tlTestCaseFilterByRequirementControl.class.php
77
* @package TestLink
88
* @author Tanguy Oger
9-
* @copyright 2006-2016, TestLink community
9+
* @copyright 2006-2019, TestLink community
1010
* @link http://testlink.sourceforge.net/
1111
*
1212
*
@@ -884,21 +884,22 @@ private function init_setting_testplan()
884884
}
885885

886886

887-
/**
887+
/**
888888
*
889889
*/
890-
protected function init_setting_testsgroupby()
891-
{
892-
$key = 'setting_testsgroupby';
893-
894-
// now load info from session
895-
$mode = (isset($_REQUEST[$key])) ? $_REQUEST[$key] : 0;
896-
$this->args->testsgroupedby_mode = $mode;
897-
$this->args->{$key} = $mode;
898-
$this->settings[$key]['selected'] = $mode;
899-
900-
$this->settings[$key]['items']['mode_test_suite'] = lang_get('mode_test_suite');
901-
$this->settings[$key]['items']['mode_req_coverage'] = lang_get('mode_req_coverage');
890+
protected function init_setting_testsgroupby() {
891+
$key = 'setting_testsgroupby';
892+
893+
// now load info from session
894+
$mode = (isset($_REQUEST[$key])) ? $_REQUEST[$key] : 0;
895+
$this->args->testsgroupedby_mode = $mode;
896+
$this->args->{$key} = $mode;
897+
$this->settings[$key]['selected'] = $mode;
898+
899+
$k2l = array('mode_test_suite','mode_req_coverage');
900+
foreach( $k2l as $ak ) {
901+
$this->settings[$key]['items'][$ak] = lang_get($ak);
902+
}
902903
} // end of method
903904

904905
/*

lib/functions/tlUser.class.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @filesource tlUser.class.php
77
* @package TestLink
8-
* @copyright 2007-2018, TestLink community
8+
* @copyright 2007-2019, TestLink community
99
* @link http://www.testlink.org
1010
*
1111
*/
@@ -1526,4 +1526,17 @@ static public function setExpirationDate(&$dbHandler,$userID,$ISODate)
15261526
return tl::OK;
15271527
}
15281528

1529+
/**
1530+
*
1531+
*/
1532+
function hasRightWrap(&$db,$roleQuestion,$context=null) {
1533+
1534+
$cx = array('tproject_id' => null,'tplan_id' => null,
1535+
'checkPublicPrivateAttr' => false);
1536+
$cx = array_merge($cx,(array)$context);
1537+
return $this->hasRight($db,$roleQuestion,
1538+
$cx['tproject_id'],$cx['tplan_id'],
1539+
$cx['checkPublicPrivateAttr']);
1540+
}
1541+
15291542
}

0 commit comments

Comments
 (0)