Example #1
1
function initializeGui(&$dbHandler, &$argsObj, &$cfgObj, &$tplanMgr, &$tcaseMgr)
{
    $buildMgr = new build_mgr($dbHandler);
    $platformMgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui = new stdClass();
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->build_id = $argsObj->build_id;
    $gui->platform_id = $argsObj->platform_id;
    $gui->execStatusValues = null;
    $gui->can_use_bulk_op = 0;
    $gui->exec_notes_editors = null;
    $gui->bulk_exec_notes_editor = null;
    $gui->req_details = null;
    $gui->attachmentInfos = null;
    $gui->bugs = null;
    $gui->other_exec_cfields = null;
    $gui->ownerDisplayName = null;
    $gui->editorType = $cfgObj->editorCfg['type'];
    $gui->filter_assigned_to = $argsObj->filter_assigned_to;
    $gui->tester_id = $argsObj->user_id;
    $gui->include_unassigned = $argsObj->include_unassigned;
    $gui->tpn_view_status = $argsObj->tpn_view_status;
    $gui->bn_view_status = $argsObj->bn_view_status;
    $gui->bc_view_status = $argsObj->bc_view_status;
    $gui->platform_notes_view_status = $argsObj->platform_notes_view_status;
    $gui->refreshTree = $argsObj->refreshTree;
    if (!$argsObj->status || $argsObj->status == $cfgObj->tc_status['not_run']) {
        $gui->refreshTree = 0;
    }
    $gui->map_last_exec_any_build = null;
    $gui->map_last_exec = null;
    // 20081122 - franciscom
    // Just for the record:
    // doing this here, we avoid to do on processTestSuite() and processTestCase(),
    // but absolutely this will not improve in ANY WAY perfomance, because we do not loop
    // over these two functions.
    $tprojectMgr = new testproject($dbHandler);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
    $build_info = $buildMgr->get_by_id($argsObj->build_id);
    $gui->build_notes = $build_info['notes'];
    $gui->build_is_open = $build_info['is_open'] == 1 ? 1 : 0;
    $gui->execution_types = $tcaseMgr->get_execution_types();
    if ($argsObj->filter_assigned_to) {
        $userSet = tlUser::getByIds($dbHandler, array_values($argsObj->filter_assigned_to));
        if ($userSet) {
            foreach ($userSet as $key => $userObj) {
                $gui->ownerDisplayName[$key] = $userObj->getDisplayName();
            }
        }
    }
    // ------------------------------------------------------------------
    $the_builds = $tplanMgr->get_builds_for_html_options($argsObj->tplan_id);
    $gui->build_name = isset($the_builds[$argsObj->build_id]) ? $the_builds[$argsObj->build_id] : '';
    // 20090419 - franciscom
    $gui->grants = initializeRights($dbHandler, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $gui->exec_mode = initializeExecMode($dbHandler, $cfgObj->exec_cfg, $argsObj->user, $argsObj->tproject_id, $argsObj->tplan_id);
    $rs = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testplan_notes = $rs['notes'];
    // Important note:
    // custom fields for test plan can be edited ONLY on design, that's reason why we are using
    // scope = 'design' instead of 'execution'
    $gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id, 'design', array('show_on_execution' => 1));
    $gui->history_on = manage_history_on($_REQUEST, $_SESSION, $cfgObj->exec_cfg, 'btn_history_on', 'btn_history_off', 'history_on');
    $gui->history_status_btn_name = $gui->history_on ? 'btn_history_off' : 'btn_history_on';
    $dummy = $platformMgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->has_platforms = !is_null($dummy) ? 1 : 0;
    $gui->platform_info['id'] = 0;
    $gui->platform_info['name'] = '';
    if (!is_null($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
    }
    $gui->node_id = $argsObj->id;
    return $gui;
}
Example #2
0
function initializeGui(&$dbHandler, &$argsObj)
{
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $guiObj = new stdClass();
    $guiObj->platforms = $platform_mgr->getAll(array('include_linked_count' => true));
    $guiObj->canManage = $argsObj->currentUser->hasRight($dbHandler, "platform_management", $argsObj->tproject_id);
    $guiObj->user_feedback = null;
    $guiObj->tproject_id = $argsObj->tproject_id;
    return $guiObj;
}
Example #3
0
/**
 * @param object dbHandler reference to db handler
 *
 */
function doImport(&$dbHandler, $testproject_id)
{
    $import_msg = array('ok' => array(), 'ko' => array());
    $file_check = array('show_results' => 0, 'status_ok' => 0, 'msg' => '', 'filename' => '', 'import_msg' => $import_msg);
    $key = 'targetFilename';
    $dest = TL_TEMP_PATH . session_id() . "-import_platforms.tmp";
    $fInfo = $_FILES[$key];
    $source = isset($fInfo['tmp_name']) ? $fInfo['tmp_name'] : null;
    if ($source != 'none' && $source != '') {
        $file_check['filename'] = $fInfo['name'];
        $xml = false;
        if (move_uploaded_file($source, $dest)) {
            $xml = @simplexml_load_file($dest);
        }
        if ($xml !== FALSE) {
            $file_check['status_ok'] = 1;
            $file_check['show_results'] = 1;
            $platform_mgr = new tlPlatform($dbHandler, $testproject_id);
            $platformsOnSystem = $platform_mgr->getAllAsMap('name', 'rows');
            foreach ($xml as $platform) {
                // Check if platform with this name already exists on test Project
                // if answer is yes => update fields
                $name = trim($platform->name);
                if (isset($platformsOnSystem[$name])) {
                    $import_msg['ok'][] = sprintf(lang_get('platform_updated'), $platform->name);
                    $platform_mgr->update($platformsOnSystem[$name]['id'], $name, $platform->notes);
                } else {
                    $import_msg['ok'][] = sprintf(lang_get('platform_imported'), $platform->name);
                    $platform_mgr->create($name, $platform->notes);
                }
            }
        } else {
            $file_check['msg'] = lang_get('problems_loading_xml_content');
        }
    } else {
        $msg = getFileUploadErrorMessage($fInfo);
        $file_check = array('show_results' => 0, 'status_ok' => 0, 'msg' => $msg);
    }
    $file_check['import_msg'] = $import_msg;
    return $file_check;
}
Example #4
0
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr, &$tcaseMgr)
{
    $tcase_cfg = config_get('testcase_cfg');
    $title_separator = config_get('gui_title_separator_1');
    $gui = new stdClass();
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->testCasePrefix = $tcaseMgr->tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
    $gui->testCasePrefix .= $tcase_cfg->glue_character;
    $gui->can_remove_executed_testcases = $argsObj->user->hasRight($dbHandler, "testplan_unlink_executed_testcases", $argsObj->tproject_id);
    $gui->can_remove_executed_testcases = $gui->can_remove_executed_testcases == 'yes';
    $tprojectInfo = $tcaseMgr->tproject_mgr->get_by_id($argsObj->tproject_id);
    $gui->priorityEnabled = $tprojectInfo['opt']->testPriorityEnabled;
    $gui->keywordsFilterType = $argsObj->keywordsFilterType;
    $gui->keywords_filter = '';
    $gui->has_tc = 0;
    $gui->items = null;
    $gui->has_linked_items = false;
    $gui->keywordsFilterType = new stdClass();
    $gui->keywordsFilterType->options = array('OR' => 'Or', 'AND' => 'And');
    $gui->keywordsFilterType->selected = $argsObj->keywordsFilterType;
    // full_control, controls the operations planAddTC_m1.tpl will allow
    // 1 => add/remove
    // 0 => just remove
    $gui->full_control = 1;
    $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testPlanName = $tplan_info['name'];
    $gui->pageTitle = lang_get('test_plan') . $title_separator . $gui->testPlanName;
    $gui->refreshTree = $argsObj->refreshTree;
    $tproject_mgr = new testproject($dbHandler);
    $tproject_info = $tproject_mgr->get_by_id($argsObj->tproject_id);
    $userSet = $argsObj->user->getAll($dbHandler);
    $gui->testers = tlUser::getTestersForHtmlOptions($tplan_info, $tproject_info, $userSet);
    $gui->testerID = $argsObj->testerID;
    $gui->send_mail = $argsObj->send_mail;
    $gui->send_mail_checked = '';
    if ($gui->send_mail) {
        $gui->send_mail_checked = ' checked="checked" ';
    }
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui->platforms = $platform_mgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->platformsForHtmlOptions = null;
    $gui->usePlatforms = $platform_mgr->platformsActiveForTestplan($argsObj->tplan_id);
    if ($gui->usePlatforms) {
        // Create options for two different select boxes. $bulk_platforms
        // has "All platforms" on top and "$platformsForHtmlOptions" has an
        // empty item
        $gui->platformsForHtmlOptions[0] = '';
        foreach ($gui->platforms as $elem) {
            $gui->platformsForHtmlOptions[$elem['id']] = $elem['name'];
        }
        $gui->bulk_platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
        $gui->bulk_platforms[0] = lang_get("all_platforms");
        ksort($gui->bulk_platforms);
    }
    //
    $gui->warning_msg = new stdClass();
    $gui->warning_msg->executed = lang_get('executed_can_not_be_removed');
    if ($gui->can_remove_executed_testcases) {
        $gui->warning_msg->executed = lang_get('has_been_executed');
    }
    // BUGID 3406
    $gui->build = init_build_selector($tplanMgr, $argsObj);
    return $gui;
}
Example #5
0
/**
 *
 *
 */
