Passed
Push — master ( 34e8da...f497d2 )
by
unknown
06:10 queued 02:50
created
mapi/class.baserecurrence.php 1 patch
Switch Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1739,193 +1739,193 @@
 block discarded – undo
1739 1739
 				// Loop through the entire recurrence range of dates, and check for each occurrence whether it is in the view range.
1740 1740
 
1741 1741
 				switch ($this->recur["type"]) {
1742
-				case 10:
1743
-					// Daily
1744
-					if ($this->recur["everyn"] <= 0) {
1745
-						$this->recur["everyn"] = 1440;
1746
-					}
1747
-
1748
-					if ($this->recur["subtype"] == 0) {
1749
-						// Every Nth day
1750
-						for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * $this->recur["everyn"]) {
1751
-							$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1752
-						}
1753
-					}
1754
-					else {
1755
-						// Every workday
1756
-						for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * 1440) {
1757
-							$nowtime = $this->gmtime($now);
1758
-							if ($nowtime["tm_wday"] > 0 && $nowtime["tm_wday"] < 6) { // only add items in the given timespace
1759
-								$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1760
-							}
1761
-						}
1762
-					}
1763
-
1764
-					break;
1765
-
1766
-				case 11:
1767
-					// Weekly
1768
-					if ($this->recur["everyn"] <= 0) {
1769
-						$this->recur["everyn"] = 1;
1770
-					}
1771
-
1772
-					// If sliding flag is set then move to 'n' weeks
1773
-					if ($this->recur['regen']) {
1774
-						$daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1775
-					}
1776
-
1777
-					for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += (60 * 60 * 24 * 7 * $this->recur["everyn"])) {
1778
-						if ($this->recur['regen']) {
1779
-							$this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1780
-						}
1781
-						else {
1782
-							// Loop through the whole following week to the first occurrence of the week, add each day that is specified
1783
-							for ($wday = 0; $wday < 7; ++$wday) {
1784
-								$daynow = $now + $wday * 60 * 60 * 24;
1785
-								// checks weather the next coming day in recurring pattern is less than or equal to end day of the recurring item
1786
-								if ($daynow <= $dayend) {
1787
-									$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1788
-									if (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"]))) { // Selected ?
1789
-										$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1790
-									}
1791
-								}
1792
-							}
1793
-						}
1794
-					}
1795
-
1796
-					break;
1797
-
1798
-				case 12:
1799
-					// Monthly
1800
-					if ($this->recur["everyn"] <= 0) {
1801
-						$this->recur["everyn"] = 1;
1802
-					}
1803
-
1804
-					// Loop through all months from start to end of occurrence, starting at beginning of first month
1805
-					for ($now = $this->monthStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1806
-						if (isset($this->recur["monthday"]) && ($this->recur['monthday'] != "undefined") && !$this->recur['regen']) { // Day M of every N months
1807
-							$difference = 1;
1808
-							if ($this->daysInMonth($now, $this->recur["everyn"]) < $this->recur["monthday"]) {
1809
-								$difference = $this->recur["monthday"] - $this->daysInMonth($now, $this->recur["everyn"]) + 1;
1810
-							}
1811
-							$daynow = $now + (($this->recur["monthday"] - $difference) * 24 * 60 * 60);
1812
-							// checks weather the next coming day in recurrence pattern is less than or equal to end day of the recurring item
1813
-							if ($daynow <= $dayend) {
1814
-								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1815
-							}
1816
-						}
1817
-						elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1818
-							// Sanitize input
1819
-							if ($this->recur["weekdays"] == 0) {
1820
-								$this->recur["weekdays"] = 1;
1821
-							}
1822
-
1823
-							// If nday is not set to the last day in the month
1824
-							if ($this->recur["nday"] < 5) {
1825
-								// keep the track of no. of time correct selection pattern(like 2nd weekday, 4th fiday, etc.)is matched
1826
-								$ndaycounter = 0;
1827
-								// Find matching weekday in this month
1828
-								for ($day = 0, $total = $this->daysInMonth($now, 1); $day < $total; ++$day) {
1829
-									$daynow = $now + $day * 60 * 60 * 24;
1830
-									$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1831
-
1832
-									if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1833
-										++$ndaycounter;
1834
-									}
1835
-									// check the selected pattern is same as asked Nth weekday,If so set the firstday
1836
-									if ($this->recur["nday"] == $ndaycounter) {
1837
-										$firstday = $day;
1838
-
1839
-										break;
1840
-									}
1841
-								}
1842
-								// $firstday is the day of the month on which the asked pattern of nth weekday matches
1843
-								$daynow = $now + $firstday * 60 * 60 * 24;
1844
-							}
1845
-							else {
1846
-								// Find last day in the month ($now is the firstday of the month)
1847
-								$NumDaysInMonth = $this->daysInMonth($now, 1);
1848
-								$daynow = $now + (($NumDaysInMonth - 1) * 24 * 60 * 60);
1849
-
1850
-								$nowtime = $this->gmtime($daynow);
1851
-								while (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) == 0) {
1852
-									$daynow -= 86400;
1853
-									$nowtime = $this->gmtime($daynow);
1854
-								}
1855
-							}
1856
-
1857
-							/*
1742
+				    case 10:
1743
+					    // Daily
1744
+					    if ($this->recur["everyn"] <= 0) {
1745
+						    $this->recur["everyn"] = 1440;
1746
+					    }
1747
+
1748
+					    if ($this->recur["subtype"] == 0) {
1749
+						    // Every Nth day
1750
+						    for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * $this->recur["everyn"]) {
1751
+							    $this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1752
+						    }
1753
+					    }
1754
+					    else {
1755
+						    // Every workday
1756
+						    for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += 60 * 1440) {
1757
+							    $nowtime = $this->gmtime($now);
1758
+							    if ($nowtime["tm_wday"] > 0 && $nowtime["tm_wday"] < 6) { // only add items in the given timespace
1759
+								    $this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1760
+							    }
1761
+						    }
1762
+					    }
1763
+
1764
+					    break;
1765
+
1766
+				    case 11:
1767
+					    // Weekly
1768
+					    if ($this->recur["everyn"] <= 0) {
1769
+						    $this->recur["everyn"] = 1;
1770
+					    }
1771
+
1772
+					    // If sliding flag is set then move to 'n' weeks
1773
+					    if ($this->recur['regen']) {
1774
+						    $daystart += (60 * 60 * 24 * 7 * $this->recur["everyn"]);
1775
+					    }
1776
+
1777
+					    for ($now = $daystart; $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += (60 * 60 * 24 * 7 * $this->recur["everyn"])) {
1778
+						    if ($this->recur['regen']) {
1779
+							    $this->processOccurrenceItem($items, $start, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1780
+						    }
1781
+						    else {
1782
+							    // Loop through the whole following week to the first occurrence of the week, add each day that is specified
1783
+							    for ($wday = 0; $wday < 7; ++$wday) {
1784
+								    $daynow = $now + $wday * 60 * 60 * 24;
1785
+								    // checks weather the next coming day in recurring pattern is less than or equal to end day of the recurring item
1786
+								    if ($daynow <= $dayend) {
1787
+									    $nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1788
+									    if (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"]))) { // Selected ?
1789
+										    $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1790
+									    }
1791
+								    }
1792
+							    }
1793
+						    }
1794
+					    }
1795
+
1796
+					    break;
1797
+
1798
+				    case 12:
1799
+					    // Monthly
1800
+					    if ($this->recur["everyn"] <= 0) {
1801
+						    $this->recur["everyn"] = 1;
1802
+					    }
1803
+
1804
+					    // Loop through all months from start to end of occurrence, starting at beginning of first month
1805
+					    for ($now = $this->monthStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1806
+						    if (isset($this->recur["monthday"]) && ($this->recur['monthday'] != "undefined") && !$this->recur['regen']) { // Day M of every N months
1807
+							    $difference = 1;
1808
+							    if ($this->daysInMonth($now, $this->recur["everyn"]) < $this->recur["monthday"]) {
1809
+								    $difference = $this->recur["monthday"] - $this->daysInMonth($now, $this->recur["everyn"]) + 1;
1810
+							    }
1811
+							    $daynow = $now + (($this->recur["monthday"] - $difference) * 24 * 60 * 60);
1812
+							    // checks weather the next coming day in recurrence pattern is less than or equal to end day of the recurring item
1813
+							    if ($daynow <= $dayend) {
1814
+								    $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1815
+							    }
1816
+						    }
1817
+						    elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] of every N months
1818
+							    // Sanitize input
1819
+							    if ($this->recur["weekdays"] == 0) {
1820
+								    $this->recur["weekdays"] = 1;
1821
+							    }
1822
+
1823
+							    // If nday is not set to the last day in the month
1824
+							    if ($this->recur["nday"] < 5) {
1825
+								    // keep the track of no. of time correct selection pattern(like 2nd weekday, 4th fiday, etc.)is matched
1826
+								    $ndaycounter = 0;
1827
+								    // Find matching weekday in this month
1828
+								    for ($day = 0, $total = $this->daysInMonth($now, 1); $day < $total; ++$day) {
1829
+									    $daynow = $now + $day * 60 * 60 * 24;
1830
+									    $nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1831
+
1832
+									    if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1833
+										    ++$ndaycounter;
1834
+									    }
1835
+									    // check the selected pattern is same as asked Nth weekday,If so set the firstday
1836
+									    if ($this->recur["nday"] == $ndaycounter) {
1837
+										    $firstday = $day;
1838
+
1839
+										    break;
1840
+									    }
1841
+								    }
1842
+								    // $firstday is the day of the month on which the asked pattern of nth weekday matches
1843
+								    $daynow = $now + $firstday * 60 * 60 * 24;
1844
+							    }
1845
+							    else {
1846
+								    // Find last day in the month ($now is the firstday of the month)
1847
+								    $NumDaysInMonth = $this->daysInMonth($now, 1);
1848
+								    $daynow = $now + (($NumDaysInMonth - 1) * 24 * 60 * 60);
1849
+
1850
+								    $nowtime = $this->gmtime($daynow);
1851
+								    while (($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) == 0) {
1852
+									    $daynow -= 86400;
1853
+									    $nowtime = $this->gmtime($daynow);
1854
+								    }
1855
+							    }
1856
+
1857
+							    /*
1858 1858
 							 * checks weather the next coming day in recurrence pattern is less than or equal to end day of the            * recurring item.Also check weather the coming day in recurrence pattern is greater than or equal to start * of recurring pattern, so that appointment that fall under the recurrence range are only displayed.
1859 1859
 							 */
