Devices: List view and button updates, other fixes.

This commit is contained in:
Nate 2020-01-08 13:28:01 -07:00
parent ab5ac47f76
commit 36334d003c
9 changed files with 491 additions and 321 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
#This file was last reorganized on 27th of September 2017 01:41:51 PM UTC #This file was last reorgantitle-device_vendor_functionized on 27th of September 2017 01:41:51 PM UTC
$text['title-devices']['en-us'] = "Devices"; $text['title-devices']['en-us'] = "Devices";
$text['title-devices']['ar-eg'] = "الأجهزة"; $text['title-devices']['ar-eg'] = "الأجهزة";
@ -5290,6 +5290,46 @@ $text['title-device_vendor']['ru-ru'] = "Производитель";
$text['title-device_vendor']['sv-se'] = "Tillverkare"; $text['title-device_vendor']['sv-se'] = "Tillverkare";
$text['title-device_vendor']['uk-ua'] = ""; $text['title-device_vendor']['uk-ua'] = "";
$text['title-device_vendor_functions']['en-us'] = "Vendor Functions";
$text['title-device_vendor_functions']['ar-eg'] = "Vendor Functions";
$text['title-device_vendor_functions']['de-at'] = "Vendor Functions";
$text['title-device_vendor_functions']['de-ch'] = "Vendor Functions";
$text['title-device_vendor_functions']['de-de'] = "Vendor Functions";
$text['title-device_vendor_functions']['es-cl'] = "Vendor Functions";
$text['title-device_vendor_functions']['es-mx'] = "Vendor Functions";
$text['title-device_vendor_functions']['fr-ca'] = "Vendor Functions";
$text['title-device_vendor_functions']['fr-fr'] = "Vendor Functions";
$text['title-device_vendor_functions']['he-il'] = "Vendor Functions";
$text['title-device_vendor_functions']['it-it'] = "Vendor Functions";
$text['title-device_vendor_functions']['nl-nl'] = "Vendor Functions";
$text['title-device_vendor_functions']['pl-pl'] = "Vendor Functions";
$text['title-device_vendor_functions']['pt-br'] = "Vendor Functions";
$text['title-device_vendor_functions']['pt-pt'] = "Vendor Functions";
$text['title-device_vendor_functions']['ro-ro'] = "Vendor Functions";
$text['title-device_vendor_functions']['ru-ru'] = "Vendor Functions";
$text['title-device_vendor_functions']['sv-se'] = "Vendor Functions";
$text['title-device_vendor_functions']['uk-ua'] = "Vendor Functions";
$text['title-device_vendor_function']['en-us'] = "Vendor Function";
$text['title-device_vendor_function']['ar-eg'] = "Vendor Function";
$text['title-device_vendor_function']['de-at'] = "Vendor Function";
$text['title-device_vendor_function']['de-ch'] = "Vendor Function";
$text['title-device_vendor_function']['de-de'] = "Vendor Function";
$text['title-device_vendor_function']['es-cl'] = "Vendor Function";
$text['title-device_vendor_function']['es-mx'] = "Vendor Function";
$text['title-device_vendor_function']['fr-ca'] = "Vendor Function";
$text['title-device_vendor_function']['fr-fr'] = "Vendor Function";
$text['title-device_vendor_function']['he-il'] = "Vendor Function";
$text['title-device_vendor_function']['it-it'] = "Vendor Function";
$text['title-device_vendor_function']['nl-nl'] = "Vendor Function";
$text['title-device_vendor_function']['pl-pl'] = "Vendor Function";
$text['title-device_vendor_function']['pt-br'] = "Vendor Function";
$text['title-device_vendor_function']['pt-pt'] = "Vendor Function";
$text['title-device_vendor_function']['ro-ro'] = "Vendor Function";
$text['title-device_vendor_function']['ru-ru'] = "Vendor Function";
$text['title-device_vendor_function']['sv-se'] = "Vendor Function";
$text['title-device_vendor_function']['uk-ua'] = "Vendor Function";
$text['description-device_vendor']['en-us'] = "Defines the list of vendors used with provisioning devices."; $text['description-device_vendor']['en-us'] = "Defines the list of vendors used with provisioning devices.";
$text['description-device_vendor']['ar-eg'] = ""; $text['description-device_vendor']['ar-eg'] = "";
$text['description-device_vendor']['de-at'] = "Definiert die Liste der Hersteller welche für die Bereitstellung der Geräte verwendet wird."; //copied from de-de $text['description-device_vendor']['de-at'] = "Definiert die Liste der Hersteller welche für die Bereitstellung der Geräte verwendet wird."; //copied from de-de
@ -5330,4 +5370,24 @@ $text['button-vendors']['ru-ru'] = "Производители";
$text['button-vendors']['sv-se'] = "Tillverkare"; $text['button-vendors']['sv-se'] = "Tillverkare";
$text['button-vendors']['uk-ua'] = ""; $text['button-vendors']['uk-ua'] = "";
$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'] = "";
?> ?>