function processTestCase(&$dbHandler, $tplEngine, $args, &$gui, $grants, $cfg)
{
    $get_path_info = false;
    $item_mgr = new testcase($dbHandler);
    // has sense only when we work on test case
    $dummy = testcase::getLayout();
    $gui->tableColspan = $dummy->tableToDisplayTestCaseSteps->colspan;
    $gui->viewerArgs['refresh_tree'] = 'no';
    $gui->path_info = null;
    $gui->platforms = null;
    $gui->loadOnCancelURL = '';
    $gui->attachments = null;
    $gui->direct_link = null;
    $gui->steps_results_layout = $cfg['spec']->steps_results_layout;
    $gui->bodyOnUnload = "storeWindowSize('TCEditPopup')";
    if ($args->caller == 'navBar' && !is_null($args->targetTestCase) && strcmp($args->targetTestCase, $args->tcasePrefix) != 0) {
        $args->id = $item_mgr->getInternalID($args->targetTestCase);
        $args->tcversion_id = testcase::ALL_VERSIONS;
        // I've added $args->caller, in order to make clear the logic, because some actions need to be done ONLY
        // when we have arrived to this script because user has requested a search from navBar.
        // Before we have trusted the existence of certain variables (do not think this old kind of approach is good).
        //
        // why strcmp($args->targetTestCase,$args->tcasePrefix) ?
        // because in navBar targetTestCase is initialized with testcase prefix to provide some help to user
        // then if user request search without adding nothing, we will not be able to search.
        // From navBar we want to allow ONLY to search for ONE and ONLY ONE test case ID.
        $gui->viewerArgs['show_title'] = 'no';
        $gui->viewerArgs['display_testproject'] = 1;
        $gui->viewerArgs['display_parent_testsuite'] = 1;
        if (!($get_path_info = $args->id > 0)) {
            $gui->warning_msg = $args->id == 0 ? lang_get('testcase_does_not_exists') : lang_get('prefix_does_not_exists');
        }
    }
    // because we can arrive here from a User Search Request, if args->id == 0 => nothing found
    if ($args->id > 0) {
        if ($get_path_info || $args->show_path) {
            $gui->path_info = $item_mgr->tree_manager->get_full_path_verbose($args->id);
        }
        $platform_mgr = new tlPlatform($dbHandler, $args->tproject_id);
        $gui->platforms = $platform_mgr->getAllAsMap();
        $gui->attachments[$args->id] = getAttachmentInfosFrom($item_mgr, $args->id);
        $gui->direct_link = $item_mgr->buildDirectWebLink($_SESSION['basehref'], $args->id);
        $gui->id = $args->id;
        $identity = new stdClass();
        $identity->id = $args->id;
        $identity->tproject_id = $args->tproject_id;
        $identity->version_id = $args->tcversion_id;
        try {
            $item_mgr->show($tplEngine, $gui, $identity, $grants);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
        exit;
    } else {
        $templateCfg = templateConfiguration();
        // need to initialize search fields
        $xbm = $item_mgr->getTcSearchSkeleton();
        $xbm->warning_msg = lang_get('no_records_found');
        $xbm->pageTitle = lang_get('caption_search_form');
        $xbm->tableSet = null;
        $xbm->doSearch = false;
        $xbm->tproject_id = $args->tproject_id;
        $tplEngine->assign('gui', $xbm);
        $tplEngine->display($templateCfg->template_dir . 'tcSearchResults.tpl');
    }
}
Example #6
0
 <?php 
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->tplan_id = $_GET['id'];
$_SESSION["testplanID"] = $gui->tplan_id;
$gui->tplanDevices = $platform_mgr->getTplanDevices($gui->tplan_id);
$gui->totalDevices = count($gui->tplanDevices) - 1;
$gui->tplanCases = $platform_mgr->getTplanTestCases($gui->tplan_id);
$gui->tplanName = $_GET['name'];
$gui->username = $args->login_username;
$gui->divindex = 0;
if (isset($_GET['divindex'])) {
    $gui->divindex = $_GET['divindex'];
}
$tplan_mgr = new testplan($db);
$gui->suites = $tplan_mgr->get_all_suites();
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    $args->login_username = $_SESSION['currentUser']->getDisplayName();
    return $args;
Example #7
0
<?php

require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->user = $args->user;
$gui->device_name = $platform_mgr->getDeviceName($args->productline_id, $args->device_id);
$gui->productline_id = $args->productline_id;
setcookie(job_productline_id, $args->productline_id);
setcookie(job_tplan_id, $args->tplan_id);
setcookie(job_build_id, $args->build_id);
setcookie(job_device_id, $args->device_id);
setcookie(job_user_name, $args->user);
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->user = $_SESSION['currentUser']->getDisplayName();
    $args->productline_id = $args->testproject_id;
    $args->tplan_id = $_GET['tplan'];
    $args->build_id = $_GET['build'];
    $args->device_id = $_GET['device'];
    return $args;
}
Example #8
0
 <?php 
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$tplan_id = $_GET['tplanid'];
$device_id = $_GET['deviceid'];
$divindex = $_GET['divindex'];
$name = $_GET['tplanname'];
$cases = $platform_mgr->getTplanCasesScripts($tplan_id, $device_id);
$index = rand(1, 10);
$filename = "../../upload_area/exec_logs/var_export/testlink_cases{$index}.testlink";
$file = fopen($filename, 'w');
$text = "# This file file is created by TestLink!\r\n";
fwrite($file, $text);
foreach ($cases as $case) {
    $text = '#' . $case['script'] . '#' . "\r\n";
    fwrite($file, $text);
}
fclose($file);
echo "<script>window.open('{$filename}');self.location.href='/lib/dcnTplanCase/tplanCaseView.php?id={$tplan_id}&name={$tplanname}&divindex={$divindex}&name={$name}';</script>";
exit;
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    $args->login_username = $_SESSION['currentUser']->getDisplayName();
Example #9
0
<?php

