diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index 8ff88ccdb9..e2639f611d 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -1,5 +1,5 @@ +$text['label-column_name']['en-us'] = "Column Name"; +$text['label-column_name']['ar-eg'] = ""; +$text['label-column_name']['de-at'] = ""; +$text['label-column_name']['de-ch'] = ""; +$text['label-column_name']['de-de'] = ""; +$text['label-column_name']['es-cl'] = ""; +$text['label-column_name']['es-mx'] = ""; +$text['label-column_name']['fr-ca'] = "Nom de colonne"; +$text['label-column_name']['fr-fr'] = "Nom de colonne"; +$text['label-column_name']['he-il'] = ""; +$text['label-column_name']['it-it'] = ""; +$text['label-column_name']['nl-nl'] = "Kolomnaam"; +$text['label-column_name']['pl-pl'] = ""; +$text['label-column_name']['pt-br'] = "Nome da Coluna"; +$text['label-column_name']['pt-pt'] = ""; +$text['label-column_name']['ro-ro'] = ""; +$text['label-column_name']['ru-ru'] = ""; +$text['label-column_name']['sv-se'] = ""; +$text['label-column_name']['uk-ua'] = ""; + +?> \ No newline at end of file diff --git a/app/devices/device_download.php b/app/devices/device_download.php index 989b782fba..f6662fcbbb 100644 --- a/app/devices/device_download.php +++ b/app/devices/device_download.php @@ -25,27 +25,26 @@ */ //includes - include "root.php"; + require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions - if (permission_exists('device_export')) { - //access granted - } - else { - echo "access denied"; - exit; - } + if (permission_exists('device_export')) { + //access granted + } + else { + echo "access denied"; + exit; + } //add multi-lingual support $language = new text; $text = $language->get(); //define the functions - function array2csv(array &$array) - { + function array2csv(array &$array) { if (count($array) == 0) { return null; } @@ -88,12 +87,22 @@ //get the devices and send them as output $column_group = $_REQUEST["column_group"]; if (is_array($column_group) && @sizeof($column_group) != 0) { + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: device_download.php'); + exit; + } + //validate columns foreach ($column_group as $index => $column_name) { if (!in_array($column_name, $allowed_columns)) { unset($column_group[$index]); } } + //iterate columns if (is_array($column_group) && @sizeof($column_group) != 0) { $column_names = implode(", ", $column_group); @@ -108,73 +117,59 @@ if (is_array($devices) && @sizeof($devices) != 0) { download_send_headers("data_export_".date("Y-m-d").".csv"); echo array2csv($devices); - exit(); + exit; } } unset($column_group); } -//set the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); -//begin the page content +//include the header $document['title'] = $text['title-device_export']; require_once "resources/header.php"; - echo "
\n"; - echo " \n"; +//show the content + echo "
\n"; + + echo "
\n"; + echo "
".$text['header-device_export']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'devices.php']); + echo button::create(['type'=>'submit','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'style'=>'margin-left: 15px;']); + echo "
\n"; + echo "
\n"; echo "
\n"; - echo "".$text['header-device_export']."\n"; - echo "

