Completed
Push — 16.1 ( 26c19f...96aac5 )
by Nathan
47:03 queued 31:43
created
calendar/inc/class.calendar_uiforms.inc.php 3 patches
Switch Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -598,220 +598,220 @@  discard block
 block discarded – undo
598 598
 
599 599
 		switch((string)$button)
600 600
 		{
601
-		case 'exception':	// create an exception in a recuring event
602
-			$msg = $this->_create_exception($event,$preserv);
603
-			break;
601
+			case 'exception':	// create an exception in a recuring event
602
+				$msg = $this->_create_exception($event,$preserv);
603
+				break;
604 604
 
605
-		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
606
-			unset($event['id']);
607
-			unset($event['uid']);
608
-			unset($event['reference']);
609
-			unset($preserv['reference']);
610
-			unset($event['recurrence']);
611
-			unset($preserv['recurrence']);
612
-			unset($event['recur_exception']);
613
-			unset($event['edit_single']);	// in case it has been set
614
-			unset($event['modified']);
615
-			unset($event['modifier']);
616
-			unset($event['caldav_name']);
617
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
605
+			case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
606
+				unset($event['id']);
607
+				unset($event['uid']);
608
+				unset($event['reference']);
609
+				unset($preserv['reference']);
610
+				unset($event['recurrence']);
611
+				unset($preserv['recurrence']);
612
+				unset($event['recur_exception']);
613
+				unset($event['edit_single']);	// in case it has been set
614
+				unset($event['modified']);
615
+				unset($event['modifier']);
616
+				unset($event['caldav_name']);
617
+				$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
618
+
619
+				// Clear participant stati
620
+				foreach($event['participant_types'] as $type => &$participants)
621
+				{
622
+					foreach($participants as $id => &$p_response)
623
+					{
624
+						if($type == 'u' && $id == $event['owner']) continue;
625
+						calendar_so::split_status($p_response, $quantity, $role);
626
+						// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
627
+						$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
628
+						$p_response = calendar_so::combine_status($status,$quantity,$role);
629
+					}
630
+				}
618 631
 
619
-			// Clear participant stati
620
-			foreach($event['participant_types'] as $type => &$participants)
621
-			{
622
-				foreach($participants as $id => &$p_response)
632
+				// Copy alarms
633
+				if (is_array($event['alarm']))
623 634
 				{
624
-					if($type == 'u' && $id == $event['owner']) continue;
625
-					calendar_so::split_status($p_response, $quantity, $role);
626
-					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
627
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
628
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
635
+					foreach($event['alarm'] as $n => &$alarm)
636
+					{
637
+						unset($alarm['id']);
638
+						unset($alarm['cal_id']);
639
+					}
629 640
 				}
630
-			}
631 641
 
632
-			// Copy alarms
633
-			if (is_array($event['alarm']))
634
-			{
635
-				foreach($event['alarm'] as $n => &$alarm)
642
+				// Get links to be copied
643
+				// With no ID, $content['link_to']['to_id'] is used
644
+				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
645
+				foreach(Link::get_links('calendar', $content['id']) as $link)
636 646
 				{
637
-					unset($alarm['id']);
638
-					unset($alarm['cal_id']);
647
+					if ($link['app'] != Link::VFS_APPNAME)
648
+					{
649
+						Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
650
+					}
651
+					elseif ($link['app'] == Link::VFS_APPNAME)
652
+					{
653
+						Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
654
+							'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
655
+							'name' => $link['id'],
656
+						), $link['remark']);
657
+					}
639 658
 				}
640
-			}
659
+				unset($link);
660
+				$preserv['view'] = $preserv['edit_single'] = false;
661
+				$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry')));
662
+				$event['title'] = lang('Copy of:').' '.$event['title'];
663
+				break;
641 664
 
642
-			// Get links to be copied
643
-			// With no ID, $content['link_to']['to_id'] is used
644
-			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
645
-			foreach(Link::get_links('calendar', $content['id']) as $link)
646
-			{
647
-				if ($link['app'] != Link::VFS_APPNAME)
665
+			case 'mail':
666
+			case 'sendrequest':
667
+			case 'save':
668
+			case 'print':
669
+			case 'apply':
670
+			case 'infolog':
671
+				if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
648 672
 				{
649
-					Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
673
+					$msg = lang('Permission denied');
674
+					$button = '';
675
+					break;
650 676
 				}
651
-				elseif ($link['app'] == Link::VFS_APPNAME)
677
+				if ($event['start'] > $event['end'])
652 678
 				{
653
-					Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
654
-						'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
655
-						'name' => $link['id'],
656
-					), $link['remark']);
679
+					$msg = lang('Error: Starttime has to be before the endtime !!!');
680
+					$button = '';
681
+					break;
657 682
 				}
658
-			}
659
-			unset($link);
660
-			$preserv['view'] = $preserv['edit_single'] = false;
661
-			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry')));
662
-			$event['title'] = lang('Copy of:').' '.$event['title'];
663
-			break;
664
-
665
-		case 'mail':
666
-		case 'sendrequest':
667
-		case 'save':
668
-		case 'print':
669
-		case 'apply':
670
-		case 'infolog':
671
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
672
-			{
673
-				$msg = lang('Permission denied');
674
-				$button = '';
675
-				break;
676
-			}
677
-			if ($event['start'] > $event['end'])
678
-			{
679
-				$msg = lang('Error: Starttime has to be before the endtime !!!');
680
-				$button = '';
681
-				break;
682
-			}
683
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
684
-			{
685
-				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
686
-				$button = '';
687
-				break;
688
-			}
689
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
690
-			{
691
-				$msg = lang('Error: Duration of event longer then recurrence interval!');
692
-				$button = '';
693
-				break;
694
-			}
695
-			if (!$event['participants'])
696
-			{
697
-				$msg = lang('Error: no participants selected !!!');
698
-				$button = '';
699
-				break;
700
-			}
701
-			// if private event with ressource reservation is forbidden
702
-			if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
703
-			{
704
-				foreach (array_keys($event['participants']) as $uid)
683
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
684
+				{
685
+					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
686
+					$button = '';
687
+					break;
688
+				}
689
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
690
+				{
691
+					$msg = lang('Error: Duration of event longer then recurrence interval!');
692
+					$button = '';
693
+					break;
694
+				}
695
+				if (!$event['participants'])
705 696
 				{
706
-					if ($uid[0] == 'r') //ressource detection
697
+					$msg = lang('Error: no participants selected !!!');
698
+					$button = '';
699
+					break;
700
+				}
701
+				// if private event with ressource reservation is forbidden
702
+				if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
703
+				{
704
+					foreach (array_keys($event['participants']) as $uid)
707 705
 					{
708
-						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
709
-						$button = '';
710
-						break 2; //break foreach and case
706
+						if ($uid[0] == 'r') //ressource detection
707
+						{
708
+							$msg = lang('Error: ressources reservation in private events is not allowed!!!');
709
+							$button = '';
710
+							break 2; //break foreach and case
711
+						}
711 712
 					}
712 713
 				}
713
-			}
714
-			if ($content['edit_single'])	// we edited a single event from a series
715
-			{
716
-				$event['reference'] = $event['id'];
717
-				$event['recurrence'] = $content['edit_single'];
718
-				unset($event['id']);
719
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
720
-				if (!is_array($conflicts) && $conflicts)
714
+				if ($content['edit_single'])	// we edited a single event from a series
721 715
 				{
722
-					// now we need to add the original start as recur-execption to the series
723
-					$recur_event = $this->bo->read($event['reference']);
724
-					$recur_event['recur_exception'][] = $content['edit_single'];
725
-					// check if we need to move the alarms, because they are next on that exception
726
-					foreach($recur_event['alarm'] as $id => $alarm)
716
+					$event['reference'] = $event['id'];
717
+					$event['recurrence'] = $content['edit_single'];
718
+					unset($event['id']);
719
+					$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
720
+					if (!is_array($conflicts) && $conflicts)
727 721
 					{
728
-						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
722
+						// now we need to add the original start as recur-execption to the series
723
+						$recur_event = $this->bo->read($event['reference']);
724
+						$recur_event['recur_exception'][] = $content['edit_single'];
725
+						// check if we need to move the alarms, because they are next on that exception
726
+						foreach($recur_event['alarm'] as $id => $alarm)
729 727
 						{
730
-							$rrule = calendar_rrule::event2rrule($recur_event, true);
731
-							foreach ($rrule as $time)
728
+							if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
732 729
 							{
733
-								if ($content['edit_single'] < $time->format('ts'))
730
+								$rrule = calendar_rrule::event2rrule($recur_event, true);
731
+								foreach ($rrule as $time)
734 732
 								{
735
-									$alarm['time'] = $time->format('ts') - $alarm['offset'];
736
-									$this->bo->save_alarm($event['reference'], $alarm);
737
-									break;
733
+									if ($content['edit_single'] < $time->format('ts'))
734
+									{
735
+										$alarm['time'] = $time->format('ts') - $alarm['offset'];
736
+										$this->bo->save_alarm($event['reference'], $alarm);
737
+										break;
738
+									}
738 739
 								}
739 740
 							}
740 741
 						}
741
-					}
742
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
743
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
744
-					$this->bo->update($recur_event,true);	// no conflict check here
742
+						unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
743
+						unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
744
+						$this->bo->update($recur_event,true);	// no conflict check here
745 745
 
746
-					// Save links
747
-					if($content['links'])
748
-					{
749
-						Link::link('calendar', $event['id'], $content['links']['to_id']);
750
-					}
746
+						// Save links
747
+						if($content['links'])
748
+						{
749
+							Link::link('calendar', $event['id'], $content['links']['to_id']);
750
+						}
751 751
 
752
-					if(Api\Json\Response::isJSONResponse())
752
+						if(Api\Json\Response::isJSONResponse())
753
+						{
754
+							// Sending null will trigger a removal of the original
755
+							// for that date
756
+							Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
757
+						}
758
+
759
+						unset($recur_event);
760
+						unset($event['edit_single']);			// if we further edit it, it's just a single event
761
+						unset($preserv['edit_single']);
762
+					}
763
+					else	// conflict or error, we need to reset everything to the state befor we tried to save it
753 764
 					{
754
-						// Sending null will trigger a removal of the original
755
-						// for that date
756
-						Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
765
+						$event['id'] = $event['reference'];
766
+						$event['reference'] = $event['recurrence'] = 0;
767
+						$event['uid'] = $content['uid'];
757 768
 					}
758
-
759
-					unset($recur_event);
760
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
761
-					unset($preserv['edit_single']);
769
+					$update_type = 'edit';
762 770
 				}
763
-				else	// conflict or error, we need to reset everything to the state befor we tried to save it
771
+				else	// we edited a non-reccuring event or the whole series
764 772
 				{
765
-					$event['id'] = $event['reference'];
766
-					$event['reference'] = $event['recurrence'] = 0;
767
-					$event['uid'] = $content['uid'];
768
-				}
769
-				$update_type = 'edit';
770
-			}
771
-			else	// we edited a non-reccuring event or the whole series
772
-			{
773
-				if (($old_event = $this->bo->read($event['id'])))
774
-				{
775
-					if ($event['recur_type'] != MCAL_RECUR_NONE)
773
+					if (($old_event = $this->bo->read($event['id'])))
776 774
 					{
777
-						$update_type = 'edit';
778
-
779
-						// we edit a existing series event
780
-						if ($event['start'] != $old_event['start'] ||
781
-							$event['whole_day'] != $old_event['whole_day'] ||
782
-							$event['end'] != $old_event['end'])
775
+						if ($event['recur_type'] != MCAL_RECUR_NONE)
783 776
 						{
784
-							// calculate offset against old series start or clicked recurrance,
785
-							// depending on which is smaller
786
-							$offset = $event['start'] - $old_event['start'];
787
-							if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
788
-							{
789
-								$offset = $off2;
790
-							}
791
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
792
-							if($msg)
777
+							$update_type = 'edit';
778
+
779
+							// we edit a existing series event
780
+							if ($event['start'] != $old_event['start'] ||
781
+								$event['whole_day'] != $old_event['whole_day'] ||
782
+								$event['end'] != $old_event['end'])
793 783
 							{
794
-								$noerror = false;
784
+								// calculate offset against old series start or clicked recurrance,
785
+								// depending on which is smaller
786
+								$offset = $event['start'] - $old_event['start'];
787
+								if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
788
+								{
789
+									$offset = $off2;
790
+								}
791
+								$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
792
+								if($msg)
793
+								{
794
+									$noerror = false;
795
+								}
795 796
 							}
796 797
 						}
797
-					}
798
-					else
799
-					{
800
-						if ($old_event['start'] != $event['start'] ||
801
-							$old_event['end'] != $event['end'] ||
802
-							$event['whole_day'] != $old_event['whole_day'])
798
+						else
803 799
 						{
804
-							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
805
-							foreach((array)$event['participants'] as $uid => $status)
800
+							if ($old_event['start'] != $event['start'] ||
801
+								$old_event['end'] != $event['end'] ||
802
+								$event['whole_day'] != $old_event['whole_day'])
806 803
 							{
807
-								$q = $r = null;
808
-								calendar_so::split_status($status,$q,$r);
809
-								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
804
+								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
805
+								foreach((array)$event['participants'] as $uid => $status)
810 806
 								{
811
-									$preferences = new Api\Preferences($uid);
812
-									$part_prefs = $preferences->read_repository();
813
-									switch ($part_prefs['calendar']['reset_stati'])
807
+									$q = $r = null;
808
+									calendar_so::split_status($status,$q,$r);
809
+									if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
814 810
 									{
811
+										$preferences = new Api\Preferences($uid);
812
+										$part_prefs = $preferences->read_repository();
813
+										switch ($part_prefs['calendar']['reset_stati'])
814
+										{
815 815
 										case 'no':
816 816
 											break;
817 817
 										case 'startday':
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 											$status_reset_to_unknown = true;
821 821
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
822 822
 											// todo: report reset status to user
823
-									}
823
+										}
824 824
 								}
825 825
 							}
826 826
 							// check if we need to move the alarms, because they are relative
@@ -962,83 +962,83 @@  discard block
 block discarded – undo
962 962
 			}
963 963
 			break;
964 964
 
965
-		case 'cancel':
966
-			if($content['cancel_needs_refresh'])
967
-			{
968
-				Framework::refresh_opener($msg, 'calendar');
969
-			}
970
-			break;
971
-
972
-		case 'delete':					// delete of event (regular or series)
973
-			$exceptions_kept = null;
974
-			if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
975
-				$content['delete_exceptions'] == 'true', $exceptions_kept))
976
-			{
977
-				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
965
+			case 'cancel':
966
+				if($content['cancel_needs_refresh'])
978 967
 				{
979
-					$msg = lang('Series deleted');
980
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
968
+					Framework::refresh_opener($msg, 'calendar');
981 969
 				}
982
-				else
970
+				break;
971
+
972
+			case 'delete':					// delete of event (regular or series)
973
+				$exceptions_kept = null;
974
+				if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
975
+					$content['delete_exceptions'] == 'true', $exceptions_kept))
983 976
 				{
984
-					$msg = lang('Event deleted');
985
-				}
977
+					if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
978
+					{
979
+						$msg = lang('Series deleted');
980
+						if ($exceptions_kept) $msg .= lang(', exceptions preserved');
981
+					}
982
+					else
983
+					{
984
+						$msg = lang('Event deleted');
985
+					}
986 986
 
987
-			}
988
-			break;
987
+				}
988
+				break;
989 989
 
990
-		case 'freetime':
991
-			// the "click" has to be in onload, to make sure the button is already created
992
-			$event['button_was'] = $button;
993
-			break;
990
+			case 'freetime':
991
+				// the "click" has to be in onload, to make sure the button is already created
992
+				$event['button_was'] = $button;
993
+				break;
994 994
 
995
-		case 'add_alarm':
996
-			$time = $content['start'];
997
-			$offset = $time - $content['new_alarm']['date'];
998
-			if ($event['recur_type'] != MCAL_RECUR_NONE &&
999
-				($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
1000
-				$time < $next_occurrence['start'])
1001
-			{
1002
-				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
1003
-			}
1004
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
1005
-			{
1006
-				$alarm = array(
1007
-					'offset' => $offset,
1008
-					'time'   => $content['new_alarm']['date'],
1009
-					'all'    => !$content['new_alarm']['owner'],
1010
-					'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
1011
-				);
1012
-				if ($alarm['time'] < $this->bo->now_su)
995
+			case 'add_alarm':
996
+				$time = $content['start'];
997
+				$offset = $time - $content['new_alarm']['date'];
998
+				if ($event['recur_type'] != MCAL_RECUR_NONE &&
999
+					($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
1000
+					$time < $next_occurrence['start'])
1013 1001
 				{
1014
-					$msg = lang("Can't add alarms in the past !!!");
1002
+					$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
1015 1003
 				}
1016
-				elseif ($event['id'])	// save the alarm immediatly
1004
+				if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
1017 1005
 				{
1018
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1006
+					$alarm = array(
1007
+						'offset' => $offset,
1008
+						'time'   => $content['new_alarm']['date'],
1009
+						'all'    => !$content['new_alarm']['owner'],
1010
+						'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
1011
+					);
1012
+					if ($alarm['time'] < $this->bo->now_su)
1013
+					{
1014
+						$msg = lang("Can't add alarms in the past !!!");
1015
+					}
1016
+					elseif ($event['id'])	// save the alarm immediatly
1019 1017
 					{
1020
-						$alarm['id'] = $alarm_id;
1021
-						$event['alarm'][$alarm_id] = $alarm;
1018
+						if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1019
+						{
1020
+							$alarm['id'] = $alarm_id;
1021
+							$event['alarm'][$alarm_id] = $alarm;
1022 1022
 
1023
-						$msg = lang('Alarm added');
1024
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1023
+							$msg = lang('Alarm added');
1024
+							Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1025
+						}
1026
+						else
1027
+						{
1028
+							$msg = lang('Error adding the alarm');
1029
+						}
1025 1030
 					}
1026 1031
 					else
1027 1032
 					{
1028
-						$msg = lang('Error adding the alarm');
1033
+						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1034
+						$event['alarm'][$alarm['id']] = $alarm;
1029 1035
 					}
1030 1036
 				}
1031 1037
 				else
1032 1038
 				{
1033
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1034
-					$event['alarm'][$alarm['id']] = $alarm;
1039
+					$msg = lang('Permission denied');
1035 1040
 				}
1036
-			}
1037
-			else
1038
-			{
1039
-				$msg = lang('Permission denied');
1040
-			}
1041
-			break;
1041
+				break;
1042 1042
 		}
1043 1043
 		// add notification-errors, if we have some
1044 1044
 		if (($notification_errors = notifications::errors(true)))
Please login to merge, or discard this patch.
Braces   +294 added lines, -75 removed lines patch added patch discarded remove patch
@@ -121,11 +121,14 @@  discard block
 block discarded – undo
121 121
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
122 122
 			!$this->bo->check_perms(Acl::ADD,0,$owner))
