/**
  * Class constructor
  * 
  * @param resource &$db reference to the database handler
  */
 function __construct(&$db)
 {
     parent::__construct();
     $this->getTypes();
     // populate types property
     $this->db =& $db;
 }
Beispiel #2
0
 /**
  * Class costructor
  * @param resource &$db reference to database handler
  */
 function __construct(&$db)
 {
     parent::__construct();
     $this->db =& $db;
     $this->node_descr_id = array_flip($this->node_types);
     $this->object_table = $this->tables['nodes_hierarchy'];
 }
 /** class constructor
  * @param $label string the label to localize, use {%1} to {%n} for parameters inserted into the localized string 
  * @param $args array the array of parameters
  */
 public function __construct($label = null, $args = null)
 {
     parent::__construct();
     $this->helper = new tlMetaStringHelper();
     if ($label) {
         $this->initialize($label, $args);
     }
 }
 /**
  * constructor
  * @param tlInputParameter $parameterInfo Infos about the parameter source
  * @param tl<TYPE>ValidationInfo $validationInfo Info about the validation of the parameter
  */
 function __construct($parameterInfo, $validationInfo = null)
 {
     parent::__construct();
     $this->validationInfo = $validationInfo;
     $this->parameterInfo = $parameterInfo;
     $this->fetchParameter();
     $this->normalize();
     $this->validate();
 }
Beispiel #5
0
 /**
  * Class costructor
  * @param resource &$db reference to database handler
  */
 function __construct(&$db)
 {
     parent::__construct();
     $this->db =& $db;
     $this->node_descr_id = array_flip($this->node_types);
     $this->object_table = $this->tables['nodes_hierarchy'];
     $this->node_tables = $this->node_tables_by['name'];
     foreach ($this->node_tables_by['name'] as $key => $tbl) {
         $this->node_tables_by['id'][$this->node_descr_id[$key]] = $tbl;
     }
 }
Beispiel #6
0
 /**
  * Class costructor
  * @param resource &$db reference to database handler
  */
 function __construct(&$db)
 {
     if (!is_object($db)) {
         $msg = __METHOD__ . ' :: FATAL Error $db IS NOT AN Object';
         throw new Exception($msg);
     }
     parent::__construct();
     $this->db =& $db;
     $this->object_table = $this->tables['nodes_hierarchy'];
     $this->node_tables = $this->node_tables_by['name'];
     $this->node_descr_id = array_flip($this->node_types);
     foreach ($this->node_tables_by['name'] as $key => $tbl) {
         $this->node_tables_by['id'][$this->node_descr_id[$key]] = $tbl;
     }
     $nodeCodeId = array_flip($this->node_types);
     $this->nodeWithoutClass[$nodeCodeId['requirement_spec_revision']] = 'deleted when reqspec is deleted';
 }
 public function __construct()
 {
     parent::__construct();
 }
 /** 
  * Class constructor
  *
  * @param integer $dbID (optional) the database identifier
  */
 function __construct($dbID = null)
 {
     parent::__construct();
     $this->dbID = $dbID;
     $this->detailLevel = self::TLOBJ_O_GET_DETAIL_FULL;
 }
Beispiel #9
0
/**
 * send mail to administrators (users that have default role = administrator) 
 * to warn about new user created.
 *
 */
function notifyGlobalAdmins(&$dbHandler, &$userObj)
{
    // Get email addresses for all users that have default role = administrator
    $cfg = config_get('notifications');
    if (!is_null($cfg->userSignUp->to->roles)) {
        foreach ($cfg->userSignUp->to->roles as $roleID) {
            $roleMgr = new tlRole($roleID);
            $userSet = $roleMgr->getUsersWithGlobalRole($dbHandler);
            $key2loop = array_keys($userSet);
            foreach ($key2loop as $userID) {
                if (!isset($mail['to'][$userID])) {
                    $mail['to'][$userID] = $userSet[$userID]->emailAddress;
                }
            }
        }
    }
    if (!is_null($cfg->userSignUp->to->users)) {
        // Brute force query
        $tables = tlObject::getDBTables('users');
        $sql = " SELECT id,email FROM {$tables['users']} " . " WHERE login IN('" . implode("','", $cfg->userSignUp->to->users) . "')";
        $userSet = $dbHandler->fetchRowsIntoMap($sql, 'id');
        if (!is_null($userSet)) {
            foreach ($userSet as $userID => $elem) {
                if (!isset($mail['to'][$userID])) {
                    $mail['to'][$userID] = $elem['email'];
                }
            }
        }
    }
    $mail['to'] = implode(',', $mail['to']);
    // email_api uses ',' as list separator
    $mail['subject'] = lang_get('new_account');
    $mail['body'] = lang_get('new_account') . "\n";
    $mail['body'] .= " user:{$userObj->login}\n";
    $mail['body'] .= " first name:{$userObj->firstName} surname:{$userObj->lastName}\n";
    $mail['body'] .= " email:{$userObj->emailAddress}\n";
    // silence errors
    @email_send(config_get('from_email'), $mail['to'], $mail['subject'], $mail['body']);
}
 /** 
  * @param resource &$db reference to database handler
  **/
 public static function getAll(&$db, $whereClause = null, $column = null, $orderBy = null, $detailLevel = self::TLOBJ_O_GET_DETAIL_FULL)
 {
     $tables = tlObject::getDBTables('rights');
     $sql = " SELECT id FROM {$tables['rights']} ";
     if (!is_null($whereClause)) {
         $sql .= ' ' . $whereClause;
     }
     $sql .= is_null($orderBy) ? " ORDER BY id ASC " : $orderBy;
     return tlDBObject::createObjectsFromDBbySQL($db, $sql, 'id', __CLASS__, true, $detailLevel);
 }