\n"; - - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo "
Column NameDescription
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; echo "\n"; - foreach ($allowed_columns as $column_name) { - echo "\n"; - echo " \n"; - echo " "; - echo " "; - echo ""; - if ($c==0) { $c=1; } else { $c=0; } + if (is_array($allowed_columns) && @sizeof($allowed_columns) != 0) { + $x = 0; + foreach ($allowed_columns as $column_name) { + echo "\n"; + echo " \n"; + echo " "; + echo " "; + echo ""; + $x++; + } } - echo " \n"; - echo " \n"; - echo " "; - - echo "
\n"; + echo " \n"; + echo " ".$text['label-column_name']."".$text['label-description']."
\n"; - echo " "; - echo " ".$column_name."
\n"; + echo " \n"; + echo " ".$column_name." 
\n"; - echo "
"; - echo " \n"; - echo "
"; - echo "

"; - echo "
"; - - //define the checkbox_toggle function - echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; //include the footer require_once "resources/footer.php"; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 1589bfcb44..608ceaccf0 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -533,51 +533,13 @@ //show the header require_once "resources/header.php"; -//javascript to change select to input and back again - ?> - - -\n"; echo " var fade_speed = 400;\n"; echo " function show_files() {\n"; echo " document.getElementById('file_action').value = 'files';\n"; - echo " $('#button_back_location').fadeOut(fade_speed);\n"; echo " $('#button_files').fadeOut(fade_speed, function() {\n"; - echo " $('#button_back').fadeIn(fade_speed);\n"; echo " $('#target_file').fadeIn(fade_speed);\n"; echo " $('#button_download').fadeIn(fade_speed);\n"; echo " });"; @@ -586,10 +548,6 @@ echo " document.getElementById('file_action').value = '';\n"; echo " $('#button_download').fadeOut(fade_speed);\n"; echo " $('#target_file').fadeOut(fade_speed);\n"; - echo " $('#button_back').fadeOut(fade_speed, function() {\n"; - echo " $('#button_files').fadeIn(fade_speed)\n"; - echo " $('#button_back_location').fadeIn(fade_speed);\n"; - echo " });"; echo " document.getElementById('target_file').selectedIndex = 0;\n"; echo " }\n"; @@ -733,17 +691,15 @@ //show the content echo "
\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - echo " ".$text['header-device'].""; - echo "\n"; - echo " \n"; + + echo "
\n"; + echo "
".$text['header-device']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'devices.php']); if (permission_exists("device_line_password") && $device_template == "grandstream/wave") { - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','onclick'=>"$('#qr_code_container').fadeIn(400);"]); } - echo "  \n"; + echo button::create(['type'=>'button','label'=>$text['button-provision'],'icon'=>'fax','link'=>PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".urlencode($sip_profile_name)."&user=".urlencode($user_id)."@".urlencode($server_address)."&domain=".urlencode($server_address)."&agent=".urlencode($device_vendor)]); if (permission_exists("device_files")) { //get the template directory $prov = new provision; @@ -751,9 +707,8 @@ $template_dir = $prov->template_dir; $files = glob($template_dir.'/'.$device_template.'/*'); //add file buttons and the file list - echo " "; - echo " "; - echo " \n"; echo " \n"; foreach ($files as $file) { //format the mac address and @@ -764,23 +719,19 @@ //add the select option echo " \n"; } - echo " \n"; - //echo " "; + echo " "; } if (permission_exists('device_add') && $action != "add") { - echo " \n"; + 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 " \n"; - echo "
\n"; - echo " ".$text['description-device']; - echo "

"; - echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>'submit_form()']); + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo $text['description-device']."\n"; + echo "

\n"; echo "\n"; echo "\n"; @@ -1619,8 +1570,6 @@ echo " \n"; } echo " \n"; - echo "
"; - echo " \n"; echo " \n"; echo " "; echo "
"; diff --git a/app/devices/device_imports.php b/app/devices/device_imports.php index 3b4b5b1327..72e93b8f23 100644 --- a/app/devices/device_imports.php +++ b/app/devices/device_imports.php @@ -43,7 +43,7 @@ $text = $language->get(); //built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher - if(!function_exists('str_getcsv')) { + if (!function_exists('str_getcsv')) { function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") { $fp = fopen("php://memory", 'r+'); fputs($fp, $input); @@ -95,7 +95,7 @@ $x = 0; include ("app/devices/app_config.php"); $i = 0; - foreach($apps[0]['db'] as $table) { + foreach ($apps[0]['db'] as $table) { //get the table name and parent name $table_name = $table["table"]['name']; $parent_name = $table["table"]['parent']; @@ -137,45 +137,37 @@ //match the column names to the field names if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { - //form to match the fields to the column names + //include header $document['title'] = $text['title-device_import']; require_once "resources/header.php"; - echo "\n"; + //form to match the fields to the column names + echo "\n"; + + echo "
\n"; + echo "
".$text['header-import']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'device_imports.php']); + echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import']]); + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['description-import']."\n"; + echo "

\n"; + echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - //echo "\n"; - //echo "\n"; - //echo "\n"; - //echo "\n"; - //loop through user columns $x = 0; foreach ($line_fields as $line_field) { $line_field = trim(trim($line_field), $enclosure); echo "\n"; - echo "\n"; - echo "\n"; echo " \n"; echo "
\n"; - echo " ".$text['header-import']."
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['description-import']."\n"; - echo "
".$text['header-import']."\n"; - //echo " \n"; - //echo "
\n"; + echo "\n"; //echo " ".$text['label-zzz']."\n"; echo $line_field; echo "\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; - echo " \n"; echo "
\n"; + + echo " \n"; + echo "\n"; + require_once "resources/footer.php"; //normalize the column names @@ -238,6 +233,14 @@ //upload the csv if (file_exists($_SESSION['file']) && $action == 'import') { + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: users.php'); + exit; + } + //form to match the fields to the column names //$document['title'] = $text['title-device_import']; //require_once "resources/header.php"; @@ -354,34 +357,36 @@ } } +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + //include the header $document['title'] = $text['title-device_import']; require_once "resources/header.php"; -//begin the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['header-device_import']."
\n"; - echo " ".$text['description-import']."\n"; - echo "
\n"; - echo " \n"; - //echo " \n"; - echo "
"; +//show content + echo "
\n"; - echo "
\n"; + echo "
\n"; + echo "
".$text['header-device_import']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'devices.php']); + echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload']]); + echo "
\n"; + echo "
\n"; + echo "
\n"; - echo "\n"; - echo " \n"; + echo $text['description-import']."\n"; + echo "

\n"; + + echo "
\n"; echo "\n"; - echo "\n"; - echo "\n"; echo " \n"; echo " \n"; echo "
\n"; + echo "\n"; echo " ".$text['label-import_data']."\n"; echo "\n"; + echo "\n"; echo " \n"; echo "
\n"; echo $text['description-import_data']."\n"; @@ -450,8 +455,7 @@ echo "
\n"; echo " \n"; - echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; @@ -461,4 +465,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index 094e9fdf11..7edf14b7a6 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -314,27 +314,27 @@ //show the content echo "\n"; + + echo "
\n"; + echo "
".$text['title-device_profile']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'device_profiles.php']); + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'link'=>'device_profile_copy.php?id='.urlencode($device_profile_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { 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"; + + echo $text['description-device_profiles']."\n"; + echo "

\n"; + echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } @@ -383,11 +383,11 @@ //set the column names if ($previous_profile_key_vendor != $row['profile_key_vendor']) { echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; if (permission_exists('device_key_extension')) { echo " \n"; @@ -633,7 +633,7 @@ echo " \n"; echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; $x = 0; foreach($device_profile_settings as $row) { @@ -736,7 +736,6 @@ echo " \n"; echo " "; echo "
".$text['title-device_profile']."

\n"; - echo " "; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['description-device_profiles']."

\n"; - echo "
\n"; + echo "\n"; echo " ".$text['label-device_profile_name']."\n"; echo "\n"; + echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_profile_name']."\n"; @@ -363,7 +363,7 @@ } echo "
".$text['label-device_key_label']."".$text['label-device_key_icon']."
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_vendor']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_category']."\n"; + echo " ".$text['label-device_key_id']."\n"; + echo " ".$text['label-device_vendor']."\n"; + echo " ".$text['label-device_key_type']."\n"; + echo " ".$text['label-device_key_line']."\n"; echo " ".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']."
\n"; echo " \n"; echo " \n"; - echo " \n"; echo "
"; diff --git a/app/devices/device_vendor_edit.php b/app/devices/device_vendor_edit.php index 1e5a24a72f..ee57061d50 100644 --- a/app/devices/device_vendor_edit.php +++ b/app/devices/device_vendor_edit.php @@ -146,21 +146,24 @@ require_once "resources/header.php"; //show the content + echo "
\n"; + echo "
".$text['title-device_vendor']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'device_vendors.php']); + echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>"document.getElementById('frm').submit();"]); + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; echo " "; echo "
".$text['title-device_vendor']."

\n"; - echo " "; - echo " "; - echo "
\n"; + echo "\n"; echo " ".$text['label-name']."\n"; echo "\n"; + echo "\n"; echo " \n"; echo "
\n"; echo $text['description-name']."\n"; @@ -197,7 +200,6 @@ echo " \n"; } echo " \n"; - echo " \n"; echo "
"; diff --git a/app/devices/device_vendor_function_edit.php b/app/devices/device_vendor_function_edit.php index ae7813513e..0e8a490810 100644 --- a/app/devices/device_vendor_function_edit.php +++ b/app/devices/device_vendor_function_edit.php @@ -250,7 +250,7 @@ $parameters['group_uuid_'.$index] = $group_uuid; } if (is_array($sql_where) && @sizeof($sql_where) != 0) { - $sql .= implode(' and ', $sql_where); + $sql .= implode(' and ', $sql_where).' '; } } $sql .= "order by domain_uuid desc, group_name asc "; @@ -263,35 +263,28 @@ $token = $object->create($_SERVER['PHP_SELF']); //show the header + $document['title'] = $text['title-device_vendor_function']; require_once "resources/header.php"; //show the content echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - //echo "\n"; - //echo "\n"; - //echo "\n"; - //echo "\n"; + echo "
\n"; + echo "
".$text['title-device_vendor_function']."
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'device_vendor_edit.php?id='.urlencode($device_vendor_uuid)]); + 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"; + + echo "
".$text['title-device_vendor_function']."

