private function doSearch($itemtype, $params, array $forcedisplay = array())
{
global $DEBUG_SQL;
// check param itemtype exists (to avoid search errors)
$this->assertTrue(is_subclass_of($itemtype, "CommonDBTM"));
// login to glpi if needed
if (!isset($_SESSION['glpiname'])) {
$this->Login();
}
// force session in debug mode (to store & retrieve sql errors)
$glpi_use_mode = $_SESSION['glpi_use_mode'];
$_SESSION['glpi_use_mode'] = Session::DEBUG_MODE;
// don't compute last request from session
$params['reset'] = 'reset';
// do search
$params = Search::manageParams($itemtype, $params);
$data = Search::getDatas($itemtype, $params, $forcedisplay);
// append existing errors to returned data
$data['last_errors'] = array();
if (isset($DEBUG_SQL['errors'])) {
$data['last_errors'] = implode(', ', $DEBUG_SQL['errors']);
unset($DEBUG_SQL['errors']);
}
// restore glpi mode to previous
$_SESSION['glpi_use_mode'] = $glpi_use_mode;
// do not store this search from session
Search::resetSaveSearch();
return $data;
}