View File

@ -25,7 +25,7 @@
*/ */
//includes //includes
include "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
@ -44,8 +44,7 @@
$text = $language->get(); $text = $language->get();
//define the functions //define the functions
function array2csv(array &$array) function array2csv(array &$array) {
{
if (count($array) == 0) { if (count($array) == 0) {
return null; return null;
} }
@ -88,12 +87,22 @@
//get the devices and send them as output //get the devices and send them as output
$column_group = $_REQUEST["column_group"]; $column_group = $_REQUEST["column_group"];
if (is_array($column_group) && @sizeof($column_group) != 0) { 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 //validate columns
foreach ($column_group as $index => $column_name) { foreach ($column_group as $index => $column_name) {
if (!in_array($column_name, $allowed_columns)) { if (!in_array($column_name, $allowed_columns)) {
unset($column_group[$index]); unset($column_group[$index]);
} }
} }
//iterate columns //iterate columns
if (is_array($column_group) && @sizeof($column_group) != 0) { if (is_array($column_group) && @sizeof($column_group) != 0) {
$column_names = implode(", ", $column_group); $column_names = implode(", ", $column_group);
@ -108,73 +117,59 @@
if (is_array($devices) && @sizeof($devices) != 0) { if (is_array($devices) && @sizeof($devices) != 0) {
download_send_headers("data_export_".date("Y-m-d").".csv"); download_send_headers("data_export_".date("Y-m-d").".csv");
echo array2csv($devices); echo array2csv($devices);
exit(); exit;
} }
} }
unset($column_group); unset($column_group);
} }
//set the row style //create token
$c = 0; $object = new token;
$row_style["0"] = "row_style0"; $token = $object->create($_SERVER['PHP_SELF']);
$row_style["1"] = "row_style1";
//begin the page content //include the header
$document['title'] = $text['title-device_export']; $document['title'] = $text['title-device_export'];
require_once "resources/header.php"; require_once "resources/header.php";
echo "<div style='float: right;'>\n"; //show the content
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n"; echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar sub'>\n";
echo " <div class='heading'><b>".$text['header-device_export']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
echo "<b>".$text['header-device_export']."</b>\n"; echo "<table class='list'>\n";
echo "<br /><br />\n"; echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo "<form method='post' name='frm' action='device_download.php' autocomplete='off'>\n"; echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($allowed_columns ?: "style='visibility: hidden;'").">\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo " </th>\n";
echo " <th><input type=\"checkbox\" id=\"selectall\" onclick=\"checkbox_toggle();\"/></th>\n"; echo " <th>".$text['label-column_name']."</th>\n";
echo " <th>Column Name</th>\n"; echo " <th>".$text['label-description']."</th>\n";
echo " <th>Description</th>\n";
echo "</tr>\n"; echo "</tr>\n";
if (is_array($allowed_columns) && @sizeof($allowed_columns) != 0) {
$x = 0;
foreach ($allowed_columns as $column_name) { foreach ($allowed_columns as $column_name) {
echo "<tr>\n"; echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td width = '20px' valign='top' class='".$row_style[$c]."'>\n"; echo " <td class='checkbox'>\n";
echo " <input class=\"checkbox1\" type=\"checkbox\" name=\"column_group[]\" value=\"".$column_name."\"/>"; echo " <input type='checkbox' name='column_group[]' id='checkbox_".$x."' value=\"".$column_name."\" onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " </td>\n"; echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$column_name."</td>"; echo " <td>".$column_name."</td>";
echo " <td valign='top' class='".$row_style[$c]."'></td>"; echo " <td class='description overflow hide-sm-dn'>&nbsp;</td>";
echo "</tr>"; echo "</tr>";
if ($c==0) { $c=1; } else { $c=0; } $x++;
}
} }
echo " <tr>\n"; echo "</table>\n";
echo " <td colspan='3' align='right'>\n"; echo "<br />\n";
echo " <br>"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' class='btn' value='".$text['button-export']."'>\n"; echo "</form>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
//define the checkbox_toggle function
echo "<script type=\"text/javascript\">\n";
echo " function checkbox_toggle(item) {\n";
echo " var inputs = document.getElementsByTagName(\"input\");\n";
echo " for (var i = 0, max = inputs.length; i < max; i++) {\n";
echo " if (inputs[i].type === 'checkbox') {\n";
echo " if (document.getElementById('selectall').checked == true) {\n";
echo " inputs[i].checked = true;\n";
echo " }\n";
echo " else {\n";
echo " inputs[i].checked = false;\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";

View File

@ -533,51 +533,13 @@
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//javascript to change select to input and back again
?>
<script language="javascript">
var objs;
function change_to_input(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
//tb.setAttribute('id', 'ivr_menu_option_param');
tb.setAttribute('style', 'width:175px;');
tb.value=obj.options[obj.selectedIndex].value;
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ replace_param(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
replace_param(this.objs);
}
function replace_param(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
}
</script>
<?php
//select file download javascript //select file download javascript
if (permission_exists("device_files")) { if (permission_exists("device_files")) {
echo "<script language='javascript' type='text/javascript'>\n"; echo "<script language='javascript' type='text/javascript'>\n";
echo " var fade_speed = 400;\n"; echo " var fade_speed = 400;\n";
echo " function show_files() {\n"; echo " function show_files() {\n";
echo " document.getElementById('file_action').value = '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_files').fadeOut(fade_speed, function() {\n";
echo " $('#button_back').fadeIn(fade_speed);\n";
echo " $('#target_file').fadeIn(fade_speed);\n"; echo " $('#target_file').fadeIn(fade_speed);\n";
echo " $('#button_download').fadeIn(fade_speed);\n"; echo " $('#button_download').fadeIn(fade_speed);\n";
echo " });"; echo " });";
@ -586,10 +548,6 @@
echo " document.getElementById('file_action').value = '';\n"; echo " document.getElementById('file_action').value = '';\n";
echo " $('#button_download').fadeOut(fade_speed);\n"; echo " $('#button_download').fadeOut(fade_speed);\n";
echo " $('#target_file').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 " document.getElementById('target_file').selectedIndex = 0;\n";
echo " }\n"; echo " }\n";
@ -733,17 +691,15 @@
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input type='hidden' name='file_action' id='file_action' value='' />\n"; echo "<input type='hidden' name='file_action' id='file_action' value='' />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo "<td align='left' nowrap='nowrap' valign='top'>"; echo " <div class='heading'><b>".$text['header-device']."</b></div>\n";
echo " <b>".$text['header-device']."</b>"; echo " <div class='actions'>\n";
echo "</td>\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'devices.php']);
echo "<td align='right' valign='top'>\n";
echo " <input type='button' class='btn' id='button_back_location' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'/>\n";
if (permission_exists("device_line_password") && $device_template == "grandstream/wave") { if (permission_exists("device_line_password") && $device_template == "grandstream/wave") {
echo " <input type='button' class='btn' name='' alt='".$text['button-qr_code']."' onclick=\"$('#qr_code_container').fadeIn(400);\" value='".$text['button-qr_code']."'>\n"; echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
} }
echo " <input type='button' class='btn' value='".$text['button-provision']."' onclick=\"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".escape($sip_profile_name)."&user=".escape($user_id)."@".escape($server_address)."&domain=".$server_address."&agent=".escape($device_vendor)."';\">&nbsp;\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")) { if (permission_exists("device_files")) {
//get the template directory //get the template directory
$prov = new provision; $prov = new provision;
@ -751,8 +707,7 @@
$template_dir = $prov->template_dir; $template_dir = $prov->template_dir;
$files = glob($template_dir.'/'.$device_template.'/*'); $files = glob($template_dir.'/'.$device_template.'/*');
//add file buttons and the file list //add file buttons and the file list
echo " <input type='button' class='btn' id='button_files' name='' alt='".$text['button-files']."' onclick='show_files();' value='".$text['button-files']."'/>"; echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$_SESSION['theme']['button_icon_download'],'onclick'=>'show_files()']);
echo " <input type='button' class='btn' style='display: none;' id='button_back' name='' alt='".$text['button-back']."' onclick='hide_files();' value='".$text['button-back']."'/> ";
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n"; echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
echo " <option value=''>".$text['label-download']."</option>\n"; echo " <option value=''>".$text['label-download']."</option>\n";
foreach ($files as $file) { foreach ($files as $file) {
@ -764,23 +719,19 @@
//add the select option //add the select option
echo " <option value='".basename($file)."'>".$file_name."</option>\n"; echo " <option value='".basename($file)."'>".$file_name."</option>\n";
} }
echo " </select>\n"; echo " </select>";
//echo " <input type='button' class='btn' id='button_download' style='display: none;' alt='".$text['button-download']."' value='".$text['button-download']."' onclick='document.forms.frm.submit();'>";
} }
if (permission_exists('device_add') && $action != "add") { if (permission_exists('device_add') && $action != "add") {
echo " <input type='button' class='btn' name='' alt='".$text['button-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; }\" value='".$text['button-copy']."'/>\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 " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'/>\n"; echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>'submit_form()']);
echo "</td>\n"; echo " </div>\n";
echo "</tr>\n"; echo " <div style='clear: both;'></div>\n";
echo "<tr>\n"; echo "</div>\n";
echo "<td colspan='2'>\n";
echo " ".$text['description-device']; echo $text['description-device']."\n";
echo " <br><br>"; echo "<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
@ -1619,8 +1570,6 @@
echo " <input type='hidden' name='device_uuid' value='".escape($device_uuid)."'/>\n"; echo " <input type='hidden' name='device_uuid' value='".escape($device_uuid)."'/>\n";
} }
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <br>";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'/>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";

View File

@ -137,45 +137,37 @@
//match the column names to the field names //match the column names to the field names
if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { 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']; $document['title'] = $text['title-device_import'];
require_once "resources/header.php"; require_once "resources/header.php";
echo "<form action='device_imports.php' method='POST' enctype='multipart/form-data' name='frmUpload' onSubmit=''>\n"; //form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-import']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
echo " <b>".$text['header-import']."</b><br />\n";
echo " </td>\n";
echo " <td valign='top' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
echo " <input name='submit' type='submit' class='btn' id='import' value=\"".$text['button-import']."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='left'>\n";
echo " ".$text['description-import']."\n";
echo " </td>\n";
echo " </tr>\n";
//echo "<tr>\n";
//echo "<td align='left' width='30%' nowrap='nowrap'><b>".$text['header-import']."</b></td>\n";
//echo "<td width='70%' align='right'>\n";
//echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
//echo "</td>\n";
//echo "</tr>\n";
//loop through user columns //loop through user columns
$x = 0; $x = 0;
foreach ($line_fields as $line_field) { foreach ($line_fields as $line_field) {
$line_field = trim(trim($line_field), $enclosure); $line_field = trim(trim($line_field), $enclosure);
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n"; //echo " ".$text['label-zzz']."\n";
echo $line_field; echo $line_field;
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]'>\n"; echo " <select class='formfld' style='' name='fields[$x]'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach($schema as $row) { foreach($schema as $row) {
@ -205,12 +197,15 @@
echo " <input name='from_row' type='hidden' value='$from_row'>\n"; echo " <input name='from_row' type='hidden' value='$from_row'>\n";
echo " <input name='data_delimiter' type='hidden' value='$delimiter'>\n"; echo " <input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo " <input name='data_enclosure' type='hidden' value='$enclosure'>\n"; echo " <input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo " <input type='submit' class='btn' id='import' value=\"".$text['button-import']."\">\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
//normalize the column names //normalize the column names
@ -238,6 +233,14 @@
//upload the csv //upload the csv
if (file_exists($_SESSION['file']) && $action == 'import') { 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 //form to match the fields to the column names
//$document['title'] = $text['title-device_import']; //$document['title'] = $text['title-device_import'];
//require_once "resources/header.php"; //require_once "resources/header.php";
@ -354,34 +357,36 @@
} }
} }
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header //include the header
$document['title'] = $text['title-device_import']; $document['title'] = $text['title-device_import'];
require_once "resources/header.php"; require_once "resources/header.php";
//begin the content //show content
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo " <tr>\n";
echo " <td valign='top' align='left' width='30%' nowrap='nowrap'>\n";
echo " <b>".$text['header-device_import']."</b><br />\n";
echo " ".$text['description-import']."\n";
echo " </td>\n";
echo " <td valign='top' width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
//echo " <input name='submit' type='submit' class='btn' id='import' value=\"".$text['button-import']."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
echo "<br />\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-device_import']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-import']."\n";
echo "<br /><br />\n";
echo "<form action='' method='POST' enctype='multipart/form-data' name='frmUpload' onSubmit=''>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n"; echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n"; echo " ".$text['label-import_data']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' rows='7' class='formfld' style='width: 100%;' wrap='off'>$data</textarea>\n"; echo " <textarea name='data' id='data' rows='7' class='formfld' style='width: 100%;' wrap='off'>$data</textarea>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-import_data']."\n"; echo $text['description-import_data']."\n";
@ -450,8 +455,7 @@
echo " </td>\n"; echo " </td>\n";
echo " <td valign='bottom' align='right' nowrap>\n"; echo " <td valign='bottom' align='right' nowrap>\n";
echo " <input name='type' type='hidden' value='csv'>\n"; echo " <input name='type' type='hidden' value='csv'>\n";
echo " <br />\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input name='submit' type='submit' class='btn' id='import' value=\"".$text['button-import']."\">\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";

