diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index fdf4d62b58..d519e556a3 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -20,6 +20,26 @@ $text['title-devices']['ru-ru'] = "Устройства"; $text['title-devices']['sv-se'] = "Enheter"; $text['title-devices']['uk-ua'] = "Пристрої"; +$text['title-device']['en-us'] = "Device"; +$text['title-device']['ar-eg'] = ""; +$text['title-device']['de-at'] = "Gerät"; //copied from de-de +$text['title-device']['de-ch'] = "Gerät"; //copied from de-de +$text['title-device']['de-de'] = "Gerät"; +$text['title-device']['es-cl'] = "Dispositivo"; +$text['title-device']['es-mx'] = "Dispositivo"; //copied from es-cl +$text['title-device']['fr-ca'] = "Equipement"; //copied from fr-fr +$text['title-device']['fr-fr'] = "Equipement"; +$text['title-device']['he-il'] = "מכשיר"; +$text['title-device']['it-it'] = "Dispositivo"; +$text['title-device']['nl-nl'] = "Apparaat"; +$text['title-device']['pl-pl'] = "Urządzenie"; +$text['title-device']['pt-br'] = "Dispositivo"; //copied from pt-pt +$text['title-device']['pt-pt'] = "Dispositivo"; +$text['title-device']['ro-ro'] = ""; +$text['title-device']['ru-ru'] = "Устройство"; +$text['title-device']['sv-se'] = "Enhet"; +$text['title-device']['uk-ua'] = ""; + $text['title-device_import']['en-us'] = "Device Import"; $text['title-device_import']['ar-eg'] = ""; $text['title-device_import']['de-at'] = "Importieren"; //copied from de-de @@ -64,7 +84,7 @@ $text['title-device_export']['sv-se'] = "Export"; $text['title-device_export']['uk-ua'] = "Експортувати"; $text['title-device_export']['tr-tr'] = "Dışa Aktar"; -$text['title-device_profiles']['en-us'] = "Profiles"; +$text['title-device_profiles']['en-us'] = "Device Profiles"; $text['title-device_profiles']['ar-eg'] = ""; $text['title-device_profiles']['de-at'] = "Profile"; //copied from de-de $text['title-device_profiles']['de-ch'] = "Profile"; //copied from de-de @@ -84,7 +104,7 @@ $text['title-device_profiles']['ru-ru'] = "Профили"; $text['title-device_profiles']['sv-se'] = "Profiler"; $text['title-device_profiles']['uk-ua'] = "Профілі"; -$text['title-device_profile']['en-us'] = "Profile"; +$text['title-device_profile']['en-us'] = "Device Profile"; $text['title-device_profile']['ar-eg'] = ""; $text['title-device_profile']['de-at'] = "Profil"; //copied from de-de $text['title-device_profile']['de-ch'] = "Profil"; //copied from de-de @@ -2564,25 +2584,25 @@ $text['label-device_password']['ru-ru'] = "Пароль"; $text['label-device_password']['sv-se'] = "Lösenord"; $text['label-device_password']['uk-ua'] = "Пароль"; -$text['label-device_profiles']['en-us'] = "Profile"; -$text['label-device_profiles']['ar-eg'] = "Profile"; -$text['label-device_profiles']['de-at'] = "Profile"; //copied from de-de -$text['label-device_profiles']['de-ch'] = "Profile"; //copied from de-de -$text['label-device_profiles']['de-de'] = "Profile"; -$text['label-device_profiles']['es-cl'] = "Profile"; -$text['label-device_profiles']['es-mx'] = "Profile"; //copied from es-cl -$text['label-device_profiles']['fr-ca'] = "Profil"; //copied from fr-fr -$text['label-device_profiles']['fr-fr'] = "Profil"; -$text['label-device_profiles']['he-il'] = "פרופילים"; -$text['label-device_profilesl']['it-it'] = "Profile"; -$text['label-device_profiles']['nl-nl'] = "Profiel"; -$text['label-device_profiles']['pl-pl'] = "Profile"; -$text['label-device_profiles']['pt-br'] = "Perfil"; //copied from pt-pt -$text['label-device_profiles']['pt-pt'] = "Profile"; -$text['label-device_profiles']['ro-ro'] = ""; -$text['label-device_profiles']['ru-ru'] = "Профили"; -$text['label-device_profiles']['sv-se'] = "Profiler"; -$text['label-device_profiles']['uk-ua'] = "Профіль"; +$text['label-device_profile']['en-us'] = "Profile"; +$text['label-device_profile']['ar-eg'] = "Profile"; +$text['label-device_profile']['de-at'] = "Profile"; //copied from de-de +$text['label-device_profile']['de-ch'] = "Profile"; //copied from de-de +$text['label-device_profile']['de-de'] = "Profile"; +$text['label-device_profile']['es-cl'] = "Profile"; +$text['label-device_profile']['es-mx'] = "Profile"; //copied from es-cl +$text['label-device_profile']['fr-ca'] = "Profil"; //copied from fr-fr +$text['label-device_profile']['fr-fr'] = "Profil"; +$text['label-device_profile']['he-il'] = "פרופילים"; +$text['label-device_profile']['it-it'] = "Profile"; +$text['label-device_profile']['nl-nl'] = "Profiel"; +$text['label-device_profile']['pl-pl'] = "Profile"; +$text['label-device_profile']['pt-br'] = "Perfil"; //copied from pt-pt +$text['label-device_profile']['pt-pt'] = "Profile"; +$text['label-device_profile']['ro-ro'] = ""; +$text['label-device_profile']['ru-ru'] = "Профили"; +$text['label-device_profile']['sv-se'] = "Profiler"; +$text['label-device_profile']['uk-ua'] = "Профіль"; $text['label-device_profile_keys']['en-us'] = "Keys"; $text['label-device_profile_keys']['ar-eg'] = ""; @@ -5229,7 +5249,7 @@ $text['button-files']['ru-ru'] = "Файлы"; $text['button-files']['sv-se'] = "Filer"; $text['button-files']['uk-ua'] = ""; -$text['title-device_vendors']['en-us'] = "Vendors"; +$text['title-device_vendors']['en-us'] = "Device Vendors"; $text['title-device_vendors']['ar-eg'] = ""; $text['title-device_vendors']['de-at'] = "Hersteller"; //copied from de-de $text['title-device_vendors']['de-ch'] = "Hersteller"; //copied from de-de @@ -5269,7 +5289,7 @@ $text['description-device_vendors']['ru-ru'] = "Определяет списо $text['description-device_vendors']['sv-se'] = "Definierar listan över leverantörer som används med provisioning-enheter."; $text['description-device_vendors']['uk-ua'] = ""; -$text['title-device_vendor']['en-us'] = "Vendor"; +$text['title-device_vendor']['en-us'] = "Device Vendor"; $text['title-device_vendor']['ar-eg'] = ""; $text['title-device_vendor']['de-at'] = "Hersteller"; //copied from de-de $text['title-device_vendor']['de-ch'] = "Hersteller"; //copied from de-de diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 563922d73a..f3a9857c1a 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -17,7 +17,8 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2008-2019 All Rights Reserved. + Portions created by the Initial Developer are Copyright (C) 2008-2020 + the Initial Developer. All Rights Reserved. */ @@ -69,6 +70,25 @@ //get http post variables and set them to php variables if (count($_POST) > 0) { + + //process the http post data by submitted action + if ($_POST['action'] != '' && is_uuid($_POST['device_uuid'])) { + $array[0]['checked'] = 'true'; + $array[0]['uuid'] = $_POST['device_uuid']; + + switch ($_POST['action']) { + case 'delete': + if (permission_exists('device_delete')) { + $obj = new device; + $obj->delete($array); + } + break; + } + + header('Location: devices.php'); + exit; + } + //device mac address if (permission_exists('device_mac_address')) { $device_mac_address = $_POST["device_mac_address"]; @@ -106,6 +126,7 @@ $device_description = $_POST["device_description"]; //lines $device_lines = $_POST["device_lines"]; + $device_lines_delete = $_POST["device_lines_delete"]; //$line_number = $_POST["line_number"]; //$server_address = $_POST["server_address"]; //$outbound_proxy_primary = $_POST["outbound_proxy_primary"]; @@ -118,6 +139,7 @@ $device_profile_uuid = $_POST["device_profile_uuid"]; //keys $device_keys = $_POST["device_keys"]; + $device_keys_delete = $_POST["device_keys_delete"]; //$device_key_category = $_POST["device_key_category"]; //$device_key_id = $_POST["device_key_id"]; //$device_key_type = $_POST["device_key_type"]; @@ -128,6 +150,7 @@ //$device_key_icon = $_POST["device_key_icon"]; //settings $device_settings = $_POST["device_settings"]; + $device_settings_delete = $_POST["device_settings_delete"]; //$device_setting_category = $_POST["device_setting_category"]); //$device_setting_subcategory = $_POST["device_setting_subcategory"]; //$device_setting_name = $_POST["device_setting_name"]; @@ -321,6 +344,42 @@ $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; $database->save($array); + //remove checked lines + if ( + $action == 'update' + && permission_exists('device_line_delete') + && is_array($device_lines_delete) + && @sizeof($device_lines_delete) != 0 + ) { + $obj = new device; + $obj->device_uuid = $device_uuid; + $obj->delete_lines($device_lines_delete); + } + + //remove checked keys + if ( + $action == 'update' + && permission_exists('device_key_delete') + && is_array($device_keys_delete) + && @sizeof($device_keys_delete) != 0 + ) { + $obj = new device; + $obj->device_uuid = $device_uuid; + $obj->delete_keys($device_keys_delete); + } + + //remove checked settings + if ( + $action == 'update' + && permission_exists('device_setting_delete') + && is_array($device_settings_delete) + && @sizeof($device_settings_delete) != 0 + ) { + $obj = new device; + $obj->device_uuid = $device_uuid; + $obj->delete_settings($device_settings_delete); + } + //write the provision files if (strlen($_SESSION['provision']['path']['text']) > 0) { $prov = new provision; @@ -343,8 +402,8 @@ exit; } - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) + } + } //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { @@ -531,6 +590,7 @@ $token = $object->create($_SERVER['PHP_SELF']); //show the header + $document['title'] = $text['title-device']; require_once "resources/header.php"; //select file download javascript @@ -689,7 +749,7 @@ } //show the content - echo "
\n"; + echo "\n"; echo "\n"; echo "
\n"; @@ -721,11 +781,13 @@ } echo " "; } - - if (permission_exists('device_add') && $action != "add") { + if (permission_exists('device_add') && $action == 'update') { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"var new_mac = prompt('".$text['message_device']."'); if (new_mac != null) { window.location='device_copy.php?id=".escape($device_uuid)."&mac=' + new_mac; }"]); } - echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>'submit_form()']); + if (permission_exists('device_delete') && $action == 'update') { + echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'action','value'=>'delete','onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]); + } + echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']); echo "
\n"; echo "
\n"; echo "\n"; @@ -849,7 +911,9 @@ echo " ".$text['label-shared_line']."\n"; } echo " ".$text['label-enabled']."\n"; - echo "  \n"; + if (is_array($device_lines) && @sizeof($device_lines) > 1 && permission_exists('device_line_delete')) { + echo " ".$text['label-delete']."\n"; + } echo " \n"; $x = 0; @@ -989,15 +1053,18 @@ echo " \n"; echo " \n"; - echo " \n"; - if (is_uuid($row['device_line_uuid'])) { - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; + if (is_array($device_lines) && @sizeof($device_lines) > 1 && permission_exists('device_line_delete')) { + echo " \n"; + if (is_uuid($row['device_line_uuid'])) { + echo " \n"; + echo " \n"; + } + echo " \n"; } - } - echo " \n"; - echo " \n"; - $x++; + + echo "\n"; + //increment counter + $x++; } echo " \n"; if (strlen($text['description-lines']) > 0) { @@ -1059,7 +1126,9 @@ } echo " ".$text['label-device_key_label']."\n"; echo " ".$text['label-device_key_icon']."\n"; - echo "  \n"; + if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { + echo " ".$text['label-delete']."\n"; + } echo " \n"; } @@ -1082,7 +1151,9 @@ } echo " ".$text['label-device_key_label']."\n"; echo " ".$text['label-device_key_icon']."\n"; - echo "  \n"; + if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { + echo " ".$text['label-delete']."\n"; + } echo " \n"; } //determine whether to hide the element @@ -1232,9 +1303,9 @@ else { $device_key_vendor = $device_vendor; } - ?> - - \n"; + echo "\n"; echo "\n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - if (is_uuid($row['device_key_uuid'])) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; + if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { + echo " \n"; + if (is_uuid($row['device_key_uuid'])) { + echo " \n"; + echo " \n"; } } echo " \n"; @@ -1324,7 +1393,9 @@ echo " ".$text['label-device_setting_value']."\n"; echo " ".$text['label-enabled']."\n"; echo " ".$text['label-device_setting_description']."\n"; - echo "  \n"; + if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete')) { + echo " ".$text['label-delete']."\n"; + } echo " \n"; $x = 0; @@ -1345,6 +1416,7 @@ //show alls rows in the array echo "\n"; + echo "\n"; echo " \n"; echo "\n"; @@ -1375,31 +1447,27 @@ echo " \n"; echo "\n"; - if (strlen($text['description-settings']) > 0) { - echo "
".$text['description-settings']."\n"; + if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete')) { + echo "\n"; + if (is_uuid($row['device_setting_uuid'])) { + echo " \n"; + echo " \n"; + } + echo "\n"; } - echo " "; - echo " \n"; - if (is_uuid($row['device_setting_uuid'])) { - if (permission_exists('device_edit')) { - echo " $v_link_label_edit\n"; - } - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; - } - } - echo " \n"; - echo " \n"; + echo "\n"; $x++; } - /* - echo " \n"; - echo " \n"; - */ - echo " \n"; - echo " \n"; - echo " \n"; + + echo "\n"; + + if (strlen($text['description-settings']) > 0) { + echo "
".$text['description-settings']."\n"; + } + + echo "\n"; + echo "\n"; } if (permission_exists('device_user')) { @@ -1607,4 +1675,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php index 4573edb858..bf63889f7a 100644 --- a/app/devices/resources/classes/device.php +++ b/app/devices/resources/classes/device.php @@ -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