예제 #1
0
  @link      https://forge.indepnet.net/projects/barscode
  @since     2009

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET['id'])) {
    $_GET['id'] = '';
}
$PluginRelation = new PluginRelationRelation();
if (isset($_POST['additem']) && isset($_POST['type']) && isset($_POST['items_id']) > 0) {
    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);