Update device_profile_delete.php
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Copyright (C) 2008-2016 All Rights Reserved.
|
Copyright (C) 2019 All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
@@ -28,68 +28,73 @@
|
|||||||
require_once "resources/require.php";
|
require_once "resources/require.php";
|
||||||
require_once "resources/check_auth.php";
|
require_once "resources/check_auth.php";
|
||||||
|
|
||||||
//check permissions
|
|
||||||
if (permission_exists('device_profile_delete')) {
|
|
||||||
//access granted
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo "access denied";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//get the id
|
//delete the message
|
||||||
$device_profile_uuid = $_GET["id"];
|
message::add($text['message-delete']);
|
||||||
|
|
||||||
//delete the data and subdata
|
//delete the data
|
||||||
if (is_uuid($device_profile_uuid)) {
|
if (isset($_GET["id"]) && is_uuid($_GET["id"]) && permission_exists('device_profile_delete')) {
|
||||||
|
|
||||||
//add temp permissions
|
//get the id
|
||||||
$p = new permissions;
|
$id = $_GET["id"];
|
||||||
$p->add('device_key_delete', 'temp');
|
|
||||||
$p->add('device_edit', 'temp');
|
|
||||||
|
|
||||||
//create array
|
//delete the data
|
||||||
$array['device_keys'][0]['device_profile_uuid'] = $device_profile_uuid;
|
$array['device_profile_keys'][]['device_profile_uuid'] = $id;
|
||||||
$array['device_profiles'][0]['device_profile_uuid'] = $device_profile_uuid;
|
$array['device_profile_settings'][]['device_profile_uuid'] = $id;
|
||||||
|
$array['device_profiles'][]['device_profile_uuid'] = $id;
|
||||||
//delete
|
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$database->app_name = 'devices';
|
$database->app_name = 'devices';
|
||||||
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
||||||
$database->delete($array);
|
$database->delete($array);
|
||||||
unset($array);
|
unset($array);
|
||||||
|
|
||||||
//remove device profile uuid from any assigned devices
|
//redirect the user
|
||||||
$sql = "update v_devices set ";
|
header('Location: device_profiles.php');
|
||||||
$sql .= "device_profile_uuid = null ";
|
|
||||||
$sql .= "where device_profile_uuid = :device_profile_uuid ";
|
|
||||||
$parameters['device_profile_uuid'] = $device_profile_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
//remove temp permissions
|
|
||||||
$p->delete('device_key_delete', 'temp');
|
|
||||||
$p->delete('device_edit', 'temp');
|
|
||||||
|
|
||||||
//write the provision files
|
|
||||||
if ($_SESSION['provision']['path']['text'] != '') {
|
|
||||||
$prov = new provision;
|
|
||||||
$prov->domain_uuid = $domain_uuid;
|
|
||||||
$response = $prov->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
//set message
|
|
||||||
message::add($text['message-delete']);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//redirect the user
|
//delete the child data
|
||||||
header("Location: device_profiles.php");
|
if (isset($_REQUEST["device_profile_key_uuid"]) && is_uuid($_REQUEST["device_profile_key_uuid"]) && permission_exists('device_profile_key_delete')) {
|
||||||
return;
|
//select from v_device_profile_keys
|
||||||
|
$sql = "select device_profile_uuid from v_device_profile_keys ";
|
||||||
|
$sql .= "where device_profile_key_uuid = :device_profile_key_uuid ";
|
||||||
|
$parameters['device_profile_key_uuid'] = $_REQUEST["device_profile_key_uuid"];
|
||||||
|
$database = new database;
|
||||||
|
$device_profile_uuid = $database->select($sql, $parameters, 'column');
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
//delete the row
|
||||||
|
$array['device_profile_keys'][]['device_profile_key_uuid'] = $_REQUEST["device_profile_key_uuid"];
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'devices';
|
||||||
|
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
||||||
|
$database->delete($array);
|
||||||
|
|
||||||
|
//redirect the user
|
||||||
|
header('Location: device_profile_edit.php?id='.urlencode($device_profile_uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete the child data
|
||||||
|
if (isset($_REQUEST["device_profile_setting_uuid"]) && is_uuid($_REQUEST["device_profile_setting_uuid"]) && permission_exists('device_profile_setting_delete')) {
|
||||||
|
//select from v_device_profile_settings
|
||||||
|
$sql = "select device_profile_uuid from v_device_profile_settings ";
|
||||||
|
$sql .= "where device_profile_setting_uuid = :device_profile_setting_uuid ";
|
||||||
|
$parameters['device_profile_setting_uuid'] = $_REQUEST["device_profile_setting_uuid"];
|
||||||
|
$database = new database;
|
||||||
|
$device_profile_uuid = $database->select($sql, $parameters, 'column');
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
//delete the row
|
||||||
|
$array['device_profile_settings'][]['device_profile_setting_uuid'] = $_REQUEST["device_profile_setting_uuid"];
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'devices';
|
||||||
|
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
||||||
|
$database->delete($array);
|
||||||
|
|
||||||
|
//redirect the user
|
||||||
|
header('Location: device_profile_edit.php?id='.urlencode($device_profile_uuid));
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user