PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/phpical2/functions/end_vevent.php

https://gitlab.com/endomorphosis/fusenews
PHP | 663 lines | 553 code | 41 blank | 69 comment | 180 complexity | 201bc02f92241fba5e5345563260419d MD5 | raw file
  1. <?php
  2. /* end_vevent.php
  3. What happens in this file:
  4. 1. Initialization
  5. 2.
  6. */
  7. if (!isset($url)) $url = '';
  8. if (!isset($type)) $type = '';
  9. // Handle DURATION
  10. if (!isset($end_unixtime)) {
  11. if(!isset($the_duration)) $the_duration = 0;
  12. $end_unixtime = $start_unixtime + $the_duration;
  13. $end_time = date ('Hi', $end_unixtime);
  14. }
  15. // CLASS support
  16. if (isset($class)) {
  17. if ($class == 'PRIVATE') {
  18. $summary ='**PRIVATE**';
  19. $description ='**PRIVATE**';
  20. } elseif ($class == 'CONFIDENTIAL') {
  21. $summary ='**CONFIDENTIAL**';
  22. $description ='**CONFIDENTIAL**';
  23. }
  24. }
  25. // make sure we have some value for $uid
  26. if (!isset($uid)) {
  27. $uid = $uid_counter;
  28. $uid_counter++;
  29. $uid_valid = false;
  30. } else {
  31. $uid_valid = true;
  32. }
  33. if (!isset($summary)) $summary = '';
  34. if (!isset($description)) $description = '';
  35. if (!isset($status)) $status = '';
  36. if (!isset($class)) $class = '';
  37. if (!isset($location)) $location = '';
  38. # set bounds on master_array
  39. # mktime int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
  40. $start_month = $this_month - 1;
  41. $start_year = $this_year;
  42. $end_month = $this_month + 1;
  43. $end_year = $this_year;
  44. if ($this_month == 1){
  45. $start_month = 12;
  46. $start_year--;
  47. }
  48. if ($this_month == 12){
  49. $end_month = 1;
  50. $end_year++;
  51. }
  52. switch ($current_view){
  53. case 'month':
  54. case 'week':
  55. case 'day':
  56. $mArray_begin = mktime (0,0,0,$start_month,21,($start_year));
  57. $mArray_end = mktime (0,0,0,$end_month,12,($end_year));
  58. break;
  59. default:
  60. $mArray_begin = mktime (0,0,0,12,21,($this_year - 1));
  61. $mArray_end = mktime (0,0,0,1,12,($this_year + 1));
  62. }
  63. # adjust event start and end times
  64. if (isset($start_time) && isset($end_time)) {
  65. // Mozilla style all-day events or just really long events
  66. if (($end_time - $start_time) > 2345) {
  67. $allday_start = $start_date;
  68. $allday_end = ($start_date + 1);
  69. }
  70. }
  71. # look for events that span more than one day
  72. if (isset($start_unixtime,$end_unixtime) && date('Ymd',$start_unixtime) != date('Ymd',$end_unixtime)) {
  73. $spans_day = true;
  74. $bleed_check = (($start_unixtime - $end_unixtime) < (60*60*24)) ? '-1' : '0';
  75. } else {
  76. $spans_day = false;
  77. $bleed_check = 0;
  78. }
  79. # get hour and minute adjusted to allowed grid times
  80. if (isset($start_time) && $start_time != '') {
  81. preg_match ('/([0-9]{2})([0-9]{2})/', $start_time, $time);
  82. preg_match ('/([0-9]{2})([0-9]{2})/', $end_time, $time2);
  83. if (isset($start_unixtime) && isset($end_unixtime)) {
  84. $length = $end_unixtime - $start_unixtime;
  85. } else {
  86. $length = ($time2[1]*60+$time2[2]) - ($time[1]*60+$time[2]);
  87. }
  88. $drawKey = drawEventTimes($start_time, $end_time);
  89. preg_match ('/([0-9]{2})([0-9]{2})/', $drawKey['draw_start'], $time3);
  90. $hour = $time3[1];
  91. $minute = $time3[2];
  92. }
  93. // RECURRENCE-ID Support
  94. if (isset($recurrence_d)) {
  95. $recurrence_delete["$recurrence_d"]["$recurrence_t"] = $uid;
  96. }
  97. # treat nonrepeating events as rrule events with one instance
  98. if (!isset($rrule_array) && $start_unixtime < $mArray_end && $end_unixtime > $mArray_begin){
  99. $rrule_array['FREQ'] = 'YEARLY';
  100. $rrule_array['START_DATE'] = $start_date;
  101. $rrule_array['UNTIL'] = $start_date;
  102. $rrule_array['END'] = 'end';
  103. }
  104. if (isset($allday_start) && $allday_start != '') {
  105. $hour = '-';
  106. $minute = '1';
  107. $rrule_array['START_DAY'] = $allday_start;
  108. # $rrule_array['END_DAY'] = $allday_end; # this doesn't seem to be used anywhere.
  109. $rrule_array['END'] = 'end';
  110. $recur_start = $allday_start;
  111. $start_date = $allday_start;
  112. if (isset($allday_end)) {
  113. $diff_allday_days = dayCompare($allday_end, $allday_start);
  114. } else {
  115. $diff_allday_days = 1;
  116. }
  117. } else {
  118. $rrule_array['START_DATE'] = $start_date;
  119. $rrule_array['START_TIME'] = $start_time;
  120. $rrule_array['END_TIME'] = $end_time;
  121. $rrule_array['END'] = 'end';
  122. }
  123. $start_date_time = strtotime($start_date);
  124. if (!isset($fromdate)){
  125. #this should happen if not in one of the rss views
  126. $this_month_start_time = strtotime($this_year.$this_month.'01');
  127. if ($current_view == 'year' || ($save_parsed_cals == 'yes' && !$is_webcal)|| $current_view == 'print' && $printview == 'year') {
  128. $start_range_time = strtotime($this_year.'-01-01 -2 weeks');
  129. $end_range_time = strtotime($this_year.'-12-31 +2 weeks');
  130. } else {
  131. $start_range_time = strtotime('-1 month -2 day', $this_month_start_time);
  132. $end_range_time = strtotime('+2 month +2 day', $this_month_start_time);
  133. }
  134. }else{
  135. $start_range_time = strtotime($fromdate);
  136. $end_range_time = strtotime($todate)+60*60*24;
  137. }
  138. $freq_type = 'year';
  139. foreach ($rrule_array as $key => $val) {
  140. switch($key) {
  141. case 'FREQ':
  142. switch ($val) {
  143. case 'YEARLY': $freq_type = 'year'; break;
  144. case 'MONTHLY': $freq_type = 'month'; break;
  145. case 'WEEKLY': $freq_type = 'week'; break;
  146. case 'DAILY': $freq_type = 'day'; break;
  147. case 'HOURLY': $freq_type = 'hour'; break;
  148. case 'MINUTELY': $freq_type = 'minute'; break;
  149. case 'SECONDLY': $freq_type = 'second'; break;
  150. }
  151. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = strtolower($val);
  152. break;
  153. case 'COUNT':
  154. $count = $val;
  155. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $count;
  156. break;
  157. case 'UNTIL':
  158. $until = str_replace('T', '', $val);
  159. $until = str_replace('Z', '', $until);
  160. if (strlen($until) == 8) $until = $until.'235959';
  161. $abs_until = $until;
  162. ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs);
  163. $until = mktime($regs[4],$regs[5],$regs[6],$regs[2],$regs[3],$regs[1]);
  164. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until);
  165. break;
  166. case 'INTERVAL':
  167. if ($val > 0){
  168. $number = $val;
  169. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $number;
  170. }
  171. break;
  172. case 'BYSECOND':
  173. $bysecond = $val;
  174. $bysecond = split (',', $bysecond);
  175. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond;
  176. break;
  177. case 'BYMINUTE':
  178. $byminute = $val;
  179. $byminute = split (',', $byminute);
  180. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute;
  181. break;
  182. case 'BYHOUR':
  183. $byhour = $val;
  184. $byhour = split (',', $byhour);
  185. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour;
  186. break;
  187. case 'BYDAY':
  188. $byday = $val;
  189. $byday = split (',', $byday);
  190. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday;
  191. break;
  192. case 'BYMONTHDAY':
  193. $bymonthday = $val;
  194. $bymonthday = split (',', $bymonthday);
  195. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday;
  196. break;
  197. case 'BYYEARDAY':
  198. $byyearday = $val;
  199. $byyearday = split (',', $byyearday);
  200. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday;
  201. break;
  202. case 'BYWEEKNO':
  203. $byweekno = $val;
  204. $byweekno = split (',', $byweekno);
  205. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno;
  206. break;
  207. case 'BYMONTH':
  208. $bymonth = $val;
  209. $bymonth = split (',', $bymonth);
  210. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth;
  211. break;
  212. case 'BYSETPOS':
  213. $bysetpos = $val;
  214. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos;
  215. break;
  216. case 'WKST':
  217. $wkst = $val;
  218. $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $wkst;
  219. break;
  220. case 'END':
  221. $recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur'];
  222. // Modify the COUNT based on BYDAY
  223. if ((isset ($byday) && is_array($byday)) && (isset($count))) {
  224. $blah = sizeof($byday);
  225. $count = ($count / $blah);
  226. unset ($blah);
  227. }
  228. if (!isset($number)) $number = 1;
  229. // if $until isn't set yet, we set it to the end of our range we're looking at
  230. if (!isset($until)) $until = $end_range_time;
  231. if (!isset($abs_until)) $abs_until = date('YmdHis', $end_range_time);
  232. $end_date_time = $until;
  233. $start_range_time_tmp = $start_range_time;
  234. $end_range_time_tmp = $end_range_time;
  235. // If the $end_range_time is less than the $start_date_time, or $start_range_time is greater
  236. // than $end_date_time, we may as well forget the whole thing
  237. // It doesn't do us any good to spend time adding data we aren't even looking at
  238. // this will prevent the year view from taking way longer than it needs to
  239. if ($end_range_time_tmp >= $start_date_time && $start_range_time_tmp <= $end_date_time) {
  240. // if the beginning of our range is less than the start of the item, we may as well set it equal to it
  241. if ($start_range_time_tmp < $start_date_time){
  242. $start_range_time_tmp = $start_date_time;
  243. }
  244. if ($end_range_time_tmp > $end_date_time) $end_range_time_tmp = $end_date_time;
  245. // initialize the time we will increment
  246. $next_range_time = $start_range_time_tmp;
  247. // FIXME: This is a hack to fix repetitions with $interval > 1
  248. if ($count > 1 && $number > 1) $count = 1 + ($count - 1) * $number;
  249. $count_to = 0;
  250. // start at the $start_range and go until we hit the end of our range.
  251. if(!isset($wkst)) $wkst='SU';
  252. $wkst3char = two2threeCharDays($wkst);
  253. # set first instance if it's in range
  254. if ($start_unixtime < $mArray_end && $end_unixtime > $mArray_begin){
  255. $recur_data[] = $start_unixtime;
  256. }
  257. while (($next_range_time >= $start_range_time_tmp) && ($next_range_time <= $end_range_time_tmp) && ($count_to != $count)) {
  258. $func = $freq_type.'Compare';
  259. $diff = $func(date('Ymd',$next_range_time), $start_date);
  260. if ($diff < $count) {
  261. if ($diff % $number == 0) {
  262. $interval = $number;
  263. switch ($rrule_array['FREQ']) {
  264. case 'DAILY':
  265. $next_date_time = $next_range_time;
  266. $recur_data[] = $next_date_time;
  267. break;
  268. case 'WEEKLY':
  269. // Populate $byday with the default day if it's not set.
  270. if (!isset($byday)) {
  271. $byday[] = strtoupper(substr(date('D', $start_date_time), 0, 2));
  272. }
  273. if (is_array($byday)) {
  274. foreach($byday as $day) {
  275. $day = two2threeCharDays($day);
  276. #need to find the first day of the appropriate week.
  277. #dateOfweek uses weekstartday as a global variable. This has to be changed to $wkst,
  278. #but then needs to be reset for other functions
  279. $week_start_day_tmp = $week_start_day;
  280. $week_start_day = $wkst3char;
  281. $the_sunday = dateOfWeek(date("Ymd",$next_range_time), $wkst3char);
  282. $next_date_time = strtotime($day,strtotime($the_sunday)) + (12 * 60 * 60);
  283. $week_start_day = $week_start_day_tmp; #see above reset to global value
  284. #reset $next_range_time to first instance in this week.
  285. if ($next_date_time < $next_range_time){
  286. $next_range_time = $next_date_time;
  287. }
  288. // Since this renders events from $next_range_time to $next_range_time + 1 week, I need to handle intervals
  289. // as well. This checks to see if $next_date_time is after $day_start (i.e., "next week"), and thus
  290. // if we need to add $interval weeks to $next_date_time.
  291. if ($next_date_time > strtotime($week_start_day, $next_range_time) && $interval > 1) {
  292. # $next_date_time = strtotime('+'.($interval - 1).' '.$freq_type, $next_date_time);
  293. }
  294. $recur_data[] = $next_date_time;
  295. }
  296. }
  297. break;
  298. case 'MONTHLY':
  299. if (empty($bymonth)) $bymonth = array(1,2,3,4,5,6,7,8,9,10,11,12);
  300. $next_range_time = strtotime(date('Y-m-01', $next_range_time));
  301. $next_date_time = $next_date_time;
  302. if (isset($bysetpos)){
  303. /* bysetpos code from dustinbutler
  304. start on day 1 or last day.
  305. if day matches any BYDAY the count is incremented.
  306. SETPOS = 4, need 4th match
  307. SETPOS = -1, need 1st match
  308. */
  309. $year = date('Y', $next_range_time);
  310. $month = date('m', $next_range_time);
  311. if ($bysetpos > 0) {
  312. $next_day = '+1 day';
  313. $day = 1;
  314. } else {
  315. $next_day = '-1 day';
  316. $day = $totalDays[$month];
  317. }
  318. $day = mktime(0, 0, 0, $month, $day, $year);
  319. $countMatch = 0;
  320. while ($countMatch != abs($bysetpos)) {
  321. /* Does this day match a BYDAY value? */
  322. $thisDay = $day;
  323. $textDay = strtoupper(substr(date('D', $thisDay), 0, 2));
  324. if (in_array($textDay, $byday)) {
  325. $countMatch++;
  326. }
  327. $day = strtotime($next_day, $thisDay);
  328. }
  329. $recur_data[] = $thisDay;
  330. }elseif ((isset($bymonthday)) && (!isset($byday))) {
  331. foreach($bymonthday as $day) {
  332. if ($day < 0) $day = ((date('t', $next_range_time)) + ($day)) + 1;
  333. $year = date('Y', $next_range_time);
  334. $month = date('m', $next_range_time);
  335. if (checkdate($month,$day,$year)) {
  336. $next_date_time = mktime(0,0,0,$month,$day,$year);
  337. $recur_data[] = $next_date_time;
  338. }
  339. }
  340. } elseif (is_array($byday)) {
  341. foreach($byday as $day) {
  342. ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
  343. //Added for 2.0 when no modifier is set
  344. if ($byday_arr[2] != '') {
  345. $nth = $byday_arr[2]-1;
  346. } else {
  347. $nth = 0;
  348. }
  349. $on_day = two2threeCharDays($byday_arr[3]);
  350. $on_day_num = two2threeCharDays($byday_arr[3],false);
  351. if ((isset($byday_arr[1])) && ($byday_arr[1] == '-')) {
  352. $last_day_tmp = date('t',$next_range_time);
  353. $next_range_time = strtotime(date('Y-m-'.$last_day_tmp, $next_range_time));
  354. $last_tmp = (date('w',$next_range_time) == $on_day_num) ? '' : 'last ';
  355. $next_date_time = strtotime($last_tmp.$on_day, $next_range_time) - ($nth * 604800);
  356. $month = date('m', $next_date_time);
  357. if (in_array($month, $bymonth)) {
  358. $recur_data[] = $next_date_time;
  359. }
  360. #reset next_range_time to start of month
  361. $next_range_time = strtotime(date('Y-m-'.'1', $next_range_time));
  362. } elseif (isset($bymonthday) && (!empty($bymonthday))) {
  363. // This supports MONTHLY where BYDAY and BYMONTH are both set
  364. foreach($bymonthday as $day) {
  365. $year = date('Y', $next_range_time);
  366. $month = date('m', $next_range_time);
  367. if (checkdate($month,$day,$year)) {
  368. $next_date_time = mktime(0,0,0,$month,$day,$year);
  369. $daday = strtolower(strftime("%a", $next_date_time));
  370. if ($daday == $on_day && in_array($month, $bymonth)) {
  371. $recur_data[] = $next_date_time;
  372. }
  373. }
  374. }
  375. } elseif ((isset($byday_arr[1])) && ($byday_arr[1] != '-')) {
  376. $next_date_time = strtotime($on_day, strtotime($on_day, $next_range_time) + $nth * 604800);
  377. $month = date('m', $next_date_time);
  378. if (in_array($month, $bymonth)) {
  379. if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time;
  380. }
  381. }
  382. $next_date = date('Ymd', $next_date_time);
  383. }
  384. }
  385. break;
  386. case 'YEARLY':
  387. if ((!isset($bymonth)) || (sizeof($bymonth) == 0)) {
  388. $m = date('m', $start_date_time);
  389. $bymonth = array("$m");
  390. }
  391. foreach($bymonth as $month) {
  392. // Make sure the month & year used is within the start/end_range.
  393. if ($month < date('m', $next_range_time)) {
  394. $year = date('Y', $next_range_time);
  395. } else {
  396. $year = date('Y', $next_range_time);
  397. }
  398. if (isset($bysetpos)){
  399. /* bysetpos code from dustinbutler
  400. start on day 1 or last day.
  401. if day matches any BYDAY the count is incremented.
  402. SETPOS = 4, need 4th match
  403. SETPOS = -1, need 1st match
  404. */
  405. if ($bysetpos > 0) {
  406. $next_day = '+1 day';
  407. $day = 1;
  408. } else {
  409. $next_day = '-1 day';
  410. $day = date("t",$month);
  411. }
  412. $day = mktime(12, 0, 0, $month, $day, $year);
  413. $countMatch = 0;
  414. while ($countMatch != abs($bysetpos)) {
  415. /* Does this day match a BYDAY value? */
  416. $thisDay = $day;
  417. $textDay = strtoupper(substr(date('D', $thisDay), 0, 2));
  418. if (in_array($textDay, $byday)) {
  419. $countMatch++;
  420. }
  421. $day = strtotime($next_day, $thisDay);
  422. }
  423. $recur_data[] = $thisDay;
  424. }
  425. if ((isset($byday)) && (is_array($byday))) {
  426. $checkdate_time = mktime(0,0,0,$month,1,$year);
  427. foreach($byday as $day) {
  428. ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
  429. if ($byday_arr[2] != '') {
  430. $nth = $byday_arr[2]-1;
  431. } else {
  432. $nth = 0;
  433. }
  434. $on_day = two2threeCharDays($byday_arr[3]);
  435. $on_day_num = two2threeCharDays($byday_arr[3],false);
  436. if ($byday_arr[1] == '-') {
  437. $last_day_tmp = date('t',$checkdate_time);
  438. $checkdate_time = strtotime(date('Y-m-'.$last_day_tmp, $checkdate_time));
  439. $last_tmp = (date('w',$checkdate_time) == $on_day_num) ? '' : 'last ';
  440. $next_date_time = strtotime($last_tmp.$on_day.' -'.$nth.' week', $checkdate_time);
  441. } else {
  442. $next_date_time = strtotime($on_day.' +'.$nth.' week', $checkdate_time);
  443. }
  444. }
  445. } else {
  446. $day = date('d', $start_date_time);
  447. $next_date_time = mktime(0,0,0,$month,$day,$year+1);
  448. //echo date('Ymd',$next_date_time).$summary.'<br>';
  449. }
  450. if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time;
  451. }
  452. if (isset($byyearday)) {
  453. foreach ($byyearday as $yearday) {
  454. ereg ('([-\+]{0,1})?([0-9]{1,3})', $yearday, $byyearday_arr);
  455. if ($byyearday_arr[1] == '-') {
  456. $ydtime = mktime(0,0,0,12,31,$this_year);
  457. $yearnum = $byyearday_arr[2] - 1;
  458. $next_date_time = strtotime('-'.$yearnum.' days', $ydtime);
  459. } else {
  460. $ydtime = mktime(0,0,0,1,1,$this_year);
  461. $yearnum = $byyearday_arr[2] - 1;
  462. $next_date_time = strtotime('+'.$yearnum.' days', $ydtime);
  463. }
  464. if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time;
  465. }
  466. }
  467. break;
  468. default:
  469. // anything else we need to end the loop
  470. $next_range_time = $end_range_time_tmp + 100;
  471. $count_to = $count;
  472. }
  473. } else {
  474. $interval = 1;
  475. }
  476. $next_range_time = strtotime('+'.$interval.' '.$freq_type, $next_range_time);
  477. } else {
  478. // end the loop because we aren't going to write this event anyway
  479. $count_to = $count;
  480. }
  481. // use the same code to write the data instead of always changing it 5 times
  482. if (isset($recur_data) && is_array($recur_data)) {
  483. $recur_data_hour = @substr($start_time,0,2);
  484. $recur_data_minute = @substr($start_time,2,2);
  485. foreach($recur_data as $recur_data_time) {
  486. $recur_data_year = date('Y', $recur_data_time);
  487. $recur_data_month = date('m', $recur_data_time);
  488. $recur_data_day = date('d', $recur_data_time);
  489. $recur_data_date = $recur_data_year.$recur_data_month.$recur_data_day;
  490. if (($recur_data_time >= $start_date_time) && ($recur_data_time <= $end_date_time) && ($count_to != $count) && !in_array($recur_data_date, $except_dates)) {
  491. if (isset($allday_start) && $allday_start != '') {
  492. $start_time2 = $recur_data_time;
  493. $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_time);
  494. while ($start_time2 < $end_time2) {
  495. $start_date2 = date('Ymd', $start_time2);
  496. $master_array[($start_date2)][('-1')][$uid] = array (
  497. 'event_text' => $summary,
  498. 'description' => $description,
  499. 'location' => $location,
  500. 'organizer' => serialize($organizer),
  501. 'attendee' => serialize($attendee),
  502. 'calnumber' => $calnumber,
  503. 'calname' => $actual_calname,
  504. 'url' => $url,
  505. 'status' => $status,
  506. 'class' => $class,
  507. 'recur' => $recur );
  508. $start_time2 = strtotime('+1 day', $start_time2);
  509. }
  510. } else {
  511. $start_unixtime_tmp = mktime($recur_data_hour,$recur_data_minute,0,$recur_data_month,$recur_data_day,$recur_data_year);
  512. $end_unixtime_tmp = $start_unixtime_tmp + $length;
  513. if (($end_time >= $bleed_time) && ($bleed_check == '-1')) {
  514. $start_tmp = strtotime(date('Ymd',$start_unixtime_tmp));
  515. $end_date_tmp = date('Ymd',$end_unixtime_tmp);
  516. while ($start_tmp < $end_unixtime_tmp) {
  517. $start_date_tmp = date('Ymd',$start_tmp);
  518. if ($start_date_tmp == $recur_data_year.$recur_data_month.$recur_data_day) {
  519. $time_tmp = $hour.$minute;
  520. $start_time_tmp = $start_time;
  521. } else {
  522. $time_tmp = '0000';
  523. $start_time_tmp = '0000';
  524. }
  525. if ($start_date_tmp == $end_date_tmp) {
  526. $end_time_tmp = $end_time;
  527. } else {
  528. $end_time_tmp = '2400';
  529. $display_end_tmp = $end_time;
  530. }
  531. // Let's double check the until to not write past it
  532. $until_check = $start_date_tmp.$time_tmp.'00';
  533. if ($abs_until > $until_check) {
  534. $master_array[$start_date_tmp][$time_tmp][$uid] = array (
  535. 'event_start' => $start_time_tmp,
  536. 'event_end' => $end_time_tmp,
  537. 'start_unixtime' => $start_unixtime_tmp,
  538. 'end_unixtime' => $end_unixtime_tmp,
  539. 'event_text' => $summary,
  540. 'event_length' => $length,
  541. 'event_overlap' => 0,
  542. 'description' => $description,
  543. 'status' => $status,
  544. 'class' => $class,
  545. 'spans_day' => true,
  546. 'location' => $location,
  547. 'organizer' => serialize($organizer),
  548. 'attendee' => serialize($attendee),
  549. 'calnumber' => $calnumber,
  550. 'calname' => $actual_calname,
  551. 'url' => $url,
  552. 'recur' => $recur);
  553. if (isset($display_end_tmp)){
  554. $master_array[$start_date_tmp][$time_tmp][$uid]['display_end'] = $display_end_tmp;
  555. }
  556. checkOverlap($start_date_tmp, $time_tmp, $uid);
  557. }
  558. $start_tmp = strtotime('+1 day',$start_tmp);
  559. }
  560. } else {
  561. if ($bleed_check == '-1') {
  562. $display_end_tmp = $end_time;
  563. $end_time_tmp1 = '2400';
  564. }
  565. if (!isset($end_time_tmp1)) $end_time_tmp1 = $end_time;
  566. // Let's double check the until to not write past it
  567. $until_check = $recur_data_date.$hour.$minute.'00';
  568. if ($abs_until > $until_check) {
  569. $master_array[($recur_data_date)][($hour.$minute)][$uid] = array (
  570. 'event_start' => $start_time,
  571. 'event_end' => $end_time_tmp1,
  572. 'start_unixtime' => $start_unixtime_tmp,
  573. 'end_unixtime' => $end_unixtime_tmp,
  574. 'event_text' => $summary,
  575. 'event_length' => $length,
  576. 'event_overlap' => 0,
  577. 'description' => $description,
  578. 'status' => $status,
  579. 'class' => $class,
  580. 'spans_day' => false,
  581. 'location' => $location,
  582. 'organizer' => serialize($organizer),
  583. 'attendee' => serialize($attendee),
  584. 'calnumber' => $calnumber,
  585. 'calname' => $actual_calname,
  586. 'url' => $url,
  587. 'recur' => $recur);
  588. if (isset($display_end_tmp)){
  589. $master_array[($recur_data_date)][($hour.$minute)][$uid]['display_end'] = $display_end_tmp;
  590. }
  591. checkOverlap($recur_data_date, ($hour.$minute), $uid);
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. } #end while loop
  599. } # end if time compare
  600. unset($recur_data);
  601. } # end switch $key (rrule type)
  602. } # end foreach rrule
  603. // This should remove any exdates that were missed.
  604. // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start
  605. if (is_array($except_dates)) {
  606. foreach ($except_dates as $key => $value) {
  607. if (isset ($master_array[$value])){
  608. foreach ($master_array[$value] as $time => $value2){
  609. if (!isset($value2[$uid]['event_start'])){
  610. unset($master_array[$value][$time][$uid]);
  611. }
  612. }
  613. }
  614. }
  615. }
  616. // Clear event data now that it's been saved.
  617. unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $description, $status, $class, $location, $organizer, $attendee);
  618. ?>