Exemplo n.º 1
0
 * @package 	TestLink
 * @author 		Martin Havlat
 * @copyright 	2009,2011 TestLink community 
 *
 * @internal revisions
 *
 **/
require_once '../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
$data['userfeedback'] = lang_get('inventory_msg_no_action');
$data['success'] = FALSE;
$args = init_args();
checkRights($db, $_SESSION['currentUser'], $args);
if ($_SESSION['currentUser']->hasRight($db, "project_inventory_management", $args->tproject_id)) {
    $tlIs = new tlInventory($args->tproject_id, $db);
    $data['success'] = $tlIs->setInventory($args);
    $data['success'] = $data['success'] == 1 ? true : false;
    $data['userfeedback'] = $tlIs->getUserFeedback();
    $data['record'] = $tlIs->getCurrentData();
} else {
    tLog('User has not rights to set a device!', 'ERROR');
    $data['userfeedback'] = lang_get('inventory_msg_no_rights');
}
echo json_encode($data);
/**
 * 
 *
 */
function init_args()
{
 * @author 		Martin Havlat
 * @copyright 	2009, TestLink community 
 * @version    	CVS: $Id: deleteInventory.php,v 1.3 2010/02/20 09:27:29 franciscom Exp $
 *
 * @internal Revisions:
 * None
 *
 **/
require_once '../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
$data['userfeedback'] = lang_get('inventory_msg_no_action');
$data['success'] = FALSE;
$args = init_args();
if ($_SESSION['currentUser']->hasRight($db, "project_inventory_management")) {
    $tlIs = new tlInventory($args->testprojectId, $db);
    $data['success'] = $tlIs->deleteInventory($args->machineID);
    $data['success'] = $data['success'] == 1 ? true : false;
    $data['userfeedback'] = $tlIs->getUserFeedback();
} else {
    tLog('User has not rights to set a device!', 'ERROR');
    $data['userfeedback'] = lang_get('inventory_msg_no_rights');
}
echo json_encode($data);
function init_args()
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $iParams = array("machineID" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    // from session
 *
 * 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);
Exemplo n.º 4
0
 /**
  * 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;
 }