header("Content-Type:text/html;charset=utf-8");
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
$jobid = $_GET['id'];
if (is_null($_GET['confirm'])) {
    echo "<script>if(window.confirm('注意:只有因本地moni/dauto平台异常或手动退出后,才能将testlink上对应任务(异常任务)清理归档!')) location.href='jobtrash.php?id={$jobid}&confirm=yes';else location.href='jobtrash.php?id={$jobid}&confirm=no';</script>";
} else {
    $confirm = $_GET['confirm'];
    if ($confirm == 'yes') {
        $platform_mgr = new tlPlatform($db, $testproject_id);
        $result = $platform_mgr->jobtrash($jobid);
        if ($result == 1) {
            echo '<script type="text/javascript">window.alert("该任务成功归档至历史任务!");location.href="/lib/dcnJobs/jobsView.php";</script>';
        } else {
            echo '<script type="text/javascript">window.alert("归档失败,请检查后重试!");location.href="/lib/dcnJobs/jobsView.php";</script>';
        }
    } else {
        echo '<script type="text/javascript">location.href="/lib/dcnJobs/jobsView.php";</script>';
    }
}
function checkRights(&$db, &$user)
{
    return True;
}
Example #10
0
 <?php 
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$tplan_id = $_GET['tplanid'];
$device_id = $_GET['deviceid'];
$suite = $_GET['suite'];
$tplanname = $_GET['tplanname'];
$divindex = $_GET['divindex'];
$rs = $platform_mgr->pullCasesFromVar($tplan_id, $device_id, $suite, $args->login_username);
if ($rs != 'OK') {
    echo "<script>alert('{$rs}');</script>";
}
echo "<script>self.location.href='/lib/dcnTplanCase/tplanCaseView.php?id={$tplan_id}&name={$tplanname}&divindex={$divindex}';</script>";
exit;
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    $args->login_username = $_SESSION['currentUser']->getDisplayName();
    return $args;
}
function checkRights(&$db, &$user)
{
    return True;
}
Example #11
0
<?php 
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$var_id = $_GET['varid'];
$suite_id = $_GET['suiteid'];
//var_cases
$fp = @fopen($_FILES['varfile']['tmp_name'], "r");
switch ($suite_id) {
    case '3959':
        //affirm2
        if (preg_match("/^.*?\\.tcl/i", $_FILES['varfile']['name'], $temp)) {
            if ($fp) {
                $var_cases = array();
                while (!feof($fp)) {
                    $buffer = fgets($fp, 4096);
                    if (preg_match("/^set {affirm_(.*?)} 1/i", $buffer, $case)) {
                        $tcversion_id = $platform_mgr->getTcversionidByName($case[1], 'affirm2');
                        if ($tcversion_id != 0) {
                            $var_cases[] = $tcversion_id;
                        }
                    } elseif (preg_match("/^set {(bf.*?)} 1/i", $buffer, $case)) {
                        $tcversion_id = $platform_mgr->getTcversionidByName($case[1], 'affirm2');
                        if ($tcversion_id != 0) {
                            $var_cases[] = $tcversion_id;
                        }
                    } elseif (preg_match("/^set {(mt.*?)} 1/i", $buffer, $case)) {
                        $tcversion_id = $platform_mgr->getTcversionidByName($case[1], 'affirm2');
Example #12
0
<?php

require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->nowdate = isset($_POST['mydate']) ? $_POST['mydate'] : strftime("%Y-%m", time());
$gui->postdate = isset($_POST['mydate']) ? $_POST['mydate'] : 0;
$gui->tpreport = isset($_POST['testplan_monthreport']) ? $_POST['testplan_monthreport'] : 0;
if (isset($_POST['mydate'])) {
    $gui->monthJobs = $platform_mgr->getMonthReport($_POST['mydate'], $gui->tpreport);
    $gui->num_monthJobs = count($gui->monthJobs);
}
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    return $args;
}
function checkRights(&$db, &$user)
{
    return True;
}
Example #13
0
/**
 * @internal revisions
 */
function importTestPlanLinksFromXML(&$dbHandler, &$tplanMgr, $targetFile, $contextObj)
{
    //   <testplan>
    //     <name></name>
    //     <platforms>
    //       <platform>
    //         <name> </name>
    //         <internal_id></internal_id>
    //       </platform>
    //       <platform>
    //       ...
    //       </platform>
    //     </platforms>
    //     <executables>
    //       <link>
    //         <platform>
    //           <name> </name>
    //         </platform>
    //         <testcase>
    //           <name> </name>
    //           <externalid> </externalid>
    //           <version> </version>
    //           <execution_order> </execution_order>
    //         </testcase>
    //       </link>
    //       <link>
    //       ...
    //       </link>
    //     </executables>
    //   </testplan>
    // </xml>
    $msg = array();
    $labels = init_labels(array('link_without_required_platform' => null, 'ok' => null, 'link_without_platform_element' => null, 'no_platforms_on_tproject' => null, 'tcase_link_updated' => null, 'link_with_platform_not_needed' => null, 'tproject_has_zero_testcases' => null, 'platform_not_on_tproject' => null, 'platform_linked' => null, 'platform_not_linked' => null, 'tcase_doesnot_exist' => null, 'tcversion_doesnot_exist' => null, 'not_imported' => null, 'link_to_tplan_feedback' => null, 'link_to_platform' => null));
    // Double Check
    // Check if Test Plan Parent (Test Project) has testcases, if not abort
    $tprojectMgr = new testproject($dbHandler);
    $tprojectInfo = $tprojectMgr->get_by_id($contextObj->tproject_id);
    $tcasePrefix = $tprojectInfo['prefix'] . config_get('testcase_cfg')->glue_character;
    $tprojectHasTC = $tprojectMgr->count_testcases($contextObj->tproject_id) > 0;
    if (!$tprojectHasTC) {
        $msg[] = array(sprintf($labels['tproject_has_zero_testcases'], $tprojectInfo['name']), $labels['not_imported']);
        return $msg;
        // >>>-----> Bye
    }
    $xml = @simplexml_load_file_wrapper($targetFile);
    if ($xml !== FALSE) {
        $tcaseMgr = new testcase($dbHandler);
        $tcaseSet = array();
        $tprojectMgr->get_all_testcases_id($contextObj->tproject_id, $tcaseSet, array('output' => 'external_id'));
        $tcaseSet = array_flip($tcaseSet);
        // Test Plan name will not be used
        // <testplan>  <name></name>
        //
        // Platform definition info will not be used
        //
        // I will try to link the platforms if are defined
        $status_ok = true;
        if (property_exists($xml, 'platforms')) {
            $platformMgr = new tlPlatform($dbHandler, $contextObj->tproject_id);
            $platformUniverse = $platformMgr->getAllAsMap();
            if (is_null($platformUniverse)) {
                $status_ok = false;
                $msg[] = array($labels['no_platforms_on_tproject'], $labels['not_imported']);
            } else {
                $platformUniverse = array_flip($platformUniverse);
                $op = processPlatforms($platformMgr, $tplanMgr, $platformUniverse, $xml->platforms, $labels, $contextObj->tplan_id);
                $status_ok = $op['status_ok'];
                $msg = $op['msg'];
            }
        }
        if ($status_ok && $xml->xpath('//executables')) {
            $tables = tlObjectWithDB::getDBTables(array('testplan_tcversions'));
            $platformSet = $tplanMgr->getPlatforms($contextObj->tplan_id, array('outputFormat' => 'mapAccessByName'));
            $targetHasPlatforms = count($platformSet) > 0;
            $xmlLinks = $xml->executables->children();
            $loops2do = count($xmlLinks);
            // new dBug($platformSet);
            for ($idx = 0; $idx < $loops2do; $idx++) {
                // if Target Test Plan has platforms and importing file NO => Fatal Error
                $targetName = null;
                $platformID = -1;
                $linkWithPlatform = false;
                $status_ok = false;
                $dummy_msg = null;
                $import_status = $labels['ok'];
                if ($platformElementExists = property_exists($xmlLinks[$idx], 'platform')) {
                    $targetName = trim((string) $xmlLinks[$idx]->platform->name);
                    $linkWithPlatform = $targetName != '';
                }
                // echo "\$targetHasPlatforms:$targetHasPlatforms<br>";
                // echo "\$linkWithPlatform:$linkWithPlatform<br>";
                if ($targetHasPlatforms) {
                    // each link need to have platform or will not be imported
                    if ($linkWithPlatform && isset($platformSet[$targetName])) {
                        $platformID = $platformSet[$targetName]['id'];
                        $status_ok = true;
                        $dummy_msg = null;
                    } else {
                        $import_status = $labels['not_imported'];
                        if (!$platformElementExists) {
                            $dummy_msg = sprintf($labels['link_without_platform_element'], $idx + 1);
                        } else {
                            if (!$linkWithPlatform) {
                                $dummy_msg = sprintf($labels['link_without_required_platform'], $idx + 1);
                            } else {
                                $dummy_msg = sprintf($labels['platform_not_linked'], $idx + 1, $targetName, $contextObj->tplan_name);
                            }
                        }
                    }
                } else {
                    if ($linkWithPlatform) {
                        $import_status = $labels['not_imported'];
                        $dummy_msg = sprintf($labels['link_with_platform_not_needed'], $idx + 1);
                    } else {
                        $platformID = 0;
                        $status_ok = true;
                    }
                }
                if (!is_null($dummy_msg)) {
                    $msg[] = array($dummy_msg, $import_status);
                }
                // echo '$status_ok' . $status_ok . ' ' . __LINE__ . '<br>' ;
                if ($status_ok) {
                    $createLink = false;
                    $updateLink = false;
                    // Link passed ok check on platform
                    // Now we need to understand if requested Test case is present on Test Project
                    $externalID = (int) $xmlLinks[$idx]->testcase->externalid;
                    $tcaseName = (string) $xmlLinks[$idx]->testcase->name;
                    $execOrder = (int) $xmlLinks[$idx]->testcase->execution_order;
                    $version = (int) $xmlLinks[$idx]->testcase->version;
                    if (isset($tcaseSet[$externalID])) {
                        // now need to check if requested version exists
                        $dummy = $tcaseMgr->get_basic_info($tcaseSet[$externalID], array('number' => $version));
                        if (count($dummy) > 0) {
                            // Check :
                            // for same test plan there is a different version already linked ?
                            // if YES => error.
                            //
                            $lvFilters = array('tplan_id' => $contextObj->tplan_id);
                            $linkedVersions = $tcaseMgr->get_linked_versions($dummy[0]['id'], $lvFilters);
                            $updateLink = false;
                            $doUpdateFeedBack = true;
                            // TICKET 5189: Import a test plan does not import test cases execution order
                            // new dBug($linkedVersions);
                            if (!($createLink = is_null($linkedVersions))) {
                                // Now need to understand if is already linked with this signature.
                                if (!isset($linkedVersions[$dummy[0]['tcversion_id']])) {
                                    //echo 'CREATE';
                                    $createLink = true;
                                } else {
                                    // linked platforms
                                    $createLink = false;
                                    $updateLink = false;
                                    $plat_keys = array_keys($linkedVersions[$dummy[0]['tcversion_id']][$contextObj->tplan_id]);
                                    $plat_keys = array_flip($plat_keys);
                                    if (isset($plat_keys[$platformID])) {
                                        $updateLink = true;
                                    } else {
                                        if ($platformID == 0) {
                                            // User request to add without platform, but platforms exist => SKIP
                                            $msg[] = array('platform 0 missing messages', $labels['not_imported']);
                                        } else {
                                            $createLink = true;
                                        }
                                    }
                                }
                            }
                            if ($createLink) {
                                // Create link
                                // function link_tcversions($id,&$items_to_link,$userId)
                                $item2link['items'] = array($dummy[0]['id'] => array($platformID => $dummy[0]['tcversion_id']));
                                $item2link['tcversion'] = array($dummy[0]['id'] => $dummy[0]['tcversion_id']);
                                $tplanMgr->link_tcversions($contextObj->tplan_id, $item2link, $contextObj->userID);
                                $dummy_msg = sprintf($labels['link_to_tplan_feedback'], $externalID, $version);
                                if ($platformID > 0) {
                                    $dummy_msg .= sprintf($labels['link_to_platform'], $targetName);
                                }
                                $msg[] = array($dummy_msg, $labels['ok']);
                                // TICKET 5189: Import a test plan does not import test cases execution order
                                $updateLink = true;
                                $doUpdateFeedBack = false;
                            }
                            if ($updateLink) {
                                $newOrder = array($dummy[0]['tcversion_id'] => $execOrder);
                                $tplanMgr->setExecutionOrder($contextObj->tplan_id, $newOrder);
                                if ($doUpdateFeedBack) {
                                    $dummy_msg = sprintf($labels['tcase_link_updated'], $tcasePrefix . $externalID . ' ' . $tcaseName, $version);
                                    $msg[] = array($dummy_msg, $labels['ok']);
                                }
                            }
                        } else {
                            $msg[] = array(sprintf($labels['tcversion_doesnot_exist'], $externalID, $version, $tprojectInfo['name']));
                        }
                    } else {
                        $msg[] = array(sprintf($labels['tcase_doesnot_exist'], $externalID, $tprojectInfo['name']));
                    }
                    //$tcaseMgr->get_by_external
                    // echo '<pre><xmp>';
                    // var_dump($xmlLinks[$idx]->testcase);
                    // echo 'TCBAME' . (string)$xmlLinks[$idx]->testcase->name;
                    // echo '</xmp></pre>';
                }
            }
        }
    }
    return $msg;
}
 private function init_setting_platform()
 {
     if (!$this->platform_mgr) {
         $this->platform_mgr = new tlPlatform($this->db);
     }
     $key = 'setting_platform';
     $this->settings[$key] = array('items' => null, 'selected' => $this->args->{$key});
     $testplan_id = $this->settings['setting_testplan']['selected'];
     $this->settings[$key]['items'] = $this->platform_mgr->getLinkedToTestplanAsMap($testplan_id);
     // BUGID 3726
     $session_key = $testplan_id . '_stored_setting_platform';
     $session_selection = isset($_SESSION[$session_key]) ? $_SESSION[$session_key] : null;
     if (!$this->settings[$key]['selected']) {
         $this->settings[$key]['selected'] = $session_selection;
     }
     if (!isset($this->settings[$key]['items']) || !is_array($this->settings[$key]['items'])) {
         $this->settings[$key] = false;
     } else {
         if (isset($this->settings[$key]['items']) && is_array($this->settings[$key]['items']) && is_null($this->settings[$key]['selected'])) {
             // platforms exist, but none has been selected yet, so select first one
             $this->settings[$key]['selected'] = key($this->settings[$key]['items']);
         }
     }
     $_SESSION[$session_key] = $this->settings[$key]['selected'];
 }
Example #15
0
 * @author 		Martin Havlat
 * 
 * Report requirement based results
 * 
 * @internal revisions
 */
require_once "../../config.inc.php";
require_once "common.php";
require_once 'requirements.inc.php';
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$tproject_mgr = new testproject($db);
$tplan_mgr = new testplan($db);
$req_mgr = new requirement_mgr($db);
$req_spec_mgr = new requirement_spec_mgr($db);
$platform_mgr = new tlPlatform($db);
$glue_char = config_get('gui_title_separator_1');
$glue_char_tc = config_get('testcase_cfg')->glue_character;
// BUGID 3439
$charset = config_get('charset');
$req_cfg = config_get('req_cfg');
$req_spec_cfg = config_get('req_spec_cfg');
$results_cfg = config_get('results');
$labels = init_labels(array('requirement' => null, 'requirements' => null, 'type' => null, 'req_availability' => null, 'linked_tcs' => null, 'no_linked_tcs' => null, 'goto_testspec' => null, 'design' => null, 'no_label_for_req_type' => null, 'na' => 'not_aplicable', 'no_srs' => 'no_srs_defined', 'no_matching_reqs' => null, 'execution' => null, 'execution_history' => null));
$labels['req_types'] = init_labels($req_cfg->type_labels);
$labels['req_spec_types'] = init_labels($req_spec_cfg->type_labels);
$labels['status'] = init_labels($req_cfg->status_labels);
$history_icon = TL_THEME_IMG_DIR . "history_small.png";
$exec_img = TL_THEME_IMG_DIR . "exec_icon.png";
$edit_icon = TL_THEME_IMG_DIR . "edit_icon.png";
$status_code_map = array();
Example #16
0
<?php

require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->job_id = isset($_GET['id']) ? $_GET['id'] : 0;
if (isset($_GET['id'])) {
    $gui->jobReport = $platform_mgr->getMonthReportJob($_GET['id']);
}
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    return $args;
}
function checkRights(&$db, &$user)
{
    return True;
}
 * This script is distributed under the GNU General Public License 2 or later. 
 *
 * Filename $RCSfile: platformsView.php,v $
 *
 * @version $Revision: 1.7 $
 * @modified $Date: 2010/09/12 15:16:09 $ by $Author: franciscom $
 *
 * allows users to manage platforms. 
 * @internal revisions
 */
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->platforms = $platform_mgr->getAll(array('include_linked_count' => true));
$gui->canManage = $args->currentUser->hasRight($db, "platform_management");
$gui->user_feedback = null;
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/**
 * 
 *
 */
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
Example #18
0
 /**
  * Copy platforms
  * 
  * @param int $source_id original Test Project identificator
  * @param int $target_id new Test Project identificator
  */
 private function copy_platforms($source_id, $target_id)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $platform_mgr = new tlPlatform($this->db, $source_id);
     $old_new = null;
     $platformSet = $platform_mgr->getAll();
     if (!is_null($platformSet)) {
         $platform_mgr->setTestProjectID($target_id);
         foreach ($platformSet as $platform) {
             $op = $platform_mgr->create($platform['name'], $platform['notes']);
             $old_new[$platform['id']] = $op['id'];
         }
     }
     return $old_new;
 }
 /**
  * Get test case executions by BuildId and RequirementId and PlatformId
  *
  * @param struct $args
  * @param string $args["devKey"]
  * @param int $args["testprojectid"]
  * @param int $args["buildid"]
  * @param int $args["requirementid"]
  * @param int $args["platformid"]
  * @return mixed
  * @access public
  */
 public function getTestCasesExecutionsByBuildAndPlatformAndRequirement($args)
 {
     $this->_setArgs($args);
     if (!$this->authenticate()) {
         return $this->errors;
     }
     $projectId = $this->args[self::$testProjectIDParamName];
     $buildId = $this->args[self::$buildIDParamName];
     $requirementId = $this->args[self::$requirementIDParamName];
     $platformId = $this->args[self::$platformIDParamName];
     $testProject = $this->tprojectMgr->get_by_id($projectId);
     $build = $this->buildMgr->get_by_id($buildId);
     $requirement = $this->reqMgr->get_by_id($requirementId);
     $platformMgr = new tlPlatform($this->dbObj, $projectId);
     $platform = $platformMgr->getById($platformId);
     $hasError = false;
     if (is_null($testProject)) {
         $this->errors[] = new IXR_ERROR(100007, 'Project does not exists');
         $hasError = true;
     } else {
         if (is_null($build['id'])) {
             $this->errors[] = new IXR_ERROR(100100, 'Build does not exists');
             $hasError = true;
         } else {
             if (is_null($requirement)) {
                 $this->errors[] = new IXR_ERROR(100200, 'Requirement does not exists');
                 $hasError = true;
             } else {
                 if (is_null($platform)) {
                     $this->errors[] = new IXR_ERROR(100300, 'Platform does not exists');
                     $hasError = true;
                 }
             }
         }
     }
     if ($hasError) {
         return $this->errors;
     }
     $sql = "SELECT NHTCV.parent_id AS tcase_id, E.status AS exec_status FROM testplan_tcversions TPTCV JOIN nodes_hierarchy NHTCV ON NHTCV.id = TPTCV.tcversion_id LEFT OUTER JOIN executions E ON E.testplan_id = TPTCV.testplan_id AND E.platform_id = TPTCV.platform_id AND E.tcversion_id = TPTCV.tcversion_id AND E.build_id = {$build['id']} WHERE TPTCV.testplan_id = {$build['testplan_id']} AND TPTCV.platform_id = {$platform['id']}";
     $test_cases_executions = $this->dbObj->fetchRowsIntoMap($sql, 'tcase_id');
     $testcase_ids = array_keys($test_cases_executions);
     if (empty($testcase_ids)) {
         return array_values(array());
     }
     $in_clause = implode(",", (array) $testcase_ids);
     $sql = "SELECT testcase_id FROM req_coverage WHERE req_id IN ({$requirementId}) AND testcase_id IN ({$in_clause})";
     $reqTestCasesIds = array_keys($this->dbObj->fetchRowsIntoMap($sql, 'testcase_id'));
     return $this->convert_test_cases($reqTestCasesIds, $test_cases_executions);
 }
Example #20
0
function initializeGui(&$dbHandler, &$argsObj, &$cfgObj, &$tplanMgr)
{
    $buildMgr = new build_mgr($dbHandler);
    $platformMgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $gui = new stdClass();
    $gui->form_token = $argsObj->form_token;
    $gui->remoteExecFeedback = $gui->user_feedback = '';
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->build_id = $argsObj->build_id;
    $gui->platform_id = $argsObj->platform_id;
    $gui->attachmentInfos = null;
    $gui->refreshTree = 0;
    // Just for the records:
    // doing this here, we avoid to do on processTestSuite() and processTestCase(),
    // but absolutely this will not improve in ANY WAY perfomance, because we do not loop
    // over these two functions.
    $tprojectMgr = new testproject($dbHandler);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id);
    $build_info = $buildMgr->get_by_id($argsObj->build_id);
    $gui->build_notes = $build_info['notes'];
    $gui->build_is_open = $build_info['is_open'] == 1 ? 1 : 0;
    $dummy = $tplanMgr->get_builds_for_html_options($argsObj->tplan_id);
    $gui->build_name = isset($dummy[$argsObj->build_id]) ? $dummy[$argsObj->build_id] : '';
    $rs = $tplanMgr->get_by_id($argsObj->tplan_id);
    $gui->testplan_notes = $rs['notes'];
    $gui->testplan_name = $rs['name'];
    // Important note:
    // custom fields for test plan can be edited ONLY on design, that's reason why we are using
    // scope = 'design' instead of 'execution'
    $gui->testplan_cfields = $tplanMgr->html_table_of_custom_field_values($argsObj->tplan_id, 'design', array('show_on_execution' => 1));
    $gui->build_cfields = $buildMgr->html_table_of_custom_field_values($argsObj->build_id, $argsObj->tproject_id, 'design', array('show_on_execution' => 1));
    $dummy = $platformMgr->getLinkedToTestplan($argsObj->tplan_id);
    $gui->has_platforms = !is_null($dummy) ? 1 : 0;
    $gui->platform_info['id'] = 0;
    $gui->platform_info['name'] = '';
    if (!is_null($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $gui->platform_info = $platformMgr->getByID($argsObj->platform_id);
    }
    $gui->pageTitlePrefix = lang_get('execution_context') . ':';
    return $gui;
}
Example #21
0
 /**
 	 * Show Test Case logic
 	 * 
 	 * @param object $smarty reference to smarty object (controls viewer).
 	 * @param integer $id Test case unique identifier
 	 * @param integer $version_id (optional) you can work on ONE test case version, 
 	 * 				or on ALL; default: ALL
 	 * 
 	 * @internal
         [viewer_args]: map with keys
 	                       action
 	                       msg_result
 	                       refresh_tree: controls if tree view is refreshed after every operation.
 	                                     default: yes
 	                       user_feedback
 	                       disable_edit: used to overwrite user rights
 	                                        default: 0 -> no
   returns:
   rev :
 	       20090215 - franciscom - added info about links to test plans
 	       
 	       20081114 - franciscom -
 	       added arguments and options that are useful when this method is
 	       used to display test case search results.
 	       path_info: map: key: testcase id
 	                       value: array with path to test case, where:
 	                              element 0 -> test project name
 	                              other elements test suites name
 	       
 	       new options on viewer_args: hilite_testcase_name,show_match_count
 	       
 	       20070930 - franciscom - REQ - BUGID 1078
 	       added disable_edit argument
 */
 function show(&$smarty, $guiObj, $template_dir, $id, $version_id = self::ALL_VERSIONS, $viewer_args = null, $path_info = null, $mode = null)
 {
     // echo 'DEBUG' . __FUNCTION__ . '<br>';
     $status_ok = 1;
     $gui = is_null($guiObj) ? new stdClass() : $guiObj;
     $gui->parentTestSuiteName = '';
     $gui->path_info = $path_info;
     $gui->tprojectName = '';
     $gui->linked_versions = null;
     $gui->tc_current_version = array();
     $gui->bodyOnLoad = "";
     // 20101008 - asimon - BUGID 3311
     $gui->bodyOnUnload = "storeWindowSize('TCEditPopup')";
     $gui->submitCode = "";
     $gui->dialogName = '';
     $gui->platforms = null;
     $gui->tableColspan = 5;
     // sorry magic related to table to display steps
     $gui->opt_requirements = false;
     $gui_cfg = config_get('gui');
     $the_tpl = config_get('tpl');
     $my_template = isset($the_tpl['tcView']) ? $the_tpl['tcView'] : 'tcView.tpl';
     $tcase_cfg = config_get('testcase_cfg');
     $req_mgr = new requirement_mgr($this->db);
     $tc_other_versions = array();
     $status_quo_map = array();
     $keywords_map = array();
     $arrReqs = array();
     $userid_array = array();
     // 20090718 - franciscom
     $cf_smarty = null;
     $formatOptions = null;
     $cfPlaces = $this->buildCFLocationMap();
     if (!is_null($mode) && $mode == 'editOnExec') {
         // refers to two javascript functions present in testlink_library.js
         // and logic used to refresh both frames when user call this
         // method to edit a test case while executing it.
         $gui->dialogName = 'tcview_dialog';
         $gui->bodyOnLoad = "dialog_onLoad({$gui->dialogName})";
         $gui->bodyOnUnload = "dialog_onUnload({$gui->dialogName})";
         $gui->submitCode = "return dialog_onSubmit({$gui->dialogName})";
     }
     $viewer_defaults = array('title' => lang_get('title_test_case'), 'show_title' => 'no', 'action' => '', 'msg_result' => '', 'user_feedback' => '', 'refreshTree' => 1, 'disable_edit' => 0, 'display_testproject' => 0, 'display_parent_testsuite' => 0, 'hilite_testcase_name' => 0, 'show_match_count' => 0);
     if (!is_null($viewer_args) && is_array($viewer_args)) {
         foreach ($viewer_defaults as $key => $value) {
             if (isset($viewer_args[$key])) {
                 $viewer_defaults[$key] = $viewer_args[$key];
             }
         }
     }
     $gui->show_title = $viewer_defaults['show_title'];
     $gui->display_testcase_path = !is_null($path_info);
     $gui->hilite_testcase_name = $viewer_defaults['hilite_testcase_name'];
     $gui->pageTitle = $viewer_defaults['title'];
     $gui->show_match_count = $viewer_defaults['show_match_count'];
     if ($gui->show_match_count && $gui->display_testcase_path) {
         $gui->match_count = count($path_info);
     }
     // fine grain control of operations
     // if( $viewer_defaults['disable_edit'] == 1 || has_rights($this->db,"mgt_modify_tc") == 'no' )
     // BUGID 3387
     if ($viewer_defaults['disable_edit'] == 1 || has_rights($this->db, "mgt_modify_tc") == false) {
         $mode = 'editDisabled';
     }
     $gui->show_mode = $mode;
     $gui->can_do = $this->getShowViewerActions($mode);
     if (is_array($id)) {
         $a_id = $id;
     } else {
         $status_ok = $id > 0 ? 1 : 0;
         $a_id = array($id);
     }
     if ($status_ok) {
         $path2root = $this->tree_manager->get_path($a_id[0]);
         $tproject_id = $path2root[0]['parent_id'];
         $info = $this->tproject_mgr->get_by_id($tproject_id);
         $gui->opt_requirements = $info['opt']->requirementsEnabled;
         $platformMgr = new tlPlatform($this->db, $tproject_id);
         $gui->platforms = $platformMgr->getAllAsMap();
         // BUGID 2378
         $testplans = $this->tproject_mgr->get_all_testplans($tproject_id, array('plan_status' => 1));
         $gui->has_testplans = !is_null($testplans) && count($testplans) > 0 ? 1 : 0;
         if ($viewer_defaults['display_testproject']) {
             $gui->tprojectName = $info['name'];
         }
         if ($viewer_defaults['display_parent_testsuite']) {
             $parent_idx = count($path2root) - 2;
             $gui->parentTestSuiteName = $path2root[$parent_idx]['name'];
         }
         $tcasePrefix = $this->tproject_mgr->getTestCasePrefix($tproject_id);
         if (trim($tcasePrefix) != "") {
             // Add To Testplan button will be disabled if the testcase doesn't belong to the current selected testproject
             // $gui->can_do->add2tplan = 'no';
             if ($_SESSION['testprojectPrefix'] == $tcasePrefix) {
                 $gui->can_do->add2tplan = $gui->can_do->add2tplan == 'yes' ? has_rights($this->db, "testplan_planning") : 'no';
             } else {
                 $gui->can_do->add2tplan = 'no';
             }
             $tcasePrefix .= $tcase_cfg->glue_character;
         }
     }
     if ($status_ok && sizeof($a_id)) {
         $cfx = 0;
         $allTCKeywords = $this->getKeywords($a_id, null, 'testcase_id', ' ORDER BY keyword ASC ');
         $allReqs = $req_mgr->get_all_for_tcase($a_id);
         foreach ($a_id as $key => $tc_id) {
             $tc_array = $this->get_by_id($tc_id, $version_id);
             if (!$tc_array) {
                 continue;
             }
             $tc_array[0]['tc_external_id'] = $tcasePrefix . $tc_array[0]['tc_external_id'];
             // get the status quo of execution and links of tc versions
             $status_quo_map[] = $this->get_versions_status_quo($tc_id);
             $gui->linked_versions[] = $this->get_linked_versions($tc_id);
             $keywords_map[] = isset($allTCKeywords[$tc_id]) ? $allTCKeywords[$tc_id] : null;
             $tc_current = $tc_array[0];
             $tcversion_id_current = $tc_array[0]['id'];
             $gui->tc_current_version[] = array($tc_current);
             //Get UserID and Updater ID for current Version
             $userid_array[$tc_current['author_id']] = null;
             $userid_array[$tc_current['updater_id']] = null;
             // BUGID 3431
             foreach ($cfPlaces as $locationKey => $locationFilter) {
                 // BUGID 3431
                 $cf_current_version[$cfx][$locationKey] = $this->html_table_of_custom_field_values($tc_id, 'design', $locationFilter, null, null, $tproject_id, null, $tcversion_id_current);
             }
             // Other versions (if exists)
             if (count($tc_array) > 1) {
                 $tc_other_versions[] = array_slice($tc_array, 1);
                 $target_idx = count($tc_other_versions) - 1;
                 // BUGID 3431
                 $loop2do = count($tc_other_versions[$target_idx]);
                 // echo 'count($tc_other_versions):' . count($tc_other_versions) . '<br>';
                 // echo '$loop2do:' . $loop2do . '<br>';
                 for ($qdx = 0; $qdx < $loop2do; $qdx++) {
                     $target_tcversion = $tc_other_versions[$target_idx][$qdx]['id'];
                     foreach ($cfPlaces as $locationKey => $locationFilter) {
                         // BUGID 3431
                         $cf_other_versions[$cfx][$qdx][$locationKey] = $this->html_table_of_custom_field_values($tc_id, 'design', $locationFilter, null, null, $tproject_id, null, $target_tcversion);
                     }
                 }
             } else {
                 $tc_other_versions[] = null;
                 $cf_other_versions[$cfx] = null;
             }
             $cfx++;
             // Get author and updater id for each version
             if ($tc_other_versions[0]) {
                 foreach ($tc_other_versions[0] as $key => $version) {
                     $userid_array[$version['author_id']] = null;
                     $userid_array[$version['updater_id']] = null;
                 }
             }
             $tcReqs = isset($allReqs[$tc_id]) ? $allReqs[$tc_id] : null;
             $arrReqs[] = $tcReqs;
         }
         // foreach($a_id as $key => $tc_id)
     }
     // if (sizeof($a_id))
     // Removing duplicate and NULL id's
     unset($userid_array['']);
     $passeduserarray = array_keys($userid_array);
     $gui->cf = null;
     // $cf_current_version; // $cf_smarty;
     $gui->cf_current_version = $cf_current_version;
     // $cf_smarty;
     $gui->cf_other_versions = $cf_other_versions;
     // $cf_smarty;
     $gui->refreshTree = $viewer_defaults['refreshTree'];
     $gui->sqlResult = $viewer_defaults['msg_result'];
     $gui->action = $viewer_defaults['action'];
     $gui->user_feedback = $viewer_defaults['user_feedback'];
     $gui->execution_types = $this->execution_types;
     $gui->tcase_cfg = $tcase_cfg;
     $gui->users = tlUser::getByIDs($this->db, $passeduserarray, 'id');
     $gui->status_quo = $status_quo_map;
     $gui->testcase_other_versions = $tc_other_versions;
     $gui->arrReqs = $arrReqs;
     $gui->view_req_rights = has_rights($this->db, "mgt_view_req");
     $gui->keywords_map = $keywords_map;
     $smarty->assign('gui', $gui);
     $smarty->display($template_dir . $my_template);
 }
 /**
  * 
  * 
  * 20120825 - franciscom - TICKET 5176: Possibility to filter by Platform
  *						             according mode we need to add [Any] option
  *
  */
 private function init_setting_platform()
 {
     if (!$this->platform_mgr) {
         $this->platform_mgr = new tlPlatform($this->db);
     }
     $key = 'setting_platform';
     $this->settings[$key] = array('items' => null, 'selected' => $this->args->{$key});
     $testplan_id = $this->settings['setting_testplan']['selected'];
     $checkSelected = true;
     $platformSet = $this->platform_mgr->getLinkedToTestplanAsMap($testplan_id);
     $this->settings[$key]['items'] = $platformSet;
     switch ($this->mode) {
         case 'plan_mode':
             if (!is_null($platformSet)) {
                 $this->settings[$key]['items'] = array(0 => $this->option_strings['any']);
                 $this->settings[$key]['items'] += $platformSet;
                 $checkSelected = false;
             }
             break;
     }
     // BUGID 3726
     $session_key = $testplan_id . '_stored_setting_platform';
     $session_selection = isset($_SESSION[$session_key]) ? $_SESSION[$session_key] : null;
     // if no platform has been selected when entering the feature the first time set it
     // according to preselected value on gui
     // TICKET
     $this->args->{$key} = !is_null($this->args->{$key}) ? $this->args->{$key} : $session_selection;
     if ($checkSelected && !$this->settings[$key]['selected']) {
         $this->settings[$key]['selected'] = $session_selection;
     }
     if (!isset($this->settings[$key]['items']) || !is_array($this->settings[$key]['items'])) {
         $this->settings[$key] = false;
     } else {
         if (isset($this->settings[$key]['items']) && is_array($this->settings[$key]['items']) && is_null($this->settings[$key]['selected'])) {
             // platforms exist, but none has been selected yet, so select first one
             $this->settings[$key]['selected'] = key($this->settings[$key]['items']);
         }
     }
     $_SESSION[$session_key] = $this->settings[$key]['selected'];
 }
Example #23
0
/**
 * 
 *
 */
function contextAsXML(&$dbHandler, $contextSet, &$tplanMgr)
{
    $info = array();
    $tprojectMgr = new testproject($dbHandler);
    $info['tproject'] = $tprojectMgr->get_by_id($contextSet->tproject_id);
    unset($tprojectMgr);
    $info['tplan'] = $tplanMgr->get_by_id($contextSet->tplan_id);
    $buildMgr = new build_mgr($dbHandler);
    $info['build'] = $buildMgr->get_by_id($contextSet->build_id);
    unset($buildMgr);
    $info['platform'] = null;
    $platform_template = '';
    if ($contextSet->platform_id > 0) {
        $platformMgr = new tlPlatform($dbHandler, $contextSet->tproject_id);
        $info['platform'] = $platformMgr->getByID($contextSet->platform_id);
        unset($platformMgr);
        $platform_template = "\n\t" . "<platform>" . "\t\t" . "<name><![CDATA[||PLATFORMNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||PLATFORMID||]]></internal_id>" . "\n\t" . "</platform>";
    }
    $key2loop = array_keys($info);
    foreach ($key2loop as $item_key) {
        if (!is_null($info[$item_key])) {
            $contextInfo[$item_key . '_id'] = $info[$item_key]['id'];
            $contextInfo[$item_key . '_name'] = $info[$item_key]['name'];
        }
    }
    $contextInfo['prefix'] = $info['tproject']['prefix'];
    $xml_root = "<context>{{XMLCODE}}\n</context>";
    $xml_template = "\n\t" . "<testproject>" . "\t\t" . "<name><![CDATA[||TPROJECTNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPROJECTID||]]></internal_id>" . "\t\t" . "<prefix><![CDATA[||TPROJECTPREFIX||]]></prefix>" . "\n\t" . "</testproject>" . "\n\t" . "<testplan>" . "\t\t" . "<name><![CDATA[||TPLANNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||TPLANID||]]></internal_id>" . "\n\t" . "</testplan>" . $platform_template . "\n\t" . "<build>" . "\t\t" . "<name><![CDATA[||BUILDNAME||]]></name>" . "\t\t" . "<internal_id><![CDATA[||BUILDID||]]></internal_id>" . "\n\t" . "</build>";
    $xml_mapping = null;
    $xml_mapping = array("||TPROJECTNAME||" => "tproject_name", "||TPROJECTID||" => 'tproject_id', "||TPROJECTPREFIX||" => "prefix", "||TPLANNAME||" => "tplan_name", "||TPLANID||" => 'tplan_id', "||BUILDNAME||" => "build_name", "||BUILDID||" => 'build_id', "||PLATFORMNAME||" => "platform_name", "||PLATFORMID||" => 'platform_id');
    $mm = array($contextInfo);
    $contextXML = exportDataToXML($mm, $xml_root, $xml_template, $xml_mapping, 'noXMLHeader' == 'noXMLHeader');
    // echo '<pre><xmp>';
    // echo $contextXML;
    // echo '</xmp></pre>';
    return $contextXML;
}
Example #24
0
        $gui->steps_results_layout = config_get('spec_cfg')->steps_results_layout;
        // has been called from a test case search
        if (!is_null($args->targetTestCase) && strcmp($args->targetTestCase, $args->tcasePrefix) != 0) {
            $viewerArgs['show_title'] = 'no';
            $viewerArgs['display_testproject'] = 1;
            $viewerArgs['display_parent_testsuite'] = 1;
            $args->id = $item_mgr->getInternalID($args->targetTestCase);
            if (!($get_path_info = $args->id > 0)) {
                $gui->warning_msg = $args->id == 0 ? lang_get('testcase_does_not_exists') : lang_get('prefix_does_not_exists');
            }
        }
        if ($args->id > 0) {
            if ($get_path_info || $args->show_path) {
                $path_info = $item_mgr->tree_manager->get_full_path_verbose($args->id);
            }
            $platform_mgr = new tlPlatform($db, $args->tproject_id);
            $gui->platforms = $platform_mgr->getAllAsMap();
            $gui->attachments[$args->id] = getAttachmentInfosFrom($item_mgr, $args->id);
            $gui->direct_link = $item_mgr->buildDirectWebLink($_SESSION['basehref'], $args->id);
        }
        $gui->id = $args->id;
        $item_mgr->show($smarty, $gui, $templateCfg->template_dir, $args->id, $args->tcversion_id, $viewerArgs, $path_info, $args->show_mode);
        break;
    default:
        tLog('Argument "edit" has invalid value: ' . $args->feature, 'ERROR');
        trigger_error($_SESSION['currentUser']->login . '> Argument "edit" has invalid value.', E_USER_ERROR);
}
/**
 * 
 *
 */
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr, &$tcaseMgr)
{
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $tcase_cfg = config_get('testcase_cfg');
    $gui = new stdClass();
    $gui->platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->usePlatforms = $platform_mgr->platformsActiveForTestplan($argsObj->tplan_id);
    $gui->bulk_platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->bulk_platforms[0] = lang_get("all_platforms");
    ksort($gui->bulk_platforms);
    $gui->send_mail = $argsObj->send_mail;
    $gui->send_mail_checked = "";
    if ($gui->send_mail) {
        $gui->send_mail_checked = ' checked="checked" ';
    }
    $gui->glueChar = $tcase_cfg->glue_character;
    if ($argsObj->level != 'testproject') {
        $gui->testCasePrefix = $tcaseMgr->tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
        $gui->testCasePrefix .= $tcase_cfg->glue_character;
        $gui->keywordsFilterType = $argsObj->keywordsFilterType;
        $gui->build_id = $argsObj->build_id;
        $gui->tplan_id = $argsObj->tplan_id;
        $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
        $gui->testPlanName = $tplan_info['name'];
        $build_info = $tplanMgr->get_build_by_id($argsObj->tplan_id, $argsObj->build_id);
        $gui->buildName = $build_info['name'];
        $gui->main_descr = sprintf(lang_get('title_tc_exec_assignment'), $gui->buildName, $gui->testPlanName);
        $tproject_mgr = new testproject($dbHandler);
        $tproject_info = $tproject_mgr->get_by_id($argsObj->tproject_id);
        $gui->all_users = tlUser::getAll($dbHandler, null, "id", null);
        $gui->users = getUsersForHtmlOptions($dbHandler, null, null, null, $gui->all_users);
        $gui->testers = getTestersForHtmlOptions($dbHandler, $argsObj->tplan_id, $tproject_info, $gui->all_users);
    }
    return $gui;
}
Example #26
0
/**
 * 
 *
 */