Beispiel #11
0
/**
 * 
 * 
 */
function update_status_for_colors(&$dbHandler, &$items, $context, $statusCfg)
{
    $tables = tlObject::getDBTables(array('executions', 'nodes_hierarchy'));
    $dummy = current($items);
    $key2scan = array_keys($items);
    $keySet = null;
    foreach ($key2scan as $fx) {
        $keySet[] = $items[$fx]['tcversion_id'];
    }
    extract($context);
    // magic to create single variables
    $sql = " SELECT E.status, NH_TCV.parent_id AS tcase_id " . " FROM {$tables['executions']} E " . " JOIN {$tables['nodes_hierarchy']} NH_TCV ON NH_TCV.id = E.tcversion_id " . " JOIN " . " ( SELECT MAX(E2.id) AS last_exec_id " . "   FROM {$tables['executions']} E2 " . "   WHERE testplan_id = {$tplanID} " . "   AND tcversion_id IN (" . implode(',', $keySet) . ") " . "   AND platform_id = {$dummy['platform_id']} " . "   AND build_id = {$buildID} " . "   GROUP BY testplan_id,tcversion_id,platform_id,build_id ) AS EY " . " ON E.id = EY.last_exec_id ";
    $result = null;
    $rs = $dbHandler->fetchRowsIntoMap($sql, 'tcase_id');
    if (!is_null($rs)) {
        foreach ($key2scan as $tcase_id) {
            $rr = isset($rs[$tcase_id]['status']) && !is_null($rs[$tcase_id]['status']) ? $rs[$tcase_id]['status'] : $statusCfg['not_run'];
            if ($rr != $items[$tcase_id]['exec_status']) {
                $items[$tcase_id]['exec_status'] = $rr;
            }
        }
    }
}
Beispiel #12
0
 /**
  * get roles present on system and return map with colour associations
  * if there is no colour configured for role '' is returned as colour.
  *
  */
 public static function getRoleColourCfg(&$db)
 {
     $role_colour = config_get('role_colour');
     $tables = tlObject::getDBTables("roles");
     $sql = "SELECT description FROM {$tables['roles']} ";
     $roles = $db->fetchColumnsIntoArray($sql, "description");
     foreach ($roles as $description) {
         if (!isset($role_colour[$description])) {
             $role_colour[$description] = '';
         }
     }
     return $role_colour;
 }
Beispiel #13
0
 /** 
  * class constructor 
  * 
  * @param resource &$db reference to database handler
  **/
 function milestone_mgr(&$db)
 {
     parent::__construct();
     $this->db =& $db;
 }
 /**
  * Class constructor
  * 
  * @param resource &$db reference to the database handler
  */
 function __construct(&$db)
 {
     parent::__construct();
     $this->db =& $db;
     $this->tree_manager = new tree($this->db);
     $cfConfig = config_get('custom_fields');
     $this->sizes = $cfConfig->sizes;
     if (property_exists($cfConfig, 'types') && !is_null($cfConfig->types)) {
         $this->custom_field_types += $cfConfig->types;
         ksort($this->custom_field_types);
     }
     if (property_exists($cfConfig, 'possible_values_cfg') && !is_null($cfConfig->possible_values_cfg)) {
         $this->possible_values_cfg += $cfConfig->possible_values_cfg;
     }
     $this->object_table = $this->tables["custom_fields"];
     $this->max_length_value = $cfConfig->max_length;
     $this->max_length_possible_values = $this->max_length_value;
     $this->locations = $this->getLocations();
 }
