@@ -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 | } |
@@ -84,31 +84,31 @@ |
||
| 84 | 84 | curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
| 85 | 85 | } else { |
| 86 | 86 | switch ($method) { |
| 87 | - case 'DELETE': |
|
| 88 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 89 | - break; |
|
| 90 | - case 'DELETEARRAY': |
|
| 91 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 92 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 93 | - break; |
|
| 94 | - case 'PUT': |
|
| 95 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 96 | - break; |
|
| 97 | - case 'POST': |
|
| 98 | - if (isset($body)) { |
|
| 99 | - $bodyData = json_encode($body); |
|
| 100 | - if (isset($options['HTTPHEADER'])) { |
|
| 101 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 102 | - $bodyData = $body; |
|
| 103 | - } |
|
| 87 | + case 'DELETE': |
|
| 88 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 89 | + break; |
|
| 90 | + case 'DELETEARRAY': |
|
| 91 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 92 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 93 | + break; |
|
| 94 | + case 'PUT': |
|
| 95 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 96 | + break; |
|
| 97 | + case 'POST': |
|
| 98 | + if (isset($body)) { |
|
| 99 | + $bodyData = json_encode($body); |
|
| 100 | + if (isset($options['HTTPHEADER'])) { |
|
| 101 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 102 | + $bodyData = $body; |
|
| 104 | 103 | } |
| 105 | - |
|
| 106 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 107 | 104 | } |
| 108 | - break; |
|
| 109 | - case 'ADD': |
|
| 110 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 111 | - break; |
|
| 105 | + |
|
| 106 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 107 | + } |
|
| 108 | + break; |
|
| 109 | + case 'ADD': |
|
| 110 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 111 | + break; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |