Passed
Branch master (ff9d34)
by Mike
09:14
created
mapi/class.baserecurrence.php 1 patch
Braces   +109 added lines, -79 removed lines patch added patch discarded remove patch
@@ -232,8 +232,9 @@  discard block
 block discarded – undo
232 232
 
233 233
                 case 0x0d:
234 234
                     // Yearly
235
-                    if (strlen($rdata) < 16)
236
-                        return $ret;
235
+                    if (strlen($rdata) < 16) {
236
+                                            return $ret;
237
+                    }
237 238
 
238 239
                     $data = unpack("Vmonth/Veveryn/Vregen/Vmonthday", $rdata);
239 240
 
@@ -564,8 +565,9 @@  discard block
 block discarded – undo
564 565
         function saveRecurrence()
565 566
         {
566 567
             // Only save if a message was passed
567
-            if(!isset($this->message))
568
-                return;
568
+            if(!isset($this->message)) {
569
+                            return;
570
+            }
569 571
 
570 572
             // Abort if no recurrence was set
571 573
             if(!isset($this->recur["type"], $this->recur["subtype"], $this->recur["start"], $this->recur["end"], $this->recur["startocc"], $this->recur["endocc"])) {
@@ -622,8 +624,9 @@  discard block
 block discarded – undo
622 624
                         $dayskip = -1;
623 625
                         for($j = 0; $j < 7; $j++) {
624 626
                             if(((int) $this->recur["weekdays"]) & (1<<( ($dayofweek+$j)%7)) ) {
625
-                                if($dayskip == -1)
626
-                                    $dayskip = $j;
627
+                                if($dayskip == -1) {
628
+                                                                    $dayskip = $j;
629
+                                }
627 630
 
628 631
                                 $daycount++;
629 632
                             }
@@ -633,8 +636,9 @@  discard block
 block discarded – undo
633 636
                         // $daycount is the number of days per week that an occurrence occurs
634 637
 
635 638
                         $weekskip = 0;
636
-                        if(($dayofweek < $weekstart && $dayskip > 0) || ($dayofweek+$dayskip) > 6)
637
-                            $weekskip = 1;
639
+                        if(($dayofweek < $weekstart && $dayskip > 0) || ($dayofweek+$dayskip) > 6) {
640
+                                                    $weekskip = 1;
641
+                        }
638 642
 
639 643
                         // Check if the recurrence ends after a number of occurences, in that case we must calculate the
640 644
                         // remaining occurences based on the start of the recurrence.
@@ -662,10 +666,11 @@  discard block
 block discarded – undo
662 666
 
663 667
                     $firstocc -= (((int) gmdate("w", (int) $this->recur["start"])) - 1) * 24 * 60;
664 668
 
665
-                    if ($this->recur["regen"])
666
-                        $rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], 1);
667
-                    else
668
-                        $rdata .= pack("VVVV", $firstocc, (int) $this->recur["everyn"], 0, (int) $this->recur["weekdays"]);
669
+                    if ($this->recur["regen"]) {
670
+                                            $rdata .= pack("VVV", $firstocc, (int) $this->recur["everyn"], 1);
671
+                    } else {
672
+                                            $rdata .= pack("VVVV", $firstocc, (int) $this->recur["everyn"], 0, (int) $this->recur["weekdays"]);
673
+                    }
669 674
                     break;
670 675
                 case 0x0C:
671 676
                     // Monthly
@@ -680,7 +685,7 @@  discard block
 block discarded – undo
680 685
 
681 686
                     if($term == 0x0C /*monthly*/) {
682 687
                         $everyn = (int) $this->recur["everyn"];
683
-                    }else {
688
+                    } else {
684 689
                         $everyn = $this->recur["regen"] ? ((int) $this->recur["everyn"]) * 12 : 12;
685 690
                     }
686 691
 
@@ -800,17 +805,18 @@  discard block
 block discarded – undo
800 805
                             if($nday == 5) {
801 806
                                 // Set date on the last day of the last month
802 807
                                 $monthbegindow += (gmdate("t", $monthbegindow ) - gmdate("j", $monthbegindow )) * 24 * 60 * 60;
803
-                            }else {
808
+                            } else {
804 809
                                 // Set on the first day of the month
805 810
                                 $monthbegindow -= ((gmdate("j", $monthbegindow )-1) * 24 * 60 * 60);
806 811
                             }
807 812
 
808 813
                             if($term == 0x0D /*yearly*/) {
809 814
                                 // Set on right month
810
-                                if($selmonth < $curmonth)
811
-                                    $tmp = 12 - $curmonth + $selmonth;
812
-                                else
813
-                                    $tmp = ($selmonth - $curmonth);
815
+                                if($selmonth < $curmonth) {
816
+                                                                    $tmp = 12 - $curmonth + $selmonth;
817
+                                } else {
818
+                                                                    $tmp = ($selmonth - $curmonth);
819
+                                }
814 820
 
815 821
                                 for($i=0; $i < $tmp; $i++) {
816 822
                                     $monthbegindow += $this->getMonthInSeconds($curyear, $curmonth);
@@ -822,7 +828,7 @@  discard block
 block discarded – undo
822 828
                                     $curmonth++;
823 829
                                 }
824 830
 
825
-                            }else {
831
+                            } else {
826 832
                                 // Check or you exist in the right month
827 833
 
828 834
                                 $dayofweek = gmdate("w", $monthbegindow);
@@ -830,7 +836,7 @@  discard block
 block discarded – undo
830 836
                                     if($nday == 5 && (($dayofweek-$i)%7 >= 0) && (1<<( ($dayofweek-$i)%7) ) & $weekdays) {
831 837
                                         $day = gmdate("j", $monthbegindow) - $i;
832 838
                                         break;
833
-                                    }else if($nday != 5 && (1<<( ($dayofweek+$i)%7) ) & $weekdays) {
839
+                                    } else if($nday != 5 && (1<<( ($dayofweek+$i)%7) ) & $weekdays) {
834 840
                                         $day = (($nday-1)*7) + ($i+1);
835 841
                                         break;
836 842
                                     }
@@ -872,15 +878,16 @@  discard block
 block discarded – undo
872 878
                                 if($nday == 5 && (($dayofweek-$i)%7) >= 0&& (1<<(($dayofweek-$i)%7) ) & $weekdays) {
873 879
                                     $day = $i;
874 880
                                     break;
875
-                                }else if($nday != 5 && (1<<( ($dayofweek+$i)%7) ) & $weekdays) {
881
+                                } else if($nday != 5 && (1<<( ($dayofweek+$i)%7) ) & $weekdays) {
876 882
                                     $day = ($nday - 1) * 7 + ($i+1);
877 883
                                     break;
878 884
                                 }
879 885
                             }
880
-                            if($nday == 5)
881
-                                $monthbegindow -= $day * 24 * 60 *60;
882
-                            else
883
-                                $monthbegindow += ($day-1) * 24 * 60 *60;
886
+                            if($nday == 5) {
887
+                                                            $monthbegindow -= $day * 24 * 60 *60;
888
+                            } else {
889
+                                                            $monthbegindow += ($day-1) * 24 * 60 *60;
890
+                            }
884 891
 
885 892
                             $firstocc = 0;
886 893
 
@@ -955,15 +962,17 @@  discard block
 block discarded – undo
955 962
             // Merge deleted and changed items into one list
956 963
             $items = $deleted_items;
957 964
 
958
-            foreach($changed_items as $changed_item)
959
-                array_push($items, $changed_item["basedate"]);
965
+            foreach($changed_items as $changed_item) {
966
+                            array_push($items, $changed_item["basedate"]);
967
+            }
960 968
 
961 969
             sort($items);
962 970
 
963 971
             // Add the merged list in to the rdata
964 972
             $rdata .= pack("V", count($items));
965
-            foreach($items as $item)
966
-                $rdata .= pack("V", $this->unixDataToRecurData($item));
973
+            foreach($items as $item) {
974
+                            $rdata .= pack("V", $this->unixDataToRecurData($item));
975
+            }
967 976
 
968 977
             // Loop through the changed exceptions (not deleted)
969 978
             $rdata .= pack("V", count($changed_items));
@@ -977,8 +986,9 @@  discard block
 block discarded – undo
977 986
             sort($items);
978 987
 
979 988
             // Add the changed items list int the rdata
980
-            foreach($items as $item)
981
-                $rdata .= pack("V", $this->unixDataToRecurData($item));
989
+            foreach($items as $item) {
990
+                            $rdata .= pack("V", $this->unixDataToRecurData($item));
991
+            }
982 992
 
983 993
             // Set start date
984 994
             $rdata .= pack("V", $this->unixDataToRecurData((int) $this->recur["start"]));
@@ -1014,8 +1024,9 @@  discard block
 block discarded – undo
1014 1024
 
1015 1025
                                     $j++;
1016 1026
 
1017
-                                    if($restocc <= 0)
1018
-                                        break;
1027
+                                    if($restocc <= 0) {
1028
+                                                                            break;
1029
+                                    }
1019 1030
 
1020 1031
                                     $occenddate += 24*60*60;
1021 1032
                                 }
