static function manageRedirect($where)
{
global $CFG_GLPI, $PLUGIN_HOOKS;
if (!empty($where)) {
if (isset($_SESSION["glpiactiveprofile"]["interface"]) && !empty($_SESSION["glpiactiveprofile"]["interface"])) {
$decoded_where = rawurldecode($where);
// redirect to URL : URL must be rawurlencoded
if ($link = preg_match('/(https?:\\/\\/[^\\/]+)\\/.+/', $decoded_where, $matches)) {
if ($matches[1] !== $CFG_GLPI['url_base']) {
Session::addMessageAfterRedirect('Redirection failed');
if ($_SESSION["glpiactiveprofile"]["interface"] === "helpdesk") {
Html::redirect($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
} else {
Html::redirect($CFG_GLPI["root_doc"] . "/front/central.php");
}
} else {
Html::redirect($decoded_where);
}
}
// Redirect based on GLPI_ROOT : URL must be rawurlencoded
if ($decoded_where[0] == '/') {
// echo $decoded_where;exit();
Html::redirect($CFG_GLPI["root_doc"] . $decoded_where);
}
$data = explode("_", $where);
$forcetab = '';
// forcetab for simple items
if (isset($data[2])) {
$forcetab = 'forcetab=' . $data[2];
}
switch ($_SESSION["glpiactiveprofile"]["interface"]) {
case "helpdesk":
switch (strtolower($data[0])) {
// Use for compatibility with old name
case "tracking":
case "ticket":
$data[0] = 'Ticket';
// redirect to item
if (isset($data[1]) && is_numeric($data[1]) && $data[1] > 0) {
// Check entity
if (($item = getItemForItemtype($data[0])) && $item->isEntityAssign()) {
if ($item->getFromDB($data[1])) {
if (!Session::haveAccessToEntity($item->getEntityID())) {
Session::changeActiveEntities($item->getEntityID(), 1);
}
}
}
Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $data[1] . "&{$forcetab}");
} else {
if (!empty($data[0])) {
// redirect to list
if ($item = getItemForItemtype($data[0])) {
Html::redirect($item->getSearchURL() . "?{$forcetab}");
}
}
}
Html::redirect($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
break;
case "preference":
Html::redirect($CFG_GLPI["root_doc"] . "/front/preference.php?{$forcetab}");
break;
case "reservation":
Html::redirect($CFG_GLPI["root_doc"] . "/front/reservation.form.php?id=" . $data[1] . "&{$forcetab}");
break;
default:
Html::redirect($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
break;
}
break;
case "central":
switch (strtolower($data[0])) {
case "preference":
Html::redirect($CFG_GLPI["root_doc"] . "/front/preference.php?{$forcetab}");
break;
// Use for compatibility with old name
// no break
// Use for compatibility with old name
// no break
case "tracking":
$data[0] = "Ticket";
default:
// redirect to item
if (!empty($data[0]) && isset($data[1]) && is_numeric($data[1]) && $data[1] > 0) {
// Check entity
if ($item = getItemForItemtype($data[0])) {
if ($item->isEntityAssign()) {
if ($item->getFromDB($data[1])) {
if (!Session::haveAccessToEntity($item->getEntityID())) {
Session::changeActiveEntities($item->getEntityID(), 1);
}
}
}
Html::redirect($item->getFormURL() . "?id=" . $data[1] . "&{$forcetab}");
}
} else {
if (!empty($data[0])) {
// redirect to list
if ($item = getItemForItemtype($data[0])) {
Html::redirect($item->getSearchURL() . "?{$forcetab}");
}
}
}
Html::redirect($CFG_GLPI["root_doc"] . "/front/central.php");
break;
}
break;
}
}
}
}