1860
-							if ($daynow <= $dayend && $daynow >= $daystart) {
1861
-								$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1862
-							}
1863
-						}
1864
-						elseif ($this->recur['regen']) {
1865
-							$next_month_start = $now + ($this->daysInMonth($now, 1) * 24 * 60 * 60);
1866
-							$now = $daystart + ($this->daysInMonth($next_month_start, $this->recur['everyn']) * 24 * 60 * 60);
1867
-
1868
-							if ($now <= $dayend) {
1869
-								$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1870
-							}
1871
-						}
1872
-					}
1873
-
1874
-					break;
1875
-
1876
-				case 13:
1877
-					// Yearly
1878
-					if ($this->recur["everyn"] <= 0) {
1879
-						$this->recur["everyn"] = 12;
1880
-					}
1881
-
1882
-					for ($now = $this->yearStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1883
-						if (isset($this->recur["monthday"]) && !$this->recur['regen']) { // same as monthly, but in a specific month
1884
-							// recur["month"] is in minutes since the beginning of the year
1885
-							$month = $this->monthOfYear($this->recur["month"]); // $month is now month of year [0..11]
1886
-							$monthday = $this->recur["monthday"]; // $monthday is day of the month [1..31]
1887
-							$monthstart = $now + $this->daysInMonth($now, $month) * 24 * 60 * 60; // $monthstart is the timestamp of the beginning of the month
1888
-							if ($monthday > $this->daysInMonth($monthstart, 1)) {
1889
-								$monthday = $this->daysInMonth($monthstart, 1);
1890
-							}    // Cap $monthday on month length (eg 28 feb instead of 29 feb)
1891
-							$daynow = $monthstart + ($monthday - 1) * 24 * 60 * 60;
1892
-							$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1893
-						}
1894
-						elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1895
-							// Go the correct month
1896
-							$monthnow = $now + $this->daysInMonth($now, $this->monthOfYear($this->recur["month"])) * 24 * 60 * 60;
1897
-
1898
-							// Find first matching weekday in this month
1899
-							for ($wday = 0; $wday < 7; ++$wday) {
1900
-								$daynow = $monthnow + $wday * 60 * 60 * 24;
1901
-								$nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1902
-
1903
-								if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1904
-									$firstday = $wday;
1905
-
1906
-									break;
1907
-								}
1908
-							}
1909
-
1910
-							// Same as above (monthly)
1911
-							$daynow = $monthnow + ($firstday + ($this->recur["nday"] - 1) * 7) * 60 * 60 * 24;
1912
-
1913
-							while ($this->monthStartOf($daynow) != $this->monthStartOf($monthnow)) {
1914
-								$daynow -= 7 * 60 * 60 * 24;
1915
-							}
1916
-
1917
-							$this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1918
-						}
1919
-						elseif ($this->recur['regen']) {
1920
-							$year_starttime = $this->gmtime($now);
1921
-							$is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1);    // +1 next year
1922
-							$now = $daystart + ($is_next_leapyear ? 31622400 /* Leap year in seconds */ : 31536000 /* year in seconds */);
1923
-
1924
-							if ($now <= $dayend) {
1925
-								$this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1926
-							}
1927
-						}
1928
-					}
1860
+							    if ($daynow <= $dayend && $daynow >= $daystart) {
1861
+								    $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1862
+							    }
1863
+						    }
1864
+						    elseif ($this->recur['regen']) {
1865
+							    $next_month_start = $now + ($this->daysInMonth($now, 1) * 24 * 60 * 60);
1866
+							    $now = $daystart + ($this->daysInMonth($next_month_start, $this->recur['everyn']) * 24 * 60 * 60);
1867
+
1868
+							    if ($now <= $dayend) {
1869
+								    $this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1870
+							    }
1871
+						    }
1872
+					    }
1873
+
1874
+					    break;
1875
+
1876
+				    case 13:
1877
+					    // Yearly
1878
+					    if ($this->recur["everyn"] <= 0) {
1879
+						    $this->recur["everyn"] = 12;
1880
+					    }
1881
+
1882
+					    for ($now = $this->yearStartOf($daystart); $now <= $dayend && ($limit == 0 || count($items) < $limit); $now += $this->daysInMonth($now, $this->recur["everyn"]) * 24 * 60 * 60) {
1883
+						    if (isset($this->recur["monthday"]) && !$this->recur['regen']) { // same as monthly, but in a specific month
1884
+							    // recur["month"] is in minutes since the beginning of the year
1885
+							    $month = $this->monthOfYear($this->recur["month"]); // $month is now month of year [0..11]
1886
+							    $monthday = $this->recur["monthday"]; // $monthday is day of the month [1..31]
1887
+							    $monthstart = $now + $this->daysInMonth($now, $month) * 24 * 60 * 60; // $monthstart is the timestamp of the beginning of the month
1888
+							    if ($monthday > $this->daysInMonth($monthstart, 1)) {
1889
+								    $monthday = $this->daysInMonth($monthstart, 1);
1890
+							    }    // Cap $monthday on month length (eg 28 feb instead of 29 feb)
1891
+							    $daynow = $monthstart + ($monthday - 1) * 24 * 60 * 60;
1892
+							    $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1893
+						    }
1894
+						    elseif (isset($this->recur["nday"], $this->recur["weekdays"])) { // Nth [weekday] in month X of every N years
1895
+							    // Go the correct month
1896
+							    $monthnow = $now + $this->daysInMonth($now, $this->monthOfYear($this->recur["month"])) * 24 * 60 * 60;
1897
+
1898
+							    // Find first matching weekday in this month
1899
+							    for ($wday = 0; $wday < 7; ++$wday) {
1900
+								    $daynow = $monthnow + $wday * 60 * 60 * 24;
1901
+								    $nowtime = $this->gmtime($daynow); // Get the weekday of the current day
1902
+
1903
+								    if ($this->recur["weekdays"] & (1 << $nowtime["tm_wday"])) { // Selected ?
1904
+									    $firstday = $wday;
1905
+
1906
+									    break;
1907
+								    }
1908
+							    }
1909
+
1910
+							    // Same as above (monthly)
1911
+							    $daynow = $monthnow + ($firstday + ($this->recur["nday"] - 1) * 7) * 60 * 60 * 24;
1912
+
1913
+							    while ($this->monthStartOf($daynow) != $this->monthStartOf($monthnow)) {
1914
+								    $daynow -= 7 * 60 * 60 * 24;
1915
+							    }
1916
+
1917
+							    $this->processOccurrenceItem($items, $start, $end, $daynow, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1918
+						    }
1919
+						    elseif ($this->recur['regen']) {
1920
+							    $year_starttime = $this->gmtime($now);
1921
+							    $is_next_leapyear = $this->isLeapYear($year_starttime['tm_year'] + 1900 + 1);    // +1 next year
1922
+							    $now = $daystart + ($is_next_leapyear ? 31622400 /* Leap year in seconds */ : 31536000 /* year in seconds */);
1923
+
1924
+							    if ($now <= $dayend) {
1925
+								    $this->processOccurrenceItem($items, $daystart, $end, $now, $this->recur["startocc"], $this->recur["endocc"], $this->tz, $remindersonly);
1926
+							    }
1927
+						    }
1928
+					    }
1929 1929
 				}
1930 1930
 				// to get all exception items
1931 1931
 				if (!empty($this->recur['changed_occurrences'])) {
Please login to merge, or discard this patch.
lib/utils/g_RFC822.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -410,22 +410,22 @@
 block discarded – undo
410 410
 
411 411
 		for (; $i < $iMax; ++$i) {
412 412
 			switch ($string[$i]) {
413
-			case '\\':
414
-				++$slashes;
413
+			    case '\\':
414
+				    ++$slashes;
415 415
 
416
-				break;
416
+				    break;
417 417
 
418
-			case '"':
419
-				if ($slashes % 2 == 0) {
420
-					$in_quote = !$in_quote;
421
-				}
422
-				// Fall through to default action below.
418
+			    case '"':
419
+				    if ($slashes % 2 == 0) {
420
+					    $in_quote = !$in_quote;
421
+				    }
422
+				    // Fall through to default action below.
423 423
 
424
-				// no break
425
-			default:
426
-				$slashes = 0;
424
+				    // no break
425
+			    default:
426
+				    $slashes = 0;
427 427
 
428
-				break;
428
+				    break;
429 429
 			}
430 430
 		}
431 431
 
Please login to merge, or discard this patch.