@@ -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 | } |
@@ -119,42 +119,42 @@ |
||
| 119 | 119 | curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
| 120 | 120 | } else { |
| 121 | 121 | switch ($method) { |
| 122 | - case 'DELETE': |
|
| 123 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 124 | - break; |
|
| 125 | - case 'DELETEARRAY': |
|
| 126 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 127 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 128 | - break; |
|
| 129 | - case 'PUT': |
|
| 130 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 131 | - break; |
|
| 132 | - case 'POST': |
|
| 133 | - if (isset($body)) { |
|
| 134 | - $bodyData = json_encode($body); |
|
| 135 | - if (isset($options['HTTPHEADER'])) { |
|
| 136 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 137 | - $bodyData = $body; |
|
| 138 | - } |
|
| 122 | + case 'DELETE': |
|
| 123 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 124 | + break; |
|
| 125 | + case 'DELETEARRAY': |
|
| 126 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
| 127 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 128 | + break; |
|
| 129 | + case 'PUT': |
|
| 130 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 131 | + break; |
|
| 132 | + case 'POST': |
|
| 133 | + if (isset($body)) { |
|
| 134 | + $bodyData = json_encode($body); |
|
| 135 | + if (isset($options['HTTPHEADER'])) { |
|
| 136 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 137 | + $bodyData = $body; |
|
| 139 | 138 | } |
| 140 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 141 | 139 | } |
| 142 | - break; |
|
| 143 | - case 'ADD': |
|
| 144 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 145 | - break; |
|
| 146 | - case 'PATCH': |
|
| 147 | - if (isset($body)) { |
|
| 148 | - $bodyData = json_encode($body); |
|
| 149 | - if (isset($options['HTTPHEADER'])) { |
|
| 150 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 151 | - $bodyData = $body; |
|
| 152 | - } |
|
| 140 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 141 | + } |
|
| 142 | + break; |
|
| 143 | + case 'ADD': |
|
| 144 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 145 | + break; |
|
| 146 | + case 'PATCH': |
|
| 147 | + if (isset($body)) { |
|
| 148 | + $bodyData = json_encode($body); |
|
| 149 | + if (isset($options['HTTPHEADER'])) { |
|
| 150 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
| 151 | + $bodyData = $body; |
|
| 153 | 152 | } |
| 154 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 155 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 156 | 153 | } |
| 157 | - break; |
|
| 154 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 155 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 156 | + } |
|
| 157 | + break; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |