@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | $caldavClient = new SimpleCaldavAdapter(); |
111 | 111 | $caldavClient->connect($this->calendar->url, $this->calendar->username, \Crypt::decrypt($this->calendar->password)); |
112 | 112 | $calendars = $caldavClient->findCalendars(); |
113 | - if(!isset($calendars[$this->calendar->calendar_name])) |
|
113 | + if (!isset($calendars[ $this->calendar->calendar_name ])) |
|
114 | 114 | throw new CaldavException("calendar inserted doesn't exist"); |
115 | - $caldavClient->setCalendar($calendars[$this->calendar->calendar_name]);//TODO error if the calendar name is wrong |
|
115 | + $caldavClient->setCalendar($calendars[ $this->calendar->calendar_name ]); //TODO error if the calendar name is wrong |
|
116 | 116 | /** |
117 | 117 | * 26 hours before to avoid tiemezone problems and dst problems |
118 | 118 | * 30 days after |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | { |
129 | 129 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
130 | 130 | if (preg_match_all($pattern, $event->getData(), $matches)) { |
131 | - if (!isset($matches[4]) || count($matches[4]) != 2) |
|
131 | + if (!isset($matches[ 4 ]) || count($matches[ 4 ]) != 2) |
|
132 | 132 | return null; |
133 | - $ret = []; |
|
134 | - if ($tmp = $this->parseDate($matches[4][0])) |
|
135 | - $ret['time_start'] = $tmp; |
|
133 | + $ret = [ ]; |
|
134 | + if ($tmp = $this->parseDate($matches[ 4 ][ 0 ])) |
|
135 | + $ret[ 'time_start' ] = $tmp; |
|
136 | 136 | else |
137 | 137 | return null; |
138 | - if ($tmp = $this->parseDate($matches[4][1])) |
|
139 | - $ret['time_end'] = $tmp; |
|
138 | + if ($tmp = $this->parseDate($matches[ 4 ][ 1 ])) |
|
139 | + $ret[ 'time_end' ] = $tmp; |
|
140 | 140 | else |
141 | 141 | return null; |
142 | 142 | return $ret; |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | { |
153 | 153 | $pattern = "/^((TZID=)|(VALUE=))(.*):(.*)\$/m"; |
154 | 154 | if (preg_match_all($pattern, $date, $matches)) { |
155 | - if ($matches[1][0] == 'TZID=') { |
|
156 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0], new \DateTimeZone($matches[4][0])); |
|
157 | - } else if ($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') { |
|
158 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0] . 'T000000'); |
|
155 | + if ($matches[ 1 ][ 0 ] == 'TZID=') { |
|
156 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ], new \DateTimeZone($matches[ 4 ][ 0 ])); |
|
157 | + } else if ($matches[ 1 ][ 0 ] == 'VALUE=' && $matches[ 4 ][ 0 ] == 'DATE') { |
|
158 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ].'T000000'); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | return null; |
@@ -90,10 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | //insert new timeslots |
92 | 92 | foreach ($events as $event) { |
93 | - if (!($event = $this->parseEvent($event))) |
|
94 | - \Event::fire(new ErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
95 | - else |
|
96 | - $calendarMain->timeslots()->create($event); |
|
93 | + if (!($event = $this->parseEvent($event))) { |
|
94 | + \Event::fire(new ErrorEvent($this->calendar, 'problem during the parsing an event')); |
|
95 | + } else { |
|
96 | + $calendarMain->timeslots()->create($event); |
|
97 | + } |
|
97 | 98 | } |
98 | 99 | \Event::fire(new OkEvent($this->calendar)); |
99 | 100 | } |
@@ -110,8 +111,9 @@ discard block |
||
110 | 111 | $caldavClient = new SimpleCaldavAdapter(); |
111 | 112 | $caldavClient->connect($this->calendar->url, $this->calendar->username, \Crypt::decrypt($this->calendar->password)); |
112 | 113 | $calendars = $caldavClient->findCalendars(); |
113 | - if(!isset($calendars[$this->calendar->calendar_name])) |
|
114 | - throw new CaldavException("calendar inserted doesn't exist"); |
|
114 | + if(!isset($calendars[$this->calendar->calendar_name])) { |
|
115 | + throw new CaldavException("calendar inserted doesn't exist"); |
|
116 | + } |
|
115 | 117 | $caldavClient->setCalendar($calendars[$this->calendar->calendar_name]);//TODO error if the calendar name is wrong |
116 | 118 | /** |
117 | 119 | * 26 hours before to avoid tiemezone problems and dst problems |
@@ -128,17 +130,20 @@ discard block |
||
128 | 130 | { |
129 | 131 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
130 | 132 | if (preg_match_all($pattern, $event->getData(), $matches)) { |
131 | - if (!isset($matches[4]) || count($matches[4]) != 2) |
|
132 | - return null; |
|
133 | + if (!isset($matches[4]) || count($matches[4]) != 2) { |
|
134 | + return null; |
|
135 | + } |
|
133 | 136 | $ret = []; |
134 | - if ($tmp = $this->parseDate($matches[4][0])) |
|
135 | - $ret['time_start'] = $tmp; |
|
136 | - else |
|
137 | - return null; |
|
138 | - if ($tmp = $this->parseDate($matches[4][1])) |
|
139 | - $ret['time_end'] = $tmp; |
|
140 | - else |
|
141 | - return null; |
|
137 | + if ($tmp = $this->parseDate($matches[4][0])) { |
|
138 | + $ret['time_start'] = $tmp; |
|
139 | + } else { |
|
140 | + return null; |
|
141 | + } |
|
142 | + if ($tmp = $this->parseDate($matches[4][1])) { |
|
143 | + $ret['time_end'] = $tmp; |
|
144 | + } else { |
|
145 | + return null; |
|
146 | + } |
|
142 | 147 | return $ret; |
143 | 148 | } |
144 | 149 | return null; |