* * Get inventory data * * @package TestLink * @author Martin Havlat * @copyright 2009, TestLink community * @version CVS: $Id: getInventory.php,v 1.2 2010/02/20 09:27:29 franciscom Exp $ * * @internal Revisions: * None * **/ require_once '../../config.inc.php'; require_once 'common.php'; testlinkInitPage($db); $tlIs = new tlInventory($_SESSION['testprojectID'], $db); $data = $tlIs->getAll(); $tlUser = new tlUser($_SESSION['userID']); $users = $tlUser->getNames($db); // fill login instead of user ID if (!is_null($data)) { foreach ($data as $k => $v) { if ($v['owner_id'] != '0') { $data[$k]['owner'] = $users[$v['owner_id']]['login']; } else { $data[$k]['owner'] = ''; } } } //new dBug($data); echo json_encode($data);
/** * delete test project from system, deleting all dependent data: * keywords, requirements, custom fields, testsuites, testplans, * testcases, results, testproject related roles, * * @param integer $id test project id * @return integer status * */ function delete($id) { $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; $ret['msg'] = 'ok'; $ret['status_ok'] = 1; $error = ''; $reqspec_mgr = new requirement_spec_mgr($this->db); // // Notes on delete related to Foreing Keys // All link tables has to be deleted first // // req_relations // // testplan_tcversions // testplan_platforms // object_keywords // user_assignments // builds // milestones // // testplans // keywords // platforms // attachtments // testcases // testsuites // inventory // // testproject $this->deleteKeywords($id); $this->deleteAttachments($id); $reqSpecSet = $reqspec_mgr->get_all_in_testproject($id); if (!is_null($reqSpecSet) && count($reqSpecSet) > 0) { foreach ($reqSpecSet as $reqSpec) { $reqspec_mgr->delete_deep($reqSpec['id']); } } $tplanSet = $this->get_all_testplans($id); if (!is_null($tplanSet) && count($tplanSet) > 0) { $tplan_mgr = new testplan($this->db); $items = array_keys($tplanSet); foreach ($items as $key) { $tplan_mgr->delete($key); } } $platform_mgr = new tlPlatform($this->db, $id); $platform_mgr->deleteByTestProject($id); $a_sql[] = array("/* {$debugMsg} */ UPDATE {$this->tables['users']} " . " SET default_testproject_id = NULL " . " WHERE default_testproject_id = {$id}", 'info_resetting_default_project_fails'); // BUGID 3464 $inventory_mgr = new tlInventory($id, $this->db); $invOpt = array('detailLevel' => 'minimun', 'accessKey' => 'id'); $inventorySet = $inventory_mgr->getAll($invOpt); if (!is_null($inventorySet)) { foreach ($inventorySet as $key => $dummy) { $inventory_mgr->deleteInventory($key); } } foreach ($a_sql as $oneSQL) { if (empty($error)) { $sql = $oneSQL[0]; $result = $this->db->exec_query($sql); if (!$result) { $error .= lang_get($oneSQL[1]); } } } if ($this->deleteUserRoles($id) < tl::OK) { $error .= lang_get('info_deleting_project_roles_fails'); } // --------------------------------------------------------------------------------------- // delete product itself and items directly related to it like: // custom fields assignments // custom fields values ( right now we are not using custom fields on test projects) // attachments if (empty($error)) { $sql = "/* {$debugMsg} */ DELETE FROM {$this->tables['cfield_testprojects']} WHERE testproject_id = {$id} "; $this->db->exec_query($sql); $sql = "/* {$debugMsg} */ DELETE FROM {$this->object_table} WHERE id = {$id}"; $result = $this->db->exec_query($sql); if ($result) { $tproject_id_on_session = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : $id; if ($id == $tproject_id_on_session) { $this->setSessionProject(null); } } else { $error .= lang_get('info_product_delete_fails'); } } if (empty($error)) { // BUGID 3147 - Delete test project with requirements defined crashed with memory exhausted $this->tree_manager->delete_subtree_objects($id, $id, '', array('testcase' => 'exclude_tcversion_nodes')); $sql = "/* {$debugMsg} */ DELETE FROM {$this->tables['nodes_hierarchy']} WHERE id = {$id} "; $this->db->exec_query($sql); } if (!empty($error)) { $ret['msg'] = $error; $ret['status_ok'] = 0; } return $ret; }