@@ -1039,8 +1050,9 @@  discard block
 block discarded – undo
1039 1050
                             for($j = 1; $restocc>0; $j++)
1040 1051
                             {
1041 1052
                                 // Jump to the next week (which may be N weeks away) when going over the week boundary
1042
-                                if((($dayofweek+$j)%7) == $weekstart)
1043
-                                    $occenddate += (((int) $this->recur["everyn"])-1) * 7 * 24*60*60;
1053
+                                if((($dayofweek+$j)%7) == $weekstart) {
1054
+                                                                    $occenddate += (((int) $this->recur["everyn"])-1) * 7 * 24*60*60;
1055
+                                }
1044 1056
 
1045 1057
                                 // If this is a matching day, once less occurrence to process
1046 1058
                                 if(((int) $this->recur["weekdays"]) & (1<<(($dayofweek+$j)%7)) ) {
@@ -1079,10 +1091,11 @@  discard block
 block discarded – undo
1079 1091
                                     if(((int) $this->recur["monthday"]) >=28 && ((int) $this->recur["monthday"]) <= 31 &&
1080 1092
                                         gmdate("j", $occenddate) < ((int) $this->recur["monthday"]))
1081 1093
                                     {
1082
-                                        if(gmdate("j", $occenddate) < 28)
1083
-                                            $occenddate -= gmdate("j", $occenddate) * 24 * 60 *60;
1084
-                                        else
1085
-                                            $occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 *60;
1094
+                                        if(gmdate("j", $occenddate) < 28) {
1095
+                                                                                    $occenddate -= gmdate("j", $occenddate) * 24 * 60 *60;
1096
+                                        } else {
1097
+                                                                                    $occenddate += (gmdate("t", $occenddate) - gmdate("j", $occenddate)) * 24 * 60 *60;
1098
+                                        }
1086 1099
                                     }
1087 1100
 
1088 1101
 
@@ -1108,7 +1121,7 @@  discard block
 block discarded – undo
1108 1121
                                     if($nday == 5) {
1109 1122
                                         // Set date on the last day of the last month
1110 1123
                                         $occenddate += (gmdate("t", $occenddate ) - gmdate("j", $occenddate )) * 24 * 60 * 60;
1111
-                                    }else {
1124
+                                    } else {
1112 1125
                                         // Set date on the first day of the last month
1113 1126
                                         $occenddate -= (gmdate("j", $occenddate )-1) * 24 * 60 * 60;
1114 1127
                                     }
@@ -1118,7 +1131,7 @@  discard block
 block discarded – undo
1118 1131
                                         if($nday == 5 && (($dayofweek-$i)%7) >= 0&& (1<<(($dayofweek-$i)%7) ) & $weekdays) {
1119 1132
                                             $occenddate -= $i * 24 * 60 * 60;
1120 1133
                                             break;
1121
-                                        }else if($nday != 5 && (1<<(($dayofweek+$i)%7) ) & $weekdays) {
1134
+                                        } else if($nday != 5 && (1<<(($dayofweek+$i)%7) ) & $weekdays) {
1122 1135
                                             $occenddate +=  ($i + (($nday-1) *7)) * 24 * 60 * 60;
1123 1136
                                             break;
1124 1137
                                         }
@@ -1131,8 +1144,9 @@  discard block
 block discarded – undo
1131 1144
 
1132 1145
                     }
1133 1146
 
1134
-                    if (defined("PHP_INT_MAX") && $occenddate > PHP_INT_MAX)
1135
-                        $occenddate = PHP_INT_MAX;
1147
+                    if (defined("PHP_INT_MAX") && $occenddate > PHP_INT_MAX) {
1148
+                                            $occenddate = PHP_INT_MAX;
1149
+                    }
1136 1150
 
1137 1151
                     $this->recur["end"] = $occenddate;
1138 1152
 
@@ -1419,8 +1433,9 @@  discard block
 block discarded – undo
1419 1433
                 $day = 30;
1420 1434
             } else {
1421 1435
                 $day = 28;
1422
-                if( $this->isLeapYear($year) == 1 )
1423
-                    $day++;
1436
+                if( $this->isLeapYear($year) == 1 ) {
1437
+                                    $day++;
1438
+                }
1424 1439
             }