View File

@ -314,27 +314,27 @@
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-device_profile']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-device_profiles']."\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_profile']."</b><br><br></td>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_profiles.php'\" value='".$text['button-back']."'>";
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"window.location='device_profile_copy.php?id=".urlencode($device_profile_uuid)."'\" value='".$text['button-copy']."'>";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan='2'>\n";
echo " ".$text['description-device_profiles']."<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_profile_name']."\n"; echo " ".$text['label-device_profile_name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "<td width='70%' class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='device_profile_name' maxlength='255' value='".escape($device_profile_name)."'>\n"; echo " <input class='formfld' type='text' name='device_profile_name' maxlength='255' value='".escape($device_profile_name)."'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-device_profile_name']."\n"; echo $text['description-device_profile_name']."\n";
@ -363,7 +363,7 @@
} }
echo " <td class='vtable'>".$text['label-device_key_label']."</td>\n"; echo " <td class='vtable'>".$text['label-device_key_label']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_icon']."</td>\n"; echo " <td class='vtable'>".$text['label-device_key_icon']."</td>\n";
echo " <td class='vtable'></td>\n"; echo " <td></td>\n";
echo " </tr>\n"; echo " </tr>\n";
} }
@ -383,11 +383,11 @@
//set the column names //set the column names
if ($previous_profile_key_vendor != $row['profile_key_vendor']) { if ($previous_profile_key_vendor != $row['profile_key_vendor']) {
echo " <tr>\n"; echo " <tr>\n";
echo " <td class='vtablereq'>".$text['label-device_key_category']."</td>\n"; echo " <th class='vtablereq'>".$text['label-device_key_category']."</td>\n";
echo " <td class='vtablereq'>".$text['label-device_key_id']."</td>\n"; echo " <th class='vtablereq'>".$text['label-device_key_id']."</td>\n";
echo " <td class='vtablereq'>".$text['label-device_vendor']."</td>\n"; echo " <th class='vtablereq'>".$text['label-device_vendor']."</td>\n";
echo " <td class='vtablereq'>".$text['label-device_key_type']."</td>\n"; echo " <th class='vtablereq'>".$text['label-device_key_type']."</td>\n";
echo " <td class='vtablereq'>".$text['label-device_key_line']."</td>\n"; echo " <th class='vtablereq'>".$text['label-device_key_line']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_value']."</td>\n"; echo " <td class='vtable'>".$text['label-device_key_value']."</td>\n";
if (permission_exists('device_key_extension')) { if (permission_exists('device_key_extension')) {
echo " <td class='vtable'>".$text['label-device_key_extension']."</td>\n"; echo " <td class='vtable'>".$text['label-device_key_extension']."</td>\n";
@ -633,7 +633,7 @@
echo " <td class='vtable'>".$text['label-device_setting_value']."</td>\n"; echo " <td class='vtable'>".$text['label-device_setting_value']."</td>\n";
echo " <th class='vtablereq'>".$text['label-enabled']."</th>\n"; echo " <th class='vtablereq'>".$text['label-enabled']."</th>\n";
echo " <td class='vtable'>".$text['label-device_setting_description']."</td>\n"; echo " <td class='vtable'>".$text['label-device_setting_description']."</td>\n";
echo " <td class='vtable'></td>\n"; echo " <td></td>\n";
echo " </tr>\n"; echo " </tr>\n";
$x = 0; $x = 0;
foreach($device_profile_settings as $row) { foreach($device_profile_settings as $row) {
@ -736,7 +736,6 @@
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='device_profile_uuid' value='".escape($device_profile_uuid)."'>\n"; echo " <input type='hidden' name='device_profile_uuid' value='".escape($device_profile_uuid)."'>\n";
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";

View File

@ -146,21 +146,24 @@
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-device_vendor']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendors.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"".escape($name)."\">\n"; echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"".escape($name)."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-name']."\n"; echo $text['description-name']."\n";
@ -197,7 +200,6 @@
echo " <input type='hidden' name='device_vendor_uuid' value='".escape($device_vendor_uuid)."'>\n"; echo " <input type='hidden' name='device_vendor_uuid' value='".escape($device_vendor_uuid)."'>\n";
} }
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";

View File

@ -250,7 +250,7 @@
$parameters['group_uuid_'.$index] = $group_uuid; $parameters['group_uuid_'.$index] = $group_uuid;
} }
if (is_array($sql_where) && @sizeof($sql_where) != 0) { 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 "; $sql .= "order by domain_uuid desc, group_name asc ";
@ -263,35 +263,28 @@
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
$document['title'] = $text['title-device_vendor_function'];
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-device_vendor_function']."</b></div>\n";
echo " <div class='actions'>\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 " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor_function']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendor_edit.php?id=".escape($device_vendor_uuid)."'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
//echo "<tr>\n";
//echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-label']."\n";
//echo "</td>\n";
//echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='label' maxlength='255' value=\"".escape($label)."\">\n";
//echo "<br />\n";
//echo $text['description-label']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"".escape($name)."\">\n"; echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"".escape($name)."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-name']."\n"; echo $text['description-name']."\n";
@ -389,7 +382,6 @@
echo " <input type='hidden' name='device_vendor_function_uuid' value='".escape($device_vendor_function_uuid)."'>\n"; echo " <input type='hidden' name='device_vendor_function_uuid' value='".escape($device_vendor_function_uuid)."'>\n";
} }
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";

