\n";
- echo "| \n";
+ echo " | \n";
echo " ".$text['label-name']."\n";
echo " | \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 "";
@@ -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 " | ".$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 "| ".$text['label-label']." | \n";
+ 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
|