/** * **/ function getIssue($id) { $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; if (!$this->isConnected()) { return false; } $sql = "/* {$debugMsg} */ SELECT id,status,summary FROM mantis_bug_table " . " WHERE id=" . intval($id); $rs = $this->dbConnection->fetchRowsIntoMap($sql, 'id'); $issue = null; if (!is_null($rs)) { $issueOnMantisDB = current($rs); $issue = new stdClass(); $issue->IDHTMLString = "<b>{$id} : </b>"; $issue->summaryHTMLString = $issueOnMantisDB['summary']; $issue->statusCode = $issueOnMantisDB['status']; $issue->isResolved = isset($this->resolvedStatus->byCode[$issue->statusCode]); if (isset($this->code_status[$issue->statusCode])) { $issue->statusVerbose = $this->code_status[$issue->statusCode]; } else { // give info to user on Event Viewer $msg = lang_get('MANTIS_status_not_configured'); $msg = sprintf($msg, $issueOnMantisDB['status']); logWarningEvent($msg, "MANTIS INTEGRATION"); $issue->statusVerbose = 'custom_undefined_on_tl'; } $issue->statusHTMLString = $this->buildStatusHTMLString($issue->statusVerbose); $issue->statusColor = isset($this->status_color[$issue->statusVerbose]) ? $this->status_color[$issue->statusVerbose] : 'white'; } return $issue; }
/** * Retrieves an internationalized string * This function will return one of (in order of preference): * 1. The string in the current user's preferred language (if defined) * 2. The string in English * * @param mixed $p_string string or array of string with term keys * * @internal Revisions: * 20070501 - franciscom - added TL_LOCALIZE_TAG in order to * improve label management for custom fields */ function lang_get($p_string, $p_lang = null, $bDontFireEvents = false) { if ($p_string == '' || is_null($p_string)) { return $p_string; } $t_lang = $p_lang; if (null === $t_lang) { $t_lang = isset($_SESSION['locale']) ? $_SESSION['locale'] : TL_DEFAULT_LOCALE; } lang_ensure_loaded($t_lang); global $g_lang_strings; $loc_str = null; $missingL18N = false; $englishSolutionFound = false; if (isset($g_lang_strings[$t_lang][$p_string])) { $loc_str = $g_lang_strings[$t_lang][$p_string]; } else { if ($t_lang != 'en_GB') { // force load of english strings lang_ensure_loaded('en_GB'); } if (isset($g_lang_strings['en_GB'][$p_string])) { $missingL18N = true; $englishSolutionFound = true; $loc_str = $g_lang_strings['en_GB'][$p_string]; } } $the_str = $loc_str; $missingL18N = is_null($loc_str) || $missingL18N; if (!is_null($loc_str)) { $stringFileCharset = "ISO-8859-1"; if (isset($g_lang_strings[$t_lang]['STRINGFILE_CHARSET'])) { $stringFileCharset = $g_lang_strings[$t_lang]['STRINGFILE_CHARSET']; } if ($stringFileCharset != TL_TPL_CHARSET) { $the_str = iconv($stringFileCharset, TL_TPL_CHARSET, $loc_str); } } if ($missingL18N) { // if( $t_lang != 'en_GB' ) // { // // force load of english strings // lang_ensure_loaded('en_GB'); // } if (!$bDontFireEvents) { // 20100823 - franciscom // When testing with a user with locale = italian, found // 1. missing localized string was replaced with version present on english strings // 2. no log written to event viewer // 3. detected a call to lang_get() with language en_GB // $msg = sprintf("string '%s' is not localized for locale '%s'", $p_string, $t_lang); logWarningEvent($msg, "LOCALIZATION"); } if (!$englishSolutionFound) { $the_str = TL_LOCALIZE_TAG . $p_string; } } return $the_str; }
/** * include php errors, warnings and notices to TestLink log * * @internal * * Important Notice: * when using Smarty3 on demo.testlink.org, this kind of error started to appear * * Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php * in /path/to/smarty/libs/sysplugins/smarty_resource.php * * According to Smarty documentation: * This means that your application registered a custom error hander (using set_error_handler()) * which is not respecting the given $errno as it should. * If, for whatever reason, this is the desired behaviour of your custom error handler, please call muteExpectedErrors() * after you've registered your custom error handler. * * @20130815 my choice is: (strpos($errfile,"Warning: filemtime()") !== false) */ function watchPHPErrors($errno, $errstr, $errfile, $errline) { $errors = array(E_USER_NOTICE => "E_USER_NOTICE", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_NOTICE => "E_NOTICE", E_STRICT => "E_STRICT"); if (isset($errors[$errno])) { // suppress some kind of errors // strftime(),strtotime(),date() // work in block just to make copy and paste easier // Block 1 - errstr // Block 2 - errfile // if ($errno == E_NOTICE && strpos($errstr, "unserialize()") !== false || $errno == E_NOTICE && strpos($errstr, "ob_end_clean()") !== false || $errno == E_STRICT && strpos($errstr, "strftime()") !== false || $errno == E_STRICT && strpos($errstr, "mktime()") !== false || $errno == E_STRICT && strpos($errstr, "date()") !== false || $errno == E_STRICT && strpos($errstr, "strtotime()") !== false || $errno == E_WARNING && strpos($errstr, "filemtime") !== false || $errno == E_STRICT && strpos($errfile, "xmlrpc.inc") !== false || $errno == E_STRICT && strpos($errfile, "xmlrpcs.inc") !== false || $errno == E_STRICT && strpos($errfile, "xmlrpc_wrappers.inc") !== false || $errno == E_NOTICE && strpos($errfile, "Config_File.class.php") !== false || $errno == E_WARNING && strpos($errfile, "smarty_internal_write_file.php") !== false || strpos($errfile, "Smarty_Compiler.class.php") !== false) { return; } logWarningEvent($errors[$errno] . "\n" . $errstr . " - in " . $errfile . " - Line " . $errline, "PHP"); } }
/** * Returns the status of the bug with the given id * this function is not directly called by TestLink. * * @return string returns the status of the given bug (if found in the db), or false else **/ function getBugStatus($id) { if (!$this->isConnected()) { return false; } $status = false; $query = "SELECT status FROM mantis_bug_table WHERE id='" . $id . "'"; $result = $this->dbConnection->exec_query($query); if ($result) { $status_rs = $this->dbConnection->fetch_array($result); $status = null; if ($status_rs) { // BUGID 3195 if (isset($this->code_status[$status_rs['status']])) { $status = $this->code_status[$status_rs['status']]; } else { // give info to user on Event Viewer $msg = lang_get('MANTIS_status_not_configured'); $msg = sprintf($msg, $status_rs['status']); logWarningEvent($msg, "MANTIS INTEGRATION"); $status = 'custom_undefined_on_tl'; } } } return $status; }