Beispiel #15
0
/**
 * filter testcases by the result of their latest execution
 * 
 * @param object &$db reference to database handler
 * @param object &$tplan_mgr reference to test plan manager object
 * @param array &$tcase_set reference to test case set to filter
 * @param integer $tplan_id ID of test plan
 * @param array $filters filters to apply to test case set
 * @return array new tcase_set
 */
function filter_by_status_for_last_execution(&$db, &$tplan_mgr, &$tcase_set, $tplan_id, $filters)
{
    $tables = tlObject::getDBTables('executions');
    $result_key = 'filter_result_result';
    $in_status = implode("','", $filters->{$result_key});
    foreach ($tcase_set as $tc_id => $tc_info) {
        // get last execution result for each testcase,
        // if it differs from the result in tcase_set the tcase will be deleted from set
        $sql = " SELECT status FROM {$tables['executions']} E " . " WHERE tcversion_id = {$tc_info['tcversion_id']} AND testplan_id = {$tplan_id} " . " AND platform_id = {$tc_info['platform_id']} " . " AND status = '{$tc_info['exec_status']}' " . " AND status IN ('{$in_status}') " . " ORDER BY execution_ts DESC limit 1 ";
        $result = null;
        $result = $db->fetchArrayRowsIntoMap($sql, 'status');
        if (is_null($result)) {
            unset($tcase_set[$tc_id]);
        }
    }
    return $tcase_set;
}
Beispiel #16
0
function getAllUsersRoles(&$db, $order_by = null)
{
    $tables = tlObject::getDBTables(array('users', 'roles'));
    $sql = "SELECT users.id FROM {$tables['users']} users " . " LEFT OUTER JOIN {$tables['roles']} roles ON users.role_id = roles.id ";
    $sql .= is_null($order_by) ? " ORDER BY login " : $order_by;
    $users = tlDBObject::createObjectsFromDBbySQL($db, $sql, "id", "tlUser", false, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM);
    return $users;
}
Beispiel #17
0
 public static function getByAPIKey(&$dbHandler, $value)
 {
     $tables = tlObject::getDBTables('users');
     $target = $dbHandler->prepare_string($value);
     $sql = "SELECT * FROM {$tables['users']} WHERE script_key='{$target}'";
     $rs = $dbHandler->fetchRowsIntoMap($sql, "id");
     return $rs;
 }
/**
 *
 */
function getAllUsersForGrid(&$dbHandler)
{
    $tables = tlObject::getDBTables(array('users', 'roles'));
    // Column extraction order is CRITIC for correct behaviour of Ext-JS
    $sql = " SELECT '' AS handle,U.first,U.last,U.email,R.description,U.locale,U.active," . " /* this columns will not visible on GUI */ " . " '' AS place_holder,R.id AS role_id,U.id AS user_id,U.login, 0 AS is_special " . " FROM {$tables['users']} U " . " JOIN {$tables['roles']} R ON U.role_id = R.id  ORDER BY U.login ";
    $users = $dbHandler->get_recordset($sql);
    // because we need to render this on EXT-JS, we have issues with <no rights> role
    // due to <, then we are going to escape values in description column
    $loop2do = count($users);
    for ($idx = 0; $idx < $loop2do; $idx++) {
        $users[$idx]['description'] = htmlentities($users[$idx]['description']);
    }
    // Still need to understand why, but with MSSQL we use on ADODB
    // fetch mode = ADODB_FETCH_BOTH, this generates numeric AND literal keys
    // on row maps => for each column on result set we get to elements on row map.
    // example 0,handle,1,first, and so on.
    // This drives crazy EXT-JS grid
    if (!is_null($users) && $dbHandler->dbType == 'mssql') {
        $clean = array();
        foreach ($users as $row) {
            $cr = array();
            $elem = array_keys($row);
            foreach ($elem as $accessKey) {
                if (!is_numeric($accessKey)) {
                    $cr[$accessKey] = $row[$accessKey];
                }
            }
            $clean[] = $cr;
        }
        $users = $clean;
    }
    if (config_get('demoMode')) {
        $loop2do = count($users);
        $specialK = array_flip((array) config_get('demoSpecialUsers'));
        for ($idx = 0; $idx < $loop2do; $idx++) {
            $users[$idx]['is_special'] = isset($specialK[$users[$idx]['login']]) ? 1 : 0;
        }
    }
    return $users;
}
Beispiel #19
0
/**
 * filter testcases by the result of their latest execution
 * 
 * @param object &$db reference to database handler
 * @param object &$tplan_mgr reference to test plan manager object
 * @param array &$tcase_set reference to test case set to filter
 * @param integer $tplan_id ID of test plan
 * @param array $filters filters to apply to test case set
 * @return array new tcase_set
 */
