Skip to content
Permalink
Browse files

Update magichome_devices_edit.inc.php

  • Loading branch information...
directman66 committed Sep 19, 2018
1 parent 3f81840 commit b3d83688a421297098434a96c733e17d28077879
Showing with 5 additions and 52 deletions.
  1. +5 −52 modules/magichome/magichome_devices_edit.inc.php
@@ -17,70 +17,23 @@
if ($rec['TITLE']=='') {
$out['ERR_TITLE']=1;
$ok=0;
}
//updating 'IP' (varchar)
global $ip;
$rec['IP']=$ip;
if (!$rec['IP']) {
$ok=0;
$out['ERR_IP']=1;
}
//updating 'ZONE' (varchar)
global $zone;
$rec['ZONE']=(int)$zone;
//updating 'DEVICE_TYPE' (varchar)
global $device_type;
$rec['DEVICE_TYPE']=(int)$device_type;
}
}}}
// step: data
if ($this->tab=='data') {
}
//UPDATING RECORD
if ($ok) {
if ($rec['ID']) {
SQLUpdate($table_name, $rec); // update
} else {
$new_rec=1;
$rec['ID']=SQLInsert($table_name, $rec); // adding new record
}
$out['OK']=1;
$commands=array('command','status','level');
if ($rec['DEVICE_TYPE']=='1') {
$commands[]='color';
} else {
//$commands[]='warm';
}
$total = count($commands);
for ($i = 0; $i < $total; $i++) {
$cmd_rec=SQLSelectOne("SELECT ID FROM magichome_commands WHERE DEVICE_ID=".$rec['ID']." AND TITLE LIKE '".$commands[$i]."'");
if (!$cmd_rec['ID']) {
$cmd_rec=array();
$cmd_rec['DEVICE_ID']=$rec['ID'];
$cmd_rec['TITLE']=$commands[$i];
SQLInsert('milight_commands',$cmd_rec);
}
}
} else {
$out['ERR']=1;
}
}
// step: default
if ($this->tab=='') {
}
// step: data
if ($this->tab=='data') {
}
if ($this->tab=='data') {
//dataset2
$new_id=0;
global $delete_id;
if ($delete_id) {
SQLExec("DELETE FROM milight_commands WHERE ID='".(int)$delete_id."'");
}
$properties=SQLSelect("SELECT * FROM milight_commands WHERE DEVICE_ID='".$rec['ID']."' ORDER BY ID");
$properties=SQLSelect("SELECT * FROM magichome_commands WHERE DEVICE_ID='".$rec['ID']."' ORDER BY ID");
$total=count($properties);
for($i=0;$i<$total;$i++) {
if ($properties[$i]['ID']==$new_id) continue;
@@ -95,7 +48,8 @@
$properties[$i]['LINKED_OBJECT']=trim(${'linked_object'.$properties[$i]['ID']});
global ${'linked_property'.$properties[$i]['ID']};
$properties[$i]['LINKED_PROPERTY']=trim(${'linked_property'.$properties[$i]['ID']});
SQLUpdate('milight_commands', $properties[$i]);
SQLUpdate('magichome_commands', $properties[$i]);
$old_linked_object=$properties[$i]['LINKED_OBJECT'];
$old_linked_property=$properties[$i]['LINKED_PROPERTY'];
if ($old_linked_object && $old_linked_object!=$properties[$i]['LINKED_OBJECT'] && $old_linked_property && $old_linked_property!=$properties[$i]['LINKED_PROPERTY']) {
@@ -126,4 +80,3 @@
}
}
outHash($rec, $out);

0 comments on commit b3d8368

Please sign in to comment.
You can’t perform that action at this time.