@@ -582,70 +582,70 @@ |
||
582 | 582 | |
583 | 583 | if ('daily' != $mode) { |
584 | 584 | switch ($mode) { |
585 | - case 'weekly': |
|
586 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
587 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
588 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
589 | - } else { |
|
590 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
591 | - } |
|
585 | + case 'weekly': |
|
586 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
587 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
588 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
589 | + } else { |
|
590 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
591 | + } |
|
592 | + } else { |
|
593 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
594 | + } |
|
595 | + break; |
|
596 | + case 'monthly': |
|
597 | + $monthlyMode = ''; |
|
598 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
599 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
600 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
601 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
592 | 602 | } else { |
593 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
603 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
604 | + } |
|
605 | + } else { |
|
606 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
607 | + } |
|
608 | + |
|
609 | + if ('' != $monthlyMode) { |
|
610 | + switch ($monthlyMode) { |
|
611 | + case 'dates': |
|
612 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
613 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
614 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
615 | + } else { |
|
616 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
617 | + } |
|
594 | 618 | } |
595 | 619 | break; |
596 | - case 'monthly': |
|
597 | - $monthlyMode = ''; |
|
598 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
599 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
600 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
601 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
602 | - } else { |
|
603 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
604 | - } |
|
620 | + case 'nth': |
|
621 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
622 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
623 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
605 | 624 | } else { |
606 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
625 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
626 | + } |
|
627 | + } else { |
|
628 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
607 | 629 | } |
608 | 630 | |
609 | - if ('' != $monthlyMode) { |
|
610 | - switch ($monthlyMode) { |
|
611 | - case 'dates': |
|
612 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
613 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
614 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
615 | - } else { |
|
616 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
617 | - } |
|
618 | - } |
|
619 | - break; |
|
620 | - case 'nth': |
|
621 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
622 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
623 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
624 | - } else { |
|
625 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
626 | - } |
|
627 | - } else { |
|
628 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
629 | - } |
|
630 | - |
|
631 | - if ('' != $curSchedule) { |
|
632 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
633 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
634 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_what']].'}}'; |
|
635 | - } else { |
|
636 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
637 | - } |
|
638 | - } else { |
|
639 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
640 | - } |
|
641 | - } |
|
642 | - break; |
|
631 | + if ('' != $curSchedule) { |
|
632 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
633 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_what']])) { |
|
634 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_what']].'}}'; |
|
635 | + } else { |
|
636 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
643 | 637 | } |
638 | + } else { |
|
639 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
640 | + } |
|
644 | 641 | } |
645 | 642 | break; |
646 | - default: |
|
647 | - $curSchedule = ''; |
|
643 | + } |
|
644 | + } |
|
648 | 645 | break; |
646 | + default: |
|
647 | + $curSchedule = ''; |
|
648 | + break; |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 |
@@ -209,16 +209,16 @@ |
||
209 | 209 | |
210 | 210 | foreach ($device->Attributes as $attr) { |
211 | 211 | switch ($attr->AttributeDisplayName) { |
212 | - case 'desc': |
|
213 | - $this->_doorName = $attr->Value; |
|
214 | - break; |
|
215 | - case 'doorstate': |
|
216 | - $this->_doorState = $attr->Value; |
|
217 | - // UpdatedTime is a timestamp in ms, so we truncate |
|
218 | - $this->_doorStateTime = (int) $attr->UpdatedTime / 1000; |
|
219 | - break; |
|
220 | - default: |
|
221 | - continue; |
|
212 | + case 'desc': |
|
213 | + $this->_doorName = $attr->Value; |
|
214 | + break; |
|
215 | + case 'doorstate': |
|
216 | + $this->_doorState = $attr->Value; |
|
217 | + // UpdatedTime is a timestamp in ms, so we truncate |
|
218 | + $this->_doorStateTime = (int) $attr->UpdatedTime / 1000; |
|
219 | + break; |
|
220 | + default: |
|
221 | + continue; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
@@ -79,30 +79,30 @@ |
||
79 | 79 | curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
80 | 80 | } else { |
81 | 81 | switch ($method) { |
82 | - case 'DELETE': |
|
83 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
84 | - break; |
|
85 | - case 'DELETEARRAY': |
|
86 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
87 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
88 | - break; |
|
89 | - case 'PUT': |
|
90 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
91 | - break; |
|
92 | - case 'POST': |
|
93 | - if (isset($body)) { |
|
94 | - $bodyData = json_encode($body); |
|
95 | - if (isset($options['HTTPHEADER'])) { |
|
96 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
97 | - $bodyData = $body; |
|
98 | - } |
|
82 | + case 'DELETE': |
|
83 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
84 | + break; |
|
85 | + case 'DELETEARRAY': |
|
86 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
87 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
88 | + break; |
|
89 | + case 'PUT': |
|
90 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
91 | + break; |
|
92 | + case 'POST': |
|
93 | + if (isset($body)) { |
|
94 | + $bodyData = json_encode($body); |
|
95 | + if (isset($options['HTTPHEADER'])) { |
|
96 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
97 | + $bodyData = $body; |
|
99 | 98 | } |
100 | - |
|
101 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
102 | 99 | } |
103 | - break; |
|
104 | - case 'ADD': |
|
105 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
100 | + |
|
101 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
102 | + } |
|
103 | + break; |
|
104 | + case 'ADD': |
|
105 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |