Hi,
I am trying to add a new link to get information about test-cases added recently (say last 7 days). Now I am able to modified the code till the extent where I know, in the tree, which test-cases are added recently, but I do not know how to delete other nodes so that when the final tree gets displayed, it does not have *old* test-cases.
For this I modified generateTestSpecTree() present in treeMenu.inc.php. Here after getting the data from getsubtree into $test_spec function, I added a recursive function to iterate through the tree to figure out which test-cases are recently added and which are not.
function generateTestSpecTree(....)
{
.
..
...
.....
foreach ($test_spec as $the_key => $elem)
{
if($the_key == 'childNodes')
{
recTree($db,$elem);
}
}
......
.......
}
//Newly added funtion
function recTree(&$db,&$elem)
{
$size = count($elem);
for($cold = 0; $cold < $size; $cold++)
{
$delete = 0;
if($elem[$cold]['node_type_id'] == 3)
{
$version_id=TC_ALL_VERSIONS;
$tc_cs = new testcase($db);
$tc_array = $tc_cs->get_by_id($elem[$cold]['id'],$version_id);
$tc_version_ct = count($tc_array);
for($no = 0; $no < $tc_version_ct; $no++)
{
$tcv_id = $tc_array[$no]['id'];
$sql = "SELECT creation_ts FROM tcversions where creation_ts >= date_sub(curdate(), interval 4 day)
and id = $tcv_id";
$recordset = $tc_cs->db->fetchFirstRow($sql);
if(!is_null($recordset['creation_ts']))
{
print "<p> recordset:: {$recordset['creation_ts']} </p>";
continue;
}
else
{
print "<p> NOT recently CREATED </p>";
$delete = 1;
continue;
}
}
}
//
//HERE I NEED TO FIGURE OUT HOW TO DELETE THE NODE!!!
//
if($delete)
{
unset($elem[$cold]['childNodes']); //This did not work for me....
}
recTree($db,$elem[$cold]['childNodes']);
}
}
The code it now very clean as I am still in development mode, but core logic is working. I am very new to PHP so do not have much idea about deletion of a node in such a complex associate array.
Once this part is done, I should be able to complete this and would be able to share with all soon.
Looking forward for some solution to this problem.
Regards,
Arun Garg