mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Devices - Edit: Integrate checkboxes on Lines, Keys and Settings for bulk delete on Save (uses token). Add delete button with dynamic action.
This commit is contained in:
@@ -30,6 +30,7 @@ include "root.php";
|
||||
public $db;
|
||||
public $domain_uuid;
|
||||
public $template_dir;
|
||||
public $device_uuid;
|
||||
public $device_vendor_uuid;
|
||||
public $device_profile_uuid;
|
||||
|
||||
@@ -351,6 +352,147 @@ include "root.php";
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_lines($records) {
|
||||
//assign private variables
|
||||
$this->permission_prefix = 'device_line_';
|
||||
$this->table = 'device_lines';
|
||||
$this->uuid_prefix = 'device_line_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked device lines, build delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['device_uuid'] = $this->device_uuid;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_keys($records) {
|
||||
//assign private variables
|
||||
$this->permission_prefix = 'device_key_';
|
||||
$this->table = 'device_keys';
|
||||
$this->uuid_prefix = 'device_key_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked device keys, build delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['device_uuid'] = $this->device_uuid;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_settings($records) {
|
||||
//assign private variables
|
||||
$this->permission_prefix = 'device_setting_';
|
||||
$this->table = 'device_settings';
|
||||
$this->uuid_prefix = 'device_setting_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked device settings, build delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['device_uuid'] = $this->device_uuid;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_vendors($records) {
|
||||
|
||||
//assign private variables
|
||||
|
||||
Reference in New Issue
Block a user