1425 1440
             return $day * 24 * 60 * 60;
1426 1441
         }
@@ -1453,8 +1468,9 @@  discard block
 block discarded – undo
1453 1468
             // if we are in the next month, then back up a week, because week '5' means
1454 1469
             // 'last week of month'
1455 1470
 
1456
-            if($gmdate["tm_mon"]+1 != $month)
1457
-                $date -= 7 * 24 * 60 * 60;
1471
+            if($gmdate["tm_mon"]+1 != $month) {
1472
+                            $date -= 7 * 24 * 60 * 60;
1473
+            }
1458 1474
 
1459 1475
             return $date;
1460 1476
         }
@@ -1466,8 +1482,9 @@  discard block
 block discarded – undo
1466 1482
         function getTimezone($tz, $date)
1467 1483
         {
1468 1484
             // No timezone -> GMT (+0)
1469
-            if(!isset($tz["timezone"]))
1470
-                return 0;
1485
+            if(!isset($tz["timezone"])) {
1486
+                            return 0;
1487
+            }
1471 1488
 
1472 1489
             $dst = false;
1473 1490
             $gmdate = $this->gmtime($date);
@@ -1511,8 +1528,9 @@  discard block
 block discarded – undo
1511 1528
          */
1512 1529
         function parseTimezone($data)
1513 1530
         {
1514
-            if(strlen($data) < 48)
1515
-                return;
1531
+            if(strlen($data) < 48) {
1532
+                            return;
1533
+            }
1516 1534
 
1517 1535
             $tz = unpack("ltimezone/lunk/ltimezonedst/lunk/ldstendmonth/vdstendweek/vdstendhour/lunk/lunk/vunk/ldststartmonth/vdststartweek/vdststarthour/lunk/vunk", $data);
1518 1536
             return $tz;
@@ -1550,8 +1568,9 @@  discard block
 block discarded – undo
1550 1568
          * toGMT returns a timestamp in GMT time for the time and timezone given
1551 1569
          */
1552 1570
         function toGMT($tz, $date) {
1553
-            if(!isset($tz['timezone']))
1554
-                return $date;
1571
+            if(!isset($tz['timezone'])) {
1572
+                            return $date;
1573
+            }
1555 1574
             $offset = $this->getTimezone($tz, $date);
1556 1575
 
1557 1576
             return $date + $offset * 60;
@@ -1627,21 +1646,24 @@  discard block
 block discarded – undo
1627 1646
                     // Loop through all changed exceptions
1628 1647
                     foreach($this->recur["changed_occurences"] as $exception) {
1629 1648
                         // Check reminder set
1630
-                        if(!isset($exception["reminder"]) || $exception["reminder"] == false)
1631
-                            continue;
1649
+                        if(!isset($exception["reminder"]) || $exception["reminder"] == false) {
1650
+                                                    continue;
1651
+                        }
1632 1652
 
1633 1653
                         // Convert to GMT
1634 1654
                         $occstart = $this->toGMT($this->tz, $exception["start"]); // seb changed $tz to $this->tz
1635 1655
                         $occend = $this->toGMT($this->tz, $exception["end"]); // seb changed $tz to $this->tz
1636 1656
 
1637 1657
                         // Check range criterium
1638
-                        if($occstart > $end || $occend < $start)
1639
-                            continue;
1658
+                        if($occstart > $end || $occend < $start) {
1659
+                                                    continue;
1660
+                        }
1640 1661
 
1641 1662
                         // OK, add to items.
1642 1663
                         array_push($items, $this->getExceptionProperties($exception));
1643
-                        if($limit && (count($items) == $limit))
1644
-                            break;
1664
+                        if($limit && (count($items) == $limit)) {
1665
+                                                    break;
1666
+                        }
1645 1667
                     }
1646 1668
 
1647 1669
                     uasort($items, array($this, "sortStarttime"));
@@ -1674,8 +1696,9 @@  discard block
 block discarded – undo
1674 1696
                 {
1675 1697
                 case 10:
1676 1698
                     // Daily
1677
-                    if($this->recur["everyn"] <= 0)
1678
-                        $this->recur["everyn"] = 1440;
1699
+                    if($this->recur["everyn"] <= 0) {
1700
+                                            $this->recur["everyn"] = 1440;
1701
+                    }
1679 1702
 
1680 1703
                     if($this->recur["subtype"] == 0) {
1681 1704
                         // Every Nth day
@@ -1695,11 +1718,14 @@  discard block
 block discarded – undo
1695 1718
                     break;
1696 1719
                 case 11:
1697 1720
                     // Weekly
1698
-                    if($this->recur["everyn"] <= 0)
1699
-                        $this->recur["everyn"] = 1;
1721
+                    if($this->recur["everyn"] <= 0) {
1722
+                                            $this->recur["everyn"] = 1;
1723
+                    }
1700 1724
 
1701 1725
                     // If sliding flag is set then move to 'n' weeks
1702
-                    if ($this->recur['regen']) $daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1726
+                    if ($this->recur['regen']) {
1727
+                        $daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1728
+                    }
1703 1729
 
1704 1730
                     for($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += (60 * 60 * 24 * 7 * $this->recur["everyn"]))
1705 1731
                     {
@@ -1723,8 +1749,9 @@  discard block
 block discarded – undo
1723 1749
                     break;
1724 1750
                 case 12:
1725 1751
                     // Monthly
1726
-                    if($this->recur["everyn"] <= 0)
1727
-                        $this->recur["everyn"] = 1;
1752
+                    if($this->recur["everyn"] <= 0) {
1753
+                                            $this->recur["everyn"] = 1;
1754
+                    }
1728 1755
 
1729 1756
                     // Loop through all months from start to end of occurrence, starting at beginning of first month
1730 1757
                     for($now = $this->monthStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60 )
@@ -1739,11 +1766,11 @@  discard block
 block discarded – undo
1739 1766
                             if ($daynow <= $dayend){
1740 1767
                                 $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1741 1768
                             }
1742
-                        }
1743
-                        else if(isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1769
+                        } else if(isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1744 1770
                             // Sanitize input
1745
-                            if($this->recur["weekdays"] == 0)
1746
-                                $this->recur["weekdays"] = 1;
1771
+                            if($this->recur["weekdays"] == 0) {
1772
+                                                            $this->recur["weekdays"] = 1;
1773
+                            }
1747 1774
 
1748 1775
                             // If nday is not set to the last day in the month
1749 1776
                             if ($this->recur["nday"] < 5) {
@@ -1766,7 +1793,7 @@  discard block
 block discarded – undo
1766 1793
                                 }
1767 1794
                                 // $firstday is the day of the month on which the asked pattern of nth weekday matches
1768 1795
                                 $daynow = $now + $firstday * 60 * 60 * 24;
1769
-                            }else{
1796
+                            } else{
1770 1797
                                 // Find last day in the month ($now is the firstday of the month)
1771 1798
                                 $NumDaysInMonth =  $this->daysInMonth($now, 1);
1772 1799
                                 $daynow = $now + (($NumDaysInMonth-1) * 24*60*60);
@@ -1796,8 +1823,9 @@  discard block
 block discarded – undo
1796 1823
                     break;
1797 1824
                 case 13:
1798 1825
                     // Yearly
1799
-                    if($this->recur["everyn"] <= 0)
1800
-                        $this->recur["everyn"] = 12;
1826
+                    if($this->recur["everyn"] <= 0) {
1827
+                                            $this->recur["everyn"] = 12;
1828
+                    }
1801 1829
 
1802 1830
                     for($now = $this->yearStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60 )
1803 1831
                     {
@@ -1806,12 +1834,13 @@  discard block
 block discarded – undo
1806 1834
                             $month = $this->monthOfYear($this->recur["month"]); // $month is now month of year [0..11]
1807 1835
                             $monthday = $this->recur["monthday"]; // $monthday is day of the month [1..31]
1808 1836
                             $monthstart = $now + $this->daysInMonth($now, $month) * 24 * 60 * 60; // $monthstart is the timestamp of the beginning of the month
1809
-                            if($monthday > $this->daysInMonth($monthstart, 1))
1810
-                                $monthday = $this->daysInMonth($monthstart, 1);    // Cap $monthday on month length (eg 28 feb instead of 29 feb)
1837
+                            if($monthday > $this->daysInMonth($monthstart, 1)) {
1838
+                                                            $monthday = $this->daysInMonth($monthstart, 1);
1839
+                            }
1840
+                            // Cap $monthday on month length (eg 28 feb instead of 29 feb)
1811 1841
                             $daynow = $monthstart + ($monthday-1) * 24 * 60 * 60;
1812 1842
                             $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1813
-                        }
1814
-                        else if(isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1843
+                        } else if(isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1815 1844
 
1816 1845
                             // Go the correct month
1817 1846
                             $monthnow = $now + $this->daysInMonth($now, $this->monthOfYear($this->recur["month"])) * 24 * 60 * 60;
@@ -1848,8 +1877,9 @@  discard block
 block discarded – undo
1848 1877
                     }
1849 1878
                 }
1850 1879
                 //to get all exception items
1851
-                if (!empty($this->recur['changed_occurences']))
1852
-                    $this->processExceptionItems($items, $start, $end);
1880
+                if (!empty($this->recur['changed_occurences'])) {
1881
+                                    $this->processExceptionItems($items, $start, $end);
1882
+                }
1853 1883
             }
1854 1884
 
1855 1885
             // sort items on starttime
Please login to merge, or discard this patch.
mapi/class.mapiexception.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@
 block discarded – undo
22 22
          */
23 23
         public function getDisplayMessage()
24 24
         {
25
-            if(!empty($this->displayMessage))
26
-                return $this->displayMessage;
25
+            if(!empty($this->displayMessage)) {
26
+                            return $this->displayMessage;
27
+            }
27 28
 
28 29
             switch($this->getCode())
29 30
             {
Please login to merge, or discard this patch.
mapi/class.taskrecurrence.php 1 patch
Braces   +25 added lines, -13 removed lines patch added patch discarded remove patch
@@ -76,14 +76,20 @@  discard block
 block discarded – undo
76 76
             $this->recur = $recur;
77 77
             $this->action =& $recur;
78 78
 
79
-            if(!isset($this->recur["changed_occurences"]))
80
-                $this->recur["changed_occurences"] = Array();
79
+            if(!isset($this->recur["changed_occurences"])) {
80
+                            $this->recur["changed_occurences"] = Array();
81
+            }
81 82
 
82
-            if(!isset($this->recur["deleted_occurences"]))
83
-                $this->recur["deleted_occurences"] = Array();
83
+            if(!isset($this->recur["deleted_occurences"])) {
84
+                            $this->recur["deleted_occurences"] = Array();
85
+            }
84 86
 
85
-            if (!isset($this->recur['startocc'])) $this->recur['startocc'] = 0;
86
-            if (!isset($this->recur['endocc'])) $this->recur['endocc'] = 0;
87
+            if (!isset($this->recur['startocc'])) {
88
+                $this->recur['startocc'] = 0;
89
+            }
90
+            if (!isset($this->recur['endocc'])) {
91
+                $this->recur['endocc'] = 0;
92
+            }
87 93
 
88 94
             // Save recurrence because we need proper startrecurrdate and endrecurrdate
89 95
             $this->saveRecurrence();
@@ -109,7 +115,7 @@  discard block
 block discarded – undo
109 115
             // Check if it is already the first occurrence
110 116
             if($this->action['start'] == $this->recur["start"]){
111 117
                 return;
112
-            }else{
118
+            } else{
113 119
                 $items = $this->getNextOccurrence();
114 120
 
115 121
                 $props = array();
@@ -171,8 +177,9 @@  discard block
 block discarded – undo
171 177
 
172 178
                     $props[$this->proptags["dead_occurrence"]] = false;
173 179
                 } else {
174
-                    if (isset($this->action['deleteOccurrence']) && $this->action['deleteOccurrence'])
175
-                        return false;
180
+                    if (isset($this->action['deleteOccurrence']) && $this->action['deleteOccurrence']) {
181
+                                            return false;
182
+                    }
176 183
 
177 184
                     // Didn't get next occurrence, probably this is the last one, so recurrence ends here
178 185
                     $props[$this->proptags["dead_occurrence"]] = true;
@@ -224,8 +231,12 @@  discard block
 block discarded – undo
224 231
             // Get all properties
225 232
             $taskItemProps = mapi_getprops($this->message);
226 233
 
227
-            if (isset($this->action["subject"])) $taskItemProps[$this->proptags["subject"]] = $this->action["subject"];
228
-            if (isset($this->action["importance"])) $taskItemProps[$this->proptags["importance"]] = $this->action["importance"];
234
+            if (isset($this->action["subject"])) {
235
+                $taskItemProps[$this->proptags["subject"]] = $this->action["subject"];
236
+            }
237
+            if (isset($this->action["importance"])) {
238
+                $taskItemProps[$this->proptags["importance"]] = $this->action["importance"];
239
+            }
229 240
             if (isset($this->action["startdate"])) {
230 241
                 $taskItemProps[$this->proptags["startdate"]] = $this->action["startdate"];
231 242
                 $taskItemProps[$this->proptags["commonstart"]] = $this->action["startdate"];
@@ -380,8 +391,9 @@  discard block
 block discarded – undo
380 391
                 $props[$this->proptags['reset_reminder']] = false;
381 392
             }
382 393
 
383
-            if (!empty($props))
384
-                mapi_setprops($this->message, $props);
394
+            if (!empty($props)) {
395
+                            mapi_setprops($this->message, $props);
396
+            }
385 397
         }
386 398
 
387 399
         /**
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +51 added lines, -39 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 
15 15
 require_once 'vendor/autoload.php';
16 16
 
17
-if (!defined('ZPUSH_CONFIG')) define('ZPUSH_CONFIG', 'config.php');
17
+if (!defined('ZPUSH_CONFIG')) {
18
+    define('ZPUSH_CONFIG', 'config.php');
19
+}
18 20
 include_once(ZPUSH_CONFIG);
19 21
 
20 22
     // Attempt to set maximum execution time
@@ -33,8 +35,9 @@  discard block
 block discarded – undo
33 35
                         Request::GetCommand(), Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('GROMMUNIOSYNC_VERSION'), Request::GetMethod() ));
34 36
 
35 37
         // always request the authorization header
36
-        if (! Request::HasAuthenticationInfo() || !Request::GetGETUser())
37
-            throw new AuthenticationRequiredException("Access denied. Please send authorisation information");
38
+        if (! Request::HasAuthenticationInfo() || !Request::GetGETUser()) {
39
+                    throw new AuthenticationRequiredException("Access denied. Please send authorisation information");
40
+        }
38 41
 
39 42
         ZPush::CheckAdvancedConfig();
40 43
 
@@ -48,8 +51,9 @@  discard block
 block discarded – undo
48 51
         }
49 52
 
50 53
         // Check required GET parameters
51
-        if(Request::IsMethodPOST() && (Request::GetCommandCode() === false || !Request::GetDeviceID() || !Request::GetDeviceType()))
52
-            throw new FatalException("Requested the grommunio-sync URL without the required GET parameters");
54
+        if(Request::IsMethodPOST() && (Request::GetCommandCode() === false || !Request::GetDeviceID() || !Request::GetDeviceType())) {
55
+                    throw new FatalException("Requested the grommunio-sync URL without the required GET parameters");
56
+        }
53 57
 
54 58
         // Load the backend
55 59
         $backend = ZPush::GetBackend();
@@ -58,17 +62,20 @@  discard block
 block discarded – undo
58 62
         if (PROVISIONING === true && Request::IsMethodPOST() && ZPush::CommandNeedsProvisioning(Request::GetCommandCode()) &&
59 63
             ((Request::WasPolicyKeySent() && Request::GetPolicyKey() == 0) || ZPush::GetProvisioningManager()->ProvisioningRequired(Request::GetPolicyKey())) &&
60 64
             (LOOSE_PROVISIONING === false ||
61
-            (LOOSE_PROVISIONING === true && Request::WasPolicyKeySent())))
62
-            //TODO for AS 14 send a wbxml response
65
+            (LOOSE_PROVISIONING === true && Request::WasPolicyKeySent()))) {
66
+                    //TODO for AS 14 send a wbxml response
63 67
             throw new ProvisioningRequiredException();
68
+        }
64 69
 
65 70
         // most commands require an authenticated user
66
-        if (ZPush::CommandNeedsAuthentication(Request::GetCommandCode()))
67
-            RequestProcessor::Authenticate();
71
+        if (ZPush::CommandNeedsAuthentication(Request::GetCommandCode())) {
72
+                    RequestProcessor::Authenticate();
73
+        }
68 74
 
69 75
         // Do the actual processing of the request
70
-        if (Request::IsMethodGET())
71
-            throw new NoPostRequestException("This is the grommunio-sync location and can only be accessed by Microsoft ActiveSync-capable devices", NoPostRequestException::GET_REQUEST);
76
+        if (Request::IsMethodGET()) {
77
+                    throw new NoPostRequestException("This is the grommunio-sync location and can only be accessed by Microsoft ActiveSync-capable devices", NoPostRequestException::GET_REQUEST);
78
+        }
72 79
 
73 80
         // Do the actual request
74 81
         header(ZPush::GetServerHeader());
@@ -110,36 +117,35 @@  discard block
 block discarded – undo
110 117
         // data send as a 'normal' packet. If the output packet exceeds 1MB (see ob_start)
111 118
         // then it will be sent as a chunked packet anyway because PHP will have to flush
112 119
         // the buffer.
113
-        if(!headers_sent())
114
-            header("Content-Length: $len");
120
+        if(!headers_sent()) {
121
+                    header("Content-Length: $len");
122
+        }
115 123
 
116 124
         // send vnd.ms-sync.wbxml content type header if there is no content
117 125
         // otherwise text/html content type is added which might break some devices
118
-        if (!headers_sent() && $len == 0)
119
-            header("Content-Type: application/vnd.ms-sync.wbxml");
126
+        if (!headers_sent() && $len == 0) {
127
+                    header("Content-Type: application/vnd.ms-sync.wbxml");
128
+        }
120 129
 
121 130
         print $data;
122 131
 
123 132
         // destruct backend after all data is on the stream
124 133
         $backend->Logoff();
125
-    }
126
-
127
-    catch (NoPostRequestException $nopostex) {
134
+    } catch (NoPostRequestException $nopostex) {
128 135
         if ($nopostex->getCode() == NoPostRequestException::OPTIONS_REQUEST) {
129 136
             header(ZPush::GetServerHeader());
130 137
             header(ZPush::GetSupportedProtocolVersions());
131 138
             header(ZPush::GetSupportedCommands());
132 139
             ZLog::Write(LOGLEVEL_INFO, $nopostex->getMessage());
140
+        } else if ($nopostex->getCode() == NoPostRequestException::GET_REQUEST) {
141
+            if (Request::GetUserAgent()) {
142
+                            ZLog::Write(LOGLEVEL_INFO, sprintf("User-agent: '%s'", Request::GetUserAgent()));
143
+            }
144
+            if (!headers_sent() && $nopostex->showLegalNotice()) {
145
+                            ZPush::PrintGrommunioSyncLegal('GET not supported', $nopostex->getMessage());
146
+            }
133 147
         }
134
-        else if ($nopostex->getCode() == NoPostRequestException::GET_REQUEST) {
135
-            if (Request::GetUserAgent())
136
-                ZLog::Write(LOGLEVEL_INFO, sprintf("User-agent: '%s'", Request::GetUserAgent()));
137
-            if (!headers_sent() && $nopostex->showLegalNotice())
138
-                ZPush::PrintGrommunioSyncLegal('GET not supported', $nopostex->getMessage());
139
-        }
140
-    }
141
-
142
-    catch (Exception $ex) {
148
+    } catch (Exception $ex) {
143 149
         // Extract any previous exception message for logging purpose.
144 150
         $exclass = get_class($ex);
145 151
         $exception_message = $ex->getMessage();
@@ -150,20 +156,23 @@  discard block
 block discarded – undo
150 156
             } while($current_exception->getPrevious());
151 157
         }
152 158
 
153
-        if (Request::GetUserAgent())
154
-            ZLog::Write(LOGLEVEL_INFO, sprintf("User-agent: '%s'", Request::GetUserAgent()));
159
+        if (Request::GetUserAgent()) {
160
+                    ZLog::Write(LOGLEVEL_INFO, sprintf("User-agent: '%s'", Request::GetUserAgent()));
161
+        }
155 162
 
156 163
         ZLog::Write(LOGLEVEL_FATAL, sprintf('Exception: (%s) - %s', $exclass, $exception_message));
157 164
 
158 165
         if(!headers_sent()) {
159 166
             if ($ex instanceof ZPushException) {
160 167
                 header('HTTP/1.1 '. $ex->getHTTPCodeString());
161
-                foreach ($ex->getHTTPHeaders() as $h)
162
-                    header($h);
168
+                foreach ($ex->getHTTPHeaders() as $h) {
169
+                                    header($h);
170
+                }
163 171
             }
164 172
             // something really unexpected happened!
165
-            else
166
-                header('HTTP/1.1 500 Internal Server Error');
173
+            else {
174
+                            header('HTTP/1.1 500 Internal Server Error');
175
+            }
167 176
         }
168 177
 
169 178
         if ($ex instanceof AuthenticationRequiredException) {
@@ -175,8 +184,9 @@  discard block
 block discarded – undo
175 184
             }
176 185
 
177 186
             // log the failed login attempt e.g. for fail2ban
178
-            if (defined('LOGAUTHFAIL') && LOGAUTHFAIL != false)
179
-                ZLog::Write(LOGLEVEL_WARN, sprintf("IP: %s failed to authenticate user '%s'",  Request::GetRemoteAddr(), Request::GetAuthUser()? Request::GetAuthUser(): Request::GetGETUser() ));
187
+            if (defined('LOGAUTHFAIL') && LOGAUTHFAIL != false) {
188
+                            ZLog::Write(LOGLEVEL_WARN, sprintf("IP: %s failed to authenticate user '%s'",  Request::GetRemoteAddr(), Request::GetAuthUser()? Request::GetAuthUser(): Request::GetGETUser() ));
189
+            }
180 190
         }
181 191
 
182 192
         // This could be a WBXML problem.. try to get the complete request
@@ -195,16 +205,18 @@  discard block
 block discarded – undo
195 205
         }
196 206
 
197 207
         // Announce exception to process loop detection
198
-        if (ZPush::GetDeviceManager(false))
199
-            ZPush::GetDeviceManager()->AnnounceProcessException($ex);
208
+        if (ZPush::GetDeviceManager(false)) {
209
+                    ZPush::GetDeviceManager()->AnnounceProcessException($ex);
210
+        }
200 211
 
201 212
         // Announce exception if the TopCollector if available
202 213
         ZPush::GetTopCollector()->AnnounceInformation(get_class($ex), true);
203 214
     }
204 215
 
205 216
     // save device data if the DeviceManager is available
206
-    if (ZPush::GetDeviceManager(false))
207
-        ZPush::GetDeviceManager()->Save();
217
+    if (ZPush::GetDeviceManager(false)) {
218
+            ZPush::GetDeviceManager()->Save();
219
+    }
208 220
 
209 221
     // end gracefully
210 222
     ZLog::Write(LOGLEVEL_INFO,
Please login to merge, or discard this patch.