use array from POST to save
This commit is contained in:
parent
b8ec86671a
commit
ba64e7b6b2
|
|
@ -194,35 +194,36 @@
|
|||
|
||||
//update the phrase
|
||||
if ($action == "update" && permission_exists('phrase_edit')) {
|
||||
$array = [];
|
||||
if (!empty($_POST['phrase_detail_function'])) {
|
||||
for ($i = 0; $i < count($_POST['phrase_detail_function']); $i++) {
|
||||
//build data array
|
||||
$array['phrases'][0]['domain_uuid'] = $domain_uuid;
|
||||
$array['phrases'][0]['phrase_uuid'] = $phrase_uuid;
|
||||
$array['phrases'][0]['phrase_name'] = $phrase_name;
|
||||
$array['phrases'][0]['phrase_language'] = $phrase_language;
|
||||
$array['phrases'][0]['phrase_enabled'] = $phrase_enabled;
|
||||
$array['phrases'][0]['phrase_description'] = $phrase_description;
|
||||
|
||||
if ($_POST['phrase_detail_function'] != '') {
|
||||
if ($_POST['phrase_detail_function'] == 'execute' && substr($_POST['phrase_detail_data'], 0,5) != "sleep" && !permission_exists("phrase_execute")) {
|
||||
$array['phrases'][$i]['domain_uuid'] = $domain_uuid;
|
||||
$array['phrases'][$i]['phrase_uuid'] = $phrase_uuid;
|
||||
$array['phrases'][$i]['phrase_name'] = $phrase_name;
|
||||
$array['phrases'][$i]['phrase_language'] = $phrase_language;
|
||||
$array['phrases'][$i]['phrase_enabled'] = $phrase_enabled;
|
||||
$array['phrases'][$i]['phrase_description'] = $phrase_description;
|
||||
if ($_POST['phrase_detail_function'][$i] == 'execute' && substr($_POST['phrase_detail_data'][$i], 0,5) != "sleep" && !permission_exists("phrase_execute")) {
|
||||
header("Location: phrase_edit.php?id=".$phrase_uuid);
|
||||
exit;
|
||||
}
|
||||
$_POST['phrase_detail_tag'] = 'action'; // default, for now
|
||||
$_POST['phrase_detail_group'] = "0"; // one group, for now
|
||||
|
||||
if ($_POST['phrase_detail_data'] != '') {
|
||||
if (!empty($_POST['phrase_detail_data'][$i])) {
|
||||
$phrase_detail_uuid = uuid();
|
||||
$array['phrase_details'][0]['phrase_detail_uuid'] = $phrase_detail_uuid;
|
||||
$array['phrase_details'][0]['phrase_uuid'] = $phrase_uuid;
|
||||
$array['phrase_details'][0]['domain_uuid'] = $domain_uuid;
|
||||
$array['phrase_details'][0]['phrase_detail_order'] = $_POST['phrase_detail_order'];
|
||||
$array['phrase_details'][0]['phrase_detail_tag'] = $_POST['phrase_detail_tag'];
|
||||
$array['phrase_details'][0]['phrase_detail_pattern'] = $_POST['phrase_detail_pattern'] ?? null;
|
||||
$array['phrase_details'][0]['phrase_detail_function'] = $_POST['phrase_detail_function'];
|
||||
$array['phrase_details'][0]['phrase_detail_data'] = $_POST['phrase_detail_data'];
|
||||
$array['phrase_details'][0]['phrase_detail_method'] = $_POST['phrase_detail_method'] ?? null;
|
||||
$array['phrase_details'][0]['phrase_detail_type'] = $_POST['phrase_detail_type'] ?? null;
|
||||
$array['phrase_details'][0]['phrase_detail_group'] = $_POST['phrase_detail_group'];
|
||||
$array['phrase_details'][$i]['phrase_detail_uuid'] = $phrase_detail_uuid;
|
||||
$array['phrase_details'][$i]['phrase_uuid'] = $phrase_uuid;
|
||||
$array['phrase_details'][$i]['domain_uuid'] = $domain_uuid;
|
||||
$array['phrase_details'][$i]['phrase_detail_order'] = $i;
|
||||
$array['phrase_details'][$i]['phrase_detail_tag'] = $_POST['phrase_detail_tag'];
|
||||
$array['phrase_details'][$i]['phrase_detail_pattern'] = $_POST['phrase_detail_pattern'] ?? null;
|
||||
$array['phrase_details'][$i]['phrase_detail_function'] = $_POST['phrase_detail_function'][$i];
|
||||
$array['phrase_details'][$i]['phrase_detail_data'] = $_POST['phrase_detail_data'][$i];
|
||||
$array['phrase_details'][$i]['phrase_detail_method'] = $_POST['phrase_detail_method'] ?? null;
|
||||
$array['phrase_details'][$i]['phrase_detail_type'] = $_POST['phrase_detail_type'] ?? null;
|
||||
$array['phrase_details'][$i]['phrase_detail_group'] = $_POST['phrase_detail_group'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,8 +232,10 @@
|
|||
$p->add('phrase_detail_add', 'temp');
|
||||
$database->app_name = 'phrases';
|
||||
$database->app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba';
|
||||
if (count($array) > 0) {
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
}
|
||||
}
|
||||
|
||||
$p->delete('phrase_detail_add', 'temp');
|
||||
|
||||
|
|
@ -258,12 +261,9 @@
|
|||
//send a redirect
|
||||
message::add($text['message-update']);
|
||||
header("Location: phrase_edit.php?id=".$phrase_uuid);
|
||||
exit;;
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//pre-populate the form
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ function add_row() {
|
|||
const select_recording = select_list[1];
|
||||
|
||||
//set the new id and name for action
|
||||
select_action.id = 'phrase_detail_function[' + tbody.childElementCount - 1 + ']'
|
||||
select_action.setAttribute('name', 'phrase_detail_function[' + tbody.childElementCount - 1 + ']');
|
||||
select_action.id = 'phrase_detail_function[' + tbody.childElementCount + ']'
|
||||
select_action.setAttribute('name', 'phrase_detail_function[' + tbody.childElementCount + ']');
|
||||
//set the new id and name for recording
|
||||
select_recording.id = 'phrase_detail_data[' + tbody.childElementCount - 1 + ']'
|
||||
select_recording.setAttribute('name', 'phrase_detail_data[' + tbody.childElementCount - 1 + ']');
|
||||
select_recording.id = 'phrase_detail_data[' + tbody.childElementCount + ']'
|
||||
select_recording.setAttribute('name', 'phrase_detail_data[' + tbody.childElementCount + ']');
|
||||
|
||||
|
||||
//add the row to the table body
|
||||
|
|
|
|||
Loading…
Reference in New Issue