-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_submit.php
More file actions
84 lines (66 loc) · 2.79 KB
/
custom_submit.php
File metadata and controls
84 lines (66 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* This is a custom form processor, it takes an input array submitted by this
* module's settings form and does some extra preprocessing before the array gets
* passed back to the Modules Class to be serialized and saved into the database.
* Data comes into this file as '$inputArray' and MUST be passed back out as
* '$outputArray' in order for the data to be saved.
*/
### Data comes in as '$inputArray' ###
// Process submitted post varialbes
foreach($inputArray as $key=>$value){
if(in_array($key, array("digitalNum", "digitalLabel", "digitalType", "digitalGPIO", "digitalActive"))){
// Process through submitted digital sensor sub arrays and store for later nesting
$digitalPostArray[$key]=$value;
} else if(in_array($key, array("analogNum", "analogLabel", "analogType", "analogGPIO", "analogHysterisis"))){
// Process through submitted analog sensor sub arrays and store for later nesting
$analogPostArray[$key]=$value;
} else {
// Process non-array based variables normally and add to options array.
$moduleOptions[$key]=$value;
}
}
// LOOP: Process saved digital sub arrays into nested array and update gpio pins
foreach($digitalPostArray['digitalNum'] as $key=>$value){
$digitalNested[$value] = [
'label' => $digitalPostArray['digitalLabel'][$key],
'type' => $digitalPostArray['digitalType'][$key],
'gpio' => $digitalPostArray['digitalGPIO'][$key],
'active' => $digitalPostArray['digitalActive'][$key]
];
// Also build array to update GPIO Pins DB table for pin registration with OS
$gpio_array[] = [
'gpio_num' => $digitalPostArray['digitalGPIO'][$key],
'direction' => 'in',
'active' => $digitalPostArray['digitalActive'][$key],
'description' => 'DIGITAL SENSOR: ' . $digitalPostArray['digitalLabel'][$key]
];
}
// LOOP: Process saved analog sub arrays into nested array and update gpio pins
foreach($analogPostArray['analogNum'] as $key=>$value){
$analogNested[$value] = [
'label' => $analogPostArray['analogLabel'][$key],
'type' => $analogPostArray['analogType'][$key],
'gpio' => $analogPostArray['analogGPIO'][$key],
'hysterisis' => $analogPostArray['analogHysterisis'][$key]
];
// Also build array to update GPIO Pins DB table for pin registration with OS
/*
$gpio_array[] = [
'gpio_num' => $analogPostArray['analogGPIO'][$key],
'direction' => 'in',
'active' => 'analog',
'description' => 'ANALOG SENSOR: ' . $analogPostArray['analogLabel'][$key]
];
*/
}
// Update GPIO pins table with new pins.
$mod_name = $modules[$moduleID]['svxlinkName'];
$this->update_gpios($mod_name, $gpio_array);
// add nested sensor array into options array.
$moduleOptions['digital'] = $digitalNested;
$moduleOptions['analog'] = $analogNested;
// Pass NEW array back out as $outputArray
$outputArray = $moduleOptions;
### Data MUST leave as '$outputArray' ###
?>