PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/plan/planAddTCNavigator.php

https://bitbucket.org/pfernandez/testlink1.9.6
PHP | 351 lines | 25 code | 14 blank | 312 comment | 0 complexity | c8a0c843d3a0c138f329cce125502529 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. /**
  3. * TestLink Open Source Project - http://testlink.sourceforge.net/
  4. * This script is distributed under the GNU General Public License 2 or later.
  5. *
  6. * @package TestLink
  7. * @author Martin Havlat
  8. * @copyright 2005-2009, TestLink community
  9. * @version CVS: $Id: planAddTCNavigator.php,v 1.62 2010/06/28 16:19:37 asimon83 Exp $
  10. * @link http://www.teamst.org/index.php
  11. *
  12. * Navigator for feature: add Test Cases to a Test Case Suite in Test Plan.
  13. * It builds the javascript tree that allow the user select a required part
  14. * Test specification. Keywords should be used for filter.
  15. *
  16. * @internal Revisions:
  17. *
  18. * 20100628 - asimon - removal of constants from filter control class
  19. * 20100625 - asimon - refactoring for new filter features and BUGID 3516
  20. * 20100624 - asimon - CVS merge (experimental branch to HEAD)
  21. * 20100622 - asimon - huge refactorization for new tlTestCaseFilterControl class
  22. * 20100428 - asimon - BUGID 3301 and related issues - changed name or case
  23. * of some variables used in new common template,
  24. * added custom field filtering logic
  25. * 20100417 - franciscom - BUGID 2498: Add test case to test plan - Filter Test Cases based on Test Importance
  26. * 20100410 - franciscom - BUGID 2797 - filter by test case execution type
  27. * 20100228 - franciscom - BUGID 0001927: filter on keyword - Filter tree when add/remove testcases - KO
  28. * 20090415 - franciscom - BUGID 2384 - Tree doesnt load properly in Add / Remove Test Cases
  29. * 20090118 - franciscom - added logic to switch (for EXTJS tree type), how tree is builded
  30. * when there are filters
  31. */
  32. require('../../config.inc.php');
  33. require_once("common.php");
  34. require_once("treeMenu.inc.php");
  35. testlinkInitPage($db);
  36. $templateCfg = templateConfiguration();
  37. $control = new tlTestCaseFilterControl($db, 'plan_add_mode');
  38. $gui = initializeGui($control);
  39. $control->build_tree_menu($gui);
  40. $smarty = new TLSmarty();
  41. $smarty->assign('gui', $gui);
  42. $smarty->assign('control', $control);
  43. $smarty->assign('args', $gui->args);
  44. $smarty->assign('menuUrl', $gui->menuUrl);
  45. $smarty->display($templateCfg->template_dir . $templateCfg->default_template);
  46. /**
  47. * Initialize gui object for use in templates.
  48. * @param tlTestCaseFilterControl $control
  49. * @return object $gui
  50. */
  51. function initializeGui($control) {
  52. $gui = new stdClass();
  53. $gui->menuUrl = 'lib/plan/planAddTC.php';
  54. $gui->args = $control->get_argument_string();
  55. $gui->additional_string = '';
  56. $gui->src_workframe = $control->args->basehref . $gui->menuUrl .
  57. "?edit=testproject&id={$control->args->testproject_id}" . $gui->args;
  58. return $gui;
  59. }
  60. // old file content
  61. //require('../../config.inc.php');
  62. //require_once("common.php");
  63. //require_once("treeMenu.inc.php");
  64. //testlinkInitPage($db);
  65. //
  66. //$templateCfg = templateConfiguration();
  67. //$args = init_args();
  68. //// BUGID 3301 - added exec_cfield_mgr here
  69. //$exec_cfield_mgr = new exec_cfield_mgr($db,$args->tproject_id);
  70. //$gui = initializeGui($db,$args, $exec_cfield_mgr);
  71. //$gui->ajaxTree = initAjaxTree($args,$_SESSION['basehref']);
  72. //$gui->tree = buildTree($db,$gui,$args, $exec_cfield_mgr);
  73. //
  74. //$smarty = new TLSmarty();
  75. //$smarty->assign('gui', $gui);
  76. //
  77. //// IMPORTANT: A javascript variable 'args' will be initialized with this value
  78. //// using inc_head.tpl template.
  79. //$smarty->assign('args', $gui->args);
  80. //$smarty->assign('additionalArgs',$gui->additionalArgs);
  81. //
  82. //$smarty->assign('menuUrl', $gui->menuUrl);
  83. //$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
  84. //
  85. //
  86. ///*
  87. // function: init_args()
  88. // get input data
  89. // args: -
  90. //
  91. // returns: object expected parameters
  92. //
  93. //*/
  94. //function init_args()
  95. //{
  96. // $args = new stdClass();
  97. // $_REQUEST = strings_stripSlashes($_REQUEST);
  98. //
  99. // // Is an array because is a multiselect
  100. // $args->keyword_id = isset($_REQUEST['keyword_id']) ? $_REQUEST['keyword_id'] : 0;
  101. //
  102. // $args->tplan_id = isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID'];
  103. // $args->tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
  104. // $args->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : '';
  105. // $args->user_id = $_SESSION['userID'];
  106. //
  107. // $args->doUpdateTree = isset($_REQUEST['doUpdateTree']) ? 1 : 0;
  108. //
  109. // $args->called_by_me = isset($_REQUEST['called_by_me']) ? 1 : 0;
  110. // $args->called_url = isset($_REQUEST['called_url']) ? $_REQUEST['called_url'] : null;
  111. //
  112. // $args->keywordsFilterType =isset($_REQUEST['keywordsFilterType']) ? $_REQUEST['keywordsFilterType'] : 'OR';
  113. //
  114. // $args->exec_type = isset($_REQUEST['exec_type']) ? intval($_REQUEST['exec_type']) : 0;
  115. //
  116. // // BUGID 2498
  117. // $args->importance = isset($_REQUEST['importance']) ? intval($_REQUEST['importance']) : 0;
  118. //
  119. // return $args;
  120. //}
  121. //
  122. //
  123. ///*
  124. // function: initializeGui
  125. // args :
  126. // returns:
  127. //
  128. // rev:20100428 - asimon - BUGID 3301, added exec_cfield_mgr
  129. // 20080629 - franciscom - added missed argument basehref
  130. // 20080622 - franciscom - changes for ext js tree
  131. // 20080429 - franciscom
  132. //*/
  133. //function initializeGui(&$dbHandler,&$argsObj, &$exec_cfield_mgr)
  134. //{
  135. // $gui = new stdClass();
  136. // $tprojectMgr = new testproject($dbHandler);
  137. // $tcaseCfg = config_get('testcase_cfg');
  138. // $gui_open = config_get('gui_separator_open');
  139. // $gui_close = config_get('gui_separator_close');
  140. //
  141. // $gui->strOptionAny = $gui_open . lang_get('any') . $gui_close;
  142. // $gui->do_reload = 0;
  143. // $gui->src_workframe = null;
  144. //
  145. // $gui->keywordsFilterItemQty = 0;
  146. // $gui->keywordID = $argsObj->keyword_id;
  147. // $gui->keywordsMap = $tprojectMgr->get_keywords_map($argsObj->tproject_id);
  148. // if(!is_null($gui->keywordsMap))
  149. // {
  150. // $gui->keywordsMap = array( 0 => $gui->strOptionAny) + $gui->keywordsMap;
  151. // $gui->keywordsFilterItemQty = min(count($gui->keywordsMap),3);
  152. // }
  153. //
  154. // $gui->execType = $argsObj->exec_type;
  155. //
  156. // $initValues['keywords'] = $gui->keywordsMap;
  157. // $initValues['execTypes'] = 'init'; // initialisation will be done on tlControlPanel()
  158. // $gui->controlPanel = new tlControlPanel($dbHandler,$argsObj,$initValues);
  159. // $gui->execTypeMap = $gui->controlPanel->filters['execTypes']['items'];
  160. //
  161. // // filter using user roles
  162. // $opt = array('output' => 'combo');
  163. // $gui->controlPanel->settings['testPlans']['items'] =
  164. // $_SESSION['currentUser']->getAccessibleTestPlans($dbHandler,$argsObj->tproject_id,null,$opt);
  165. //
  166. // $gui->controlPanel->filters['testPlans']['items'] = $gui->controlPanel->settings['testPlans']['items'];
  167. //
  168. // $gui->mapTPlans = $gui->controlPanel->settings['testPlans']['items'];
  169. // $gui->tPlanID = $argsObj->tplan_id;
  170. // $gui->importance = $argsObj->importance;
  171. //
  172. // // 20100410
  173. //
  174. // $gui->menuUrl = 'lib/plan/planAddTC.php';
  175. // $gui->args = '&tplan_id=' . $gui->tPlanID;
  176. // if(is_array($argsObj->keyword_id))
  177. // {
  178. // $kl = implode(',',$argsObj->keyword_id);
  179. // $gui->args .= '&keyword_id=' . $kl;
  180. // }
  181. // else if($argsObj->keyword_id > 0)
  182. // {
  183. // $gui->args .= '&keyword_id='.$argsObj->keyword_id;
  184. // }
  185. // $gui->args .= '&keywordsFilterType=' . $argsObj->keywordsFilterType;
  186. // $gui->args .= '&executionType=' . $argsObj->exec_type;
  187. // $gui->args .= '&importance=' . $argsObj->importance;
  188. //
  189. //
  190. // $gui->keywordsFilterTypes = new stdClass();
  191. // $gui->keywordsFilterTypes->options = array('OR' => 'Or' , 'AND' =>'And');
  192. // $gui->keywordsFilterTypes->selected=$argsObj->keywordsFilterType;
  193. //
  194. // // BUGID 3301
  195. // $gui->design_time_cfields = $exec_cfield_mgr->html_table_of_custom_field_inputs(30);
  196. // $gui->additionalArgs = '';
  197. // return $gui;
  198. //}
  199. //
  200. //
  201. ///*
  202. // function:
  203. //
  204. // args :
  205. //
  206. // returns:
  207. //
  208. // rev:
  209. // 20100428 - asimon - BUGID 3301, added exec_cfield_mgr
  210. //
  211. //*/
  212. //function buildTree(&$dbHandler,&$guiObj,&$argsObj, &$exec_cfield_mgr)
  213. //{
  214. // $treeMenu = null;
  215. // $my_workframe = $_SESSION['basehref']. $guiObj->menuUrl .
  216. // "?edit=testproject&id={$argsObj->tproject_id}" . $guiObj->args;
  217. //
  218. // if($argsObj->doUpdateTree)
  219. // {
  220. // $guiObj->src_workframe = $my_workframe;
  221. // }
  222. // else if($argsObj->called_by_me)
  223. // {
  224. // // -------------------------------------------------------------------------------
  225. // // 20090308 - franciscom - think this is result of cut/paste from other
  226. // // piece of TL (look at edit=testsuite that has no use on
  227. // // test case testplan assignment.
  228. // //
  229. // // Explain what is objective of this chunck of code
  230. // // Warning:
  231. // // Algorithm based on field order on URL call
  232. // //
  233. // $dummy = explode('?',$argsObj->called_url);
  234. //
  235. //
  236. // $qs = isset($dummy[1]) ? explode('&',$dummy[1]) : array(0 => '');
  237. // if($qs[0] == 'edit=testsuite')
  238. // {
  239. // $guiObj->src_workframe = $dummy[0] . "?" . $qs[0] . "&" . $guiObj->args;
  240. // }
  241. // else
  242. // {
  243. // $guiObj->src_workframe = $my_workframe;
  244. // }
  245. // // -------------------------------------------------------------------------------
  246. // }
  247. //
  248. // $filters = array();
  249. // $filters['keywords'] = buildKeywordsFilter($argsObj->keyword_id,$guiObj);
  250. //
  251. //
  252. // $filters['executionType'] = buildExecTypeFilter($argsObj->exec_type); // BUGID 2797
  253. // $filters['importance'] = buildImportanceFilter($argsObj->importance); // BUGID 2498
  254. //
  255. // // BUGID 3301
  256. // $filters['cf_hash'] = $exec_cfield_mgr->get_set_values();
  257. //
  258. // $applyFilter = !is_null($filters['cf_hash']) || !is_null($filters['keywords']) ||
  259. // (!is_null($filters['executionType']) && intval($filters['executionType']->items) > 0) ||
  260. // (!is_null($filters['importance']) && intval($filters['importance']->items) > 0);
  261. //
  262. // if($applyFilter)
  263. // {
  264. // // 20100412 - franciscom
  265. // $filters['testplan'] = $argsObj->tplan_id;
  266. // $options = array('forPrinting' => NOT_FOR_PRINTING, 'hideTestCases' => HIDE_TESTCASES,
  267. // 'tc_action_enabled' => ACTION_TESTCASE_DISABLE,
  268. // 'ignore_inactive_testcases' => IGNORE_INACTIVE_TESTCASES,
  269. // 'getArguments' => $guiObj->args, 'viewType' => 'testSpecTreeForTestPlan');
  270. //
  271. // $treeMenu = generateTestSpecTree($dbHandler,$argsObj->tproject_id, $argsObj->tproject_name,
  272. // $guiObj->menuUrl,$filters,$options);
  273. //
  274. // // When using filters I need to switch to static generated tree, instead of Lazy Loading Ajax Tree
  275. // // that's reason why I'm re-creating from scratch ajaxTree.
  276. // //
  277. // $cookiePrefix = $guiObj->ajaxTree->cookiePrefix;
  278. // $guiObj->ajaxTree = new stdClass();
  279. // $guiObj->ajaxTree->loader = '';
  280. // $guiObj->ajaxTree->root_node = $treeMenu->rootnode;
  281. // $guiObj->ajaxTree->cookiePrefix = $cookiePrefix;
  282. //
  283. // // BUGID 2384 - if we return '' or null => EXT JS does not like it, we need to
  284. // // return json string that represents an EMPTY Tree => []
  285. // $guiObj->ajaxTree->children = $treeMenu->menustring ? $treeMenu->menustring : "[]";
  286. // }
  287. // return $treeMenu;
  288. //}
  289. //
  290. //
  291. ///**
  292. // * init ajax tree class
  293. // *
  294. // */
  295. //function initAjaxTree($argsObj,$basehref)
  296. //{
  297. // // need to understand if this is useless
  298. // // 20080629 - franciscom
  299. // // "filter_node={$argsObj->tsuites_to_show}";
  300. // $ajaxTree=new stdClass();
  301. // $ajaxTree->loader=$basehref . 'lib/ajax/gettprojectnodes.php?' .
  302. // "root_node={$argsObj->tproject_id}&show_tcases=0";
  303. //
  304. //
  305. // $ajaxTree->root_node=new stdClass();
  306. // $ajaxTree->root_node->href="javascript:EP({$argsObj->tproject_id})";
  307. // $ajaxTree->root_node->id=$argsObj->tproject_id;
  308. // $ajaxTree->root_node->name=$argsObj->tproject_name;
  309. //
  310. // // 20080831 - franciscom - Custom attribute
  311. // // You can access to it's value using public property 'attributes' of object of Class Ext.tree.TreeNode
  312. // // example: mynode.attributes.testlink_node_type
  313. // //
  314. // // Important:
  315. // // For root node (this node)
  316. // // You need to initialize every custom property you want to add to root node
  317. // // on the js file that create it (treebyloader.js) and smarty template
  318. // //
  319. // // Also this property must be managed in php code used to generate JSON code.
  320. // //
  321. // // I'appologize for using MAGIC constant
  322. // $ajaxTree->root_node->testlink_node_type='testproject';
  323. //
  324. // // Prefix for cookie used to save tree state
  325. // $ajaxTree->cookiePrefix="planaddtc_{$ajaxTree->root_node->id}_{$argsObj->user_id}_";
  326. //
  327. // // not allowed in this feature
  328. // $ajaxTree->dragDrop=new stdClass();
  329. // $ajaxTree->dragDrop->enabled=false;
  330. // $ajaxTree->dragDrop->BackEndUrl='';
  331. //
  332. // // TRUE -> beforemovenode() event will use our custom implementation
  333. // $ajaxTree->dragDrop->useBeforeMoveNode=FALSE;
  334. //
  335. // return $ajaxTree;
  336. //}
  337. ?>