View File

@ -27,9 +27,10 @@
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions //check permissions
require_once "resources/check_auth.php";
if (permission_exists('device_vendor_function_view')) { if (permission_exists('device_vendor_function_view')) {
//access granted //access granted
} }
@ -42,6 +43,36 @@
$language = new text; $language = new text;
$text = $language->get(); $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 //get variables used to control the order
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"];
$order = $_GET["order"]; $order = $_GET["order"];
@ -59,10 +90,6 @@
$parameters['search'] = '%'.$search.'%'; $parameters['search'] = '%'.$search.'%';
} }
//additional includes
require_once "resources/header.php";
require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(*) from v_device_vendor_functions "; $sql = "select count(*) from v_device_vendor_functions ";
$sql .= "where device_vendor_uuid = :device_vendor_uuid "; $sql .= "where device_vendor_uuid = :device_vendor_uuid ";
@ -77,7 +104,8 @@
if (isset($_GET['page'])) { if (isset($_GET['page'])) {
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 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; $offset = $rows_per_page * $page;
} }
@ -89,45 +117,54 @@
$vendor_functions = $database->select($sql, $parameters, 'all'); $vendor_functions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//alternate the row style //create token
$c = 0; $object = new token;
$row_style["0"] = "row_style0"; $token = $object->create('/app/devices/device_vendor_functions.php');
$row_style["1"] = "row_style1";
//show the content //show the content
echo "<table width='100%' border='0'>\n"; echo "<div class='action_bar sub'>\n";
echo " <tr>\n"; echo " <div class='heading'><b>".$text['title-device_vendor_functions']." (".$num_rows.")</b></div>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-device_vendor_functions']."</b></td>\n"; echo " <div class='actions'>\n";
//echo " <form method='get' action=''>\n"; if (permission_exists('device_vendor_function_add')) {
//echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; 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'])]);
//echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; }
//echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; if (permission_exists('device_vendor_function_edit') && $vendor_functions) {
//echo " </td>\n"; 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; }"]);
//echo " </form>\n"; }
echo " </tr>\n"; if (permission_exists('device_vendor_function_delete') && $vendor_functions) {
echo "</table>\n"; 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 "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<form id='form_list' method='post' action='device_vendor_functions.php'>\n";
echo "<tr>\n"; echo "<input type='hidden' id='action' name='action' value=''>\n";
//echo "<th>".$text['label-label']."</th>\n"; echo "<input type='hidden' name='device_vendor_uuid' value='".escape($device_vendor_uuid)."'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit') || permission_exists('device_vendor_function_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($vendor_functions ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('name', $text['label-name'], $order_by, $order); echo th_order_by('name', $text['label-name'], $order_by, $order);
echo th_order_by('value', $text['label-value'], $order_by, $order); echo th_order_by('value', $text['label-value'], $order_by, $order);
echo "<th>".$text['label-groups']."</th>\n"; echo "<th class='hide-sm-dn'>".$text['label-groups']."</th>\n";
echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); 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); echo th_order_by('description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'");
echo "<td class='list_control_icons'>"; if (permission_exists('device_vendor_function_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('device_vendor_function_add')) { echo " <td class='action-button'>&nbsp;</td>\n";
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".escape($_GET['id'])."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { echo "</tr>\n";
echo "&nbsp;\n";
}
echo "</td>\n";
echo "<tr>\n";
if (is_array($vendor_functions) && @sizeof($vendor_functions) != 0) { if (is_array($vendor_functions) && @sizeof($vendor_functions) != 0) {
$x = 0;
foreach ($vendor_functions as $row) { foreach ($vendor_functions as $row) {
//get the groups that have been assigned to the vendor functions //get the groups that have been assigned to the vendor functions
$sql = "select "; $sql = "select ";
$sql .= "fg.*, g.domain_uuid as group_domain_uuid "; $sql .= "fg.*, g.domain_uuid as group_domain_uuid ";
@ -152,55 +189,52 @@
} }
$group_list = isset($group_list) ? implode(', ', $group_list) : ''; $group_list = isset($group_list) ? implode(', ', $group_list) : '';
unset ($vendor_function_groups); 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 //show the row of data
echo "<tr ".$tr_link.">\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.escape($row['name'])]."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['name'])." &nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['value'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($group_list)."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['enabled'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['description'])."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_function_edit')) { if (permission_exists('device_vendor_function_edit')) {
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".escape($row['device_vendor_uuid'])."&id=".escape($row['device_vendor_function_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; $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 "<a href='device_vendor_function_delete.php?device_vendor_uuid=".escape($row['device_vendor_uuid'])."&id=".escape($row['device_vendor_function_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit') || permission_exists('device_vendor_function_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='vendor_functions[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='vendor_functions[$x][uuid]' value='".escape($row['device_vendor_function_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n";
//toggle the value of the c variable
if ($c==0) { $c=1; } else { $c=0; }
} }
unset($vendor_functions, $row); echo " <td>\n";
} if (permission_exists('device_vendor_function_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['name'])."</a>\n";
echo "<tr>\n";
echo "<td colspan='7' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_function_add')) {
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".escape($_GET['id'])."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo " ".escape($row['name']);
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " <td>".escape($row['value'])."&nbsp;</td>\n";
echo " </table>\n"; echo " <td class='hide-sm-dn'>".escape($group_list)."&nbsp;</td>\n";
if (permission_exists('device_vendor_function_edit')) {
echo " <td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['enabled']];
}
echo " </td>\n"; echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['description'])."</td>\n";
if (permission_exists('device_vendor_function_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; $x++;
echo "<br /><br />"; }
unset($vendor_functions);
}
//include the footer echo "</table>\n";
require_once "resources/footer.php"; echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
?> ?>

View File

@ -30,6 +30,7 @@ include "root.php";
public $db; public $db;
public $domain_uuid; public $domain_uuid;
public $template_dir; public $template_dir;
public $device_vendor_uuid;
/** /**
* declare private variables * 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) { public function delete_profiles($records) {
//assign private variables //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) { public function toggle_profiles($records) {
//assign private variables //assign private variables