@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | $added = FALSE; |
59 | 59 | watchdog('BAT', t('Event with @id, start date @start_date and end date @end_date was not added.', array('@id' => $event->value, '@start_date' => $event->startDateToString(), '@end_date' => $event->endDateToString()))); |
60 | 60 | break; |
61 | - } |
|
62 | - else { |
|
61 | + } else { |
|
63 | 62 | watchdog('BAT', t('Event with @id, start date @start_date and end date @end_date added.', array('@id' => $event->value, '@start_date' => $event->startDateToString(), '@end_date' => $event->endDateToString()))); |
64 | 63 | } |
65 | 64 | } |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | // Unit is in a state that is within the set of valid states so add to result set |
134 | 133 | $units[$unit] = $unit; |
135 | 134 | $response->addMatch($keyed_units[$unit], CalendarResponse::VALID_STATE); |
136 | - } |
|
137 | - else { |
|
135 | + } else { |
|
138 | 136 | $response->addMiss($keyed_units[$unit], CalendarResponse::INVALID_STATE); |
139 | 137 | } |
140 | 138 | |
@@ -184,8 +182,7 @@ discard block |
||
184 | 182 | foreach ($days as $day => $value) { |
185 | 183 | $events[$unit][BAT_DAY][$year][$month][$day] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day]); |
186 | 184 | } |
187 | - } |
|
188 | - else { |
|
185 | + } else { |
|
189 | 186 | foreach ($days as $day => $value) { |
190 | 187 | $events[$unit][BAT_DAY][$year][$month][$day] = $keyed_units[$unit]->getDefaultValue(); |
191 | 188 | } |
@@ -202,8 +199,7 @@ discard block |
||
202 | 199 | foreach ($hours as $hour => $value) { |
203 | 200 | if (isset($db_events[$unit][BAT_HOUR][$year][$month][$day][$hour])) { |
204 | 201 | $events[$unit][BAT_HOUR][$year][$month]['d' . $day][$hour] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour]); |
205 | - } |
|
206 | - else { |
|
202 | + } else { |
|
207 | 203 | // If nothing from db - then revert to the defaults |
208 | 204 | $events[$unit][BAT_HOUR][$year][$month][$day][$hour] = (int)$keyed_units[$unit]->getDefaultValue(); |
209 | 205 | } |
@@ -233,8 +229,7 @@ discard block |
||
233 | 229 | foreach ($minutes as $minute => $value) { |
234 | 230 | if (isset($db_events[$unit][BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
235 | 231 | $events[$unit][BAT_MINUTE][$year][$month]['d' .$day]['h'.$hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
236 | - } |
|
237 | - else { |
|
232 | + } else { |
|
238 | 233 | // If nothing from db - then revert to the defaults |
239 | 234 | $events[$unit][BAT_MINUTE][$year][$month][$day][$hour][$minute] = (int)$keyed_units[$unit]->getDefaultValue(); |
240 | 235 | } |
@@ -320,8 +315,7 @@ discard block |
||
320 | 315 | if ($current_value === $minute_value) { |
321 | 316 | // We are still in minutes and going through so add a minute |
322 | 317 | $end_event->add(new \DateInterval('PT1M')); |
323 | - } |
|
324 | - elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
318 | + } elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
325 | 319 | // Value just switched - let us wrap up with current event and start a new one |
326 | 320 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
327 | 321 | $start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
@@ -335,12 +329,10 @@ discard block |
||
335 | 329 | } |
336 | 330 | $current_value = $minute_value; |
337 | 331 | } |
338 | - } |
|
339 | - elseif ($current_value === $hour_value) { |
|
332 | + } elseif ($current_value === $hour_value) { |
|
340 | 333 | // We are in hours and can add something |
341 | 334 | $end_event->add(new \DateInterval('PT1H')); |
342 | - } |
|
343 | - elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
335 | + } elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
344 | 336 | // Value just switched - let us wrap up with current event and start a new one |
345 | 337 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
346 | 338 | // Start event becomes the end event with a minute added |
@@ -357,12 +349,10 @@ discard block |
||
357 | 349 | $current_value = $hour_value; |
358 | 350 | } |
359 | 351 | } |
360 | - } |
|
361 | - elseif ($current_value === $value) { |
|
352 | + } elseif ($current_value === $value) { |
|
362 | 353 | // We are adding a whole day so the end event gets moved to the end of the day we are adding |
363 | 354 | $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
364 | - } |
|
365 | - elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
355 | + } elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
366 | 356 | // Value just switched - let us wrap up with current event and start a new one |
367 | 357 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
368 | 358 | // Start event becomes the end event with a minute added |
@@ -397,8 +387,7 @@ discard block |
||
397 | 387 | if ($event->endsLater($end_date)) { |
398 | 388 | $event->setEndDate($end_date); |
399 | 389 | } |
400 | - } |
|
401 | - else { |
|
390 | + } else { |
|
402 | 391 | // Event completely not in range so unset it |
403 | 392 | unset($normalized_events[$unit][$key]); |
404 | 393 | } |
@@ -432,8 +421,7 @@ discard block |
||
432 | 421 | $e++; |
433 | 422 | $flipped[$e][$value][$datum] = $datum; |
434 | 423 | $old_value = $value; |
435 | - } |
|
436 | - else { |
|
424 | + } else { |
|
437 | 425 | $flipped[$e][$value][$datum] = $datum; |
438 | 426 | } |
439 | 427 | } |
@@ -126,8 +126,7 @@ |
||
126 | 126 | unset($this->included_set[$unit->getUnitId()]); |
127 | 127 | $this->addMiss($unit, $reason, $constraint); |
128 | 128 | return TRUE; |
129 | - } |
|
130 | - else { |
|
129 | + } else { |
|
131 | 130 | return FALSE; |
132 | 131 | } |
133 | 132 | } |
@@ -70,8 +70,7 @@ discard block |
||
70 | 70 | $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); |
71 | 71 | |
72 | 72 | $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; |
73 | - } |
|
74 | - elseif (is_numeric($this->max_days) && $diff > $this->max_days) { |
|
73 | + } elseif (is_numeric($this->max_days) && $diff > $this->max_days) { |
|
75 | 74 | $calendar_response->removeFromMatched($included_set[$unit_id]['unit'], CalendarResponse::CONSTRAINT, $this); |
76 | 75 | |
77 | 76 | $this->affected_units[$unit_id] = $included_set[$unit_id]['unit']; |
@@ -122,8 +121,7 @@ discard block |
||
122 | 121 | if ($day_of_the_week) { |
123 | 122 | if ($start_date && $end_date) { |
124 | 123 | $text = t('From @start_date to @end_date, if booking starts on @day_of_the_week', $args); |
125 | - } |
|
126 | - else { |
|
124 | + } else { |
|
127 | 125 | $text = t('If booking starts on @day_of_the_week', $args); |
128 | 126 | } |
129 | 127 | } |
@@ -132,8 +130,7 @@ discard block |
||
132 | 130 | if ($minimum_stay || $maximum_stay) { |
133 | 131 | if (empty($text)) { |
134 | 132 | $text = t('The stay') . ' '; |
135 | - } |
|
136 | - else { |
|
133 | + } else { |
|
137 | 134 | $text .= ' ' . t('the stay') . ' '; |
138 | 135 | } |
139 | 136 | } |
@@ -141,15 +138,12 @@ discard block |
||
141 | 138 | // Special case when min stay and max stay are the same. |
142 | 139 | if ($minimum_stay == $maximum_stay) { |
143 | 140 | $text .= t('must be for @minimum_stay', $args); |
144 | - } |
|
145 | - else { |
|
141 | + } else { |
|
146 | 142 | $text .= t('must be at least @minimum_stay and at most @maximum_stay', $args); |
147 | 143 | } |
148 | - } |
|
149 | - elseif ($minimum_stay) { |
|
144 | + } elseif ($minimum_stay) { |
|
150 | 145 | $text .= t('must be for at least @minimum_stay', $args); |
151 | - } |
|
152 | - elseif ($maximum_stay) { |
|
146 | + } elseif ($maximum_stay) { |
|
153 | 147 | $text .= t('cannot be more than @maximum_stay', $args); |
154 | 148 | } |
155 | 149 |
@@ -405,8 +405,7 @@ discard block |
||
405 | 405 | $itemized[BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[BAT_HOUR][$sy][$sm]['d' . $sd]; |
406 | 406 | $itemized[BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[BAT_MINUTE][$sy][$sm]['d' . $sd]; |
407 | 407 | } |
408 | - } |
|
409 | - else { |
|
408 | + } else { |
|
410 | 409 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
411 | 410 | if (!($this->start_date->format('H:i') == '00:00')) { |
412 | 411 | $start_period = new \DatePeriod($start_date, $interval, new \DateTime($start_date->format("Y-n-j 23:59:59"))); |
@@ -414,8 +413,7 @@ discard block |
||
414 | 413 | $itemized[BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
415 | 414 | $itemized[BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[BAT_HOUR][$sy][$sm]['d' . $sd]; |
416 | 415 | $itemized[BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[BAT_MINUTE][$sy][$sm]['d' . $sd]; |
417 | - } |
|
418 | - else { |
|
416 | + } else { |
|
419 | 417 | // Just set an empty hour and minute |
420 | 418 | $itemized[BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
421 | 419 | $itemized[BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
@@ -455,8 +453,7 @@ discard block |
||
455 | 453 | // Not a real hour - leave as is and move on |
456 | 454 | $counter = 0; |
457 | 455 | $start_minute = 0; |
458 | - } |
|
459 | - elseif ($counter == 60 && $start_minute == 0) { |
|
456 | + } elseif ($counter == 60 && $start_minute == 0) { |
|
460 | 457 | // Did a real whole hour so initialize the hour |
461 | 458 | $itemized[BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = $this->getValue(); |
462 | 459 | // We have a whole hour so get rid of the minute info |
@@ -497,8 +494,7 @@ discard block |
||
497 | 494 | // If we are in the same month the end date is the end date of the event |
498 | 495 | if ($this->isSameMonth()) { |
499 | 496 | $dayrange = new \DatePeriod($this->start_date, $dayinterval, new \DateTime($this->end_date->format("Y-n-j 23:59:59"))); |
500 | - } |
|
501 | - else { // alternatively it is the last day of the start month |
|
497 | + } else { // alternatively it is the last day of the start month |
|
502 | 498 | $dayrange = new \DatePeriod($this->start_date, $dayinterval, $this->endMonthDate($this->start_date)); |
503 | 499 | } |
504 | 500 | foreach ($dayrange as $day) { |
@@ -110,8 +110,7 @@ discard block |
||
110 | 110 | for ($i = 0; $i<=59; $i++) { |
111 | 111 | if ($i <= 9) { |
112 | 112 | $index = 'm0'.$i; |
113 | - } |
|
114 | - else { |
|
113 | + } else { |
|
115 | 114 | $index = 'm'.$i; |
116 | 115 | } |
117 | 116 | $db_events[$data['unit_id']][Event::BAT_MINUTE][$data['year']][$data['month']][$data['day']][$data['hour']][$index] = $data[$index]; |
@@ -190,8 +189,7 @@ discard block |
||
190 | 189 | } |
191 | 190 | } |
192 | 191 | } |
193 | - } |
|
194 | - catch (\Exception $e) { |
|
192 | + } catch (\Exception $e) { |
|
195 | 193 | $saved = FALSE; |
196 | 194 | $transaction->rollback(); |
197 | 195 | watchdog_exception('BAT Event Save Exception', $e); |