if (Session::haveRight('plugin_relation', CREATE)) {
        if (PluginRelationRelation::isAncestor($_POST['items_id'], $_POST['id'], $_POST['type'])) {
            Session::addMessageAfterRedirect(__('Sorry. You cannot add an ancestor as a child!', 'Sorry. You cannot add an ancestor as a child!'), true);
        } else {
            PluginRelationRelation::addParent($_POST['id'], $_POST['items_id'], $_POST['itemtype'], $_POST['type'], $_POST['_nombresrelaciones']);
            // Logging here
            $child = PluginRelationRelation::getDeviceName($_POST['itemtype'], $_POST['items_id']);
            $parent = PluginRelationRelation::getDeviceName($_POST['type'], $_POST['id']);
            PluginRelationRelation::logChange($_POST['type'], $_POST['items_id'], $_POST['id'], $child, $parent, RELATIONS_LINK, $_POST['itemtype'], $_POST['_nombresrelaciones']);
        }
    }
    Html::redirect($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_GET['deleterelation'])) {
        //$PluginRelations->check($_GET['id'],'w');
        $DB = new DB();
        $query = "SELECT * FROM glpi_plugin_relation_relations WHERE id='" . $_GET['id'] . "'";
        $result = $DB->query($query);
        if ($data = $DB->fetch_array($result)) {
            $PluginRelation->delete($_GET);
            // Logging
            $child = PluginRelationRelation::getDeviceName($data['itemtype'], $data['items_id']);
            $parent = PluginRelationRelation::getDeviceName($data['parent_type'], $data['parent_id']);
            PluginRelationRelation::logChange($data['parent_type'], $data['items_id'], $data['parent_id'], $child, $parent, RELATIONS_UNLINK, $data['itemtype'], $data['relation_type']);
        }
        Html::back();
    } else {
        Html::back();
    }
}
//Html::back();