\n"; - echo " "; - echo " "; - echo "
\n"; - //echo " ".$text['label-label']."\n"; - //echo "\n"; - //echo " \n"; - //echo "
\n"; - //echo $text['description-label']."\n"; - //echo "
\n"; echo "\n"; - echo "\n"; - echo "
\n"; + echo "\n"; echo " ".$text['label-name']."\n"; echo "\n"; + echo "\n"; echo " \n"; echo "
\n"; echo $text['description-name']."\n"; @@ -314,7 +307,7 @@ echo "
"; if (is_array($function_groups) && @sizeof($function_groups) != 0) { echo "\n"; - foreach($function_groups as $field) { + foreach ($function_groups as $field) { if (strlen($field['group_name']) > 0) { echo "\n"; echo " \n"; echo " "; echo "
"; @@ -334,7 +327,7 @@ echo "
\n"; echo "\n"; } echo " \n"; - echo " \n"; echo "
"; @@ -399,4 +391,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/devices/device_vendor_functions.php b/app/devices/device_vendor_functions.php index e58a980bff..225e8379ef 100644 --- a/app/devices/device_vendor_functions.php +++ b/app/devices/device_vendor_functions.php @@ -27,9 +27,10 @@ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; + require_once "resources/paging.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('device_vendor_function_view')) { //access granted } @@ -42,6 +43,36 @@ $language = new text; $text = $language->get(); +//get the http post data + if (is_array($_POST['vendor_functions'])) { + $action = $_POST['action']; + $device_vendor_uuid = $_POST['device_vendor_uuid']; + $vendor_functions = $_POST['vendor_functions']; + } + +//process the http post data by action + if ($action != '' && is_array($vendor_functions) && @sizeof($vendor_functions) != 0) { + switch ($action) { + case 'toggle': + if (permission_exists('device_vendor_function_edit')) { + $obj = new device; + $obj->device_vendor_uuid = $device_vendor_uuid; + $obj->toggle_vendor_functions($vendor_functions); + } + break; + case 'delete': + if (permission_exists('device_vendor_function_delete')) { + $obj = new device; + $obj->device_vendor_uuid = $device_vendor_uuid; + $obj->delete_vendor_functions($vendor_functions); + } + break; + } + + header('Location: device_vendor_edit.php?id='.urlencode($device_vendor_uuid)); + exit; + } + //get variables used to control the order $order_by = $_GET["order_by"]; $order = $_GET["order"]; @@ -59,10 +90,6 @@ $parameters['search'] = '%'.$search.'%'; } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - //prepare to page the results $sql = "select count(*) from v_device_vendor_functions "; $sql .= "where device_vendor_uuid = :device_vendor_uuid "; @@ -77,7 +104,8 @@ if (isset($_GET['page'])) { $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; } @@ -89,45 +117,54 @@ $vendor_functions = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create('/app/devices/device_vendor_functions.php'); //show the content - echo "\n"; - echo " \n"; - echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - echo "
".$text['title-device_vendor_functions']."\n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; + echo "
\n"; + echo "
".$text['title-device_vendor_functions']." (".$num_rows.")
\n"; + echo "
\n"; + if (permission_exists('device_vendor_function_add')) { + echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'device_vendor_function_edit.php?device_vendor_uuid='.urlencode($_GET['id'])]); + } + if (permission_exists('device_vendor_function_edit') && $vendor_functions) { + echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); + } + if (permission_exists('device_vendor_function_delete') && $vendor_functions) { + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); + } + if ($paging_controls_mini != '') { + echo "".$paging_controls_mini."\n"; + } + echo "
\n"; + echo "
\n"; + echo "
\n"; - echo "\n"; - echo "\n"; - //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
".$text['label-label']."
\n"; + echo "\n"; + if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit') || permission_exists('device_vendor_function_delete')) { + echo " \n"; + } echo th_order_by('name', $text['label-name'], $order_by, $order); echo th_order_by('value', $text['label-value'], $order_by, $order); - echo "\n"; - echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); - echo th_order_by('description', $text['label-description'], $order_by, $order); - echo "\n"; + echo th_order_by('enabled', $text['label-enabled'], $order_by, $order, null, "class='center'"); + echo th_order_by('description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'"); + if (permission_exists('device_vendor_function_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; } - else { - echo " \n"; - } - echo "\n"; - echo "\n"; + echo "\n"; if (is_array($vendor_functions) && @sizeof($vendor_functions) != 0) { - foreach($vendor_functions as $row) { - + $x = 0; + foreach ($vendor_functions as $row) { //get the groups that have been assigned to the vendor functions $sql = "select "; $sql .= "fg.*, g.domain_uuid as group_domain_uuid "; @@ -152,55 +189,52 @@ } $group_list = isset($group_list) ? implode(', ', $group_list) : ''; unset ($vendor_function_groups); - //build the edit link - if (permission_exists('device_vendor_function_edit')) { - $tr_link = "href='device_vendor_function_edit.php?device_vendor_uuid=".escape($row['device_vendor_uuid'])."&id=".escape($row['device_vendor_function_uuid'])."'"; - } //show the row of data - echo "\n"; - //echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit') || permission_exists('device_vendor_function_delete')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_vendor_function_edit')) { + echo " \n"; + echo " \n"; + if (permission_exists('device_vendor_function_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } echo "\n"; - //toggle the value of the c variable - if ($c==0) { $c=1; } else { $c=0; } + $x++; } - unset($vendor_functions, $row); + unset($vendor_functions); } - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; + echo " \n"; + echo " ".$text['label-groups'].""; - if (permission_exists('device_vendor_function_add')) { - echo "$v_link_label_add"; + echo "".$text['label-groups']." 
".$text['label-'.escape($row['name'])]." ".escape($row['name'])."  ".escape($row['value'])." ".escape($group_list)." ".escape($row['enabled'])." ".escape($row['description'])." "; if (permission_exists('device_vendor_function_edit')) { - echo "$v_link_label_edit"; + $list_row_url = "device_vendor_function_edit.php?device_vendor_uuid=".urlencode($row['device_vendor_uuid'])."&id=".urlencode($row['device_vendor_function_uuid']); } - if (permission_exists('device_vendor_function_delete')) { - echo "$v_link_label_delete"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_vendor_function_edit')) { + echo " ".escape($row['name'])."\n"; + } + else { + echo " ".escape($row['name']); } echo " ".escape($row['value'])." ".escape($group_list)." \n"; + echo $text['label-'.$row['enabled']]; + } + echo " ".escape($row['description'])."\n"; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('device_vendor_function_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; + echo "
\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; + echo "\n"; + echo "\n"; -//include 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 9e40a04eaf..84cb04a6c4 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_vendor_uuid; /** * declare private variables @@ -413,6 +414,67 @@ include "root.php"; } } + public function delete_vendor_functions($records) { + + //assign private variables + $this->permission_prefix = 'device_vendor_function_'; + $this->list_page = 'device_vendor_edit.php'; + $this->tables[] = 'device_vendor_functions'; + $this->tables[] = 'device_vendor_function_groups'; + $this->uuid_prefix = 'device_vendor_function_'; + + 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('/app/devices/device_vendor_functions.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page.'?id='.$this->device_vendor_uuid); + exit; + } + + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + + //build the delete array + foreach ($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + foreach ($this->tables as $table) { + $array[$table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; + } + } + } + + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + + //grant temporary permissions + $p = new permissions; + $p->add('device_vendor_function_group_delete', 'temp'); + + //execute delete + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->delete($array); + unset($array); + + //revoke temporary permissions + $p->delete('device_vendor_function_group_delete', 'temp'); + + //set message + message::add($text['message-delete']); + + } + unset($records); + } + } + } + public function delete_profiles($records) { //assign private variables @@ -635,6 +697,79 @@ include "root.php"; } } + public function toggle_vendor_functions($records) { + + //assign private variables + $this->permission_prefix = 'device_vendor_function_'; + $this->list_page = 'device_vendor_edit.php'; + $this->table = 'device_vendor_functions'; + $this->uuid_prefix = 'device_vendor_function_'; + $this->toggle_field = 'enabled'; + $this->toggle_values = ['true','false']; + + if (permission_exists($this->permission_prefix.'edit')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate('/app/devices/device_vendor_functions.php')) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page.'?id='.$this->device_vendor_uuid); + exit; + } + + //toggle the checked records + if (is_array($records) && @sizeof($records) != 0) { + + //get current toggle state + foreach($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + $uuids[] = "'".$record['uuid']."'"; + } + } + if (is_array($uuids) && @sizeof($uuids) != 0) { + $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { + $states[$row['uuid']] = $row['toggle']; + } + } + unset($sql, $parameters, $rows, $row); + } + + //build update array + $x = 0; + foreach($states as $uuid => $state) { + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; + $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; + $x++; + } + + //save the changes + if (is_array($array) && @sizeof($array) != 0) { + + //save the array + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->save($array); + unset($array); + + //set message + message::add($text['message-toggle']); + } + unset($records, $states); + } + + } + } + public function toggle_profiles($records) { //assign private variables