function getPlatforms($db, $tproject_id, $testplan_id)
{
    $platform_mgr = new tlPlatform($db, $tproject_id);
    if (is_null($testplan_id)) {
        $platforms = $platform_mgr->getAll();
    } else {
        $platforms = $platform_mgr->getLinkedToTestplan($testplan_id);
    }
    if (is_null($platforms)) {
        // need to create fake data for platform 0 in order
        // to have only simple logic
        $platforms = array('id' => 0, 'name' => '');
    }
    return $platforms;
}
Example #27
0
<?php

require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$gui = new stdClass();
$gui->vars = $platform_mgr->getAllVars();
$total_vars = count($gui->vars);
$gui->suites = $platform_mgr->getAllSuites();
$gui->current_var = 0;
$gui->current_suite = 0;
if (isset($_GET['suite_id'])) {
    $gui->current_suite = $_GET['suite_id'];
    if (isset($_GET['add_var_name'])) {
        $addresult = $platform_mgr->addNewVar($_GET['suite_id'], $_GET['add_var_name']);
        if ($addresult == 0) {
            echo "<script>alert('分支名称已经存在,请检查!');</script>";
        }
    }
}
if (isset($_GET['var_id'])) {
    if (isset($_GET['deletecase'])) {
        $platform_mgr->deleteVarTcversion($_GET['var_id'], $_GET['deletecase']);
    }
    if (isset($_GET['add_case_script'])) {
        $result = $platform_mgr->addVarTcversion($_GET['var_id'], $_GET['add_case_script'], $args->login_username);
        echo "<script>alert('{$result}');</script>";
    }
Example #28
0
<?php 
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$var_id = $_GET['varid'];
$suite_id = $_GET['suiteid'];
$all = $_GET['all'];
$verify = isset($_GET['verify']) ? $_GET['verify'] : 0;
$devices = $platform_mgr->getVarDevices($var_id, $suite_id);
$a = count($devices[0]);
echo "<p align='center'>共有<span style='color:red'>{$a}</span>款设备:<b>{$devices['all']}</b></p>";
if ($a == 0) {
    echo "<p align='center'><a href='viewVar.php?var_id={$var_id}&suite_id={$suite_id}'>返     回</a></p>";
} else {
    echo "<form name='form1' action='/lib/dcnVars/assign2AllPlan_delete.php?varid={$var_id}&suiteid={$suite_id}&all={$all}' method='post'>";
    echo "<table align='center'><tbody>";
    foreach ($devices[0] as $device) {
        $tplans = $platform_mgr->getDeviceTplan($device['id'], $all);
        foreach ($tplans[0] as $nn => $tplan) {
            $needdelete[$device['id'] . '-' . $tplan['id']] = $platform_mgr->modifyTplanCasesFromVar($tplan['id'], $device['id'], $var_id, $suite_id, $args->login_username, 'add');
            if ($needdelete[$device['id'] . '-' . $tplan['id']] != null) {
                echo "<tr><td align='center'>{$tplan['name']}-{$device['name']}:<input type='checkbox' id='{$tplan['id']}-{$device['id']}' name='{$tplan['id']}-{$device['id']}'></input></td></tr>";
            }
        }
    }
    $allneed = 0;
    foreach ($needdelete as $tt) {
        if ($tt != null) {
            $allneed++;
Example #29
0
 /**
  *
  */
 private function initShowGui($guiObj, $grantsObj, $id, $idCard)
 {
     $goo = is_null($guiObj) ? new stdClass() : $guiObj;
     $goo->execution_types = $this->execution_types;
     $goo->tcase_cfg = $this->cfg->testcase;
     $goo->import_limit = TL_REPOSITORY_MAXFILESIZE;
     $goo->msg = '';
     $goo->fileUploadMsg = '';
     $goo->fileUploadURL = $_SESSION['basehref'] . $this->getFileUploadRelativeURL($idCard);
     $goo->delAttachmentURL = $_SESSION['basehref'] . $this->getDeleteAttachmentRelativeURL($idCard);
     $goo->requirement_mgmt = property_exists($grantsObj, 'mgt_modify_req') ? $grantsObj->mgt_modify_req : null;
     if (is_null($goo->requirement_mgmt)) {
         $goo->requirement_mgmt = property_exists($grantsObj, 'requirement_mgmt') ? $grantsObj->requirement_mgmt : 0;
     }
     // some config options have been migrated to rights
     // In order to refactor less code, we will remap to OLD config options present on config file.
     $goo->tcase_cfg->can_edit_executed = $grantsObj->testproject_edit_executed_testcases == 'yes' ? 1 : 0;
     $goo->tcase_cfg->can_delete_executed = $grantsObj->testproject_delete_executed_testcases == 'yes' ? 1 : 0;
     $goo->view_req_rights = property_exists($grantsObj, 'mgt_view_req') ? $grantsObj->mgt_view_req : 0;
     $goo->parentTestSuiteName = '';
     $goo->tprojectName = '';
     $goo->submitCode = "";
     $goo->dialogName = '';
     $goo->bodyOnLoad = "";
     $goo->bodyOnUnload = "storeWindowSize('TCEditPopup')";
     $goo->tableColspan = 5;
     // sorry magic related to table to display steps
     $goo->tc_current_version = array();
     $goo->status_quo = array();
     $goo->keywords_map = array();
     $goo->arrReqs = array();
     $goo->cf_current_version = null;
     $goo->cf_other_versions = null;
     $goo->linked_versions = null;
     $goo->platforms = null;
     $viewer_defaults = array('title' => lang_get('title_test_case'), 'show_title' => 'no', 'action' => '', 'msg_result' => '', 'user_feedback' => '', 'refreshTree' => 1, 'disable_edit' => 0, 'display_testproject' => 0, 'display_parent_testsuite' => 0, 'hilite_testcase_name' => 0, 'show_match_count' => 0);
     $viewer_defaults = array_merge($viewer_defaults, (array) $guiObj->viewerArgs);
     $goo->display_testproject = $viewer_defaults['display_testproject'];
     $goo->display_parent_testsuite = $viewer_defaults['display_parent_testsuite'];
     $goo->show_title = $viewer_defaults['show_title'];
     $goo->hilite_testcase_name = $viewer_defaults['hilite_testcase_name'];
     $goo->action = $viewer_defaults['action'];
     $goo->user_feedback = $viewer_defaults['user_feedback'];
     $goo->pageTitle = $viewer_defaults['title'];
     $goo->display_testcase_path = !is_null($goo->path_info);
     $goo->show_match_count = $viewer_defaults['show_match_count'];
     if ($goo->show_match_count && $goo->display_testcase_path) {
         $goo->pageTitle .= '-' . lang_get('match_count') . ':' . ($goo->match_count = count($goo->path_info));
     }
     $goo->refreshTree = isset($goo->refreshTree) ? $goo->refreshTree : $viewer_defaults['refreshTree'];
     $goo->sqlResult = $viewer_defaults['msg_result'];
     // fine grain control of operations
     if ($viewer_defaults['disable_edit'] == 1 || $grantsObj->mgt_modify_tc == false) {
         $goo->show_mode = 'editDisabled';
     } else {
         if (!is_null($goo->show_mode) && $goo->show_mode == 'editOnExec') {
             // refers to two javascript functions present in testlink_library.js
             // and logic used to refresh both frames when user call this
             // method to edit a test case while executing it.
             $goo->dialogName = 'tcview_dialog';
             $goo->bodyOnLoad = "dialog_onLoad({$gui->dialogName})";
             $goo->bodyOnUnload = "dialog_onUnload({$gui->dialogName})";
             $goo->submitCode = "return dialog_onSubmit({$gui->dialogName})";
         }
     }
     $dummy = getConfigAndLabels('testCaseStatus', 'code');
     $goo->domainTCStatus = $dummy['lbl'];
     $goo->can_do = $this->getShowViewerActions($goo->show_mode);
     $path2root = $this->tree_manager->get_path($id);
     $goo->tproject_id = $path2root[0]['parent_id'];
     $info = $this->tproject_mgr->get_by_id($goo->tproject_id);
     $goo->requirementsEnabled = $info['opt']->requirementsEnabled;
     if ($goo->display_testproject) {
         $goo->tprojectName = $info['name'];
     }
     if ($goo->display_parent_testsuite) {
         $parent = count($path2root) - 2;
         $goo->parentTestSuiteName = $path2root[$parent]['name'];
     }
     $testplans = $this->tproject_mgr->get_all_testplans($goo->tproject_id, array('plan_status' => 1));
     $goo->has_testplans = !is_null($testplans) && count($testplans) > 0 ? 1 : 0;
     $platformMgr = new tlPlatform($this->db, $goo->tproject_id);
     $goo->platforms = $platformMgr->getAllAsMap();
     $goo->tcasePrefix = $this->tproject_mgr->getTestCasePrefix($goo->tproject_id) . $this->cfg->testcase->glue_character;
     return $goo;
 }
 /**
  * 
  * Possibility to filter by Platform:
  * according mode we need to add [Any] option
  *
  */
 private function init_setting_platform()
 {
     if (!$this->platform_mgr) {
         $this->platform_mgr = new tlPlatform($this->db);
     }
     $testplan_id = $this->settings['setting_testplan']['selected'];
     $session_key = $testplan_id . '_stored_setting_platform';
     $session_selection = isset($_SESSION[$session_key]) ? $_SESSION[$session_key] : null;
     $key = 'setting_platform';
     $platformSet = $this->platform_mgr->getLinkedToTestplanAsMap($testplan_id);
     if (is_null($platformSet)) {
         // Brute force bye, bye !! >>--->
         $this->settings[$key] = false;
         $_SESSION[$session_key] = null;
         return;
     }
     // Ok, there are platforms, go ahead
     $this->settings[$key] = array('items' => null, 'selected' => -1);
     if (is_null($this->args->{$key})) {
         $this->args->{$key} = intval($session_selection);
     }
     switch ($this->mode) {
         case 'plan_mode':
             $this->settings[$key]['items'] = array(0 => $this->option_strings['any']);
             $this->settings[$key]['items'] += $platformSet;
             break;
         case 'execution_mode':
             $this->settings[$key]['items'] = $platformSet;
             break;
         default:
             throw new Exception(__METHOD__ . "Mode:" . $this->mode . 'Do not know what to do', 1);
             break;
     }
     // If this platform is NOT valid for Test plan, I will set the first one
     // (is any exists).
     if (!isset($this->settings[$key]['items'])) {
         $this->args->{$key} = key($this->settings[$key]['items']);
     }
     $this->settings[$key]['selected'] = $this->args->{$key};
     if ($this->args->{$key} <= 0) {
         $this->settings[$key]['selected'] = key($this->settings[$key]['items']);
     }
     $_SESSION[$session_key] = $this->settings[$key]['selected'];
 }