123 123
 		{
124
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
124
+			if ($owner)
125
+			{
126
+				// make an owner who is no user or we have no add-rights a participant
125 127
 			{
126 128
 				if(!is_array($owner))
127 129
 				{
128 130
 					$owner = explode(',',$owner);
131
+			}
129 132
 				}
130 133
 				// if we come from ressources we don't need any users selected in calendar
131 134
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -157,9 +160,17 @@  discard block
 block discarded – undo
157 160
 		$participant_types['u'] = $participant_types = $participants = array();
158 161
 		foreach($extra_participants as $uid)
159 162
 		{
160
-			if (isset($participants[$uid])) continue;	// already included
163
+			if (isset($participants[$uid]))
164
+			{
165
+				continue;
166
+			}
167
+			// already included
161 168
 
162
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
169
+			if (!$this->bo->check_acl_invite($uid))
170
+			{
171
+				continue;
172
+			}
173
+			// no right to invite --> ignored
163 174
 
164 175
 			if (is_numeric($uid))
165 176
 			{
@@ -197,10 +208,13 @@  discard block
 block discarded – undo
197 208
 				}
198 209
 			}
199 210
 		}
200
-		if (!$participants)	// if all participants got removed, include current user
211
+		if (!$participants)
212
+		{
213
+			// if all participants got removed, include current user
201 214
 		{
202 215
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
203 216
 		}
217
+		}
204 218
 		if(isset($_GET['cat_id']))
205 219
 		{
206 220
 			$cat_id = explode(',',$_GET['cat_id']);
@@ -250,10 +264,13 @@  discard block
 block discarded – undo
250 264
 	 */
251 265
 	function process_edit($content)
252 266
 	{
253
-		if (!is_array($content))	// redirect from etemplate, if POST empty
267
+		if (!is_array($content))
268
+		{
269
+			// redirect from etemplate, if POST empty
254 270
 		{
255 271
 			return $this->edit(null,null,strip_tags($_GET['msg']));
256 272
 		}
273
+		}
257 274
 		// clear notification errors
258 275
 		notifications::errors(true);
259 276
 		$messages = null;
@@ -266,7 +283,11 @@  discard block
 block discarded – undo
266 283
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
267 284
 
268 285
 		list($button) = @each($content['button']);
269
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
286
+		if (!$button && $content['action'])
287
+		{
288
+			$button = $content['action'];
289
+		}
290
+		// action selectbox
270 291
 		unset($content['button']); unset($content['action']);
271 292
 
272 293
 		$view = $content['view'];
@@ -279,7 +300,10 @@  discard block
 block discarded – undo
279 300
 		{
280 301
 			list($date) = each($content['recur_exception']['delete_exception']);
281 302
 			// eT2 converts time to
282
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
303
+			if (!is_numeric($date))
304
+			{
305
+				$date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
306
+			}
283 307
 			unset($content['recur_exception']['delete_exception']);
284 308
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
285 309
 			{
@@ -288,7 +312,10 @@  discard block
 block discarded – undo
288 312
 				foreach ($recur_exceptions as $id)
289 313
 				{
290 314
 					if (!($exception = $this->bo->read($id)) ||
291
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
315
+							$exception['recurrence'] != $content['recur_exception'][$key])
316
+					{
317
+						continue;
318
+					}
292 319
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
293 320
 					$exception['reference'] = $exception['recurrence'] = 0;
294 321
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -363,7 +390,10 @@  discard block
 block discarded – undo
363 390
 				$event['end'] = $this->bo->date2ts($event['end']);
364 391
 			}
365 392
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
366
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
393
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
394
+			{
395
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
396
+			}
367 397
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
368 398
 			{
369 399
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -489,7 +519,11 @@  discard block
 block discarded – undo
489 519
 							break;
490 520
 
491 521
 						default:		// existing participant row
492
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
522
+							if (!is_array($data))
523
+							{
524
+								continue;
525
+							}
526
+							// widgets in participant tab, above participant list
493 527
 							foreach(array('uid','status','quantity','role') as $name)
494 528
 							{
495 529
 								$$name = $data[$name];
@@ -621,7 +655,10 @@  discard block
 block discarded – undo
621 655
 			{
622 656
 				foreach($participants as $id => &$p_response)
623 657
 				{
624
-					if($type == 'u' && $id == $event['owner']) continue;
658
+					if($type == 'u' && $id == $event['owner'])
659
+					{
660
+						continue;
661
+					}
625 662
 					calendar_so::split_status($p_response, $quantity, $role);
626 663
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
627 664
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -703,17 +740,23 @@  discard block
 block discarded – undo
703 740
 			{
704 741
 				foreach (array_keys($event['participants']) as $uid)
705 742
 				{
706
-					if ($uid[0] == 'r') //ressource detection
743
+					if ($uid[0] == 'r')
744
+					{
745
+						//ressource detection
707 746
 					{
708 747
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
748
+					}
709 749
 						$button = '';
710 750
 						break 2; //break foreach and case
711 751
 					}
712 752
 				}
713 753
 			}
714
-			if ($content['edit_single'])	// we edited a single event from a series
754
+			if ($content['edit_single'])
755
+			{
756
+				// we edited a single event from a series
715 757
 			{
716 758
 				$event['reference'] = $event['id'];
759
+			}
717 760
 				$event['recurrence'] = $content['edit_single'];
718 761
 				unset($event['id']);
719 762
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -815,7 +858,10 @@  discard block
 block discarded – undo
815 858
 										case 'no':
816 859
 											break;
817 860
 										case 'startday':
818
-											if ($sameday) break;
861
+											if ($sameday)
862
+											{
863
+												break;
864
+											}
819 865
 										default:
820 866
 											$status_reset_to_unknown = true;
821 867
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -977,7 +1023,10 @@  discard block
 block discarded – undo
977 1023
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
978 1024
 				{
979 1025
 					$msg = lang('Series deleted');
980
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
1026
+					if ($exceptions_kept)
1027
+					{
1028
+						$msg .= lang(', exceptions preserved');
1029
+					}
981 1030
 				}
982 1031
 				else
983 1032
 				{
@@ -1013,11 +1062,14 @@  discard block
 block discarded – undo
1013 1062
 				{
1014 1063
 					$msg = lang("Can't add alarms in the past !!!");
1015 1064
 				}
1016
-				elseif ($event['id'])	// save the alarm immediatly
1065
+				elseif ($event['id'])
1066
+				{
1067
+					// save the alarm immediatly
1017 1068
 				{
1018 1069
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1019 1070
 					{
1020 1071
 						$alarm['id'] = $alarm_id;
1072
+				}
1021 1073
 						$event['alarm'][$alarm_id] = $alarm;
1022 1074
 
1023 1075
 						$msg = lang('Alarm added');
@@ -1030,7 +1082,9 @@  discard block
 block discarded – undo
1030 1082
 				}
1031 1083
 				else
1032 1084
 				{
1033
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1085
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1086
+					{
1087
+}	// get a temporary non-conflicting, numeric id
1034 1088
 					$event['alarm'][$alarm['id']] = $alarm;
1035 1089
 				}
1036 1090
 			}
@@ -1053,10 +1107,13 @@  discard block
 block discarded – undo
1053 1107
 		}
1054 1108
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1055 1109
 		{
1056
-			if ($content['lock_token'])	// remove an existing lock
1110
+			if ($content['lock_token'])
1111
+			{
1112
+				// remove an existing lock
1057 1113
 			{
1058 1114
 				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1059 1115
 			}
1116
+			}
1060 1117
 			if ($content['no_popup'])
1061 1118
 			{
1062 1119
 				Egw::redirect_link('/index.php',array(
@@ -1113,13 +1170,19 @@  discard block
 block discarded – undo
1113 1170
 		}
1114 1171
 
1115 1172
 		// Copy links
1116
-		if(!is_array($event['link_to'])) $event['link_to'] = array();
1173
+		if(!is_array($event['link_to']))
1174
+		{
1175
+			$event['link_to'] = array();
1176
+		}
1117 1177
 		$event['link_to']['to_app'] = 'calendar';
1118 1178
 		$event['link_to']['to_id'] = 0;
1119 1179
 		
1120 1180
 		foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1121 1181
 		{
1122
-			if(!$link['id']) continue;
1182
+			if(!$link['id'])
1183
+			{
1184
+				continue;
1185
+			}
1123 1186
 			if ($link['app'] != Link::VFS_APPNAME)
1124 1187
 			{
1125 1188
 				Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
@@ -1187,8 +1250,7 @@  discard block
 block discarded – undo
1187 1250
 		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1188 1251
 			// Adjust for requested date in the past
1189 1252
 			Api\DateTime::to($as_of_date,'ts') < time()
1190
-		)
1191
-		{
1253
+		) {
1192 1254
 
1193 1255
 			unset($orig_event);
1194 1256
 			// copy event by unsetting the id(s)
@@ -1276,30 +1338,48 @@  discard block
 block discarded – undo
1276 1338
 		foreach($event['participants'] as $uid => $status)
1277 1339
 		{
1278 1340
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1279
-			if (empty($status)) continue;
1341
+			if (empty($status))
1342
+			{
1343
+				continue;
1344
+			}
1280 1345
 			$toadd = '';
1281
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1346
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1347
+			{
1348
+				continue;
1349
+			}
1282 1350
 
1283 1351
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1284 1352
 			{
1285
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1353
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1354
+				{
1355
+					continue;
1356
+				}
1286 1357
 
1287 1358
 				$toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '.
1288 1359
 					$GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>';
1289 1360
 
1290
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1361
+				if (!in_array($toadd,$to))
1362
+				{
1363
+					$to[] = $toadd;
1364
+				}
1291 1365
 			}
1292 1366
 			elseif ($uid < 0)
1293 1367
 			{
1294 1368
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1295 1369
 				{
1296
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1370
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1371
+					{
1372
+						continue;
1373
+					}
1297 1374
 
1298 1375
 					$toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1299 1376
 						$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>';
1300 1377
 
1301 1378
 					// dont add groupmembers if they already rejected the event, or are the current user
1302
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1379
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1380
+					{
1381
+						$to[] = $toadd;
1382
+					}
1303 1383
 				}
1304 1384
 			}
1305 1385
 			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
@@ -1351,7 +1431,10 @@  discard block
 block discarded – undo
1351 1431
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1352 1432
 			'preset[size]'    => filesize($ics_file),
1353 1433
 		);
1354
-		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1434
+		if ($asrequest)
1435
+		{
1436
+			$vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1437
+		}
1355 1438
 		$response = Api\Json\Response::get();
1356 1439
 		$response->call('app.calendar.custom_mail', $vars);
1357 1440
 	}
@@ -1537,9 +1620,15 @@  discard block
 block discarded – undo
1537 1620
 				}
1538 1621
 			}
1539 1622
 			// set new start and end if given by $_GET
1540
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1541
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1542
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1623
+			if(isset($_GET['start']))
1624
+			{
1625
+$event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1626
+			if(isset($_GET['end']))
1627
+			{
1628
+$event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1629
+			if(isset($_GET['non_blocking']))
1630
+			{
1631
+$event['non_blocking'] = (bool)$_GET['non_blocking']; }
1543 1632
 			// check if the event is the whole day
1544 1633
 			$start = $this->bo->date2array($event['start']);
1545 1634
 			$end = $this->bo->date2array($event['end']);
@@ -1552,10 +1641,13 @@  discard block
 block discarded – undo
1552 1641
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1553 1642
 				{
1554 1643
 					$link_id = $link_ids[$n];
1555
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1644
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1645
+					{
1646
+						// guard against XSS
1556 1647
 					{
1557 1648
 						continue;
1558 1649
 					}
1650
+					}
1559 1651
 					if(!$n)
1560 1652
 					{
1561 1653
 						$event['title'] = Link::title($link_app,$link_id);
@@ -1564,7 +1656,10 @@  discard block
 block discarded – undo
1564 1656
 						{
1565 1657
 							foreach((array)$set['link_app'] as $i => $l_app)
1566 1658
 							{
1567
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1659
+								if (($l_id=$set['link_id'][$i]))
1660
+								{
1661
+									Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1662
+								}
1568 1663
 							}
1569 1664
 							unset($set['link_app']);
1570 1665
 							unset($set['link_id']);
@@ -1590,10 +1685,13 @@  discard block
 block discarded – undo
1590 1685
 			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1591 1686
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1592 1687
 
1593
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1688
+			if (($preserv['lock_token'] = $event['lock_token']))
1689
+			{
1690
+				// already locked --> refresh the lock
1594 1691
 			{
1595 1692
 				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1596 1693
 			}
1694
+			}
1597 1695
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1598 1696
 			{
1599 1697
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1627,14 +1725,20 @@  discard block
 block discarded – undo
1627 1725
 		));
1628 1726
 		Framework::message($msg, $msg_type);
1629 1727
 		$content['duration'] = $content['end'] - $content['start'];
1630
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1728
+		if (isset($this->durations[$content['duration']]))
1729
+		{
1730
+			$content['end'] = '';
1731
+		}
1631 1732
 
1632 1733
 		$row = 3;
1633 1734
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1634 1735
 		// preserve some ui elements, if set eg. under error-conditions
1635 1736
 		foreach(array('quantity','resource','role') as $n)
1636 1737
 		{
1637
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1738
+			if (isset($event['participants'][$n]))
1739
+			{
1740
+				$content['participants'][$n] = $event['participants'][$n];
1741
+			}
1638 1742
 		}
1639 1743
 		foreach($event['participant_types'] as $type => $participants)
1640 1744
 		{
@@ -1676,9 +1780,13 @@  discard block
 block discarded – undo
1676 1780
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1677 1781
 
1678 1782
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1679
-					$readonlys['participants'][$row]['status'] = $no_status;
1783
+				{
1784
+									$readonlys['participants'][$row]['status'] = $no_status;
1785
+				}
1680 1786
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1681
-					$readonlys['participants']['delete'][$uid] = true;
1787
+				{
1788
+									$readonlys['participants']['delete'][$uid] = true;
1789
+				}
1682 1790
 				// todo: make the participants available as links with email as title
1683 1791
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1684 1792
 				// enumerate group-invitations, so people can accept/reject them
@@ -1709,7 +1817,11 @@  discard block
 block discarded – undo
1709 1817
 			$content['participants']['cal_resources'] = '';
1710 1818
 			foreach($this->bo->resources as $data)
1711 1819
 			{
1712
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1820
+				if ($data['app'] == 'email')
1821
+				{
1822
+					continue;
1823
+				}
1824
+				// make no sense, as we cant search for email
1713 1825
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1714 1826
 			}
1715 1827
 		}
@@ -1737,9 +1849,18 @@  discard block
 block discarded – undo
1737 1849
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1738 1850
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1739 1851
 				$label = array();
1740
-				if ($days) $label[] = $days.' '.lang('days');
1741
-				if ($hours) $label[] = $hours.' '.lang('hours');
1742
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1852
+				if ($days)
1853
+				{
1854
+					$label[] = $days.' '.lang('days');
1855
+				}
1856
+				if ($hours)
1857
+				{
1858
+					$label[] = $hours.' '.lang('hours');
1859
+				}
1860
+				if ($minutes)
1861
+				{
1862
+					$label[] = $minutes.' '.lang('Minutes');
1863
+				}
1743 1864
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1744 1865
 				$content['alarm'][] = $alarm;
1745 1866
 
@@ -1802,25 +1923,34 @@  discard block
 block discarded – undo
1802 1923
 			'participants' => $this->accountsel->account_selection == 'none',
1803 1924
 			'history' => !$event['id'],
1804 1925
 		);
1805
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1926
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1927
+		{
1928
+			// no mail without mail-app
1806 1929
 		{
1807 1930
 			unset($sel_options['action']['mail']);
1931
+		}
1808 1932
 			unset($sel_options['action']['sendmeetingrequest']);
1809 1933
 		}
1810
-		if (!$event['id'])	// no ical export for new (not saved) events
1934
+		if (!$event['id'])
1935
+		{
1936
+			// no ical export for new (not saved) events
1811 1937
 		{
1812 1938
 			$readonlys['action'] = true;
1813 1939
 		}
1940
+		}
1814 1941
 		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1815 1942
 		{
1816 1943
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1817 1944
 		}
1818 1945
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1819 1946
 
1820
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1947
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))
1948
+		{
1949
+			// new event or edit rights to the event ==> allow to add alarm for all users
1821 1950
 		{
1822 1951
 			$sel_options['owner'][0] = lang('All participants');
1823 1952
 		}
1953
+		}
1824 1954
 		if (isset($event['participant_types']['u'][$this->user]))
1825 1955
 		{
1826 1956
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1862,7 +1992,10 @@  discard block
 block discarded – undo
1862 1992
 
1863 1993
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1864 1994
 
1865
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1995
+		if (!empty($preserved['lock_token']))
1996
+		{
1997
+			$content['lock_token'] = $preserved['lock_token'];
1998
+		}
1866 1999
 
1867 2000
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1868 2001
 		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
@@ -2064,7 +2197,10 @@  discard block
 block discarded – undo
2064 2197
 					// set status and send notification / meeting response
2065 2198
 					if ($this->bo->set_status($event['id'], $user, $status))
2066 2199
 					{
2067
-						if (!$msg) $msg = lang('Status changed');
2200
+						if (!$msg)
2201
+						{
2202
+							$msg = lang('Status changed');
2203
+						}
2068 2204
 					}
2069 2205
 					break;
2070 2206
 
@@ -2143,13 +2279,16 @@  discard block
 block discarded – undo
2143 2279
 
2144 2280
 		foreach (array_keys($allConflicts) as $pId)
2145 2281
 		{
2146
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2282
+			if(substr($pId,0,1) == 'r' && $resources_config )
2283
+			{
2284
+				// resources Allow ignore conflicts
2147 2285
 			{
2148 2286
 
2149 2287
 				switch ($resources_config['ignoreconflicts'])
2150 2288
 				{
2151 2289
 					case 'no':
2152 2290
 						$readonlys['button[ignore]'] = true;
2291
+			}
2153 2292
 						break;
2154 2293
 					case 'allusers':
2155 2294
 						$readonlys['button[ignore]'] = false;
@@ -2293,7 +2432,10 @@  discard block
 block discarded – undo
2293 2432
 		}
2294 2433
 		else
2295 2434
 		{
2296
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2435
+			if (!$content['duration'])
2436
+			{
2437
+				$content['duration'] = $content['end'] - $content['start'];
2438
+			}
2297 2439
 			$weekds = 0;
2298 2440
 			foreach ($content['weekdays'] as &$wdays)
2299 2441
 			{
@@ -2315,7 +2457,10 @@  discard block
 block discarded – undo
2315 2457
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2316 2458
 
2317 2459
 		$sel_options['duration'] = $this->durations;
2318
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2460
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2461
+		{
2462
+			$content['end'] = '';
2463
+		}
2319 2464
 
2320 2465
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2321 2466
 				'participants'	=> $content['participants'],
@@ -2336,7 +2481,10 @@  discard block
 block discarded – undo
2336 2481
 	 */
2337 2482
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2338 2483
 	{
2339
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2484
+		if ($this->debug > 2)
2485
+		{
2486
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2487
+		}
2340 2488
 
2341 2489
 		$busy = $this->bo->search(array(
2342 2490
 			'start' => $start,
@@ -2353,15 +2501,26 @@  discard block
 block discarded – undo
2353 2501
 		$n = 0;
2354 2502
 		foreach($busy as $event)
2355 2503
 		{
2356
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2504
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2505
+			{
2506
+				continue;
2507
+			}
2508
+			// ignore our own event
2357 2509
 
2358
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2510
+ 			if ($event['non_blocking'])
2511
+ 			{
2512
+ 				continue;
2513
+ 			}
2514
+ 			// ignore non_blocking events
2359 2515
 
2360 2516
 			// check if from all wanted participants at least one has a not rejected status in found event
2361 2517
 			$non_rejected_found = false;
2362 2518
 			foreach($participants as $uid)
2363 2519
 			{
2364
-				if ($event['participants'][$uid] == 'R') continue;
2520
+				if ($event['participants'][$uid] == 'R')
2521
+				{
2522
+					continue;
2523
+				}
2365 2524
 
2366 2525
 				if (isset($event['participants'][$uid]) ||
2367 2526
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2371,7 +2530,10 @@  discard block
 block discarded – undo
2371 2530
 					break;
2372 2531
 				}
2373 2532
 			}
2374
-			if (!$non_rejected_found) continue;
2533
+			if (!$non_rejected_found)
2534
+			{
2535
+				continue;
2536
+			}
2375 2537
 
2376 2538
 			if ($this->debug)
2377 2539
 			{
@@ -2402,11 +2564,17 @@  discard block
 block discarded – undo
2402 2564
 					'start'	=> $ft_start,
2403 2565
 					'end'	=> $ft_end,
2404 2566
 				);
2405
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2567
+				if ($this->debug > 1)
2568
+				{
2569
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2570
+				}
2406 2571
 			}
2407 2572
 			$ft_start = $event['end'];
2408 2573
 		}
2409
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2574
+		if ($this->debug > 0)
2575
+		{
2576
+			$this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2577
+		}
2410 2578
 
2411 2579
 		return $freetime;
2412 2580
 	}
@@ -2426,10 +2594,16 @@  discard block
 block discarded – undo
2426 2594
 	 */
2427 2595
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2428 2596
 	{
2429
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2597
+		if ($this->debug > 1)
2598
+		{
2599
+			$this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2600
+		}
2430 2601
 
2431 2602
 		$freetime_daywise = array();
2432
-		if (!is_array($sel_options)) $sel_options = array();
2603
+		if (!is_array($sel_options))
2604
+		{
2605
+			$sel_options = array();
2606
+		}
2433 2607
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2434 2608
 
2435 2609
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2439,7 +2613,10 @@  discard block
 block discarded – undo
2439 2613
 		if (($end_time - $start_time)*HOUR_s < $duration)
2440 2614
 		{
2441 2615
 			$end_time = 0;
2442
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2616
+			if ($this->debug > 1)
2617
+			{
2618
+				$this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2619
+			}
2443 2620
 		}
2444 2621
 		$n = 0;
2445 2622
 		foreach($freetime as $ft)
@@ -2460,13 +2637,19 @@  discard block
 block discarded – undo
2460 2637
 				}
2461 2638
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2462 2639
 
2463
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2640
+				if ($start-$daybegin < $start_time*HOUR_s)
2641
+				{
2642
+					// start earlier then start_time
2464 2643
 				{
2465 2644
 					$start = $daybegin + $start_time*HOUR_s;
2466 2645
 				}
2646
+				}
2467 2647
 				// if end_time given use it, else the original slot's end
2468 2648
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2469
-				if ($end > $ft['end']) $end = $ft['end'];
2649
+				if ($end > $ft['end'])
2650
+				{
2651
+					$end = $ft['end'];
2652
+				}
2470 2653
 
2471 2654
 				// slot to small for duration
2472 2655
 				if ($end - $start < $duration)
@@ -2508,7 +2691,10 @@  discard block
 block discarded – undo
2508 2691
 			{
2509 2692
 				$msg = lang('Permission denied');
2510 2693
 
2511
-				if ($return_error) return $msg;
2694
+				if ($return_error)
2695
+				{
2696
+					return $msg;
2697
+				}
2512 2698
 			}
2513 2699
 			else
2514 2700
 			{
@@ -2570,27 +2756,42 @@  discard block
 block discarded – undo
2570 2756
 		{
2571 2757
 			list($button) = each($_content['button']);
2572 2758
 			unset($_content['button']);
2573
-			if ($button != 'cancel')	// store changed Acl
2759
+			if ($button != 'cancel')
2760
+			{
2761
+				// store changed Acl
2574 2762
 			{
2575 2763
 				foreach($_content as $data)
2576 2764
 				{
2577 2765
 					if (!($cat_id = $data['cat_id'])) continue;
2766
+			}
2578 2767
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2579 2768
 					{
2580 2769
 						$rights = 0;
2581
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2582
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2583
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2770
+						if (in_array($account_id,(array)$data['add']))
2771
+						{
2772
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2773
+						}
2774
+						if (in_array($account_id,(array)$data['status']))
2775
+						{
2776
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2777
+						}
2778
+						if ($account_id)
2779
+						{
2780
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2781
+						}
2584 2782
 					}
2585 2783
 				}
2586 2784
 			}
2587
-			if ($button != 'apply')	// end dialog
2785
+			if ($button != 'apply')
2786
+			{
2787
+				// end dialog
2588 2788
 			{
2589 2789
 				Egw::redirect_link('/index.php', array(
2590 2790
 					'menuaction' => 'admin.admin_ui.index',
2591 2791
 					'ajax' => 'true'
2592 2792
 				), 'admin');
2593 2793
 			}
2794
+			}
2594 2795
 		}
2595 2796
 		$content= $preserv = array();
2596 2797
 		$n = 1;
@@ -2604,8 +2805,14 @@  discard block
 block discarded – undo
2604 2805
 			);
2605 2806
 			foreach($data as $account_id => $rights)
2606 2807
 			{
2607
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2608
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2808
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2809
+				{
2810
+					$row['add'][] = $account_id;
2811
+				}
2812
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2813
+				{
2814
+					$row['status'][] = $account_id;
2815
+				}
2609 2816
 			}
2610 2817
 			$content[$n] = $row;
2611 2818
 			$preserv[$n] = array(
@@ -2733,7 +2940,10 @@  discard block
 block discarded – undo
2733 2940
 					break;
2734 2941
 				}
2735 2942
 			}
2736
-			if($return) return;
2943
+			if($return)
2944
+			{
2945
+				return;
2946
+			}
2737 2947
 		}
2738 2948
 		$old_event=$event=$this->bo->read($eventId);
2739 2949
 		if (!$durationT)
@@ -2827,7 +3037,10 @@  discard block
 block discarded – undo
2827 3037
 			$this->bo->update($event,true, true, false, true, $message,true);
2828 3038
 
2829 3039
 			// Whole day non blocking with DAY_s would add a day
2830
-			if($duration==DAY_s) $duration=0;
3040
+			if($duration==DAY_s)
3041
+			{
3042
+				$duration=0;
3043
+			}
2831 3044
 		}
2832 3045
 
2833 3046
 		$status_reset_to_unknown = false;
@@ -2845,7 +3058,10 @@  discard block
 block discarded – undo
2845 3058
 					case 'no':
2846 3059
 						break;
2847 3060
 					case 'startday':
2848
-						if ($sameday) break;
3061
+						if ($sameday)
3062
+						{
3063
+							break;
3064
+						}
2849 3065
 					default:
2850 3066
 						$status_reset_to_unknown = true;
2851 3067
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2889,7 +3105,10 @@  discard block
 block discarded – undo
2889 3105
 		{
2890 3106
 			$response->call('egw.message',  implode('<br />', $message));
2891 3107
 		}
2892
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
3108
+		if($event['id'] != $eventId )
3109
+		{
3110
+			$this->update_client($_eventId);
3111
+		}
2893 3112
 		if ($status_reset_to_unknown)
2894 3113
 		{
2895 3114
 			foreach((array)$event['participants'] as $uid => $status)
Please login to merge, or discard this patch.
Spacing   +466 added lines, -468 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var locktime in seconds
57 57
 	 */
58
-	var $locktime_default=1;
58
+	var $locktime_default = 1;
59 59
 
60 60
 	/**
61 61
 	 * Constructor
62 62
 	 */
63 63
 	function __construct()
64 64
 	{
65
-		parent::__construct(true);	// call the parent's constructor
65
+		parent::__construct(true); // call the parent's constructor
66 66
 
67
-		for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
67
+		for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
68 68
 		{
69
-			$this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60);
69
+			$this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60);
70 70
 		}
71 71
 	}
72 72
 
@@ -78,11 +78,10 @@  discard block
 block discarded – undo
78 78
 	function &default_add_event()
79 79
 	{
80 80
 		$extra_participants = $_GET['participants'] ?
81
-			(!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) :
82
-			array();
81
+			(!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array();
83 82
 
84 83
 		// if participant is a contact, add its link title as title
85
-		foreach($extra_participants as $uid)
84
+		foreach ($extra_participants as $uid)
86 85
 		{
87 86
 			if ($uid[0] == 'c')
88 87
 			{
@@ -94,14 +93,14 @@  discard block
 block discarded – undo
94 93
 		if (isset($_GET['owner']))
95 94
 		{
96 95
 			$owner = $_GET['owner'];
97
-			if(!is_array($owner) && strpos($owner, ','))
96
+			if (!is_array($owner) && strpos($owner, ','))
98 97
 			{
99
-				$owner = explode(',',$owner);
98
+				$owner = explode(',', $owner);
100 99
 			}
101
-			if(is_array($owner))
100
+			if (is_array($owner))
102 101
 			{
103 102
 				// old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0'
104
-				if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
103
+				if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
105 104
 				{
106 105
 					$extra_participants += $owner;
107 106
 				}
@@ -117,21 +116,21 @@  discard block
 block discarded – undo
117 116
 			// old behavior "selected" should also be used for not set preference, therefore we need to test for === '0'
118 117
 			$owner = $this->cal_prefs['default_participant'] === '0' ? $this->user : $this->owner;
119 118
 		}
120
-		error_log(__METHOD__ . ' owner: ' . array2string($owner));
119
+		error_log(__METHOD__.' owner: '.array2string($owner));
121 120
 
122 121
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
123
-			!$this->bo->check_perms(Acl::ADD,0,$owner))
122
+			!$this->bo->check_perms(Acl::ADD, 0, $owner))
124 123
 		{
125 124
 			if ($owner)	// make an owner who is no user or we have no add-rights a participant
126 125
 			{
127
-				if(!is_array($owner))
126
+				if (!is_array($owner))
128 127
 				{
129
-					$owner = explode(',',$owner);
128
+					$owner = explode(',', $owner);
130 129
 				}
131 130
 				// if we come from ressources we don't need any users selected in calendar
132 131
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
133 132
 				{
134
-					foreach($owner as $uid)
133
+					foreach ($owner as $uid)
135 134
 					{
136 135
 						$extra_participants[] = $uid;
137 136
 					}
@@ -141,71 +140,71 @@  discard block
 block discarded – undo
141 140
 		}
142 141
 		//error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")");
143 142
 
144
-		if(isset($_GET['start']))
143
+		if (isset($_GET['start']))
145 144
 		{
146 145
 			$start = Api\DateTime::to($_GET['start'], 'ts');
147 146
 		}
148 147
 		else
149 148
 		{
150 149
 			$start = $this->bo->date2ts(array(
151
-				'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date,
152
-				'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
153
-				'minute' => (int) $_GET['minute'],
150
+				'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date,
151
+				'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
152
+				'minute' => (int)$_GET['minute'],
154 153
 			));
155 154
 		}
156 155
 		//echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n";
157 156
 
158 157
 		$participant_types['u'] = $participant_types = $participants = array();
159
-		foreach($extra_participants as $uid)
158
+		foreach ($extra_participants as $uid)
160 159
 		{
161
-			if (isset($participants[$uid])) continue;	// already included
160
+			if (isset($participants[$uid])) continue; // already included
162 161
 
163
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
162
+			if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored
164 163
 
165 164
 			if (is_numeric($uid))
166 165
 			{
167 166
 				$participants[$uid] = $participant_types['u'][$uid] =
168
-					calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
169
-					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
167
+					calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
168
+					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
170 169
 			}
171 170
 			elseif (is_array($this->bo->resources[$uid[0]]))
172 171
 			{
173 172
 				// Expand mailing lists
174
-				if($uid[0] == 'l')
173
+				if ($uid[0] == 'l')
175 174
 				{
176
-					foreach($this->bo->enum_mailing_list($uid) as $contact)
175
+					foreach ($this->bo->enum_mailing_list($uid) as $contact)
177 176
 					{
178
-						$participants[$contact] = $participant_types['c'][substr($contact,1)] =
179
-							calendar_so::combine_status('U',1,'REQ-PARTICIPANT');
177
+						$participants[$contact] = $participant_types['c'][substr($contact, 1)] =
178
+							calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT');
180 179
 					}
181 180
 					continue;
182 181
 				}
183 182
 				// if contact is a user, use the user instead (as the GUI)
184
-				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
183
+				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id')))
185 184
 				{
186 185
 					$uid = $account_id;
187 186
 					$participants[$uid] = $participant_types['u'][$uid] =
188
-						calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
189
-						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
187
+						calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
188
+						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
190 189
 					continue;
191 190
 				}
192 191
 				$res_data = $this->bo->resources[$uid[0]];
193
-				list($id,$quantity) = explode(':',substr($uid,1));
194
-				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U'))
192
+				list($id, $quantity) = explode(':', substr($uid, 1));
193
+				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U'))
195 194
 				{
196 195
 					$participants[$uid] = $participant_types[$uid[0]][$id] =
197
-						calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT');
196
+						calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT');
198 197
 				}
199 198
 			}
200 199
 		}
201 200
 		if (!$participants)	// if all participants got removed, include current user
202 201
 		{
203
-			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
202
+			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR');
204 203
 		}
205
-		if(isset($_GET['cat_id']))
204
+		if (isset($_GET['cat_id']))
206 205
 		{
207
-			$cat_id = explode(',',$_GET['cat_id']);
208
-			foreach($cat_id as &$cat)
206
+			$cat_id = explode(',', $_GET['cat_id']);
207
+			foreach ($cat_id as &$cat)
209 208
 			{
210 209
 				$cat = (int)$cat;
211 210
 			}
@@ -216,16 +215,16 @@  discard block
 block discarded – undo
216 215
 		if ((string)$this->cal_prefs['default-alarm'] !== '')
217 216
 		{
218 217
 			$offset = 60 * $this->cal_prefs['default-alarm'];
219
-			$alarms[1] =  array(
218
+			$alarms[1] = array(
220 219
 				'default' => 1,
221
-				'offset' => $offset ,
220
+				'offset' => $offset,
222 221
 				'time'   => $start - $offset,
223 222
 				'all'    => false,
224 223
 				'owner'  => $owner,
225 224
 				'id'	=> 1,
226 225
 			);
227 226
 		}
228
-		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60;
227
+		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60;
229 228
 		$end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration;
230 229
 		return array(
231 230
 			'participant_types' => $participant_types,
@@ -234,7 +233,7 @@  discard block
 block discarded – undo
234 233
 			'start' => $start,
235 234
 			'end'   => $end,
236 235
 			'tzid'  => $this->bo->common_prefs['tz'],
237
-			'priority' => 2,	// normal
236
+			'priority' => 2, // normal
238 237
 			'public'=> $this->cal_prefs['default_private'] ? 0 : 1,
239 238
 			'alarm' => $alarms,
240 239
 			'recur_exception' => array(),
@@ -253,7 +252,7 @@  discard block
 block discarded – undo
253 252
 	{
254 253
 		if (!is_array($content))	// redirect from etemplate, if POST empty
255 254
 		{
256
-			return $this->edit(null,null,strip_tags($_GET['msg']));
255
+			return $this->edit(null, null, strip_tags($_GET['msg']));
257 256
 		}
258 257
 		// clear notification errors
259 258
 		notifications::errors(true);
@@ -267,22 +266,22 @@  discard block
 block discarded – undo
267 266
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
268 267
 
269 268
 		list($button) = @each($content['button']);
270
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
269
+		if (!$button && $content['action']) $button = $content['action']; // action selectbox
271 270
 		unset($content['button']); unset($content['action']);
272 271
 
273 272
 		$view = $content['view'];
274 273
 		if ($button == 'ical')
275 274
 		{
276
-			$msg = $this->export($content['id'],true);
275
+			$msg = $this->export($content['id'], true);
277 276
 		}
278 277
 		// delete a recur-exception
279 278
 		if ($content['recur_exception']['delete_exception'])
280 279
 		{
281 280
 			list($date) = each($content['recur_exception']['delete_exception']);
282 281
 			// eT2 converts time to
283
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
282
+			if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts');
284 283
 			unset($content['recur_exception']['delete_exception']);
285
-			if (($key = array_search($date,$content['recur_exception'])) !== false)
284
+			if (($key = array_search($date, $content['recur_exception'])) !== false)
286 285
 			{
287 286
 				// propagate the exception to a single event
288 287
 				$recur_exceptions = $this->bo->so->get_related($content['uid']);
@@ -292,7 +291,7 @@  discard block
 block discarded – undo
292 291
 							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
293 292
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
294 293
 					$exception['reference'] = $exception['recurrence'] = 0;
295
-					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
294
+					$this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']);
296 295
 					break;
297 296
 				}
298 297
 				unset($content['recur_exception'][$key]);
@@ -333,7 +332,7 @@  discard block
 block discarded – undo
333 332
 			$def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')];
334 333
 			if ((string)$def_alarm === '')
335 334
 			{
336
-				unset($content['alarm'][1]);	// '' = no alarm on whole day --> delete it
335
+				unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it
337 336
 			}
338 337
 			else
339 338
 			{
@@ -347,7 +346,7 @@  discard block
 block discarded – undo
347 346
 		unset($event['alarm']['delete_alarm']);
348 347
 		unset($event['duration']);
349 348
 
350
-		if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series')))
349
+		if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series')))
351 350
 		{
352 351
 			// no conversation necessary, event is already in the right format
353 352
 		}
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
 			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
368 367
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
369 368
 			{
370
-				$event['recur_data'] = 1 << (int)date('w',$event['start']);
369
+				$event['recur_data'] = 1 << (int)date('w', $event['start']);
371 370
 			}
372 371
 			if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate']))
373 372
 			{
@@ -379,9 +378,9 @@  discard block
 block discarded – undo
379 378
 
380 379
 				$event['participants'] = $event['participant_types'] = array();
381 380
 
382
-				foreach($content['participants'] as $key => $data)
381
+				foreach ($content['participants'] as $key => $data)
383 382
 				{
384
-					switch($key)
383
+					switch ($key)
385 384
 					{
386 385
 						case 'delete':		// handled in default
387 386
 						case 'quantity':	// handled in new_resource
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
 						case 'status_date':
391 390
 							break;
392 391
 						case 'participant':
393
-							foreach($data as $participant)
392
+							foreach ($data as $participant)
394 393
 							{
395 394
 								if (is_null($participant))
396 395
 								{
@@ -399,17 +398,17 @@  discard block
 block discarded – undo
399 398
 
400 399
 								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
401 400
 								$email = array();
402
-								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
401
+								if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email))
403 402
 								{
404
-									$status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']);
405
-									if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data))
403
+									$status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']);
404
+									if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data))
406 405
 									{
407 406
 										$event['participants'][$data] = $event['participant_types']['u'][$data] = $status;
408 407
 									}
409
-									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array(
408
+									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array(
410 409
 										'email' => $email[2],
411 410
 										'email_home' => $email[2],
412
-									),true,'','','',false,'OR')))
411
+									), true, '', '', '', false, 'OR')))
413 412
 									{
414 413
 										$event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status;
415 414
 									}
@@ -420,7 +419,7 @@  discard block
 block discarded – undo
420 419
 								}
421 420
 								else
422 421
 								{
423
-									if(is_numeric($participant))
422
+									if (is_numeric($participant))
424 423
 									{
425 424
 										$uid = $participant;
426 425
 										$id = $participant;
@@ -429,12 +428,12 @@  discard block
 block discarded – undo
429 428
 									else
430 429
 									{
431 430
 										$uid = $participant;
432
-										$id = substr($participant,1);
431
+										$id = substr($participant, 1);
433 432
 										$resource = $this->bo->resources[$participant[0]];
434 433
 									}
435
-									if(!$this->bo->check_acl_invite($uid))
434
+									if (!$this->bo->check_acl_invite($uid))
436 435
 									{
437
-										if(!$msg_permission_denied_added)
436
+										if (!$msg_permission_denied_added)
438 437
 										{
439 438
 											$msg .= lang('Permission denied!');
440 439
 											$msg_permission_denied_added = true;
@@ -444,19 +443,18 @@  discard block
 block discarded – undo
444 443
 
445 444
 									$type = $resource['type'];
446 445
 									$status = isset($this->bo->resources[$type]['new_status']) ?
447
-										ExecMethod($this->bo->resources[$type]['new_status'],$id) :
448
-										($uid == $this->bo->user ? 'A' : 'U');
446
+										ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U');
449 447
 
450 448
 									// Expand mailing lists
451
-									if($type == 'l')
449
+									if ($type == 'l')
452 450
 									{
453
-										foreach($this->bo->enum_mailing_list($participant) as $contact)
451
+										foreach ($this->bo->enum_mailing_list($participant) as $contact)
454 452
 										{
455 453
 											// Mailing lists can contain users, so allow for that possibility
456 454
 											$_type = is_numeric($contact) ? '' : $contact[0];
457
-											$_uid = is_numeric($contact) ? $contact : substr($contact,1);
455
+											$_uid = is_numeric($contact) ? $contact : substr($contact, 1);
458 456
 											$event['participants'][$contact] = $event['participant_types'][$_type][$_uid] =
459
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
457
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
460 458
 										}
461 459
 										continue;
462 460
 									}
@@ -466,8 +464,8 @@  discard block
 block discarded – undo
466 464
 										// todo check real availability = maximum - already booked quantity
467 465
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
468 466
 										{
469
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
470
-											foreach(array('quantity','resource','role') as $n)
467
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
468
+											foreach (array('quantity', 'resource', 'role') as $n)
471 469
 											{
472 470
 												$event['participants'][$n] = $content['participants'][$n];
473 471
 											}
@@ -476,7 +474,7 @@  discard block
 block discarded – undo
476 474
 										else
477 475
 										{
478 476
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
479
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
477
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
480 478
 										}
481 479
 									}
482 480
 								}
@@ -490,14 +488,14 @@  discard block
 block discarded – undo
490 488
 							break;
491 489
 
492 490
 						default:		// existing participant row
493
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
494
-							foreach(array('uid','status','quantity','role') as $name)
491
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
492
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
495 493
 							{
496 494
 								$$name = $data[$name];
497 495
 							}
498 496
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
499 497
 							{
500
-								$uid = false;	// entry has been deleted
498
+								$uid = false; // entry has been deleted
501 499
 							}
502 500
 							elseif ($uid)
503 501
 							{
@@ -508,27 +506,27 @@  discard block
 block discarded – undo
508 506
 								}
509 507
 								else
510 508
 								{
511
-									$id = substr($uid,1);
509
+									$id = substr($uid, 1);
512 510
 									$type = $uid[0];
513 511
 								}
514 512
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
515 513
 								{
516 514
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
517 515
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
518
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
516
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
519 517
 									{
520 518
 										// Update main window
521 519
 										$d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone);
522 520
 										$client_updated = $this->update_client($event['id'], $d);
523 521
 
524 522
 										// refreshing the calendar-view with the changed participant-status
525
-										if($event['recur_type'] != MCAL_RECUR_NONE)
523
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
526 524
 										{
527 525
 											$msg = lang('Status for all future scheduled days changed');
528 526
 										}
529 527
 										else
530 528
 										{
531
-											if(isset($content['edit_single']))
529
+											if (isset($content['edit_single']))
532 530
 											{
533 531
 												$msg = lang('Status for this particular day changed');
534 532
 												// prevent accidentally creating a real exception afterwards
@@ -549,7 +547,7 @@  discard block
 block discarded – undo
549 547
 										if ($status == 'R' && $event['alarm'])
550 548
 										{
551 549
 											// remove from bo->set_status deleted alarms of rejected users from UI too
552
-											foreach($event['alarm'] as $alarm_id => $alarm)
550
+											foreach ($event['alarm'] as $alarm_id => $alarm)
553 551
 											{
554 552
 												if ((string)$alarm['owner'] === (string)$uid)
555 553
 												{
@@ -562,7 +560,7 @@  discard block
 block discarded – undo
562 560
 								if ($uid && $status != 'G')
563 561
 								{
564 562
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
565
-										calendar_so::combine_status($status,$quantity,$role);
563
+										calendar_so::combine_status($status, $quantity, $role);
566 564
 								}
567 565
 							}
568 566
 							break;
@@ -581,26 +579,26 @@  discard block
 block discarded – undo
581 579
 			'tabs'			=> $content['tabs'],
582 580
 			'template'      => $content['template'],
583 581
 		);
584
-		$noerror=true;
582
+		$noerror = true;
585 583
 
586 584
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
587 585
 
588 586
 		$ignore_conflicts = $status_reset_to_unknown = false;
589 587
 
590
-		switch((string)$button)
588
+		switch ((string)$button)
591 589
 		{
592 590
 			case 'ignore':
593 591
 				$ignore_conflicts = true;
594
-				$button = $event['button_was'];	// save or apply
592
+				$button = $event['button_was']; // save or apply
595 593
 				unset($event['button_was']);
596 594
 				break;
597 595
 
598 596
 		}
599 597
 
600
-		switch((string)$button)
598
+		switch ((string)$button)
601 599
 		{
602 600
 		case 'exception':	// create an exception in a recuring event
603
-			$msg = $this->_create_exception($event,$preserv);
601
+			$msg = $this->_create_exception($event, $preserv);
604 602
 			break;
605 603
 
606 604
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -611,29 +609,29 @@  discard block
 block discarded – undo
611 609
 			unset($event['recurrence']);
612 610
 			unset($preserv['recurrence']);
613 611
 			unset($event['recur_exception']);
614
-			unset($event['edit_single']);	// in case it has been set
612
+			unset($event['edit_single']); // in case it has been set
615 613
 			unset($event['modified']);
616 614
 			unset($event['modifier']);
617 615
 			unset($event['caldav_name']);
618
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
616
+			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner'];
619 617
 
620 618
 			// Clear participant stati
621
-			foreach($event['participant_types'] as $type => &$participants)
619
+			foreach ($event['participant_types'] as $type => &$participants)
622 620
 			{
623
-				foreach($participants as $id => &$p_response)
621
+				foreach ($participants as $id => &$p_response)
624 622
 				{
625
-					if($type == 'u' && $id == $event['owner']) continue;
623
+					if ($type == 'u' && $id == $event['owner']) continue;
626 624
 					calendar_so::split_status($p_response, $quantity, $role);
627 625
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
628
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
629
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
626
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
627
+					$p_response = calendar_so::combine_status($status, $quantity, $role);
630 628
 				}
631 629
 			}
632 630
 
633 631
 			// Copy alarms
634 632
 			if (is_array($event['alarm']))
635 633
 			{
636
-				foreach($event['alarm'] as $n => &$alarm)
634
+				foreach ($event['alarm'] as $n => &$alarm)
637 635
 				{
638 636
 					unset($alarm['id']);
639 637
 					unset($alarm['cal_id']);
@@ -643,7 +641,7 @@  discard block
 block discarded – undo
643 641
 			// Get links to be copied
644 642
 			// With no ID, $content['link_to']['to_id'] is used
645 643
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
646
-			foreach(Link::get_links('calendar', $content['id']) as $link)
644
+			foreach (Link::get_links('calendar', $content['id']) as $link)
647 645
 			{
648 646
 				if ($link['app'] != Link::VFS_APPNAME)
649 647
 				{
@@ -659,7 +657,7 @@  discard block
 block discarded – undo
659 657
 			}
660 658
 			unset($link);
661 659
 			$preserv['view'] = $preserv['edit_single'] = false;
662
-			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry')));
660
+			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry')));
663 661
 			$event['title'] = lang('Copy of:').' '.$event['title'];
664 662
 			break;
665 663
 
@@ -669,7 +667,7 @@  discard block
 block discarded – undo
669 667
 		case 'print':
670 668
 		case 'apply':
671 669
 		case 'infolog':
672
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
670
+			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event))
673 671
 			{
674 672
 				$msg = lang('Permission denied');
675 673
 				$button = '';
@@ -687,7 +685,7 @@  discard block
 block discarded – undo
687 685
 				$button = '';
688 686
 				break;
689 687
 			}
690
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
688
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
691 689
 			{
692 690
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
693 691
 				$button = '';
@@ -717,14 +715,14 @@  discard block
 block discarded – undo
717 715
 				$event['reference'] = $event['id'];
718 716
 				$event['recurrence'] = $content['edit_single'];
719 717
 				unset($event['id']);
720
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
718
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
721 719
 				if (!is_array($conflicts) && $conflicts)
722 720
 				{
723 721
 					// now we need to add the original start as recur-execption to the series
724 722
 					$recur_event = $this->bo->read($event['reference']);
725 723
 					$recur_event['recur_exception'][] = $content['edit_single'];
726 724
 					// check if we need to move the alarms, because they are next on that exception
727
-					foreach($recur_event['alarm'] as $id => $alarm)
725
+					foreach ($recur_event['alarm'] as $id => $alarm)
728 726
 					{
729 727
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
730 728
 						{
@@ -740,17 +738,17 @@  discard block
 block discarded – undo
740 738
 							}
741 739
 						}
742 740
 					}
743
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
744
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
745
-					$this->bo->update($recur_event,true);	// no conflict check here
741
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
742
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
743
+					$this->bo->update($recur_event, true); // no conflict check here
746 744
 
747 745
 					// Save links
748
-					if($content['links'])
746
+					if ($content['links'])
749 747
 					{
750 748
 						Link::link('calendar', $event['id'], $content['links']['to_id']);
751 749
 					}
752 750
 
753
-					if(Api\Json\Response::isJSONResponse())
751
+					if (Api\Json\Response::isJSONResponse())
754 752
 					{
755 753
 						// Sending null will trigger a removal of the original
756 754
 						// for that date
@@ -758,7 +756,7 @@  discard block
 block discarded – undo
758 756
 					}
759 757
 
760 758
 					unset($recur_event);
761
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
759
+					unset($event['edit_single']); // if we further edit it, it's just a single event
762 760
 					unset($preserv['edit_single']);
763 761
 				}
764 762
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -789,8 +787,8 @@  discard block
 block discarded – undo
789 787
 							{
790 788
 								$offset = $off2;
791 789
 							}
792
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
793
-							if($msg)
790
+							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']);
791
+							if ($msg)
794 792
 							{
795 793
 								$noerror = false;
796 794
 							}
@@ -803,10 +801,10 @@  discard block
 block discarded – undo
803 801
 							$event['whole_day'] != $old_event['whole_day'])
804 802
 						{
805 803
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
806
-							foreach((array)$event['participants'] as $uid => $status)
804
+							foreach ((array)$event['participants'] as $uid => $status)
807 805
 							{
808 806
 								$q = $r = null;
809
-								calendar_so::split_status($status,$q,$r);
807
+								calendar_so::split_status($status, $q, $r);
810 808
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
811 809
 								{
812 810
 									$preferences = new Api\Preferences($uid);
@@ -819,7 +817,7 @@  discard block
 block discarded – undo
819 817
 											if ($sameday) break;
820 818
 										default:
821 819
 											$status_reset_to_unknown = true;
822
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
820
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
823 821
 											// todo: report reset status to user
824 822
 									}
825 823
 								}
@@ -831,43 +829,43 @@  discard block
 block discarded – undo
831 829
 				}
832 830
 				// Adding participants needs to be done as an edit, in case we
833 831
 				// have participants visible in seperate calendars
834
-				if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
832
+				if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
835 833
 				{
836 834
 					$update_type = 'edit';
837 835
 				}
838 836
 				// Changing category may affect event filtering
839
-				if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
837
+				if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
840 838
 				{
841 839
 					$update_type = 'edit';
842 840
 				}
843
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
841
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
844 842
 				unset($event['ignore']);
845 843
 			}
846 844
 			if (is_array($conflicts))
847 845
 			{
848
-				$event['button_was'] = $button;	// remember for ignore
849
-				return $this->conflicts($event,$conflicts,$preserv);
846
+				$event['button_was'] = $button; // remember for ignore
847
+				return $this->conflicts($event, $conflicts, $preserv);
850 848
 			}
851 849
 
852 850
 			// Event spans multiple days, need an edit to make sure they all get updated
853 851
 			// We could check old date, as removing from days could still be an update
854
-			if(date('Ymd', $event['start']) != date('Ymd', $event['end']))
852
+			if (date('Ymd', $event['start']) != date('Ymd', $event['end']))
855 853
 			{
856 854
 				$update_type = 'edit';
857 855
 			}
858 856
 			// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
859 857
 			if ($messages)
860 858
 			{
861
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
859
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
862 860
 			}
863 861
 			if ($conflicts === 0)
864 862
 			{
865
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
866
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
867
-								htmlspecialchars(Egw::link('/index.php',array(
863
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
864
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
865
+								htmlspecialchars(Egw::link('/index.php', array(
868 866
 								'menuaction' => 'calendar.calendar_uiforms.edit',
869 867
 								'cal_id'    => $content['id'],
870
-							))).'">','</a>');
868
+							))).'">', '</a>');
871 869
 				$noerror = false;
872 870
 			}
873 871
 			elseif ($conflicts > 0)
@@ -889,19 +887,19 @@  discard block
 block discarded – undo
889 887
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
890 888
 						if ($alarm['time'] < $this->bo->now_su)
891 889
 						{
892
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
890
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
893 891
 							{
894
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
892
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
895 893
 							}
896 894
 							else
897 895
 							{
898
-								$alarm = false;	// no (further) recurence found --> ignore alarm
896
+								$alarm = false; // no (further) recurence found --> ignore alarm
899 897
 							}
900 898
 						}
901 899
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
902 900
 						elseif ($event_time < $event['start'])
903 901
 						{
904
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
902
+							$alarm['time'] = $event['start'] - $alarm['offset'];
905 903
 						}
906 904
 						if ($alarm)
907 905
 						{
@@ -910,9 +908,9 @@  discard block
 block discarded – undo
910 908
 						}
911 909
 					}
912 910
 					// attach all future exceptions to the new series
913
-					$events =& $this->bo->search(array(
911
+					$events = & $this->bo->search(array(
914 912
 						'query' => array('cal_uid' => $old_event['uid']),
915
-						'filter' => 'owner',  // return all possible entries
913
+						'filter' => 'owner', // return all possible entries
916 914
 						'daywise' => false,
917 915
 						'date_format' => 'ts',
918 916
 					));
@@ -923,7 +921,7 @@  discard block
 block discarded – undo
923 921
 							$exception['recurrence'] += $offset;
924 922
 							$exception['reference'] = $event['id'];
925 923
 							$exception['uid'] = $event['uid'];
926
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
924
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
927 925
 						}
928 926
 					}
929 927
 				}
@@ -931,12 +929,12 @@  discard block
 block discarded – undo
931 929
 				$message = lang('Event saved');
932 930
 				if ($status_reset_to_unknown)
933 931
 				{
934
-					foreach((array)$event['participants'] as $uid => $status)
932
+					foreach ((array)$event['participants'] as $uid => $status)
935 933
 					{
936 934
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
937 935
 						{
938
-							calendar_so::split_status($status,$q,$r);
939
-							$status = calendar_so::combine_status('U',$q,$r);
936
+							calendar_so::split_status($status, $q, $r);
937
+							$status = calendar_so::combine_status('U', $q, $r);
940 938
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
941 939
 						}
942 940
 					}
@@ -944,17 +942,17 @@  discard block
 block discarded – undo
944 942
 				}
945 943
 
946 944
 				$response = Api\Json\Response::get();
947
-				if($response && $update_type != 'delete')
945
+				if ($response && $update_type != 'delete')
948 946
 				{
949 947
 					$client_updated = $this->update_client($event['id']);
950 948
 				}
951 949
 
952
-				$msg = $message . ($msg ? ', ' . $msg : '');
950
+				$msg = $message.($msg ? ', '.$msg : '');
953 951
 				Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete');
954 952
 				// writing links for new entry, existing ones are handled by the widget itself
955 953
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
956 954
 				{
957
-					Link::link('calendar',$event['id'],$content['link_to']['to_id']);
955
+					Link::link('calendar', $event['id'], $content['link_to']['to_id']);
958 956
 				}
959 957
 			}
960 958
 			else
@@ -964,7 +962,7 @@  discard block
 block discarded – undo
964 962
 			break;
965 963
 
966 964
 		case 'cancel':
967
-			if($content['cancel_needs_refresh'])
965
+			if ($content['cancel_needs_refresh'])
968 966
 			{
969 967
 				Framework::refresh_opener($msg, 'calendar');
970 968
 			}
@@ -1002,7 +1000,7 @@  discard block
 block discarded – undo
1002 1000
 			{
1003 1001
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
1004 1002
 			}
1005
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
1003
+			if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
1006 1004
 			{
1007 1005
 				$alarm = array(
1008 1006
 					'offset' => $offset,
@@ -1016,13 +1014,13 @@  discard block
 block discarded – undo
1016 1014
 				}
1017 1015
 				elseif ($event['id'])	// save the alarm immediatly
1018 1016
 				{
1019
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1017
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
1020 1018
 					{
1021 1019
 						$alarm['id'] = $alarm_id;
1022 1020
 						$event['alarm'][$alarm_id] = $alarm;
1023 1021
 
1024 1022
 						$msg = lang('Alarm added');
1025
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1023
+						Framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
1026 1024
 					}
1027 1025
 					else
1028 1026
 					{
@@ -1031,7 +1029,7 @@  discard block
 block discarded – undo
1031 1029
 				}
1032 1030
 				else
1033 1031
 				{
1034
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1032
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1035 1033
 					$event['alarm'][$alarm['id']] = $alarm;
1036 1034
 				}
1037 1035
 			}
@@ -1048,31 +1046,31 @@  discard block
 block discarded – undo
1048 1046
 		}
1049 1047
 		// New event, send data before updating so it's there
1050 1048
 		$response = Api\Json\Response::get();
1051
-		if($response && !$content['id'] && $event['id'])
1049
+		if ($response && !$content['id'] && $event['id'])
1052 1050
 		{
1053 1051
 			$client_updated = $this->update_client($event['id']);
1054 1052
 		}
1055
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1053
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1056 1054
 		{
1057 1055
 			if ($content['lock_token'])	// remove an existing lock
1058 1056
 			{
1059
-				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1057
+				Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1060 1058
 			}
1061 1059
 			if ($content['no_popup'])
1062 1060
 			{
1063
-				Egw::redirect_link('/index.php',array(
1061
+				Egw::redirect_link('/index.php', array(
1064 1062
 					'menuaction' => 'calendar.calendar_uiviews.index',
1065 1063
 					'msg'        => $msg,
1066 1064
 				));
1067 1065
 			}
1068
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1066
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1069 1067
 			{
1070
-				Framework::refresh_opener($msg,'calendar');
1068
+				Framework::refresh_opener($msg, 'calendar');
1071 1069
 			}
1072 1070
 			else
1073 1071
 			{
1074 1072
 				Framework::refresh_opener($msg, 'calendar',
1075
-					$event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ),
1073
+					$event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''),
1076 1074
 					$button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete'
1077 1075
 				);
1078 1076
 			}
@@ -1080,7 +1078,7 @@  discard block
 block discarded – undo
1080 1078
 			exit();
1081 1079
 		}
1082 1080
 		unset($event['no_notifications']);
1083
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1081
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1084 1082
 	}
1085 1083
 
1086 1084
 	/**
@@ -1092,7 +1090,7 @@  discard block
 block discarded – undo
1092 1090
 	 * @param array &$preserv
1093 1091
 	 * @return string message that exception was created
1094 1092
 	 */
1095
-	function _create_exception(&$event,&$preserv)
1093
+	function _create_exception(&$event, &$preserv)
1096 1094
 	{
1097 1095
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1098 1096
 		$preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1102,25 +1100,25 @@  discard block
 block discarded – undo
1102 1100
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1103 1101
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1104 1102
 		$event['recur_type'] = MCAL_RECUR_NONE;
1105
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1103
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1106 1104
 		{
1107 1105
 			unset($event[$name]);
1108 1106
 		}
1109 1107
 		// add all alarms as new alarms to execption
1110 1108
 		$event['alarm'] = array_values((array)$event['alarm']);
1111
-		foreach($event['alarm'] as &$alarm)
1109
+		foreach ($event['alarm'] as &$alarm)
1112 1110
 		{
1113 1111
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1114 1112
 		}
1115 1113
 
1116 1114
 		// Copy links
1117
-		if(!is_array($event['link_to'])) $event['link_to'] = array();
1115
+		if (!is_array($event['link_to'])) $event['link_to'] = array();
1118 1116
 		$event['link_to']['to_app'] = 'calendar';
1119 1117
 		$event['link_to']['to_id'] = 0;
1120 1118
 		
1121
-		foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1119
+		foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1122 1120
 		{
1123
-			if(!$link['id']) continue;
1121
+			if (!$link['id']) continue;
1124 1122
 			if ($link['app'] != Link::VFS_APPNAME)
1125 1123
 			{
1126 1124
 				Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
@@ -1136,7 +1134,7 @@  discard block
 block discarded – undo
1136 1134
 
1137 1135
 		$event['links'] = $event['link_to'];
1138 1136
 
1139
-		if($this->bo->check_perms(Acl::EDIT,$event))
1137
+		if ($this->bo->check_perms(Acl::EDIT, $event))
1140 1138
 		{
1141 1139
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1142 1140
 		}
@@ -1163,14 +1161,14 @@  discard block
 block discarded – undo
1163 1161
 	{
1164 1162
 		$msg = false;
1165 1163
 
1166
-		if(!$as_of_date )
1164
+		if (!$as_of_date)
1167 1165
 		{
1168 1166
 			$as_of_date = time();
1169 1167
 		}
1170 1168
 
1171 1169
 		//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
1172 1170
 
1173
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1171
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1174 1172
 		{
1175 1173
 			$msg = lang("Error: You can't shift a series from the past!");
1176 1174
 			return $msg;
@@ -1183,11 +1181,11 @@  discard block
 block discarded – undo
1183 1181
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1184 1182
 
1185 1183
 		// base start-date of new series on actual / clicked date
1186
-		$event['start'] = $as_of_date ;
1184
+		$event['start'] = $as_of_date;
1187 1185
 
1188
-		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1186
+		if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') ||
1189 1187
 			// Adjust for requested date in the past
1190
-			Api\DateTime::to($as_of_date,'ts') < time()
1188
+			Api\DateTime::to($as_of_date, 'ts') < time()
1191 1189
 		)
1192 1190
 		{
1193 1191
 
@@ -1207,17 +1205,17 @@  discard block
 block discarded – undo
1207 1205
 				$rriter->next_no_exception();
1208 1206
 				$occurrence = $rriter->current();
1209 1207
 			}
1210
-			while ($rriter->valid()  && (
1208
+			while ($rriter->valid() && (
1211 1209
 				Api\DateTime::to($occurrence, 'ts') <= time() ||
1212
-				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
1210
+				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd')
1213 1211
 			) && ($last = $occurrence));
1214 1212
 
1215 1213
 
1216 1214
 			// Make sure as_of_date is still valid, may have to move forward
1217
-			if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
1215
+			if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') ||
1218 1216
 				Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
1219 1217
 			{
1220
-				$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
1218
+				$event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset;
1221 1219
 			}
1222 1220
 
1223 1221
 			//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
@@ -1225,7 +1223,7 @@  discard block
 block discarded – undo
1225 1223
 			{
1226 1224
 				$event['end'] = $event['start'] + $duration;
1227 1225
 			}
1228
-			elseif($event['end'] < $event['start'])
1226
+			elseif ($event['end'] < $event['start'])
1229 1227
 			{
1230 1228
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1231 1229
 			}
@@ -1234,7 +1232,7 @@  discard block
 block discarded – undo
1234 1232
 			$event['participants'] = $old_event['participants'];
1235 1233
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1236 1234
 			{
1237
-				if ($exdate > Api\DateTime::to($last,'ts'))
1235
+				if ($exdate > Api\DateTime::to($last, 'ts'))
1238 1236
 				{
1239 1237
 					//error_log("Moved exception on " . Api\DateTime::to($exdate));
1240 1238
 					unset($old_event['recur_exception'][$key]);
@@ -1248,18 +1246,18 @@  discard block
 block discarded – undo
1248 1246
 			}
1249 1247
 			$last->setTime(0, 0, 0);
1250 1248
 			$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
1251
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1249
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1252 1250
 			{
1253
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1254
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1255
-						htmlspecialchars(Egw::link('/index.php',array(
1251
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1252
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1253
+						htmlspecialchars(Egw::link('/index.php', array(
1256 1254
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1257 1255
 							'cal_id'    => $event['id'],
1258
-						))).'">','</a>');
1256
+						))).'">', '</a>');
1259 1257
 				$event = $orig_event;
1260 1258
 			}
1261 1259
 		}
1262
-		$event['start'] = Api\DateTime::to($event['start'],'ts');
1260
+		$event['start'] = Api\DateTime::to($event['start'], 'ts');
1263 1261
 		return $msg;
1264 1262
 	}
1265 1263
 
@@ -1270,11 +1268,11 @@  discard block
 block discarded – undo
1270 1268
 	 * @param boolean $added
1271 1269
 	 * @return string javascript window.open command
1272 1270
 	 */
1273
-	function ajax_custom_mail($event,$added,$asrequest=false)
1271
+	function ajax_custom_mail($event, $added, $asrequest = false)
1274 1272
 	{
1275 1273
 		$to = array();
1276 1274
 
1277
-		foreach($event['participants'] as $uid => $status)
1275
+		foreach ($event['participants'] as $uid => $status)
1278 1276
 		{
1279 1277
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1280 1278
 			if (empty($status)) continue;
@@ -1283,32 +1281,32 @@  discard block
 block discarded – undo
1283 1281
 
1284 1282
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1285 1283
 			{
1286
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1284
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1287 1285
 
1288 1286
 				$toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '.
1289 1287
 					$GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>';
1290 1288
 
1291
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1289
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1292 1290
 			}
1293 1291
 			elseif ($uid < 0)
1294 1292
 			{
1295
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1293
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1296 1294
 				{
1297
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1295
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1298 1296
 
1299 1297
 					$toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1300 1298
 						$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>';
1301 1299
 
1302 1300
 					// dont add groupmembers if they already rejected the event, or are the current user
1303
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1301
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1304 1302
 				}
1305 1303
 			}
1306
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1304
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1307 1305
 			{
1308 1306
 				$to[] = $info['email'];
1309 1307
 				//error_log(__METHOD__.__LINE__.array2string($to));
1310 1308
 			}
1311
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1309
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1312 1310
 			{
1313 1311
 				$to[] = $info['email'];
1314 1312
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1317,7 +1315,7 @@  discard block
 block discarded – undo
1317 1315
 		// prefer event description over standard notification text
1318 1316
 		if (empty($event['description']))
1319 1317
 		{
1320
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1318
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1321 1319
 		}
1322 1320
 		else
1323 1321
 		{
@@ -1332,12 +1330,12 @@  discard block
 block discarded – undo
1332 1330
 		$boical = new calendar_ical();
1333 1331
 		// we need to pass $event[id] so iCal class reads event again,
1334 1332
 		// as event is in user TZ, but iCal class expects server TZ!
1335
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1333
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1336 1334
 
1337
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1338
-		if(($f = fopen($ics_file,'w')))
1335
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1336
+		if (($f = fopen($ics_file, 'w')))
1339 1337
 		{
1340
-			fwrite($f,$ics);
1338
+			fwrite($f, $ics);
1341 1339
 			fclose($f);
1342 1340
 		}
1343 1341
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1349,7 +1347,7 @@  discard block
 block discarded – undo
1349 1347
 			'preset[body]'    => $body,
1350 1348
 			'preset[name]'    => 'event.ics',
1351 1349
 			'preset[file]'    => $ics_file,
1352
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1350
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1353 1351
 			'preset[size]'    => filesize($ics_file),
1354 1352
 		);
1355 1353
 		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
@@ -1405,7 +1403,7 @@  discard block
 block discarded – undo
1405 1403
 	 * @param mixed $link_to_id ='' from or for the link-widget
1406 1404
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1407 1405
 	 */
1408
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1406
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1409 1407
 	{
1410 1408
 		$sel_options = array(
1411 1409
 			'recur_type' => &$this->bo->recur_types,
@@ -1429,8 +1427,8 @@  discard block
 block discarded – undo
1429 1427
 				'no_popup' => isset($_GET['no_popup']),
1430 1428
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1431 1429
 			);
1432
-			$cal_id = (int) $_GET['cal_id'];
1433
-			if($_GET['action'])
1430
+			$cal_id = (int)$_GET['cal_id'];
1431
+			if ($_GET['action'])
1434 1432
 			{
1435 1433
 				$event = $this->bo->read($cal_id);
1436 1434
 				$event['action'] = $_GET['action'];
@@ -1448,14 +1446,14 @@  discard block
 block discarded – undo
1448 1446
 			{
1449 1447
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1450 1448
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1451
-				$event =& $this->default_add_event();
1449
+				$event = & $this->default_add_event();
1452 1450
 			}
1453 1451
 			if (!empty($_GET['ical_data']) &&
1454 1452
 				!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
1455 1453
 			{
1456 1454
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1457 1455
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1458
-				$event =& $this->default_add_event();
1456
+				$event = & $this->default_add_event();
1459 1457
 			}
1460 1458
 			if (!empty($_GET['ical']))
1461 1459
 			{
@@ -1464,14 +1462,14 @@  discard block
 block discarded – undo
1464 1462
 				{
1465 1463
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1466 1464
 					$msg = lang('Error: importing the iCal');
1467
-					$event =& $this->default_add_event();
1465
+					$event = & $this->default_add_event();
1468 1466
 				}
1469 1467
 				else
1470 1468
 				{
1471 1469
 					if (count($events) > 1)
1472 1470
 					{
1473 1471
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1474
-						$msg_type = 'notice';	// no not hide automatic
1472
+						$msg_type = 'notice'; // no not hide automatic
1475 1473
 					}
1476 1474
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1477 1475
 					$this->bo->db2data($events, 'ts');
@@ -1484,7 +1482,7 @@  discard block
 block discarded – undo
1484 1482
 					else
1485 1483
 					{
1486 1484
 						$event['participant_types'] = array();
1487
-						foreach($event['participants'] as $uid => $status)
1485
+						foreach ($event['participants'] as $uid => $status)
1488 1486
 						{
1489 1487
 							$user_type = $user_id = null;
1490 1488
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1505,15 +1503,15 @@  discard block
 block discarded – undo
1505 1503
 					}
1506 1504
 					else
1507 1505
 					{
1508
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1506
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1509 1507
 						exit();
1510 1508
 					}
1511 1509
 				}
1512
-				$event =& $this->default_add_event();
1510
+				$event = & $this->default_add_event();
1513 1511
 			}
1514 1512
 			else
1515 1513
 			{
1516
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1514
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1517 1515
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1518 1516
 				{
1519 1517
 					if (empty($event['whole_day']))
@@ -1526,10 +1524,10 @@  discard block
 block discarded – undo
1526 1524
 						$date->setUser();
1527 1525
 					}
1528 1526
 					$event = $this->bo->read($cal_id, $date, true);
1529
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1527
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1530 1528
 					if ($_GET['exception'])
1531 1529
 					{
1532
-						$msg = $this->_create_exception($event,$preserv);
1530
+						$msg = $this->_create_exception($event, $preserv);
1533 1531
 					}
1534 1532
 					else
1535 1533
 					{
@@ -1538,9 +1536,9 @@  discard block
 block discarded – undo
1538 1536
 				}
1539 1537
 			}
1540 1538
 			// set new start and end if given by $_GET
1541
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1542
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1543
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1539
+			if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); }
1540
+			if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); }
1541
+			if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1544 1542
 			// check if the event is the whole day
1545 1543
 			$start = $this->bo->date2array($event['start']);
1546 1544
 			$end = $this->bo->date2array($event['end']);
@@ -1550,30 +1548,30 @@  discard block
 block discarded – undo
1550 1548
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1551 1549
 			{
1552 1550
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1553
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1551
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1554 1552
 				{
1555 1553
 					$link_id = $link_ids[$n];
1556
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1554
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1557 1555
 					{
1558 1556
 						continue;
1559 1557
 					}
1560
-					if(!$n)
1558
+					if (!$n)
1561 1559
 					{
1562
-						$event['title'] = Link::title($link_app,$link_id);
1560
+						$event['title'] = Link::title($link_app, $link_id);
1563 1561
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1564
-						if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1562
+						if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1565 1563
 						{
1566
-							foreach((array)$set['link_app'] as $i => $l_app)
1564
+							foreach ((array)$set['link_app'] as $i => $l_app)
1567 1565
 							{
1568
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1566
+								if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1569 1567
 							}
1570 1568
 							unset($set['link_app']);
1571 1569
 							unset($set['link_id']);
1572 1570
 
1573
-							$event = array_merge($event,$set);
1571
+							$event = array_merge($event, $set);
1574 1572
 						}
1575 1573
 					}
1576
-					Link::link('calendar',$link_to_id,$link_app,$link_id);
1574
+					Link::link('calendar', $link_to_id, $link_app, $link_id);
1577 1575
 				}
1578 1576
 			}
1579 1577
 		}
@@ -1583,44 +1581,44 @@  discard block
 block discarded – undo
1583 1581
 		{
1584 1582
 			$etpl->read($preserv['template'] = 'calendar.edit');
1585 1583
 		}
1586
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
1584
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event);
1587 1585
 		//echo "view=$view, event="; _debug_array($event);
1588 1586
 		// shared locking of entries to edit
1589 1587
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1590 1588
 		{
1591
-			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1589
+			$lock_path = Vfs::app_entry_lock_path('calendar', $event['id']);
1592 1590
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1593 1591
 
1594 1592
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1595 1593
 			{
1596
-				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1594
+				Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1597 1595
 			}
1598 1596
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1599 1597
 			{
1600 1598
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1601
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1599
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1602 1600
 					Api\Accounts::username($lock_uid) : $lock['owner']));
1603 1601
 			}
1604
-			elseif($lock)
1602
+			elseif ($lock)
1605 1603
 			{
1606 1604
 				$preserv['lock_token'] = $lock['token'];
1607 1605
 			}
1608
-			elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1606
+			elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1609 1607
 			{
1610 1608
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1611 1609
 			}
1612 1610
 			else
1613 1611
 			{
1614
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1612
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1615 1613
 				$view = true;
1616 1614
 			}
1617 1615
 		}
1618
-		$content = array_merge($event,array(
1616
+		$content = array_merge($event, array(
1619 1617
 			'link_to' => array(
1620 1618
 				'to_id'  => $link_to_id,
1621 1619
 				'to_app' => 'calendar',
1622 1620
 			),
1623
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1621
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1624 1622
 			'tabs'   => $preserv['tabs'],
1625 1623
 			'view' => $view,
1626 1624
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1632,11 +1630,11 @@  discard block
 block discarded – undo
1632 1630
 		$row = 3;
1633 1631
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1634 1632
 		// preserve some ui elements, if set eg. under error-conditions
1635
-		foreach(array('quantity','resource','role') as $n)
1633
+		foreach (array('quantity', 'resource', 'role') as $n)
1636 1634
 		{
1637 1635
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1638 1636
 		}
1639
-		foreach($event['participant_types'] as $type => $participants)
1637
+		foreach ($event['participant_types'] as $type => $participants)
1640 1638
 		{
1641 1639
 			$name = 'accounts';
1642 1640
 			if (isset($this->bo->resources[$type]))
@@ -1645,17 +1643,17 @@  discard block
 block discarded – undo
1645 1643
 			}
1646 1644
 			// sort participants (in there group/app) by title
1647 1645
 			uksort($participants, array($this, 'uid_title_cmp'));
1648
-			foreach($participants as $id => $status)
1646
+			foreach ($participants as $id => $status)
1649 1647
 			{
1650 1648
 				$uid = $type == 'u' ? $id : $type.$id;
1651 1649
 				$quantity = $role = null;
1652
-				calendar_so::split_status($status,$quantity,$role);
1650
+				calendar_so::split_status($status, $quantity, $role);
1653 1651
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1654 1652
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1655 1653
 					'uid'      => $uid,
1656 1654
 					'status'   => $status,
1657 1655
 					'old_status' => $status,
1658
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1656
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1659 1657
 					'role'     => $role,
1660 1658
 				);
1661 1659
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1664,33 +1662,33 @@  discard block
 block discarded – undo
1664 1662
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1665 1663
 				}
1666 1664
 				// allow third party apps to use categories for roles
1667
-				elseif(substr($role,0,6) == 'X-CAT-')
1665
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1668 1666
 				{
1669
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1667
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1670 1668
 				}
1671 1669
 				else
1672 1670
 				{
1673
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1671
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1674 1672
 				}
1675
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1673
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1676 1674
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1677 1675
 
1678
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1676
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1679 1677
 					$readonlys['participants'][$row]['status'] = $no_status;
1680
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1678
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event))
1681 1679
 					$readonlys['participants']['delete'][$uid] = true;
1682 1680
 				// todo: make the participants available as links with email as title
1683 1681
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1684 1682
 				// enumerate group-invitations, so people can accept/reject them
1685 1683
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1686
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1684
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1687 1685
 				{
1688 1686
 					$sel_options['status']['G'] = lang('Select one');
1689 1687
 					// sort members by title
1690 1688
 					usort($members, array($this, 'uid_title_cmp'));
1691
-					foreach($members as $member)
1689
+					foreach ($members as $member)
1692 1690
 					{
1693
-						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
1691
+						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member))
1694 1692
 						{
1695 1693
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1696 1694
 								'app'      => 'Group invitation',
@@ -1699,7 +1697,7 @@  discard block
 block discarded – undo
1699 1697
 							);
1700 1698
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1701 1699
 							// read access is enough to invite participants, but you need edit rights to change status
1702
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
1700
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member);
1703 1701
 							$content['participants'][$row++]['title'] = Api\Accounts::username($member);
1704 1702
 						}
1705 1703
 					}
@@ -1707,43 +1705,43 @@  discard block
 block discarded – undo
1707 1705
 			}
1708 1706
 			// resouces / apps we shedule, atm. resources and addressbook
1709 1707
 			$content['participants']['cal_resources'] = '';
1710
-			foreach($this->bo->resources as $data)
1708
+			foreach ($this->bo->resources as $data)
1711 1709
 			{
1712
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1710
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1713 1711
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1714 1712
 			}
1715 1713
 		}
1716 1714
 		$content['participants']['status_date'] = $preserv['actual_date'];
1717
-		$preserved = array_merge($preserv,$content);
1715
+		$preserved = array_merge($preserv, $content);
1718 1716
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1719 1717
 		if ($event['alarm'])
1720 1718
 		{
1721 1719
 			// makes keys of the alarm-array starting with 1
1722 1720
 			$content['alarm'] = array(false);
1723
-			foreach(array_values($event['alarm']) as $id => $alarm)
1721
+			foreach (array_values($event['alarm']) as $id => $alarm)
1724 1722
 			{
1725
-				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
1723
+				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
1726 1724
 				{
1727
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1725
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1728 1726
 				}
1729
-				$alarm['all'] = (int) $alarm['all'];
1727
+				$alarm['all'] = (int)$alarm['all'];
1730 1728
 				$after = false;
1731
-				if($alarm['offset'] < 0)
1729
+				if ($alarm['offset'] < 0)
1732 1730
 				{
1733 1731
 					$after = true;
1734 1732
 					$alarm['offset'] = -1 * $alarm['offset'];
1735 1733
 				}
1736
-				$days = (int) ($alarm['offset'] / DAY_s);
1737
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1738
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1734
+				$days = (int)($alarm['offset'] / DAY_s);
1735
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1736
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1739 1737
 				$label = array();
1740 1738
 				if ($days) $label[] = $days.' '.lang('days');
1741 1739
 				if ($hours) $label[] = $hours.' '.lang('hours');
1742 1740
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1743
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1741
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1744 1742
 				$content['alarm'][] = $alarm;
1745 1743
 
1746
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1744
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1747 1745
 			}
1748 1746
 			if (count($content['alarm']) == 1)
1749 1747
 			{
@@ -1758,20 +1756,20 @@  discard block
 block discarded – undo
1758 1756
 
1759 1757
 		if ($view)
1760 1758
 		{
1761
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1759
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1762 1760
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1763 1761
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1764 1762
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1765 1763
 
1766 1764
 			$content['participants']['no_add'] = true;
1767 1765
 
1768
-			if(!$event['whole_day'])
1766
+			if (!$event['whole_day'])
1769 1767
 			{
1770 1768
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1771 1769
 			}
1772 1770
 
1773 1771
 			// respect category permissions
1774
-			if(!empty($event['category']))
1772
+			if (!empty($event['category']))
1775 1773
 			{
1776 1774
 				$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
1777 1775
 			}
@@ -1782,7 +1780,7 @@  discard block
 block discarded – undo
1782 1780
 
1783 1781
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1784 1782
 			{
1785
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1783
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1786 1784
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1787 1785
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1788 1786
 			}
@@ -1792,9 +1790,9 @@  discard block
 block discarded – undo
1792 1790
 				$readonlys['recur_interval'] = $readonlys['recur_data'] = true;
1793 1791
 			}
1794 1792
 		}
1795
-		if($content['category'] && !is_array($content['category']))
1793
+		if ($content['category'] && !is_array($content['category']))
1796 1794
 		{
1797
-			$content['category'] = explode(',',$event['category']);
1795
+			$content['category'] = explode(',', $event['category']);
1798 1796
 		}
1799 1797
 		// disabling the custom fields tab, if there are none
1800 1798
 		$readonlys['tabs'] = array(
@@ -1811,13 +1809,13 @@  discard block
 block discarded – undo
1811 1809
 		{
1812 1810
 			$readonlys['action'] = true;
1813 1811
 		}
1814
-		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1812
+		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate'])))
1815 1813
 		{
1816 1814
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1817 1815
 		}
1818
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1816
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event);
1819 1817
 
1820
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1818
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event))	// new event or edit rights to the event ==> allow to add alarm for all users
1821 1819
 		{
1822 1820
 			$sel_options['owner'][0] = lang('All participants');
1823 1821
 		}
@@ -1825,25 +1823,25 @@  discard block
 block discarded – undo
1825 1823
 		{
1826 1824
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1827 1825
 		}
1828
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1826
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1829 1827
 		{
1830
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
1828
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid))
1831 1829
 			{
1832 1830
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1833 1831
 			}
1834 1832
 		}
1835
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1833
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1836 1834
 		if (!$event['id'])
1837 1835
 		{
1838
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1836
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1839 1837
 		}
1840 1838
 		if ($preserved['no_popup'])
1841 1839
 		{
1842
-			$etpl->set_cell_attribute('button[cancel]','onclick','');
1840
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', '');
1843 1841
 		}
1844 1842
 
1845 1843
 		// Allow admins to restore deleted events
1846
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1844
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1847 1845
 		{
1848 1846
 			$content['deleted'] = $preserved['deleted'] = null;
1849 1847
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1855,7 +1853,7 @@  discard block
 block discarded – undo
1855 1853
 		// Setup history tab
1856 1854
 		$this->setup_history($content, $sel_options);
1857 1855
 
1858
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1856
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1859 1857
 			. (!$event['id'] ? lang('Add')
1860 1858
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1861 1859
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1865,15 +1863,15 @@  discard block
 block discarded – undo
1865 1863
 		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1866 1864
 
1867 1865
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1868
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1866
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1869 1867
 		{
1870
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1868
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1871 1869
 			$content['button']['save'] = true;
1872
-			$this->process_edit(array_merge($content,$preserved));
1870
+			$this->process_edit(array_merge($content, $preserved));
1873 1871
 		}
1874 1872
 		else
1875 1873
 		{
1876
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1874
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1877 1875
 		}
1878 1876
 	}
1879 1877
 
@@ -1883,14 +1881,14 @@  discard block
 block discarded – undo
1883 1881
 	 * @param int $id
1884 1882
 	 * @param string $token
1885 1883
 	 */
1886
-	function ajax_unlock($id,$token)
1884
+	function ajax_unlock($id, $token)
1887 1885
 	{
1888
-		$lock_path = Vfs::app_entry_lock_path('calendar',$id);
1886
+		$lock_path = Vfs::app_entry_lock_path('calendar', $id);
1889 1887
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1890 1888
 
1891 1889
 		if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1892 1890
 		{
1893
-			Vfs::unlock($lock_path,$token,false);
1891
+			Vfs::unlock($lock_path, $token, false);
1894 1892
 		}
1895 1893
 	}
1896 1894
 
@@ -1902,17 +1900,17 @@  discard block
 block discarded – undo
1902 1900
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1903 1901
 	 * @param string $msg = null
1904 1902
 	 */
1905
-	function meeting(array $event=null, $msg=null)
1903
+	function meeting(array $event = null, $msg = null)
1906 1904
 	{
1907 1905
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1908 1906
 		$readonlys['button[apply]'] = true;
1909
-		$_usesession=!is_array($event);
1907
+		$_usesession = !is_array($event);
1910 1908
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1911 1909
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1912
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1910
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1913 1911
 		{
1914
-			$event=null; // set to null
1915
-			$_usesession=true; // trigger session read
1912
+			$event = null; // set to null
1913
+			$_usesession = true; // trigger session read
1916 1914
 		}
1917 1915
 		if (!is_array($event))
1918 1916
 		{
@@ -1941,7 +1939,7 @@  discard block
 block discarded – undo
1941 1939
 
1942 1940
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1943 1941
 			{
1944
-				switch(strtolower($ical_method))
1942
+				switch (strtolower($ical_method))
1945 1943
 				{
1946 1944
 					case 'reply':
1947 1945
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -1995,19 +1993,19 @@  discard block
 block discarded – undo
1995 1993
 			}
1996 1994
 			else	// event not in calendar
1997 1995
 			{
1998
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
1996
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
1999 1997
 			}
2000 1998
 			$event['participant_types'] = array();
2001
-			foreach($event['participants'] as $uid => $status)
1999
+			foreach ($event['participants'] as $uid => $status)
2002 2000
 			{
2003 2001
 				$user_type = $user_id = null;
2004 2002
 				calendar_so::split_user($uid, $user_type, $user_id);
2005 2003
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
2006
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
2004
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
2007 2005
 			}
2008 2006
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
2009 2007
 			$event['recure'] = $this->bo->recure2string($event);
2010
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
2008
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
2011 2009
 
2012 2010
 			// ignore events in the past (for recurring events check enddate!)
2013 2011
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -2027,23 +2025,23 @@  discard block
 block discarded – undo
2027 2025
 			// clear notification errors
2028 2026
 			notifications::errors(true);
2029 2027
 
2030
-			switch($button)
2028
+			switch ($button)
2031 2029
 			{
2032 2030
 				case 'reject':
2033 2031
 					if (!$event['id'])
2034 2032
 					{
2035 2033
 						// send reply to organizer
2036
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
2037
-						break;	// no need to store rejected event
2034
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
2035
+						break; // no need to store rejected event
2038 2036
 					}
2039 2037
 					// fall-through
2040 2038
 				case 'accept':
2041 2039
 				case 'tentativ':
2042
-					$status = strtoupper($button[0]);	// A, R or T
2040
+					$status = strtoupper($button[0]); // A, R or T
2043 2041
 					if (!$event['id'])
2044 2042
 					{
2045 2043
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
2046
-						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
2044
+						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner']))
2047 2045
 						{
2048 2046
 							// --> make organize a participant with role chair and current user the owner
2049 2047
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -2051,7 +2049,7 @@  discard block
 block discarded – undo
2051 2049
 							$event['owner'] = $this->user;
2052 2050
 						}
2053 2051
 						// store event without notifications!
2054
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
2052
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
2055 2053
 						{
2056 2054
 							$msg[] = lang('Event saved');
2057 2055
 						}
@@ -2089,7 +2087,7 @@  discard block
 block discarded – undo
2089 2087
 		Framework::message(implode("\n", (array)$msg));
2090 2088
 		$readonlys['button[edit]'] = !$event['id'];
2091 2089
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2092
-		switch(strtolower($ical_method))
2090
+		switch (strtolower($ical_method))
2093 2091
 		{
2094 2092
 			case 'reply':
2095 2093
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2113,37 +2111,37 @@  discard block
 block discarded – undo
2113 2111
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2114 2112
 	 * @param array $preserv data to preserv
2115 2113
 	 */
2116
-	function conflicts($event,$conflicts,$preserv)
2114
+	function conflicts($event, $conflicts, $preserv)
2117 2115
 	{
2118 2116
 		$etpl = new Etemplate('calendar.conflicts');
2119 2117
 		$allConflicts = array();
2120 2118
 
2121
-		foreach($conflicts as $k => $conflict)
2119
+		foreach ($conflicts as $k => $conflict)
2122 2120
 		{
2123
-			$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
2121
+			$is_readable = $this->bo->check_perms(Acl::READ, $conflict);
2124 2122
 
2125 2123
 			$conflicts[$k] += array(
2126 2124
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2127
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2128
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2129
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2130
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2131
-				),true,true)),	// show group invitations too
2125
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2126
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2127
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2128
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2129
+				), true, true)), // show group invitations too
2132 2130
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2133 2131
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2134 2132
 			);
2135
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2133
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2136 2134
 			}
2137 2135
 		$content = $event + array(
2138
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2136
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2139 2137
 		);
2140
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2138
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2141 2139
 		$resources_config = Api\Config::read('resources');
2142 2140
 		$readonlys = array();
2143 2141
 
2144 2142
 		foreach (array_keys($allConflicts) as $pId)
2145 2143
 		{
2146
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2144
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2147 2145
 			{
2148 2146
 
2149 2147
 				switch ($resources_config['ignoreconflicts'])
@@ -2163,7 +2161,7 @@  discard block
 block discarded – undo
2163 2161
 				}
2164 2162
 			}
2165 2163
 		}
2166
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2164
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2167 2165
 	}
2168 2166
 
2169 2167
 	/**
@@ -2181,7 +2179,7 @@  discard block
 block discarded – undo
2181 2179
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2182 2180
 
2183 2181
 		// convert start/end date-time values to timestamps
2184
-		foreach(array('start', 'end') as $name)
2182
+		foreach (array('start', 'end') as $name)
2185 2183
 		{
2186 2184
 			if (!empty($edit_content[$name]))
2187 2185
 			{
@@ -2211,7 +2209,7 @@  discard block
 block discarded – undo
2211 2209
 			'recur_type'   => $edit_content['recur_type'],
2212 2210
 			'participants' => array(),
2213 2211
 		);
2214
-		foreach($edit_content['participants'] as $key => $data)
2212
+		foreach ($edit_content['participants'] as $key => $data)
2215 2213
 		{
2216 2214
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2217 2215
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2226,21 +2224,21 @@  discard block
 block discarded – undo
2226 2224
 		// default search parameters
2227 2225
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2228 2226
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2229
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2227
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2230 2228
 		{
2231
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2229
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2232 2230
 		}
2233 2231
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2234 2232
 
2235 2233
 		$content['search_window'] = 7 * DAY_s;
2236 2234
 
2237 2235
 		// store content in session
2238
-		Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2236
+		Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2239 2237
 
2240 2238
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2241
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2239
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2242 2240
 
2243
-		$response->call('app.calendar.freetime_search_popup',$link);
2241
+		$response->call('app.calendar.freetime_search_popup', $link);
2244 2242
 
2245 2243
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2246 2244
 
@@ -2263,26 +2261,26 @@  discard block
 block discarded – undo
2263 2261
 	{
2264 2262
 		$etpl = new Etemplate('calendar.freetimesearch');
2265 2263
 		$sel_options['search_window'] = array(
2266
-			7*DAY_s		=> lang('one week'),
2267
-			14*DAY_s	=> lang('two weeks'),
2268
-			31*DAY_s	=> lang('one month'),
2269
-			92*DAY_s	=> lang('three month'),
2270
-			365*DAY_s	=> lang('one year'),
2264
+			7 * DAY_s		=> lang('one week'),
2265
+			14 * DAY_s	=> lang('two weeks'),
2266
+			31 * DAY_s	=> lang('one month'),
2267
+			92 * DAY_s	=> lang('three month'),
2268
+			365 * DAY_s	=> lang('one year'),
2271 2269
 		);
2272 2270
 		if (!is_array($content))
2273 2271
 		{
2274 2272
 			// get content from session (and delete it immediatly)
2275
-			$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2276
-			Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2273
+			$content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2274
+			Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2277 2275
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2278 2276
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2279 2277
 			$sTime = $content['start_time'];
2280 2278
 			$eTime = $content['end_time'];
2281
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2282
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2279
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2280
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2283 2281
 
2284 2282
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2285
-			foreach(array_keys($sel_options['search_window']) as $window)
2283
+			foreach (array_keys($sel_options['search_window']) as $window)
2286 2284
 			{
2287 2285
 				if ($window > $content['duration'])
2288 2286
 				{
@@ -2309,19 +2307,19 @@  discard block
 block discarded – undo
2309 2307
 		{
2310 2308
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2311 2309
 		}
2312
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2313
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2310
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2311
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2314 2312
 
2315
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2313
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2316 2314
 
2317 2315
 		$sel_options['duration'] = $this->durations;
2318 2316
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2319 2317
 
2320
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2318
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2321 2319
 				'participants'	=> $content['participants'],
2322 2320
 				'cal_id'		=> $content['cal_id'],
2323 2321
 				'recur_type'	=> $content['recur_type'],
2324
-			),2);
2322
+			), 2);
2325 2323
 	}
2326 2324
 
2327 2325
 	/**
@@ -2334,15 +2332,15 @@  discard block
 block discarded – undo
2334 2332
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2335 2333
 	 * @return array of free time-slots: array with start and end values
2336 2334
 	 */
2337
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2335
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2338 2336
 	{
2339
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2337
+		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id);
2340 2338
 
2341 2339
 		$busy = $this->bo->search(array(
2342 2340
 			'start' => $start,
2343 2341
 			'end'	=> $end,
2344 2342
 			'users'	=> $participants,
2345
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2343
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2346 2344
 		));
2347 2345
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2348 2346
 			'start'	=> $end,
@@ -2351,15 +2349,15 @@  discard block
 block discarded – undo
2351 2349
 		$ft_start = $start;
2352 2350
 		$freetime = array();
2353 2351
 		$n = 0;
2354
-		foreach($busy as $event)
2352
+		foreach ($busy as $event)
2355 2353
 		{
2356
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2354
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2357 2355
 
2358 2356
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2359 2357
 
2360 2358
 			// check if from all wanted participants at least one has a not rejected status in found event
2361 2359
 			$non_rejected_found = false;
2362
-			foreach($participants as $uid)
2360
+			foreach ($participants as $uid)
2363 2361
 			{
2364 2362
 				if ($event['participants'][$uid] == 'R') continue;
2365 2363
 
@@ -2375,10 +2373,10 @@  discard block
 block discarded – undo
2375 2373
 
2376 2374
 			if ($this->debug)
2377 2375
 			{
2378
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2376
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2379 2377
 				echo "event[title]=$event[title]<br>\n";
2380
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2381
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2378
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2379
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2382 2380
 			}
2383 2381
 			// $events ends before our actual position ==> ignore it
2384 2382
 			if ($event['end'] < $ft_start)
@@ -2402,11 +2400,11 @@  discard block
 block discarded – undo
2402 2400
 					'start'	=> $ft_start,
2403 2401
 					'end'	=> $ft_end,
2404 2402
 				);
2405
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2403
+				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n";
2406 2404
 			}
2407 2405
 			$ft_start = $event['end'];
2408 2406
 		}
2409
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2407
+		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime);
2410 2408
 
2411 2409
 		return $freetime;
2412 2410
 	}
@@ -2426,46 +2424,46 @@  discard block
 block discarded – undo
2426 2424
 	 */
2427 2425
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2428 2426
 	{
2429
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2427
+		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time);
2430 2428
 
2431 2429
 		$freetime_daywise = array();
2432 2430
 		if (!is_array($sel_options)) $sel_options = array();
2433 2431
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2434 2432
 
2435
-		$start_time = (int) $_start_time;	// ignore leading zeros
2436
-		$end_time   = (int) $_end_time;
2433
+		$start_time = (int)$_start_time; // ignore leading zeros
2434
+		$end_time   = (int)$_end_time;
2437 2435
 
2438 2436
 		// ignore the end_time, if duration would never fit
2439
-		if (($end_time - $start_time)*HOUR_s < $duration)
2437
+		if (($end_time - $start_time) * HOUR_s < $duration)
2440 2438
 		{
2441 2439
 			$end_time = 0;
2442
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2440
+			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time);
2443 2441
 		}
2444 2442
 		$n = 0;
2445
-		foreach($freetime as $ft)
2443
+		foreach ($freetime as $ft)
2446 2444
 		{
2447 2445
 			$adaybegin = $this->bo->date2array($ft['start']);
2448 2446
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2449 2447
 			unset($adaybegin['raw']);
2450 2448
 			$daybegin = $this->bo->date2ts($adaybegin);
2451 2449
 
2452
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2450
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2453 2451
 			{
2454
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2455
-				$mcal_dow = pow(2,$dow);
2456
-				if (!($weekdays & $mcal_dow))
2452
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2453
+				$mcal_dow = pow(2, $dow);
2454
+				if (!($weekdays&$mcal_dow))
2457 2455
 				{
2458 2456
 					//echo "wrong day of week $dow<br>\n";
2459
-					continue;	// wrong day of week
2457
+					continue; // wrong day of week
2460 2458
 				}
2461 2459
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2462 2460
 
2463
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2461
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2464 2462
 				{
2465
-					$start = $daybegin + $start_time*HOUR_s;
2463
+					$start = $daybegin + $start_time * HOUR_s;
2466 2464
 				}
2467 2465
 				// if end_time given use it, else the original slot's end
2468
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2466
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2469 2467
 				if ($end > $ft['end']) $end = $ft['end'];
2470 2468
 
2471 2469
 				// slot to small for duration
@@ -2479,11 +2477,11 @@  discard block
 block discarded – undo
2479 2477
 					'end'	=> $end,
2480 2478
 				);
2481 2479
 				$times = array();
2482
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2480
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2483 2481
 				{
2484 2482
 					$e = $s + $duration;
2485
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2486
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2483
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2484
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2487 2485
 				}
2488 2486
 				$sel_options[$n.'start'] = $times;
2489 2487
 			}
@@ -2498,13 +2496,13 @@  discard block
 block discarded – undo
2498 2496
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2499 2497
      * @return string error-msg if $return_error
2500 2498
      */
2501
-    function export($content=0,$return_error=false)
2499
+    function export($content = 0, $return_error = false)
2502 2500
     {
2503 2501
 		$boical = new calendar_ical();
2504 2502
 		#error_log(__METHOD__.print_r($content,true));
2505 2503
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2506 2504
 		{
2507
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2505
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2508 2506
 			{
2509 2507
 				$msg = lang('Permission denied');
2510 2508
 
@@ -2512,20 +2510,20 @@  discard block
 block discarded – undo
2512 2510
 			}
2513 2511
 			else
2514 2512
 			{
2515
-				html::content_header('event.ics','text/calendar',bytes($ical));
2513
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2516 2514
 				echo $ical;
2517 2515
 				common::egw_exit();
2518 2516
 			}
2519 2517
 		}
2520 2518
 		if (is_array($content))
2521 2519
 		{
2522
-			$events =& $this->bo->search(array(
2520
+			$events = & $this->bo->search(array(
2523 2521
 				'start' => $content['start'],
2524 2522
 				'end'   => $content['end'],
2525 2523
 				'enum_recuring' => false,
2526 2524
 				'daywise'       => false,
2527 2525
 				'owner'         => $this->owner,
2528
-				'date_format'   => 'server',    // timestamp in server time for boical class
2526
+				'date_format'   => 'server', // timestamp in server time for boical class
2529 2527
 			));
2530 2528
 			if (!$events)
2531 2529
 			{
@@ -2533,8 +2531,8 @@  discard block
 block discarded – undo
2533 2531
 			}
2534 2532
 			else
2535 2533
 			{
2536
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2537
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2534
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2535
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2538 2536
 				echo $ical;
2539 2537
 				common::egw_exit();
2540 2538
 			}
@@ -2550,9 +2548,9 @@  discard block
 block discarded – undo
2550 2548
 		}
2551 2549
 		$content['msg'] = $msg;
2552 2550
 
2553
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2551
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2554 2552
 		$etpl = new etemplate_new('calendar.export');
2555
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2553
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2556 2554
     }
2557 2555
 
2558 2556
 	/**
@@ -2560,7 +2558,7 @@  discard block
 block discarded – undo
2560 2558
 	 *
2561 2559
 	 * @param array $_content
2562 2560
 	 */
2563
-	function cat_acl(array $_content=null)
2561
+	function cat_acl(array $_content = null)
2564 2562
 	{
2565 2563
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2566 2564
 		{
@@ -2572,15 +2570,15 @@  discard block
 block discarded – undo
2572 2570
 			unset($_content['button']);
2573 2571
 			if ($button != 'cancel')	// store changed Acl
2574 2572
 			{
2575
-				foreach($_content as $data)
2573
+				foreach ($_content as $data)
2576 2574
 				{
2577 2575
 					if (!($cat_id = $data['cat_id'])) continue;
2578
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2576
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2579 2577
 					{
2580 2578
 						$rights = 0;
2581
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2582
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2583
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2579
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2580
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2581
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2584 2582
 					}
2585 2583
 				}
2586 2584
 			}
@@ -2592,20 +2590,20 @@  discard block
 block discarded – undo
2592 2590
 				), 'admin');
2593 2591
 			}
2594 2592
 		}
2595
-		$content= $preserv = array();
2593
+		$content = $preserv = array();
2596 2594
 		$n = 1;
2597
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2595
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2598 2596
 		{
2599
-			$cat_id = substr($Lcat_id,1);
2597
+			$cat_id = substr($Lcat_id, 1);
2600 2598
 			$row = array(
2601 2599
 				'cat_id' => $cat_id,
2602 2600
 				'add' => array(),
2603 2601
 				'status' => array(),
2604 2602
 			);
2605
-			foreach($data as $account_id => $rights)
2603
+			foreach ($data as $account_id => $rights)
2606 2604
 			{
2607
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2608
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2605
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2606
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2609 2607
 			}
2610 2608
 			$content[$n] = $row;
2611 2609
 			$preserv[$n] = array(
@@ -2621,7 +2619,7 @@  discard block
 block discarded – undo
2621 2619
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2622 2620
 		$tmp = new Etemplate('calendar.cat_acl');
2623 2621
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2624
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2622
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2625 2623
 	}
2626 2624
 
2627 2625
 	/**
@@ -2671,18 +2669,18 @@  discard block
 block discarded – undo
2671 2669
 
2672 2670
 
2673 2671
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2674
-		if($content['recur_type'] || $content['recurrence'])
2672
+		if ($content['recur_type'] || $content['recurrence'])
2675 2673
 		{
2676 2674
 			$content['history']['filter'] = array(
2677 2675
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2678
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2679
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2676
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2677
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2680 2678
 			);
2681 2679
 		}
2682 2680
 
2683 2681
 		// Translate labels
2684 2682
 		$tracking = new calendar_tracking();
2685
-		foreach($tracking->field2label as $field => $label)
2683
+		foreach ($tracking->field2label as $field => $label)
2686 2684
 		{
2687 2685
 			$sel_options[$status][$field] = lang($label);
2688 2686
 		}
@@ -2701,44 +2699,44 @@  discard block
 block discarded – undo
2701 2699
 	 *	which particular instance was dragged
2702 2700
 	 * @return string XML response if no error occurs
2703 2701
 	 */
2704
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2702
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2705 2703
 	{
2706
-		list($eventId, $date) = explode(':', $_eventId,2);
2704
+		list($eventId, $date) = explode(':', $_eventId, 2);
2707 2705
 		$ignore_conflicts = false;
2708 2706
 
2709 2707
 		// we do not allow dragging into another users calendar ATM
2710
-		if($targetOwner < 0)
2708
+		if ($targetOwner < 0)
2711 2709
 		{
2712 2710
 			$targetOwner = array($targetOwner);
2713 2711
 		}
2714
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2712
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2715 2713
 		{
2716 2714
 			$targetOwner = $calendarOwner;
2717 2715
 		}
2718 2716
 		// But you may be viewing multiple users, or a group calendar and
2719 2717
 		// dragging your event - dragging across calendars does not change owner
2720
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2718
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2721 2719
 		{
2722 2720
 			$return = true;
2723
-			foreach($targetOwner as $owner)
2721
+			foreach ($targetOwner as $owner)
2724 2722
 			{
2725
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2723
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2726 2724
 				{
2727 2725
 					$return = false;
2728 2726
 					break;
2729 2727
 				}
2730
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2728
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2731 2729
 				{
2732 2730
 					$return = false;
2733 2731
 					break;
2734 2732
 				}
2735 2733
 			}
2736
-			if($return) return;
2734
+			if ($return) return;
2737 2735
 		}
2738
-		$old_event=$event=$this->bo->read($eventId);
2736
+		$old_event = $event = $this->bo->read($eventId);
2739 2737
 		if (!$durationT)
2740 2738
 		{
2741
-			$duration=$event['end']-$event['start'];
2739
+			$duration = $event['end'] - $event['start'];
2742 2740
 		}
2743 2741
 		// Drag a normal event to whole day non-blocking
2744 2742
 		else if ($durationT == 'whole_day')
@@ -2746,7 +2744,7 @@  discard block
 block discarded – undo
2746 2744
 			$event['whole_day'] = true;
2747 2745
 			$event['non_blocking'] = true;
2748 2746
 			// Make duration whole days, less 1 second
2749
-			$duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1;
2747
+			$duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1;
2750 2748
 		}
2751 2749
 		else
2752 2750
 		{
@@ -2759,19 +2757,19 @@  discard block
 block discarded – undo
2759 2757
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2760 2758
 			if (!empty($event['whole_day']))
2761 2759
 			{
2762
-				$d =& $this->bo->so->startOfDay($d);
2760
+				$d = & $this->bo->so->startOfDay($d);
2763 2761
 				$d->setUser();
2764 2762
 			}
2765 2763
 			$event = $this->bo->read($eventId, $d, true);
2766 2764
 
2767 2765
 			// For DnD, create an exception if they gave the date
2768 2766
 			$preserv = null;
2769
-			$this->_create_exception($event,$preserv);
2767
+			$this->_create_exception($event, $preserv);
2770 2768
 			unset($event['id']);
2771 2769
 			$links = $event['link_to']['to_id'];
2772 2770
 
2773 2771
 			$messages = null;
2774
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2772
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2775 2773
 			if (!is_array($conflicts) && $conflicts)
2776 2774
 			{
2777 2775
 				// now we need to add the original start as recur-execption to the series
@@ -2779,28 +2777,28 @@  discard block
 block discarded – undo
2779 2777
 				$recur_event['recur_exception'][] = $d->format('ts');
2780 2778
 				// check if we need to move the alarms, because they are next on that exception
2781 2779
 				$this->bo->check_move_alarms($recur_event, null, $d);
2782
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2783
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2784
-				$this->bo->update($recur_event,true);	// no conflict check here
2780
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2781
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2782
+				$this->bo->update($recur_event, true); // no conflict check here
2785 2783
 
2786 2784
 				// Sending null will trigger a removal of the original for that date
2787 2785
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2788 2786
 
2789 2787
 				unset($recur_event);
2790
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2788
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2791 2789
 				unset($preserv['edit_single']);
2792 2790
 			}
2793 2791
 		}
2794 2792
 
2795 2793
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2796 2794
 		$event['start'] = $d->format('ts');
2797
-		$event['end'] = $event['start']+$duration;
2795
+		$event['end'] = $event['start'] + $duration;
2798 2796
 
2799 2797
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2800 2798
 		{
2801 2799
 			// calculate offset against clicked recurrance,
2802 2800
 			// depending on which is smaller
2803
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2801
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2804 2802
 			$event['start'] = $old_event['start'] + $offset;
2805 2803
 			$event['duration'] = $duration;
2806 2804
 
@@ -2811,31 +2809,31 @@  discard block
 block discarded – undo
2811 2809
 			// Can't handle conflict.  Just ignore it.
2812 2810
 			$ignore_conflicts = true;
2813 2811
 		}
2814
-		if(!$event['recur_type'])
2812
+		if (!$event['recur_type'])
2815 2813
 		{
2816 2814
 			$this->bo->check_move_alarms($event, $old_event);
2817 2815
 		}
2818 2816
 
2819 2817
 		// Drag a whole day to a time
2820
-		if($durationT && $durationT != 'whole_day')
2818
+		if ($durationT && $durationT != 'whole_day')
2821 2819
 		{
2822 2820
 			$event['whole_day'] = ($duration == DAY_s);
2823 2821
 			$event['non_blocking'] = false;
2824 2822
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2825 2823
 			// so save the change now, and then let the conflict check happen.
2826 2824
 			$message = null;
2827
-			$this->bo->update($event,true, true, false, true, $message,true);
2825
+			$this->bo->update($event, true, true, false, true, $message, true);
2828 2826
 
2829 2827
 			// Whole day non blocking with DAY_s would add a day
2830
-			if($duration==DAY_s) $duration=0;
2828
+			if ($duration == DAY_s) $duration = 0;
2831 2829
 		}
2832 2830
 
2833 2831
 		$status_reset_to_unknown = false;
2834 2832
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2835
-		foreach((array)$event['participants'] as $uid => $status)
2833
+		foreach ((array)$event['participants'] as $uid => $status)
2836 2834
 		{
2837 2835
 			$q = $r = null;
2838
-			calendar_so::split_status($status,$q,$r);
2836
+			calendar_so::split_status($status, $q, $r);
2839 2837
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2840 2838
 			{
2841 2839
 				$preferences = new Api\Preferences($uid);
@@ -2848,29 +2846,29 @@  discard block
 block discarded – undo
2848 2846
 						if ($sameday) break;
2849 2847
 					default:
2850 2848
 						$status_reset_to_unknown = true;
2851
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2849
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2852 2850
 						// todo: report reset status to user
2853 2851
 				}
2854 2852
 			}
2855 2853
 		}
2856 2854
 
2857 2855
 		$message = false;
2858
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2856
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2859 2857
 
2860 2858
 		// Save links
2861
-		if($links)
2859
+		if ($links)
2862 2860
 		{
2863 2861
 			Link::link('calendar', $event['id'], $links);
2864 2862
 		}
2865 2863
 
2866
-		$this->update_client($event['id'],$d);
2864
+		$this->update_client($event['id'], $d);
2867 2865
 		$response = Api\Json\Response::get();
2868
-		if(!is_array($conflicts) && $conflicts)
2866
+		if (!is_array($conflicts) && $conflicts)
2869 2867
 		{
2870
-			if(is_int($conflicts))
2868
+			if (is_int($conflicts))
2871 2869
 			{
2872 2870
 				$event['id'] = $conflicts;
2873
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2871
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2874 2872
 			}
2875 2873
 		}
2876 2874
 		else if ($conflicts)
@@ -2883,21 +2881,21 @@  discard block
 block discarded – undo
2883 2881
 					.'&end='.$event['end']
2884 2882
 					.'&non_interactive=true'
2885 2883
 					.'&cancel_needs_refresh=true',
2886
-				'',750,410);
2884
+				'', 750, 410);
2887 2885
 		}
2888 2886
 		else if ($message)
2889 2887
 		{
2890
-			$response->call('egw.message',  implode('<br />', $message));
2888
+			$response->call('egw.message', implode('<br />', $message));
2891 2889
 		}
2892
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2890
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2893 2891
 		if ($status_reset_to_unknown)
2894 2892
 		{
2895
-			foreach((array)$event['participants'] as $uid => $status)
2893
+			foreach ((array)$event['participants'] as $uid => $status)
2896 2894
 			{
2897 2895
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2898 2896
 				{
2899
-					calendar_so::split_status($status,$q,$r);
2900
-					$status = calendar_so::combine_status('U',$q,$r);
2897
+					calendar_so::split_status($status, $q, $r);
2898
+					$status = calendar_so::combine_status('U', $q, $r);
2901 2899
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2902 2900
 				}
2903 2901
 			}
@@ -2914,7 +2912,7 @@  discard block
 block discarded – undo
2914 2912
 	{
2915 2913
 		list($eventId, $date) = explode(':', $_eventId);
2916 2914
 		$event = $this->bo->read($eventId);
2917
-		if($date)
2915
+		if ($date)
2918 2916
 		{
2919 2917
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2920 2918
 		}
@@ -2924,29 +2922,29 @@  discard block
 block discarded – undo
2924 2922
 		{
2925 2923
 			if (!empty($event['whole_day']))
2926 2924
 			{
2927
-				$d =& $this->bo->so->startOfDay($date);
2925
+				$d = & $this->bo->so->startOfDay($date);
2928 2926
 				$d->setUser();
2929 2927
 			}
2930 2928
 			$event = $this->bo->read($eventId, $d, true);
2931 2929
 			$date = $d->format('ts');
2932 2930
 		}
2933
-		if($event['participants'][$uid])
2931
+		if ($event['participants'][$uid])
2934 2932
 		{
2935 2933
 			$q = $r = null;
2936
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2937
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2938
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2934
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2935
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2936
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2939 2937
 		}
2940 2938
 		else
2941 2939
 		{
2942 2940
 			// Group membership
2943
-			foreach($event['participants'] as $id => $status)
2941
+			foreach ($event['participants'] as $id => $status)
2944 2942
 			{
2945
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2943
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2946 2944
 				{
2947
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2948
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2949
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2945
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2946
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2947
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2950 2948
 					break;
2951 2949
 				}
2952 2950
 			}
@@ -2954,7 +2952,7 @@  discard block
 block discarded – undo
2954 2952
 
2955 2953
 		// Directly update stored data.  If event is still visible, it will
2956 2954
 		// be notified & update itself.
2957
-		$this->update_client($eventId,$d);
2955
+		$this->update_client($eventId, $d);
2958 2956
 	}
2959 2957
 
2960 2958
 	/**
@@ -2962,8 +2960,8 @@  discard block
 block discarded – undo
2962 2960
 	 */
2963 2961
 	public function ajax_delete($eventId)
2964 2962
 	{
2965
-		list($id, $date) = explode(':',$eventId);
2966
-		$event=$this->bo->read($id);
2963
+		list($id, $date) = explode(':', $eventId);
2964
+		$event = $this->bo->read($id);
2967 2965
 		$response = Api\Json\Response::get();
2968 2966
 
2969 2967
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2976,11 +2974,11 @@  discard block
 block discarded – undo
2976 2974
 			{
2977 2975
 				$msg = lang('Event deleted');
2978 2976
 			}
2979
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2977
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2980 2978
 		}
2981 2979
 		else
2982 2980
 		{
2983
-			$response->apply('egw.message', Array(lang('Error')),'error');
2981
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2984 2982
 		}
2985 2983
 	}
2986 2984
 
@@ -2993,10 +2991,10 @@  discard block
 block discarded – undo
2993 2991
 	 */
2994 2992
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
2995 2993
 	{
2996
-		list($eventId, $date) = explode(':', $_eventId,2);
2994
+		list($eventId, $date) = explode(':', $_eventId, 2);
2997 2995
 
2998 2996
 		$event = $this->bo->read($eventId);
2999
-		if($date)
2997
+		if ($date)
3000 2998
 		{
3001 2999
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
3002 3000
 		}
@@ -3006,17 +3004,17 @@  discard block
 block discarded – undo
3006 3004
 		{
3007 3005
 			if (!empty($event['whole_day']))
3008 3006
 			{
3009
-				$d =& $this->bo->so->startOfDay($date);
3007
+				$d = & $this->bo->so->startOfDay($date);
3010 3008
 				$d->setUser();
3011 3009
 			}
3012 3010
 			$event = $this->bo->read($eventId, $d, true);
3013 3011
 			// For DnD, create an exception if they gave the date
3014 3012
 			$preserv = null;
3015
-			$this->_create_exception($event,$preserv);
3013
+			$this->_create_exception($event, $preserv);
3016 3014
 			unset($event['id']);
3017 3015
 
3018 3016
 			$messages = null;
3019
-			$conflicts = $this->bo->update($event,true,true,false,true,$messages);
3017
+			$conflicts = $this->bo->update($event, true, true, false, true, $messages);
3020 3018
 			if (!is_array($conflicts) && $conflicts)
3021 3019
 			{
3022 3020
 				// now we need to add the original start as recur-execption to the series
@@ -3024,28 +3022,28 @@  discard block
 block discarded – undo
3024 3022
 				$recur_event['recur_exception'][] = $d->format('ts');
3025 3023
 				// check if we need to move the alarms, because they are next on that exception
3026 3024
 				$this->bo->check_move_alarms($recur_event, null, $d);
3027
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
3028
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
3029
-				$this->bo->update($recur_event,true);	// no conflict check here
3025
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
3026
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
3027
+				$this->bo->update($recur_event, true); // no conflict check here
3030 3028
 
3031 3029
 				// Sending null will trigger a removal of the original for that date
3032 3030
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
3033 3031
 
3034 3032
 				unset($recur_event);
3035
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
3033
+				unset($event['edit_single']); // if we further edit it, it's just a single event
3036 3034
 				unset($preserv['edit_single']);
3037 3035
 			}
3038 3036
 		}
3039
-		foreach($remove as $participant)
3037
+		foreach ($remove as $participant)
3040 3038
 		{
3041 3039
 			unset($event['participants'][$participant]);
3042 3040
 		}
3043
-		foreach($invite as $participant)
3041
+		foreach ($invite as $participant)
3044 3042
 		{
3045 3043
 			$event['participants'][$participant] = 'U';
3046 3044
 		}
3047 3045
 		$message = null;
3048
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
3046
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
3049 3047
 
3050 3048
 		$response = Api\Json\Response::get();
3051 3049
 
@@ -3053,8 +3051,8 @@  discard block
 block discarded – undo
3053 3051
 		{
3054 3052
 			// Save it anyway, was done with explicit user interaction,
3055 3053
 			// and if we don't we lose the invite
3056
-			$this->bo->update($event,true);	// no conflict check here
3057
-			$this->update_client($event['id'],$d);
3054
+			$this->bo->update($event, true); // no conflict check here
3055
+			$this->update_client($event['id'], $d);
3058 3056
 			$response->call(
3059 3057
 				'egw_openWindowCentered2',
3060 3058
 				$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
@@ -3063,22 +3061,22 @@  discard block
 block discarded – undo
3063 3061
 					.'&end='.$event['end']
3064 3062
 					.'&non_interactive=true'
3065 3063
 					.'&cancel_needs_refresh=true',
3066
-				'',750,410);
3064
+				'', 750, 410);
3067 3065
 		}
3068 3066
 		else if ($message)
3069 3067
 		{
3070
-			$response->call('egw.message',  implode('<br />', $message));
3068
+			$response->call('egw.message', implode('<br />', $message));
3071 3069
 		}
3072
-		if($conflicts)
3070
+		if ($conflicts)
3073 3071
 		{
3074
-			$this->update_client($event['id'],$d);
3075
-			if(is_int($conflicts))
3072
+			$this->update_client($event['id'], $d);
3073
+			if (is_int($conflicts))
3076 3074
 			{
3077 3075
 				$event['id'] = $conflicts;
3078 3076
 			}
3079
-			if($event['id'])
3077
+			if ($event['id'])
3080 3078
 			{
3081
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
3079
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
3082 3080
 			}
3083 3081
 		}
3084 3082
 	}
@@ -3089,13 +3087,13 @@  discard block
 block discarded – undo
3089 3087
 	 * @param array $mailContent = null mail content
3090 3088
 	 * @return  array
3091 3089
 	 */
3092
-	function mail_import(array $mailContent=null)
3090
+	function mail_import(array $mailContent = null)
3093 3091
 	{
3094 3092
 		// It would get called from compose as a popup with egw_data
3095 3093
 		if (!is_array($mailContent) && ($_GET['egw_data']))
3096 3094
 		{
3097 3095
 			// get raw mail data
3098
-			Link::get_data ($_GET['egw_data']);
3096
+			Link::get_data($_GET['egw_data']);
3099 3097
 			return false;
3100 3098
 		}
3101 3099
 
@@ -3105,7 +3103,7 @@  discard block
 block discarded – undo
3105 3103
 			$AB = new Api\Contacts();
3106 3104
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
3107 3105
 
3108
-			$participants[0] = array (
3106
+			$participants[0] = array(
3109 3107
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
3110 3108
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
3111 3109
 				'status' => 'A',
@@ -3113,23 +3111,23 @@  discard block
 block discarded – undo
3113 3111
 				'app' => 'User',
3114 3112
 				'role' => 'REQ-PARTICIPANT'
3115 3113
 			);
3116
-			foreach($mailContent['addresses'] as $address)
3114
+			foreach ($mailContent['addresses'] as $address)
3117 3115
 			{
3118 3116
 				// Get available contacts from the email
3119 3117
 				$contacts = $AB->search(array(
3120 3118
 						'email' => $address['email'],
3121 3119
 						'email_home' => $address['email']
3122
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
3120
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
3123 3121
 				if (is_array($contacts))
3124 3122
 				{
3125
-					foreach($contacts as $account)
3123
+					foreach ($contacts as $account)
3126 3124
 					{
3127 3125
 						$accounts[] = $account['account_id'];
3128 3126
 					}
3129 3127
 				}
3130 3128
 				else
3131 3129
 				{
3132
-					$participants []= array (
3130
+					$participants [] = array(
3133 3131
 						'app' => 'email',
3134 3132
 						'uid' => 'e'.$address['email'],
3135 3133
 						'status' => 'U',
@@ -3137,7 +3135,7 @@  discard block
 block discarded – undo
3137 3135
 					);
3138 3136
 				}
3139 3137
 			}
3140
-			$participants = array_merge($participants , array(
3138
+			$participants = array_merge($participants, array(
3141 3139
 				"participant" => $accounts,
3142 3140
 				"role" => "REQ-PARTICIPANT",
3143 3141
 				"add" => "pressed"
@@ -3161,14 +3159,14 @@  discard block
 block discarded – undo
3161 3159
 			{
3162 3160
 				foreach ($mailContent['attachments'] as $attachment)
3163 3161
 				{
3164
-					if($attachment['egw_data'])
3162
+					if ($attachment['egw_data'])
3165 3163
 					{
3166
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3164
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3167 3165
 					}
3168
-					else if(is_readable($attachment['tmp_name']) ||
3166
+					else if (is_readable($attachment['tmp_name']) ||
3169 3167
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3170 3168
 					{
3171
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3169
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3172 3170
 					}
3173 3171
 				}
3174 3172
 			}
Please login to merge, or discard this patch.