Files
librenms-librenms/includes/html/forms/delete-host-dependency.inc.php

47 lines
1.8 KiB
PHP
Raw Normal View History

feature: Added support for Host dependencies (#7332) * First draft of the modals and the config interfaces * GUI part done * Backend code and db schema addition * Documentation added, fixed alerting bug * Fix typos * Do not try to push an older db_schame.yaml * Small db fix * More db fixes * Travis CI fixes * missed a line in the travis error * Fixed dependency clearing bug, Manage Host dependencies button now shows current selections * Removed unnecessary index * Correct faulty query * Fixed sql query as requested, and renamed sql file * Added requested changes * Removed debug code * Renamed sql file * More fixes as requested * Trying to fix db_schema.yaml * adding laf's diff * Corrected a small bug * Try to resolve scrutinizer issue * Main page bootgrid ajax modifications * Also corrected travis ci errors * Added select2 for pull downs, removed a redundant debug output. Changed parent_id to text * Add missing class in the device settings page * Fix bug where a link wasn't added after save * Better parent down detection * Add missing comma * Behold the multi-parent code * Added lookup table * Ready for testing * Trying to fix documentation conflicts * Fix copy paste errors, and possible sql injection * indentation problems * Modified db_schema.yaml as well * Typos, typos * This should correct alerts * Try to fix travis ci error * Fix the typo in index.php * Changed to Tony's query * function explanation text changed * Updated db_schema.yaml * Trying to make automated tests happy * Changes as requested * Added acknowledgment for select2 * Added laf's patch * dbBulkInsert when adding parents
2017-12-20 17:17:52 +03:00
<?php
/*
* LibreNMS
*
* Copyright (c) 2017 Aldemir Akpinar <https://github.com/aldemira/>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (!Auth::user()->hasGlobalAdmin()) {
$status = ['status' => 1, 'message' => 'You need to be admin'];
feature: Added support for Host dependencies (#7332) * First draft of the modals and the config interfaces * GUI part done * Backend code and db schema addition * Documentation added, fixed alerting bug * Fix typos * Do not try to push an older db_schame.yaml * Small db fix * More db fixes * Travis CI fixes * missed a line in the travis error * Fixed dependency clearing bug, Manage Host dependencies button now shows current selections * Removed unnecessary index * Correct faulty query * Fixed sql query as requested, and renamed sql file * Added requested changes * Removed debug code * Renamed sql file * More fixes as requested * Trying to fix db_schema.yaml * adding laf's diff * Corrected a small bug * Try to resolve scrutinizer issue * Main page bootgrid ajax modifications * Also corrected travis ci errors * Added select2 for pull downs, removed a redundant debug output. Changed parent_id to text * Add missing class in the device settings page * Fix bug where a link wasn't added after save * Better parent down detection * Add missing comma * Behold the multi-parent code * Added lookup table * Ready for testing * Trying to fix documentation conflicts * Fix copy paste errors, and possible sql injection * indentation problems * Modified db_schema.yaml as well * Typos, typos * This should correct alerts * Try to fix travis ci error * Fix the typo in index.php * Changed to Tony's query * function explanation text changed * Updated db_schema.yaml * Trying to make automated tests happy * Changes as requested * Added acknowledgment for select2 * Added laf's patch * dbBulkInsert when adding parents
2017-12-20 17:17:52 +03:00
} else {
if ($_POST['device_id']) {
if (!is_numeric($_POST['device_id'])) {
$status = ['status' => 1, 'message' => 'Wrong device id!'];
} else {
$device = \App\Models\Device::find($_POST['device_id']);
if ($device->parents()->detach()) {
$status = ['status' => 0, 'message' => 'Device dependency has been deleted.'];
} else {
$status = ['status' => 1, 'message' => 'Device dependency cannot be deleted.'];
}
}
} elseif ($_POST['parent_ids']) {
$status = ['status' => 0, 'message' => 'Device dependencies has been deleted'];
foreach ($_POST['parent_ids'] as $parent) {
if (is_numeric($parent) && $parent != 0) {
$device = \App\Models\Device::find($_POST['device_id']);
if (!$device->children()->detach()) {
$status = ['status' => 1, 'message' => 'Device dependency cannot be deleted.'];
}
} elseif ($parent == 0) {
$status = ['status' => 1, 'message' => 'No dependency to delete.'];
break;
}
}
feature: Added support for Host dependencies (#7332) * First draft of the modals and the config interfaces * GUI part done * Backend code and db schema addition * Documentation added, fixed alerting bug * Fix typos * Do not try to push an older db_schame.yaml * Small db fix * More db fixes * Travis CI fixes * missed a line in the travis error * Fixed dependency clearing bug, Manage Host dependencies button now shows current selections * Removed unnecessary index * Correct faulty query * Fixed sql query as requested, and renamed sql file * Added requested changes * Removed debug code * Renamed sql file * More fixes as requested * Trying to fix db_schema.yaml * adding laf's diff * Corrected a small bug * Try to resolve scrutinizer issue * Main page bootgrid ajax modifications * Also corrected travis ci errors * Added select2 for pull downs, removed a redundant debug output. Changed parent_id to text * Add missing class in the device settings page * Fix bug where a link wasn't added after save * Better parent down detection * Add missing comma * Behold the multi-parent code * Added lookup table * Ready for testing * Trying to fix documentation conflicts * Fix copy paste errors, and possible sql injection * indentation problems * Modified db_schema.yaml as well * Typos, typos * This should correct alerts * Try to fix travis ci error * Fix the typo in index.php * Changed to Tony's query * function explanation text changed * Updated db_schema.yaml * Trying to make automated tests happy * Changes as requested * Added acknowledgment for select2 * Added laf's patch * dbBulkInsert when adding parents
2017-12-20 17:17:52 +03:00
}
}
header('Content-Type: application/json');
echo json_encode($status);