function filter_by_status_for_last_execution(&$tplan_mgr, &$tcase_set, $tplan_id, $filters)
{
    testlinkInitPage($db);
    //BUGID 3806
    $tables = tlObject::getDBTables('executions');
    $result_key = 'filter_result_result';
    // need to check if result is array because multiple can be selected in advanced filter mode
    $in_status = is_array($filters->{$result_key}) ? implode("','", $filters->{$result_key}) : $filters->{$result_key};
    foreach ($tcase_set as $tc_id => $tc_info) {
        // get last execution result for each testcase,
        // if it differs from the result in tcase_set the tcase will be deleted from set
        $sql = " SELECT status FROM {$tables['executions']} E " . " WHERE tcversion_id = {$tc_info['tcversion_id']} AND testplan_id = {$tplan_id} " . " AND platform_id = {$tc_info['platform_id']} " . " AND status = '{$tc_info['exec_status']}' " . " AND status IN ('{$in_status}') " . " ORDER BY execution_ts DESC ";
        $result = null;
        // BUGID 3772: MS SQL - LIMIT CLAUSE can not be used
        $result = $db->fetchArrayRowsIntoMap($sql, 'status', 1);
        if (is_null($result)) {
            unset($tcase_set[$tc_id]);
        }
    }
    return $tcase_set;
}
Beispiel #20
0
function getAllUsersRoles(&$db, $order_by = null)
{
    $tables = tlObject::getDBTables(array('users', 'roles'));
    $sql = "SELECT users.id FROM {$tables['users']} users " . " LEFT OUTER JOIN {$tables['roles']} roles ON users.role_id = roles.id ";
    $sql .= is_null($order_by) ? " ORDER BY login " : $order_by;
    $users = tlDBObject::createObjectsFromDBbySQL($db, $sql, "id", "tlUser", false, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM);
    $loop2do = count($users);
    $specialK = array_flip((array) config_get('demoSpecialUsers'));
    $demoModeEnabled = config_get('demoMode');
    for ($idx = 0; $idx < $loop2do; $idx++) {
        $users[$idx]->isDemoSpecial = $demoModeEnabled ? isset($specialK[$users[$idx]->login]) : false;
    }
    return $users;
}
Beispiel #21
0
    //
    //
    // Postgres uses as identifier quote character " (double quotes):
    $sql_create_db = $db->build_sql_create_db($db_name);
    if (!$db->exec_query($sql_create_db)) {
        echo "<span class='notok'>Failed!</span></b> - Could not create database: {$db}! " . $db->error_msg();
        $errors += 1;
        echo "<p> TestLink setup could not create the database, " . "and no existing database with the same name was found. <br />" . "Please create a database by different way (e.g. from command line)," . " or with different DB root account. Run setup again then.";
        close_html_and_exit();
    } else {
        echo "<span class='ok'>OK!</span>";
    }
}
// in upgrade mode we detect the lenght of user password field
// to identify a version with uncrypted passwords
$tables = tlObject::getDBTables();
$my_ado = $db->get_dbmgr_object();
if ($upgrade) {
    $user_table = $my_ado->MetaTables('TABLES', false, 'user');
    if (count($user_table) == 1) {
        $the_cols = $my_ado->MetaColumns('user');
        $pwd_field_len = $the_cols['PASSWORD']->max_length;
        if ($pwd_field_len == LEN_PWD_TL_1_0_4) {
            $update_pwd = 1;
            echo "<p>You are trying to upgrade from a pre-release of TestLink 1.5" . "<br />this kind of upgrade is supported by this script. Use upgrade to supported version " . "at first.</p>";
            close_html_and_exit();
        }
    }
    // ------------------------------------------------------------------------------------------------
    $a_sql_upd_dir = array();
    $a_sql_data_dir = array();
Beispiel #22
0
function doUpdate(&$dbObj, &$argsObj)
{
    $debugMsg = 'File:' . __FILE__ . ' - Function: ' . __FUNCTION__;
    $tables = tlObject::getDBTables(array('testplan_tcversions', 'executions', 'cfield_execution_values'));
    $msg = "";
    if (!is_null($argsObj->checkedTestCaseSet)) {
        foreach ($argsObj->checkedTestCaseSet as $tcaseID => $tcversionID) {
            $newtcversion = $argsObj->newVersionSet[$tcaseID];
            foreach ($tables as $table2update) {
                $sql = "/* {$debugMsg} */ UPDATE {$table2update} " . " SET tcversion_id={$newtcversion} " . " WHERE tcversion_id={$tcversionID} " . " AND testplan_id={$argsObj->tplan_id}";
                $dbObj->exec_query($sql);
            }
        }
        $msg = lang_get("tplan_updated");
    }
    return $msg;
}