Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
calendar/inc/class.calendar_uiforms.inc.php 6 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 	 *	date instead of today
1078 1078
 	 * @param boolean $no_notifications Toggle notifications to participants
1079 1079
 	 *
1080
-	 * @return false or error message
1080
+	 * @return string|false or error message
1081 1081
 	 */
1082 1082
 	function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true)
1083 1083
 	{
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 	 * Freetime search
2174 2174
 	 *
2175 2175
 	 * As the function is called in a popup via javascript, parametes get initialy transfered via the url
2176
-	 * @param array $content=null array with parameters or false (default) to use the get-params
2176
+	 * @param array $content array with parameters or false (default) to use the get-params
2177 2177
 	 * @param string start[str] start-date
2178 2178
 	 * @param string start[hour] start-hour
2179 2179
 	 * @param string start[min] start-minutes
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
 	/**
2418 2418
      * Export events as vCalendar version 2.0 files (iCal)
2419 2419
      *
2420
-     * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2420
+     * @param integer $content numeric cal_id or submitted content from etempalte::exec
2421 2421
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422 2422
      * @return string error-msg if $return_error
2423 2423
      */
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2415,14 +2415,14 @@  discard block
 block discarded – undo
2415 2415
 	}
2416 2416
 
2417 2417
 	/**
2418
-     * Export events as vCalendar version 2.0 files (iCal)
2419
-     *
2420
-     * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2421
-     * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422
-     * @return string error-msg if $return_error
2423
-     */
2424
-    function export($content=0,$return_error=false)
2425
-    {
2418
+	 * Export events as vCalendar version 2.0 files (iCal)
2419
+	 *
2420
+	 * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2421
+	 * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422
+	 * @return string error-msg if $return_error
2423
+	 */
2424
+	function export($content=0,$return_error=false)
2425
+	{
2426 2426
 		$boical = new calendar_ical();
2427 2427
 		#error_log(__METHOD__.print_r($content,true));
2428 2428
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2477 2477
 		$etpl = new etemplate_new('calendar.export');
2478 2478
 		$etpl->exec('calendar.calendar_uiforms.export',$content);
2479
-    }
2479
+	}
2480 2480
 	
2481 2481
 	/**
2482 2482
 	 * Edit category ACL (admin only)
@@ -2548,8 +2548,8 @@  discard block
 block discarded – undo
2548 2548
 	}
2549 2549
 
2550 2550
 	/**
2551
-	* Set up the required fields to get the history tab
2552
-	*/
2551
+	 * Set up the required fields to get the history tab
2552
+	 */
2553 2553
 	public function setup_history(&$content, &$sel_options)
2554 2554
 	{
2555 2555
 		$status = 'history_status';
Please login to merge, or discard this patch.
Switch Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -557,214 +557,214 @@  discard block
 block discarded – undo
557 557
 
558 558
 		switch((string)$button)
559 559
 		{
560
-		case 'exception':	// create an exception in a recuring event
561
-			$msg = $this->_create_exception($event,$preserv);
562
-			break;
560
+			case 'exception':	// create an exception in a recuring event
561
+				$msg = $this->_create_exception($event,$preserv);
562
+				break;
563 563
 
564
-		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
565
-			unset($event['id']);
566
-			unset($event['uid']);
567
-			unset($event['reference']);
568
-			unset($preserv['reference']);
569
-			unset($event['recurrence']);
570
-			unset($preserv['recurrence']);
571
-			unset($event['recur_exception']);
572
-			unset($event['edit_single']);	// in case it has been set
573
-			unset($event['modified']);
574
-			unset($event['modifier']);
575
-			unset($event['caldav_name']);
576
-			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
564
+			case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
565
+				unset($event['id']);
566
+				unset($event['uid']);
567
+				unset($event['reference']);
568
+				unset($preserv['reference']);
569
+				unset($event['recurrence']);
570
+				unset($preserv['recurrence']);
571
+				unset($event['recur_exception']);
572
+				unset($event['edit_single']);	// in case it has been set
573
+				unset($event['modified']);
574
+				unset($event['modifier']);
575
+				unset($event['caldav_name']);
576
+				$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
577
+
578
+				// Clear participant stati
579
+				foreach($event['participant_types'] as $type => &$participants)
580
+				{
581
+					foreach($participants as $id => &$p_response)
582
+					{
583
+						if($type == 'u' && $id == $event['owner']) continue;
584
+						calendar_so::split_status($p_response, $quantity, $role);
585
+						// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586
+						$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
587
+						$p_response = calendar_so::combine_status($status,$quantity,$role);
588
+					}
589
+				}
577 590
 
578
-			// Clear participant stati
579
-			foreach($event['participant_types'] as $type => &$participants)
580
-			{
581
-				foreach($participants as $id => &$p_response)
591
+				// Copy alarms
592
+				if (is_array($event['alarm']))
582 593
 				{
583
-					if($type == 'u' && $id == $event['owner']) continue;
584
-					calendar_so::split_status($p_response, $quantity, $role);
585
-					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
587
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
594
+					foreach($event['alarm'] as $n => &$alarm)
595
+					{
596
+						unset($alarm['id']);
597
+						unset($alarm['cal_id']);
598
+					}
588 599
 				}
589
-			}
590 600
 
591
-			// Copy alarms
592
-			if (is_array($event['alarm']))
593
-			{
594
-				foreach($event['alarm'] as $n => &$alarm)
601
+				// Get links to be copied
602
+				// With no ID, $content['link_to']['to_id'] is used
603
+				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
604
+				foreach(Link::get_links('calendar', $content['id']) as $link)
595 605
 				{
596
-					unset($alarm['id']);
597
-					unset($alarm['cal_id']);
606
+					if ($link['app'] != Link::VFS_APPNAME)
607
+					{
608
+						Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
609
+					}
610
+					elseif ($link['app'] == Link::VFS_APPNAME)
611
+					{
612
+						Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
613
+							'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
614
+							'name' => $link['id'],
615
+						), $link['remark']);
616
+					}
598 617
 				}
599
-			}
618
+				unset($link);
619
+				$preserv['view'] = $preserv['edit_single'] = false;
620
+				$msg = lang('Event copied - the copy can now be edited');
621
+				$event['title'] = lang('Copy of:').' '.$event['title'];
622
+				break;
600 623
 
601
-			// Get links to be copied
602
-			// With no ID, $content['link_to']['to_id'] is used
603
-			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
604
-			foreach(Link::get_links('calendar', $content['id']) as $link)
605
-			{
606
-				if ($link['app'] != Link::VFS_APPNAME)
624
+			case 'mail':
625
+			case 'sendrequest':
626
+			case 'save':
627
+			case 'print':
628
+			case 'apply':
629
+			case 'infolog':
630
+				if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
607 631
 				{
608
-					Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
632
+					$msg = lang('Permission denied');
633
+					$button = '';
634
+					break;
609 635
 				}
610
-				elseif ($link['app'] == Link::VFS_APPNAME)
636
+				if ($event['start'] > $event['end'])
611 637
 				{
612
-					Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
613
-						'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
614
-						'name' => $link['id'],
615
-					), $link['remark']);
638
+					$msg = lang('Error: Starttime has to be before the endtime !!!');
639
+					$button = '';
640
+					break;
616 641
 				}
617
-			}
618
-			unset($link);
619
-			$preserv['view'] = $preserv['edit_single'] = false;
620
-			$msg = lang('Event copied - the copy can now be edited');
621
-			$event['title'] = lang('Copy of:').' '.$event['title'];
622
-			break;
623
-
624
-		case 'mail':
625
-		case 'sendrequest':
626
-		case 'save':
627
-		case 'print':
628
-		case 'apply':
629
-		case 'infolog':
630
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
631
-			{
632
-				$msg = lang('Permission denied');
633
-				$button = '';
634
-				break;
635
-			}
636
-			if ($event['start'] > $event['end'])
637
-			{
638
-				$msg = lang('Error: Starttime has to be before the endtime !!!');
639
-				$button = '';
640
-				break;
641
-			}
642
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
643
-			{
644
-				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
645
-				$button = '';
646
-				break;
647
-			}
648
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
649
-			{
650
-				$msg = lang('Error: Duration of event longer then recurrence interval!');
651
-				$button = '';
652
-				break;
653
-			}
654
-			if (!$event['participants'])
655
-			{
656
-				$msg = lang('Error: no participants selected !!!');
657
-				$button = '';
658
-				break;
659
-			}
660
-			// if private event with ressource reservation is forbidden
661
-			if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
662
-			{
663
-				foreach (array_keys($event['participants']) as $uid)
642
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
664 643
 				{
665
-					if ($uid[0] == 'r') //ressource detection
644
+					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
645
+					$button = '';
646
+					break;
647
+				}
648
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
649
+				{
650
+					$msg = lang('Error: Duration of event longer then recurrence interval!');
651
+					$button = '';
652
+					break;
653
+				}
654
+				if (!$event['participants'])
655
+				{
656
+					$msg = lang('Error: no participants selected !!!');
657
+					$button = '';
658
+					break;
659
+				}
660
+				// if private event with ressource reservation is forbidden
661
+				if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
662
+				{
663
+					foreach (array_keys($event['participants']) as $uid)
666 664
 					{
667
-						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
668
-						$button = '';
669
-						break 2; //break foreach and case
665
+						if ($uid[0] == 'r') //ressource detection
666
+						{
667
+							$msg = lang('Error: ressources reservation in private events is not allowed!!!');
668
+							$button = '';
669
+							break 2; //break foreach and case
670
+						}
670 671
 					}
671 672
 				}
672
-			}
673
-			if ($content['edit_single'])	// we edited a single event from a series
674
-			{
675
-				$event['reference'] = $event['id'];
676
-				$event['recurrence'] = $content['edit_single'];
677
-				unset($event['id']);
678
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
679
-				if (!is_array($conflicts) && $conflicts)
673
+				if ($content['edit_single'])	// we edited a single event from a series
680 674
 				{
681
-					// now we need to add the original start as recur-execption to the series
682
-					$recur_event = $this->bo->read($event['reference']);
683
-					$recur_event['recur_exception'][] = $content['edit_single'];
684
-					// check if we need to move the alarms, because they are next on that exception
685
-					foreach($recur_event['alarm'] as $id => $alarm)
675
+					$event['reference'] = $event['id'];
676
+					$event['recurrence'] = $content['edit_single'];
677
+					unset($event['id']);
678
+					$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
679
+					if (!is_array($conflicts) && $conflicts)
686 680
 					{
687
-						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
681
+						// now we need to add the original start as recur-execption to the series
682
+						$recur_event = $this->bo->read($event['reference']);
683
+						$recur_event['recur_exception'][] = $content['edit_single'];
684
+						// check if we need to move the alarms, because they are next on that exception
685
+						foreach($recur_event['alarm'] as $id => $alarm)
688 686
 						{
689
-							$rrule = calendar_rrule::event2rrule($recur_event, true);
690
-							foreach ($rrule as $time)
687
+							if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
691 688
 							{
692
-								if ($content['edit_single'] < $time->format('ts'))
689
+								$rrule = calendar_rrule::event2rrule($recur_event, true);
690
+								foreach ($rrule as $time)
693 691
 								{
694
-									$alarm['time'] = $time->format('ts') - $alarm['offset'];
695
-									$this->bo->save_alarm($event['reference'], $alarm);
696
-									break;
692
+									if ($content['edit_single'] < $time->format('ts'))
693
+									{
694
+										$alarm['time'] = $time->format('ts') - $alarm['offset'];
695
+										$this->bo->save_alarm($event['reference'], $alarm);
696
+										break;
697
+									}
697 698
 								}
698 699
 							}
699 700
 						}
700
-					}
701
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
702
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
703
-					$this->bo->update($recur_event,true);	// no conflict check here
701
+						unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
702
+						unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
703
+						$this->bo->update($recur_event,true);	// no conflict check here
704 704
 
705
-					if(Api\Json\Response::isJSONResponse())
705
+						if(Api\Json\Response::isJSONResponse())
706
+						{
707
+							// Sending null will trigger a removal of the original
708
+							// for that date
709
+							Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
710
+						}
711
+
712
+						unset($recur_event);
713
+						unset($event['edit_single']);			// if we further edit it, it's just a single event
714
+						unset($preserv['edit_single']);
715
+					}
716
+					else	// conflict or error, we need to reset everything to the state befor we tried to save it
706 717
 					{
707
-						// Sending null will trigger a removal of the original
708
-						// for that date
709
-						Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
718
+						$event['id'] = $event['reference'];
719
+						$event['reference'] = $event['recurrence'] = 0;
720
+						$event['uid'] = $content['uid'];
710 721
 					}
711
-
712
-					unset($recur_event);
713
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
714
-					unset($preserv['edit_single']);
715
-				}
716
-				else	// conflict or error, we need to reset everything to the state befor we tried to save it
717
-				{
718
-					$event['id'] = $event['reference'];
719
-					$event['reference'] = $event['recurrence'] = 0;
720
-					$event['uid'] = $content['uid'];
722
+					$update_type = 'edit';
721 723
 				}
722
-				$update_type = 'edit';
723
-			}
724
-			else	// we edited a non-reccuring event or the whole series
725
-			{
726
-				if (($old_event = $this->bo->read($event['id'])))
724
+				else	// we edited a non-reccuring event or the whole series
727 725
 				{
728
-					if ($event['recur_type'] != MCAL_RECUR_NONE)
726
+					if (($old_event = $this->bo->read($event['id'])))
729 727
 					{
730
-						$update_type = 'edit';
731
-
732
-						// we edit a existing series event
733
-						if ($event['start'] != $old_event['start'] ||
734
-							$event['whole_day'] != $old_event['whole_day'] ||
735
-							$event['end'] != $old_event['end'])
728
+						if ($event['recur_type'] != MCAL_RECUR_NONE)
736 729
 						{
737
-							// calculate offset against old series start or clicked recurrance,
738
-							// depending on which is smaller
739
-							$offset = $event['start'] - $old_event['start'];
740
-							if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
741
-							{
742
-								$offset = $off2;
743
-							}
744
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
745
-							if($msg)
730
+							$update_type = 'edit';
731
+
732
+							// we edit a existing series event
733
+							if ($event['start'] != $old_event['start'] ||
734
+								$event['whole_day'] != $old_event['whole_day'] ||
735
+								$event['end'] != $old_event['end'])
746 736
 							{
747
-								$noerror = false;
737
+								// calculate offset against old series start or clicked recurrance,
738
+								// depending on which is smaller
739
+								$offset = $event['start'] - $old_event['start'];
740
+								if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
741
+								{
742
+									$offset = $off2;
743
+								}
744
+								$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
745
+								if($msg)
746
+								{
747
+									$noerror = false;
748
+								}
748 749
 							}
749 750
 						}
750
-					}
751
-					else
752
-					{
753
-						if ($old_event['start'] != $event['start'] ||
754
-							$old_event['end'] != $event['end'] ||
755
-							$event['whole_day'] != $old_event['whole_day'])
751
+						else
756 752
 						{
757
-							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
758
-							foreach((array)$event['participants'] as $uid => $status)
753
+							if ($old_event['start'] != $event['start'] ||
754
+								$old_event['end'] != $event['end'] ||
755
+								$event['whole_day'] != $old_event['whole_day'])
759 756
 							{
760
-								$q = $r = null;
761
-								calendar_so::split_status($status,$q,$r);
762
-								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
757
+								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
758
+								foreach((array)$event['participants'] as $uid => $status)
763 759
 								{
764
-									$preferences = CreateObject('phpgwapi.preferences',$uid);
765
-									$part_prefs = $preferences->read_repository();
766
-									switch ($part_prefs['calendar']['reset_stati'])
760
+									$q = $r = null;
761
+									calendar_so::split_status($status,$q,$r);
762
+									if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
767 763
 									{
764
+										$preferences = CreateObject('phpgwapi.preferences',$uid);
765
+										$part_prefs = $preferences->read_repository();
766
+										switch ($part_prefs['calendar']['reset_stati'])
767
+										{
768 768
 										case 'no':
769 769
 											break;
770 770
 										case 'startday':
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 											$status_reset_to_unknown = true;
774 774
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
775 775
 											// todo: report reset status to user
776
-									}
776
+										}
777 777
 								}
778 778
 							}
779 779
 							// check if we need to move the alarms, because they are relative
@@ -910,83 +910,83 @@  discard block
 block discarded – undo
910 910
 			}
911 911
 			break;
912 912
 
913
-		case 'cancel':
914
-			if($content['cancel_needs_refresh'])
915
-			{
916
-				Framework::refresh_opener($msg, 'calendar');
917
-			}
918
-			break;
919
-
920
-		case 'delete':					// delete of event (regular or series)
921
-			$exceptions_kept = null;
922
-			if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
923
-				$content['delete_exceptions'] == 'true', $exceptions_kept))
924
-			{
925
-				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
913
+			case 'cancel':
914
+				if($content['cancel_needs_refresh'])
926 915
 				{
927
-					$msg = lang('Series deleted');
928
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
916
+					Framework::refresh_opener($msg, 'calendar');
929 917
 				}
930
-				else
918
+				break;
919
+
920
+			case 'delete':					// delete of event (regular or series)
921
+				$exceptions_kept = null;
922
+				if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
923
+					$content['delete_exceptions'] == 'true', $exceptions_kept))
931 924
 				{
932
-					$msg = lang('Event deleted');
933
-				}
925
+					if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
926
+					{
927
+						$msg = lang('Series deleted');
928
+						if ($exceptions_kept) $msg .= lang(', exceptions preserved');
929
+					}
930
+					else
931
+					{
932
+						$msg = lang('Event deleted');
933
+					}
934 934
 
935
-			}
936
-			break;
935
+				}
936
+				break;
937 937
 
938
-		case 'freetime':
939
-			// the "click" has to be in onload, to make sure the button is already created
940
-			$event['button_was'] = $button;
941
-			break;
938
+			case 'freetime':
939
+				// the "click" has to be in onload, to make sure the button is already created
940
+				$event['button_was'] = $button;
941
+				break;
942 942
 
943
-		case 'add_alarm':
944
-			$time = $content['start'];
945
-			$offset = $time - $content['new_alarm']['date'];
946
-			if ($event['recur_type'] != MCAL_RECUR_NONE &&
947
-				($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
948
-				$time < $next_occurrence['start'])
949
-			{
950
-				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
951
-			}
952
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
953
-			{
954
-				$alarm = array(
955
-					'offset' => $offset,
956
-					'time'   => $content['new_alarm']['date'],
957
-					'all'    => !$content['new_alarm']['owner'],
958
-					'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
959
-				);
960
-				if ($alarm['time'] < $this->bo->now_su)
943
+			case 'add_alarm':
944
+				$time = $content['start'];
945
+				$offset = $time - $content['new_alarm']['date'];
946
+				if ($event['recur_type'] != MCAL_RECUR_NONE &&
947
+					($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
948
+					$time < $next_occurrence['start'])
961 949
 				{
962
-					$msg = lang("Can't add alarms in the past !!!");
950
+					$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
963 951
 				}
964
-				elseif ($event['id'])	// save the alarm immediatly
952
+				if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
965 953
 				{
966
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
954
+					$alarm = array(
955
+						'offset' => $offset,
956
+						'time'   => $content['new_alarm']['date'],
957
+						'all'    => !$content['new_alarm']['owner'],
958
+						'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
959
+					);
960
+					if ($alarm['time'] < $this->bo->now_su)
961
+					{
962
+						$msg = lang("Can't add alarms in the past !!!");
963
+					}
964
+					elseif ($event['id'])	// save the alarm immediatly
967 965
 					{
968
-						$alarm['id'] = $alarm_id;
969
-						$event['alarm'][$alarm_id] = $alarm;
966
+						if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
967
+						{
968
+							$alarm['id'] = $alarm_id;
969
+							$event['alarm'][$alarm_id] = $alarm;
970 970
 
971
-						$msg = lang('Alarm added');
972
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
971
+							$msg = lang('Alarm added');
972
+							Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
973
+						}
974
+						else
975
+						{
976
+							$msg = lang('Error adding the alarm');
977
+						}
973 978
 					}
974 979
 					else
975 980
 					{
976
-						$msg = lang('Error adding the alarm');
981
+						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
982
+						$event['alarm'][$alarm['id']] = $alarm;
977 983
 					}
978 984
 				}
979 985
 				else
980 986
 				{
981
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
982
-					$event['alarm'][$alarm['id']] = $alarm;
987
+					$msg = lang('Permission denied');
983 988
 				}
984
-			}
985
-			else
986
-			{
987
-				$msg = lang('Permission denied');
988
-			}
989
-			break;
989
+				break;
990 990
 		}
991 991
 		// add notification-errors, if we have some
992 992
 		if (($notification_errors = notifications::errors(true)))
Please login to merge, or discard this patch.
Spacing   +439 added lines, -440 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
 
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	function &default_add_event()
79 79
 	{
80
-		$extra_participants = $_GET['participants'] ? explode(',',$_GET['participants']) : array();
80
+		$extra_participants = $_GET['participants'] ? explode(',', $_GET['participants']) : array();
81 81
 
82 82
 		// if participant is a contact, add its link title as title
83
-		foreach($extra_participants as $uid)
83
+		foreach ($extra_participants as $uid)
84 84
 		{
85 85
 			if ($uid[0] == 'c')
86 86
 			{
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		if (isset($_GET['owner']))
93 93
 		{
94 94
 			$owner = $_GET['owner'];
95
-			if(is_array($owner))
95
+			if (is_array($owner))
96 96
 			{
97 97
 				$extra_participants += $owner;
98 98
 				$owner = count($owner) > 1 ? $this->user : $owner[0];
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
111
-			!$this->bo->check_perms(Acl::ADD,0,$owner))
111
+			!$this->bo->check_perms(Acl::ADD, 0, $owner))
112 112
 		{
113 113
 			if ($owner)	// make an owner who is no user or we have no add-rights a participant
114 114
 			{
115
-				if(!is_array($owner))
115
+				if (!is_array($owner))
116 116
 				{
117
-					$owner = explode(',',$owner);
117
+					$owner = explode(',', $owner);
118 118
 				}
119 119
 				// if we come from ressources we don't need any users selected in calendar
120 120
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
121 121
 				{
122
-					foreach($owner as $uid)
122
+					foreach ($owner as $uid)
123 123
 					{
124 124
 						// only add users or a single ressource, not all ressources displayed by a category
125 125
 						if (is_numeric($uid) || $owner == $uid)
@@ -133,61 +133,61 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 		//error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")");
135 135
 
136
-		if(isset($_GET['start']))
136
+		if (isset($_GET['start']))
137 137
 		{
138 138
 			$start = Api\DateTime::to($_GET['start'], 'ts');
139 139
 		}
140 140
 		else
141 141
 		{
142 142
 			$start = $this->bo->date2ts(array(
143
-				'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date,
144
-				'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
145
-				'minute' => (int) $_GET['minute'],
143
+				'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date,
144
+				'hour' => (int)(isset($_GET['hour']) && (int)$_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
145
+				'minute' => (int)$_GET['minute'],
146 146
 			));
147 147
 		}
148 148
 		//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";
149 149
 
150 150
 		$participant_types['u'] = $participant_types = $participants = array();
151
-		foreach($extra_participants as $uid)
151
+		foreach ($extra_participants as $uid)
152 152
 		{
153
-			if (isset($participants[$uid])) continue;	// already included
153
+			if (isset($participants[$uid])) continue; // already included
154 154
 
155
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
155
+			if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored
156 156
 
157 157
 			if (is_numeric($uid))
158 158
 			{
159 159
 				$participants[$uid] = $participant_types['u'][$uid] =
160
-					calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
161
-					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
160
+					calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
161
+					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
162 162
 			}
163 163
 			elseif (is_array($this->bo->resources[$uid[0]]))
164 164
 			{
165 165
 				// if contact is a user, use the user instead (as the GUI)
166
-				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
166
+				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id')))
167 167
 				{
168 168
 					$uid = $account_id;
169 169
 					$participants[$uid] = $participant_types['u'][$uid] =
170
-						calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
171
-						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
170
+						calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
171
+						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
172 172
 					continue;
173 173
 				}
174 174
 				$res_data = $this->bo->resources[$uid[0]];
175
-				list($id,$quantity) = explode(':',substr($uid,1));
176
-				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U'))
175
+				list($id, $quantity) = explode(':', substr($uid, 1));
176
+				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U'))
177 177
 				{
178 178
 					$participants[$uid] = $participant_types[$uid[0]][$id] =
179
-						calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT');
179
+						calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT');
180 180
 				}
181 181
 			}
182 182
 		}
183 183
 		if (!$participants)	// if all participants got removed, include current user
184 184
 		{
185
-			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
185
+			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR');
186 186
 		}
187
-		if(isset($_GET['cat_id']))
187
+		if (isset($_GET['cat_id']))
188 188
 		{
189
-			$cat_id = explode(',',$_GET['cat_id']);
190
-			foreach($cat_id as &$cat)
189
+			$cat_id = explode(',', $_GET['cat_id']);
190
+			foreach ($cat_id as &$cat)
191 191
 			{
192 192
 				$cat = (int)$cat;
193 193
 			}
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 		if ((string)$this->cal_prefs['default-alarm'] !== '')
199 199
 		{
200 200
 			$offset = 60 * $this->cal_prefs['default-alarm'];
201
-			$alarms[1] =  array(
201
+			$alarms[1] = array(
202 202
 				'default' => 1,
203
-				'offset' => $offset ,
203
+				'offset' => $offset,
204 204
 				'time'   => $start - $offset,
205 205
 				'all'    => false,
206 206
 				'owner'  => $owner,
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 			'participants' => $participants,
213 213
 			'owner' => $owner,
214 214
 			'start' => $start,
215
-			'end'   => $start + (int) $this->bo->cal_prefs['defaultlength']*60,
215
+			'end'   => $start + (int)$this->bo->cal_prefs['defaultlength'] * 60,
216 216
 			'tzid'  => $this->bo->common_prefs['tz'],
217
-			'priority' => 2,	// normal
217
+			'priority' => 2, // normal
218 218
 			'public'=> $this->cal_prefs['default_private'] ? 0 : 1,
219 219
 			'alarm' => $alarms,
220 220
 			'recur_exception' => array(),
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	{
234 234
 		if (!is_array($content))	// redirect from etemplate, if POST empty
235 235
 		{
236
-			return $this->edit(null,null,strip_tags($_GET['msg']));
236
+			return $this->edit(null, null, strip_tags($_GET['msg']));
237 237
 		}
238 238
 		// clear notification errors
239 239
 		notifications::errors(true);
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
248 248
 
249 249
 		list($button) = @each($content['button']);
250
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
250
+		if (!$button && $content['action']) $button = $content['action']; // action selectbox
251 251
 		unset($content['button']); unset($content['action']);
252 252
 
253 253
 		$view = $content['view'];
254 254
 		if ($button == 'ical')
255 255
 		{
256
-			$msg = $this->export($content['id'],true);
256
+			$msg = $this->export($content['id'], true);
257 257
 		}
258 258
 		// delete a recur-exception
259 259
 		if ($content['recur_exception']['delete_exception'])
260 260
 		{
261 261
 			list($date) = each($content['recur_exception']['delete_exception']);
262 262
 			// eT2 converts time to
263
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
263
+			if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts');
264 264
 			unset($content['recur_exception']['delete_exception']);
265
-			if (($key = array_search($date,$content['recur_exception'])) !== false)
265
+			if (($key = array_search($date, $content['recur_exception'])) !== false)
266 266
 			{
267 267
 				// propagate the exception to a single event
268 268
 				$recur_exceptions = $this->bo->so->get_related($content['uid']);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
273 273
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
274 274
 					$exception['reference'] = $exception['recurrence'] = 0;
275
-					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
275
+					$this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']);
276 276
 					break;
277 277
 				}
278 278
 				unset($content['recur_exception'][$key]);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 			$def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')];
314 314
 			if ((string)$def_alarm === '')
315 315
 			{
316
-				unset($content['alarm'][1]);	// '' = no alarm on whole day --> delete it
316
+				unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it
317 317
 			}
318 318
 			else
319 319
 			{
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		unset($event['alarm']['delete_alarm']);
328 328
 		unset($event['duration']);
329 329
 
330
-		if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series')))
330
+		if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series')))
331 331
 		{
332 332
 			// no conversation necessary, event is already in the right format
333 333
 		}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
348 348
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
349 349
 			{
350
-				$event['recur_data'] = 1 << (int)date('w',$event['start']);
350
+				$event['recur_data'] = 1 << (int)date('w', $event['start']);
351 351
 			}
352 352
 			if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate']))
353 353
 			{
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 
360 360
 				$event['participants'] = $event['participant_types'] = array();
361 361
 
362
-				foreach($content['participants'] as $key => $data)
362
+				foreach ($content['participants'] as $key => $data)
363 363
 				{
364
-					switch($key)
364
+					switch ($key)
365 365
 					{
366 366
 						case 'delete':		// handled in default
367 367
 						case 'quantity':	// handled in new_resource
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 						case 'status_date':
371 371
 							break;
372 372
 						case 'participant':
373
-							foreach($data as $participant)
373
+							foreach ($data as $participant)
374 374
 							{								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
375 375
 								$email = array();
376
-								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
376
+								if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email))
377 377
 								{
378
-									$status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']);
379
-									if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data))
378
+									$status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']);
379
+									if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data))
380 380
 									{
381 381
 										$event['participants'][$data] = $event['participant_types']['u'][$data] = $status;
382 382
 									}
383
-									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array(
383
+									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array(
384 384
 										'email' => $email[2],
385 385
 										'email_home' => $email[2],
386
-									),true,'','','',false,'OR')))
386
+									), true, '', '', '', false, 'OR')))
387 387
 									{
388 388
 										$event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status;
389 389
 									}
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 								}
395 395
 								else
396 396
 								{
397
-									if(is_numeric($participant))
397
+									if (is_numeric($participant))
398 398
 									{
399 399
 										$uid = 'u'.$participant;
400 400
 										$id = $participant;
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 									else
404 404
 									{
405 405
 										$uid = $participant;
406
-										$id = substr($participant,1);
406
+										$id = substr($participant, 1);
407 407
 										$resource = $this->bo->resources[$participant[0]];
408 408
 									}
409
-									if(!$this->bo->check_acl_invite($uid))
409
+									if (!$this->bo->check_acl_invite($uid))
410 410
 									{
411
-										if(!$msg_permission_denied_added)
411
+										if (!$msg_permission_denied_added)
412 412
 										{
413 413
 											$msg .= lang('Permission denied!');
414 414
 											$msg_permission_denied_added = true;
@@ -418,8 +418,7 @@  discard block
 block discarded – undo
418 418
 
419 419
 									$type = $resource['type'];
420 420
 									$status = isset($this->bo->resources[$type]['new_status']) ?
421
-										ExecMethod($this->bo->resources[$type]['new_status'],$id) :
422
-										($uid == $this->bo->user ? 'A' : 'U');
421
+										ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U');
423 422
 
424 423
 									if ($status)
425 424
 									{
@@ -427,8 +426,8 @@  discard block
 block discarded – undo
427 426
 										// todo check real availability = maximum - already booked quantity
428 427
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
429 428
 										{
430
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
431
-											foreach(array('quantity','resource','role') as $n)
429
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
430
+											foreach (array('quantity', 'resource', 'role') as $n)
432 431
 											{
433 432
 												$event['participants'][$n] = $content['participants'][$n];
434 433
 											}
@@ -437,7 +436,7 @@  discard block
 block discarded – undo
437 436
 										else
438 437
 										{
439 438
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
440
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
439
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
441 440
 										}
442 441
 									}
443 442
 								}
@@ -451,14 +450,14 @@  discard block
 block discarded – undo
451 450
 							break;
452 451
 
453 452
 						default:		// existing participant row
454
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
455
-							foreach(array('uid','status','quantity','role') as $name)
453
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
454
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
456 455
 							{
457 456
 								$$name = $data[$name];
458 457
 							}
459 458
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
460 459
 							{
461
-								$uid = false;	// entry has been deleted
460
+								$uid = false; // entry has been deleted
462 461
 							}
463 462
 							elseif ($uid)
464 463
 							{
@@ -469,7 +468,7 @@  discard block
 block discarded – undo
469 468
 								}
470 469
 								else
471 470
 								{
472
-									$id = substr($uid,1);
471
+									$id = substr($uid, 1);
473 472
 									$type = $uid[0];
474 473
 								}
475 474
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
@@ -477,16 +476,16 @@  discard block
 block discarded – undo
477 476
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
478 477
 									$quantity = $role = null;
479 478
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
480
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
479
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
481 480
 									{
482 481
 										// refreshing the calendar-view with the changed participant-status
483
-										if($event['recur_type'] != MCAL_RECUR_NONE)
482
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
484 483
 										{
485 484
 											$msg = lang('Status for all future scheduled days changed');
486 485
 										}
487 486
 										else
488 487
 										{
489
-											if(isset($content['edit_single']))
488
+											if (isset($content['edit_single']))
490 489
 											{
491 490
 												$msg = lang('Status for this particular day changed');
492 491
 												// prevent accidentally creating a real exception afterwards
@@ -507,7 +506,7 @@  discard block
 block discarded – undo
507 506
 										if ($status == 'R' && $event['alarm'])
508 507
 										{
509 508
 											// remove from bo->set_status deleted alarms of rejected users from UI too
510
-											foreach($event['alarm'] as $alarm_id => $alarm)
509
+											foreach ($event['alarm'] as $alarm_id => $alarm)
511 510
 											{
512 511
 												if ((string)$alarm['owner'] === (string)$uid)
513 512
 												{
@@ -520,7 +519,7 @@  discard block
 block discarded – undo
520 519
 								if ($uid && $status != 'G')
521 520
 								{
522 521
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
523
-										calendar_so::combine_status($status,$quantity,$role);
522
+										calendar_so::combine_status($status, $quantity, $role);
524 523
 								}
525 524
 							}
526 525
 							break;
@@ -539,26 +538,26 @@  discard block
 block discarded – undo
539 538
 			'tabs'			=> $content['tabs'],
540 539
 			'template'      => $content['template'],
541 540
 		);
542
-		$noerror=true;
541
+		$noerror = true;
543 542
 
544 543
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
545 544
 
546 545
 		$ignore_conflicts = $status_reset_to_unknown = false;
547 546
 
548
-		switch((string)$button)
547
+		switch ((string)$button)
549 548
 		{
550 549
 			case 'ignore':
551 550
 				$ignore_conflicts = true;
552
-				$button = $event['button_was'];	// save or apply
551
+				$button = $event['button_was']; // save or apply
553 552
 				unset($event['button_was']);
554 553
 				break;
555 554
 
556 555
 		}
557 556
 
558
-		switch((string)$button)
557
+		switch ((string)$button)
559 558
 		{
560 559
 		case 'exception':	// create an exception in a recuring event
561
-			$msg = $this->_create_exception($event,$preserv);
560
+			$msg = $this->_create_exception($event, $preserv);
562 561
 			break;
563 562
 
564 563
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -569,29 +568,29 @@  discard block
 block discarded – undo
569 568
 			unset($event['recurrence']);
570 569
 			unset($preserv['recurrence']);
571 570
 			unset($event['recur_exception']);
572
-			unset($event['edit_single']);	// in case it has been set
571
+			unset($event['edit_single']); // in case it has been set
573 572
 			unset($event['modified']);
574 573
 			unset($event['modifier']);
575 574
 			unset($event['caldav_name']);
576
-			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
575
+			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD, 0, $this->owner) ? $this->user : $this->owner;
577 576
 
578 577
 			// Clear participant stati
579
-			foreach($event['participant_types'] as $type => &$participants)
578
+			foreach ($event['participant_types'] as $type => &$participants)
580 579
 			{
581
-				foreach($participants as $id => &$p_response)
580
+				foreach ($participants as $id => &$p_response)
582 581
 				{
583
-					if($type == 'u' && $id == $event['owner']) continue;
582
+					if ($type == 'u' && $id == $event['owner']) continue;
584 583
 					calendar_so::split_status($p_response, $quantity, $role);
585 584
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
587
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
585
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
586
+					$p_response = calendar_so::combine_status($status, $quantity, $role);
588 587
 				}
589 588
 			}
590 589
 
591 590
 			// Copy alarms
592 591
 			if (is_array($event['alarm']))
593 592
 			{
594
-				foreach($event['alarm'] as $n => &$alarm)
593
+				foreach ($event['alarm'] as $n => &$alarm)
595 594
 				{
596 595
 					unset($alarm['id']);
597 596
 					unset($alarm['cal_id']);
@@ -601,7 +600,7 @@  discard block
 block discarded – undo
601 600
 			// Get links to be copied
602 601
 			// With no ID, $content['link_to']['to_id'] is used
603 602
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
604
-			foreach(Link::get_links('calendar', $content['id']) as $link)
603
+			foreach (Link::get_links('calendar', $content['id']) as $link)
605 604
 			{
606 605
 				if ($link['app'] != Link::VFS_APPNAME)
607 606
 				{
@@ -627,7 +626,7 @@  discard block
 block discarded – undo
627 626
 		case 'print':
628 627
 		case 'apply':
629 628
 		case 'infolog':
630
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
629
+			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event))
631 630
 			{
632 631
 				$msg = lang('Permission denied');
633 632
 				$button = '';
@@ -645,7 +644,7 @@  discard block
 block discarded – undo
645 644
 				$button = '';
646 645
 				break;
647 646
 			}
648
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
647
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
649 648
 			{
650 649
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
651 650
 				$button = '';
@@ -675,14 +674,14 @@  discard block
 block discarded – undo
675 674
 				$event['reference'] = $event['id'];
676 675
 				$event['recurrence'] = $content['edit_single'];
677 676
 				unset($event['id']);
678
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
677
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
679 678
 				if (!is_array($conflicts) && $conflicts)
680 679
 				{
681 680
 					// now we need to add the original start as recur-execption to the series
682 681
 					$recur_event = $this->bo->read($event['reference']);
683 682
 					$recur_event['recur_exception'][] = $content['edit_single'];
684 683
 					// check if we need to move the alarms, because they are next on that exception
685
-					foreach($recur_event['alarm'] as $id => $alarm)
684
+					foreach ($recur_event['alarm'] as $id => $alarm)
686 685
 					{
687 686
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
688 687
 						{
@@ -698,11 +697,11 @@  discard block
 block discarded – undo
698 697
 							}
699 698
 						}
700 699
 					}
701
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
702
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
703
-					$this->bo->update($recur_event,true);	// no conflict check here
700
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
701
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
702
+					$this->bo->update($recur_event, true); // no conflict check here
704 703
 
705
-					if(Api\Json\Response::isJSONResponse())
704
+					if (Api\Json\Response::isJSONResponse())
706 705
 					{
707 706
 						// Sending null will trigger a removal of the original
708 707
 						// for that date
@@ -710,7 +709,7 @@  discard block
 block discarded – undo
710 709
 					}
711 710
 
712 711
 					unset($recur_event);
713
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
712
+					unset($event['edit_single']); // if we further edit it, it's just a single event
714 713
 					unset($preserv['edit_single']);
715 714
 				}
716 715
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -741,8 +740,8 @@  discard block
 block discarded – undo
741 740
 							{
742 741
 								$offset = $off2;
743 742
 							}
744
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
745
-							if($msg)
743
+							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']);
744
+							if ($msg)
746 745
 							{
747 746
 								$noerror = false;
748 747
 							}
@@ -755,13 +754,13 @@  discard block
 block discarded – undo
755 754
 							$event['whole_day'] != $old_event['whole_day'])
756 755
 						{
757 756
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
758
-							foreach((array)$event['participants'] as $uid => $status)
757
+							foreach ((array)$event['participants'] as $uid => $status)
759 758
 							{
760 759
 								$q = $r = null;
761
-								calendar_so::split_status($status,$q,$r);
760
+								calendar_so::split_status($status, $q, $r);
762 761
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
763 762
 								{
764
-									$preferences = CreateObject('phpgwapi.preferences',$uid);
763
+									$preferences = CreateObject('phpgwapi.preferences', $uid);
765 764
 									$part_prefs = $preferences->read_repository();
766 765
 									switch ($part_prefs['calendar']['reset_stati'])
767 766
 									{
@@ -771,7 +770,7 @@  discard block
 block discarded – undo
771 770
 											if ($sameday) break;
772 771
 										default:
773 772
 											$status_reset_to_unknown = true;
774
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
773
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
775 774
 											// todo: report reset status to user
776 775
 									}
777 776
 								}
@@ -783,38 +782,38 @@  discard block
 block discarded – undo
783 782
 				}
784 783
 				// Adding participants needs to be done as an edit, in case we
785 784
 				// have participants visible in seperate calendars
786
-				if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
785
+				if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
787 786
 				{
788 787
 					$update_type = 'edit';
789 788
 				}
790
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
789
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
791 790
 				unset($event['ignore']);
792 791
 			}
793 792
 			if (is_array($conflicts))
794 793
 			{
795
-				$event['button_was'] = $button;	// remember for ignore
796
-				return $this->conflicts($event,$conflicts,$preserv);
794
+				$event['button_was'] = $button; // remember for ignore
795
+				return $this->conflicts($event, $conflicts, $preserv);
797 796
 			}
798 797
 
799 798
 			// Event spans multiple days, need an edit to make sure they all get updated
800 799
 			// We could check old date, as removing from days could still be an update
801
-			if(date('Ymd', $event['start']) != date('Ymd', $event['end']))
800
+			if (date('Ymd', $event['start']) != date('Ymd', $event['end']))
802 801
 			{
803 802
 				$update_type = 'edit';
804 803
 			}
805 804
 			// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
806 805
 			if ($messages)
807 806
 			{
808
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
807
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
809 808
 			}
810 809
 			if ($conflicts === 0)
811 810
 			{
812
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
813
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
814
-								htmlspecialchars(Egw::link('/index.php',array(
811
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
812
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
813
+								htmlspecialchars(Egw::link('/index.php', array(
815 814
 								'menuaction' => 'calendar.calendar_uiforms.edit',
816 815
 								'cal_id'    => $content['id'],
817
-							))).'">','</a>');
816
+							))).'">', '</a>');
818 817
 				$noerror = false;
819 818
 			}
820 819
 			elseif ($conflicts > 0)
@@ -836,19 +835,19 @@  discard block
 block discarded – undo
836 835
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
837 836
 						if ($alarm['time'] < $this->bo->now_su)
838 837
 						{
839
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
838
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
840 839
 							{
841
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
840
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
842 841
 							}
843 842
 							else
844 843
 							{
845
-								$alarm = false;	// no (further) recurence found --> ignore alarm
844
+								$alarm = false; // no (further) recurence found --> ignore alarm
846 845
 							}
847 846
 						}
848 847
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
849 848
 						elseif ($event_time < $event['start'])
850 849
 						{
851
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
850
+							$alarm['time'] = $event['start'] - $alarm['offset'];
852 851
 						}
853 852
 						if ($alarm)
854 853
 						{
@@ -857,9 +856,9 @@  discard block
 block discarded – undo
857 856
 						}
858 857
 					}
859 858
 					// attach all future exceptions to the new series
860
-					$events =& $this->bo->search(array(
859
+					$events = & $this->bo->search(array(
861 860
 						'query' => array('cal_uid' => $old_event['uid']),
862
-						'filter' => 'owner',  // return all possible entries
861
+						'filter' => 'owner', // return all possible entries
863 862
 						'daywise' => false,
864 863
 						'date_format' => 'ts',
865 864
 					));
@@ -870,7 +869,7 @@  discard block
 block discarded – undo
870 869
 							$exception['recurrence'] += $offset;
871 870
 							$exception['reference'] = $event['id'];
872 871
 							$exception['uid'] = $event['uid'];
873
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
872
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
874 873
 						}
875 874
 					}
876 875
 				}
@@ -878,12 +877,12 @@  discard block
 block discarded – undo
878 877
 				$message = lang('Event saved');
879 878
 				if ($status_reset_to_unknown)
880 879
 				{
881
-					foreach((array)$event['participants'] as $uid => $status)
880
+					foreach ((array)$event['participants'] as $uid => $status)
882 881
 					{
883 882
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
884 883
 						{
885
-							calendar_so::split_status($status,$q,$r);
886
-							$status = calendar_so::combine_status('U',$q,$r);
884
+							calendar_so::split_status($status, $q, $r);
885
+							$status = calendar_so::combine_status('U', $q, $r);
887 886
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
888 887
 						}
889 888
 					}
@@ -891,17 +890,17 @@  discard block
 block discarded – undo
891 890
 				}
892 891
 
893 892
 				$response = Api\Json\Response::get();
894
-				if($response && $update_type != 'delete')
893
+				if ($response && $update_type != 'delete')
895 894
 				{
896 895
 					$this->update_client($event['id']);
897 896
 				}
898 897
 
899
-				$msg = $message . ($msg ? ', ' . $msg : '');
898
+				$msg = $message.($msg ? ', '.$msg : '');
900 899
 				Framework::refresh_opener($msg, 'calendar', $event['id'], $event['recur_type'] ? 'edit' : $update_type);
901 900
 				// writing links for new entry, existing ones are handled by the widget itself
902 901
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
903 902
 				{
904
-					Link::link('calendar',$event['id'],$content['link_to']['to_id']);
903
+					Link::link('calendar', $event['id'], $content['link_to']['to_id']);
905 904
 				}
906 905
 			}
907 906
 			else
@@ -911,7 +910,7 @@  discard block
 block discarded – undo
911 910
 			break;
912 911
 
913 912
 		case 'cancel':
914
-			if($content['cancel_needs_refresh'])
913
+			if ($content['cancel_needs_refresh'])
915 914
 			{
916 915
 				Framework::refresh_opener($msg, 'calendar');
917 916
 			}
@@ -949,7 +948,7 @@  discard block
 block discarded – undo
949 948
 			{
950 949
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
951 950
 			}
952
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
951
+			if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
953 952
 			{
954 953
 				$alarm = array(
955 954
 					'offset' => $offset,
@@ -963,13 +962,13 @@  discard block
 block discarded – undo
963 962
 				}
964 963
 				elseif ($event['id'])	// save the alarm immediatly
965 964
 				{
966
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
965
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
967 966
 					{
968 967
 						$alarm['id'] = $alarm_id;
969 968
 						$event['alarm'][$alarm_id] = $alarm;
970 969
 
971 970
 						$msg = lang('Alarm added');
972
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
971
+						Framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
973 972
 					}
974 973
 					else
975 974
 					{
@@ -978,7 +977,7 @@  discard block
 block discarded – undo
978 977
 				}
979 978
 				else
980 979
 				{
981
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
980
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
982 981
 					$event['alarm'][$alarm['id']] = $alarm;
983 982
 				}
984 983
 			}
@@ -995,26 +994,26 @@  discard block
 block discarded – undo
995 994
 		}
996 995
 		// New event, send data before updating so it's there
997 996
 		$response = Api\Json\Response::get();
998
-		if($response && !$content['id'] && $event['id'])
997
+		if ($response && !$content['id'] && $event['id'])
999 998
 		{
1000 999
 			$this->update_client($event['id']);
1001 1000
 		}
1002
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1001
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1003 1002
 		{
1004 1003
 			if ($content['lock_token'])	// remove an existing lock
1005 1004
 			{
1006
-				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1005
+				Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1007 1006
 			}
1008 1007
 			if ($content['no_popup'])
1009 1008
 			{
1010
-				Egw::redirect_link('/index.php',array(
1009
+				Egw::redirect_link('/index.php', array(
1011 1010
 					'menuaction' => 'calendar.calendar_uiviews.index',
1012 1011
 					'msg'        => $msg,
1013 1012
 				));
1014 1013
 			}
1015
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1014
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1016 1015
 			{
1017
-				Framework::refresh_opener($msg,'calendar');
1016
+				Framework::refresh_opener($msg, 'calendar');
1018 1017
 			}
1019 1018
 			else
1020 1019
 			{
@@ -1024,7 +1023,7 @@  discard block
 block discarded – undo
1024 1023
 			exit();
1025 1024
 		}
1026 1025
 		unset($event['no_notifications']);
1027
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1026
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1028 1027
 	}
1029 1028
 
1030 1029
 	/**
@@ -1036,7 +1035,7 @@  discard block
 block discarded – undo
1036 1035
 	 * @param array &$preserv
1037 1036
 	 * @return string message that exception was created
1038 1037
 	 */
1039
-	function _create_exception(&$event,&$preserv)
1038
+	function _create_exception(&$event, &$preserv)
1040 1039
 	{
1041 1040
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1042 1041
 		$preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1046,17 +1045,17 @@  discard block
 block discarded – undo
1046 1045
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1047 1046
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1048 1047
 		$event['recur_type'] = MCAL_RECUR_NONE;
1049
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1048
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1050 1049
 		{
1051 1050
 			unset($event[$name]);
1052 1051
 		}
1053 1052
 		// add all alarms as new alarms to execption
1054 1053
 		$event['alarm'] = array_values((array)$event['alarm']);
1055
-		foreach($event['alarm'] as &$alarm)
1054
+		foreach ($event['alarm'] as &$alarm)
1056 1055
 		{
1057 1056
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1058 1057
 		}
1059
-		if($this->bo->check_perms(Acl::EDIT,$event))
1058
+		if ($this->bo->check_perms(Acl::EDIT, $event))
1060 1059
 		{
1061 1060
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1062 1061
 		}
@@ -1083,14 +1082,14 @@  discard block
 block discarded – undo
1083 1082
 	{
1084 1083
 		$msg = false;
1085 1084
 
1086
-		if(!$as_of_date )
1085
+		if (!$as_of_date)
1087 1086
 		{
1088 1087
 			$as_of_date = time();
1089 1088
 		}
1090 1089
 
1091 1090
 		//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
1092 1091
 
1093
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1092
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1094 1093
 		{
1095 1094
 			$msg = lang("Error: You can't shift a series from the past!");
1096 1095
 			return $msg;
@@ -1103,11 +1102,11 @@  discard block
 block discarded – undo
1103 1102
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1104 1103
 
1105 1104
 		// base start-date of new series on actual / clicked date
1106
-		$event['start'] = $as_of_date ;
1105
+		$event['start'] = $as_of_date;
1107 1106
 
1108
-		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1107
+		if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') ||
1109 1108
 			// Adjust for requested date in the past
1110
-			Api\DateTime::to($as_of_date,'ts') < time()
1109
+			Api\DateTime::to($as_of_date, 'ts') < time()
1111 1110
 		)
1112 1111
 		{
1113 1112
 
@@ -1127,17 +1126,17 @@  discard block
 block discarded – undo
1127 1126
 				$rriter->next_no_exception();
1128 1127
 				$occurrence = $rriter->current();
1129 1128
 			}
1130
-			while ($rriter->valid()  && (
1129
+			while ($rriter->valid() && (
1131 1130
 				Api\DateTime::to($occurrence, 'ts') <= time() ||
1132
-				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
1131
+				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd')
1133 1132
 			) && ($last = $occurrence));
1134 1133
 
1135 1134
 
1136 1135
 			// Make sure as_of_date is still valid, may have to move forward
1137
-			if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
1136
+			if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') ||
1138 1137
 				Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
1139 1138
 			{
1140
-				$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
1139
+				$event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset;
1141 1140
 			}
1142 1141
 
1143 1142
 			//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
@@ -1145,7 +1144,7 @@  discard block
 block discarded – undo
1145 1144
 			{
1146 1145
 				$event['end'] = $event['start'] + $duration;
1147 1146
 			}
1148
-			elseif($event['end'] < $event['start'])
1147
+			elseif ($event['end'] < $event['start'])
1149 1148
 			{
1150 1149
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1151 1150
 			}
@@ -1154,7 +1153,7 @@  discard block
 block discarded – undo
1154 1153
 			$event['participants'] = $old_event['participants'];
1155 1154
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1156 1155
 			{
1157
-				if ($exdate > Api\DateTime::to($last,'ts'))
1156
+				if ($exdate > Api\DateTime::to($last, 'ts'))
1158 1157
 				{
1159 1158
 					//error_log("Moved exception on " . Api\DateTime::to($exdate));
1160 1159
 					unset($old_event['recur_exception'][$key]);
@@ -1168,18 +1167,18 @@  discard block
 block discarded – undo
1168 1167
 			}
1169 1168
 			$last->setTime(0, 0, 0);
1170 1169
 			$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
1171
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1170
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1172 1171
 			{
1173
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1174
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1175
-						htmlspecialchars(Egw::link('/index.php',array(
1172
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1173
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1174
+						htmlspecialchars(Egw::link('/index.php', array(
1176 1175
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1177 1176
 							'cal_id'    => $event['id'],
1178
-						))).'">','</a>');
1177
+						))).'">', '</a>');
1179 1178
 				$event = $orig_event;
1180 1179
 			}
1181 1180
 		}
1182
-		$event['start'] = Api\DateTime::to($event['start'],'ts');
1181
+		$event['start'] = Api\DateTime::to($event['start'], 'ts');
1183 1182
 		return $msg;
1184 1183
 	}
1185 1184
 
@@ -1190,11 +1189,11 @@  discard block
 block discarded – undo
1190 1189
 	 * @param boolean $added
1191 1190
 	 * @return string javascript window.open command
1192 1191
 	 */
1193
-	function ajax_custom_mail($event,$added,$asrequest=false)
1192
+	function ajax_custom_mail($event, $added, $asrequest = false)
1194 1193
 	{
1195 1194
 		$to = array();
1196 1195
 
1197
-		foreach($event['participants'] as $uid => $status)
1196
+		foreach ($event['participants'] as $uid => $status)
1198 1197
 		{
1199 1198
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1200 1199
 			if (empty($status)) continue;
@@ -1203,35 +1202,35 @@  discard block
 block discarded – undo
1203 1202
 
1204 1203
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1205 1204
 			{
1206
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1205
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1207 1206
 
1208 1207
 				$lid = $firstname = $lastname = null;
1209
-				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1208
+				$GLOBALS['egw']->accounts->get_account_name($status['uid'], $lid, $firstname, $lastname);
1210 1209
 
1211 1210
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1212
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1211
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1213 1212
 				//error_log(__METHOD__.__LINE__.array2string($to));
1214 1213
 			}
1215 1214
 			elseif ($uid < 0)
1216 1215
 			{
1217
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1216
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1218 1217
 				{
1219
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1218
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1220 1219
 
1221
-					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1220
+					$GLOBALS['egw']->accounts->get_account_name($uid, $lid, $firstname, $lastname);
1222 1221
 
1223 1222
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1224 1223
 					// dont add groupmembers if they already rejected the event, or are the current user
1225
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1224
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1226 1225
 					//error_log(__METHOD__.__LINE__.array2string($to));
1227 1226
 				}
1228 1227
 			}
1229
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1228
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1230 1229
 			{
1231 1230
 				$to[] = $info['email'];
1232 1231
 				//error_log(__METHOD__.__LINE__.array2string($to));
1233 1232
 			}
1234
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1233
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1235 1234
 			{
1236 1235
 				$to[] = $info['email'];
1237 1236
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1240,7 +1239,7 @@  discard block
 block discarded – undo
1240 1239
 		// prefer event description over standard notification text
1241 1240
 		if (empty($event['description']))
1242 1241
 		{
1243
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1242
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1244 1243
 		}
1245 1244
 		else
1246 1245
 		{
@@ -1255,12 +1254,12 @@  discard block
 block discarded – undo
1255 1254
 		$boical = new calendar_ical();
1256 1255
 		// we need to pass $event[id] so iCal class reads event again,
1257 1256
 		// as event is in user TZ, but iCal class expects server TZ!
1258
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1257
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1259 1258
 
1260
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1261
-		if(($f = fopen($ics_file,'w')))
1259
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1260
+		if (($f = fopen($ics_file, 'w')))
1262 1261
 		{
1263
-			fwrite($f,$ics);
1262
+			fwrite($f, $ics);
1264 1263
 			fclose($f);
1265 1264
 		}
1266 1265
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1272,7 +1271,7 @@  discard block
 block discarded – undo
1272 1271
 			'preset[body]'    => $body,
1273 1272
 			'preset[name]'    => 'event.ics',
1274 1273
 			'preset[file]'    => $ics_file,
1275
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1274
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1276 1275
 			'preset[size]'    => filesize($ics_file),
1277 1276
 		);
1278 1277
 		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.');
@@ -1328,7 +1327,7 @@  discard block
 block discarded – undo
1328 1327
 	 * @param mixed $link_to_id ='' from or for the link-widget
1329 1328
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1330 1329
 	 */
1331
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1330
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1332 1331
 	{
1333 1332
 		$sel_options = array(
1334 1333
 			'recur_type' => &$this->bo->recur_types,
@@ -1352,8 +1351,8 @@  discard block
 block discarded – undo
1352 1351
 				'no_popup' => isset($_GET['no_popup']),
1353 1352
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1354 1353
 			);
1355
-			$cal_id = (int) $_GET['cal_id'];
1356
-			if($_GET['action'])
1354
+			$cal_id = (int)$_GET['cal_id'];
1355
+			if ($_GET['action'])
1357 1356
 			{
1358 1357
 				$event = $this->bo->read($cal_id);
1359 1358
 				$event['action'] = $_GET['action'];
@@ -1371,14 +1370,14 @@  discard block
 block discarded – undo
1371 1370
 			{
1372 1371
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1373 1372
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1374
-				$event =& $this->default_add_event();
1373
+				$event = & $this->default_add_event();
1375 1374
 			}
1376 1375
 			if (!empty($_GET['ical_data']) &&
1377 1376
 				!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
1378 1377
 			{
1379 1378
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1380 1379
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1381
-				$event =& $this->default_add_event();
1380
+				$event = & $this->default_add_event();
1382 1381
 			}
1383 1382
 			if (!empty($_GET['ical']))
1384 1383
 			{
@@ -1387,14 +1386,14 @@  discard block
 block discarded – undo
1387 1386
 				{
1388 1387
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1389 1388
 					$msg = lang('Error: importing the iCal');
1390
-					$event =& $this->default_add_event();
1389
+					$event = & $this->default_add_event();
1391 1390
 				}
1392 1391
 				else
1393 1392
 				{
1394 1393
 					if (count($events) > 1)
1395 1394
 					{
1396 1395
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1397
-						$msg_type = 'notice';	// no not hide automatic
1396
+						$msg_type = 'notice'; // no not hide automatic
1398 1397
 					}
1399 1398
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1400 1399
 					$this->bo->db2data($events, 'ts');
@@ -1407,7 +1406,7 @@  discard block
 block discarded – undo
1407 1406
 					else
1408 1407
 					{
1409 1408
 						$event['participant_types'] = array();
1410
-						foreach($event['participants'] as $uid => $status)
1409
+						foreach ($event['participants'] as $uid => $status)
1411 1410
 						{
1412 1411
 							$user_type = $user_id = null;
1413 1412
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1428,15 +1427,15 @@  discard block
 block discarded – undo
1428 1427
 					}
1429 1428
 					else
1430 1429
 					{
1431
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1430
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1432 1431
 						exit();
1433 1432
 					}
1434 1433
 				}
1435
-				$event =& $this->default_add_event();
1434
+				$event = & $this->default_add_event();
1436 1435
 			}
1437 1436
 			else
1438 1437
 			{
1439
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1438
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1440 1439
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1441 1440
 				{
1442 1441
 					if (empty($event['whole_day']))
@@ -1449,10 +1448,10 @@  discard block
 block discarded – undo
1449 1448
 						$date->setUser();
1450 1449
 					}
1451 1450
 					$event = $this->bo->read($cal_id, $date, true);
1452
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1451
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1453 1452
 					if ($_GET['exception'])
1454 1453
 					{
1455
-						$msg = $this->_create_exception($event,$preserv);
1454
+						$msg = $this->_create_exception($event, $preserv);
1456 1455
 					}
1457 1456
 					else
1458 1457
 					{
@@ -1461,9 +1460,9 @@  discard block
 block discarded – undo
1461 1460
 				}
1462 1461
 			}
1463 1462
 			// set new start and end if given by $_GET
1464
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1465
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1466
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1463
+			if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); }
1464
+			if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); }
1465
+			if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1467 1466
 			// check if the event is the whole day
1468 1467
 			$start = $this->bo->date2array($event['start']);
1469 1468
 			$end = $this->bo->date2array($event['end']);
@@ -1473,30 +1472,30 @@  discard block
 block discarded – undo
1473 1472
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1474 1473
 			{
1475 1474
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1476
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1475
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1477 1476
 				{
1478 1477
 					$link_id = $link_ids[$n];
1479
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1478
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1480 1479
 					{
1481 1480
 						continue;
1482 1481
 					}
1483
-					if(!$n)
1482
+					if (!$n)
1484 1483
 					{
1485
-						$event['title'] = Link::title($link_app,$link_id);
1484
+						$event['title'] = Link::title($link_app, $link_id);
1486 1485
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1487
-						if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1486
+						if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1488 1487
 						{
1489
-							foreach((array)$set['link_app'] as $i => $l_app)
1488
+							foreach ((array)$set['link_app'] as $i => $l_app)
1490 1489
 							{
1491
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1490
+								if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1492 1491
 							}
1493 1492
 							unset($set['link_app']);
1494 1493
 							unset($set['link_id']);
1495 1494
 
1496
-							$event = array_merge($event,$set);
1495
+							$event = array_merge($event, $set);
1497 1496
 						}
1498 1497
 					}
1499
-					Link::link('calendar',$link_to_id,$link_app,$link_id);
1498
+					Link::link('calendar', $link_to_id, $link_app, $link_id);
1500 1499
 				}
1501 1500
 			}
1502 1501
 		}
@@ -1506,44 +1505,44 @@  discard block
 block discarded – undo
1506 1505
 		{
1507 1506
 			$etpl->read($preserv['template'] = 'calendar.edit');
1508 1507
 		}
1509
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
1508
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event);
1510 1509
 		//echo "view=$view, event="; _debug_array($event);
1511 1510
 		// shared locking of entries to edit
1512 1511
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1513 1512
 		{
1514
-			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1513
+			$lock_path = Vfs::app_entry_lock_path('calendar', $event['id']);
1515 1514
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1516 1515
 
1517 1516
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1518 1517
 			{
1519
-				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1518
+				Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1520 1519
 			}
1521 1520
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1522 1521
 			{
1523 1522
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1524
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1523
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1525 1524
 					Api\Accounts::username($lock_uid) : $lock['owner']));
1526 1525
 			}
1527
-			elseif($lock)
1526
+			elseif ($lock)
1528 1527
 			{
1529 1528
 				$preserv['lock_token'] = $lock['token'];
1530 1529
 			}
1531
-			elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1530
+			elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1532 1531
 			{
1533 1532
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1534 1533
 			}
1535 1534
 			else
1536 1535
 			{
1537
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1536
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1538 1537
 				$view = true;
1539 1538
 			}
1540 1539
 		}
1541
-		$content = array_merge($event,array(
1540
+		$content = array_merge($event, array(
1542 1541
 			'link_to' => array(
1543 1542
 				'to_id'  => $link_to_id,
1544 1543
 				'to_app' => 'calendar',
1545 1544
 			),
1546
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1545
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1547 1546
 			'tabs'   => $preserv['tabs'],
1548 1547
 			'view' => $view,
1549 1548
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1555,11 +1554,11 @@  discard block
 block discarded – undo
1555 1554
 		$row = 3;
1556 1555
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1557 1556
 		// preserve some ui elements, if set eg. under error-conditions
1558
-		foreach(array('quantity','resource','role') as $n)
1557
+		foreach (array('quantity', 'resource', 'role') as $n)
1559 1558
 		{
1560 1559
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1561 1560
 		}
1562
-		foreach($event['participant_types'] as $type => $participants)
1561
+		foreach ($event['participant_types'] as $type => $participants)
1563 1562
 		{
1564 1563
 			$name = 'accounts';
1565 1564
 			if (isset($this->bo->resources[$type]))
@@ -1568,17 +1567,17 @@  discard block
 block discarded – undo
1568 1567
 			}
1569 1568
 			// sort participants (in there group/app) by title
1570 1569
 			uksort($participants, array($this, 'uid_title_cmp'));
1571
-			foreach($participants as $id => $status)
1570
+			foreach ($participants as $id => $status)
1572 1571
 			{
1573 1572
 				$uid = $type == 'u' ? $id : $type.$id;
1574 1573
 				$quantity = $role = null;
1575
-				calendar_so::split_status($status,$quantity,$role);
1574
+				calendar_so::split_status($status, $quantity, $role);
1576 1575
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1577 1576
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1578 1577
 					'uid'      => $uid,
1579 1578
 					'status'   => $status,
1580 1579
 					'old_status' => $status,
1581
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1580
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1582 1581
 					'role'     => $role,
1583 1582
 				);
1584 1583
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1587,33 +1586,33 @@  discard block
 block discarded – undo
1587 1586
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1588 1587
 				}
1589 1588
 				// allow third party apps to use categories for roles
1590
-				elseif(substr($role,0,6) == 'X-CAT-')
1589
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1591 1590
 				{
1592
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1591
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1593 1592
 				}
1594 1593
 				else
1595 1594
 				{
1596
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1595
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1597 1596
 				}
1598
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1597
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1599 1598
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1600 1599
 
1601
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1600
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1602 1601
 					$readonlys['participants'][$row]['status'] = $no_status;
1603
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1602
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event))
1604 1603
 					$readonlys['participants']['delete'][$uid] = true;
1605 1604
 				// todo: make the participants available as links with email as title
1606 1605
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1607 1606
 				// enumerate group-invitations, so people can accept/reject them
1608 1607
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1609
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1608
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1610 1609
 				{
1611 1610
 					$sel_options['status']['G'] = lang('Select one');
1612 1611
 					// sort members by title
1613 1612
 					usort($members, array($this, 'uid_title_cmp'));
1614
-					foreach($members as $member)
1613
+					foreach ($members as $member)
1615 1614
 					{
1616
-						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
1615
+						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member))
1617 1616
 						{
1618 1617
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1619 1618
 								'app'      => 'Group invitation',
@@ -1622,7 +1621,7 @@  discard block
 block discarded – undo
1622 1621
 							);
1623 1622
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1624 1623
 							// read access is enough to invite participants, but you need edit rights to change status
1625
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
1624
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member);
1626 1625
 							$content['participants'][$row++]['title'] = Api\Accounts::username($member);
1627 1626
 						}
1628 1627
 					}
@@ -1630,43 +1629,43 @@  discard block
 block discarded – undo
1630 1629
 			}
1631 1630
 			// resouces / apps we shedule, atm. resources and addressbook
1632 1631
 			$content['participants']['cal_resources'] = '';
1633
-			foreach($this->bo->resources as $data)
1632
+			foreach ($this->bo->resources as $data)
1634 1633
 			{
1635
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1634
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1636 1635
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1637 1636
 			}
1638 1637
 		}
1639 1638
 		$content['participants']['status_date'] = $preserv['actual_date'];
1640
-		$preserved = array_merge($preserv,$content);
1639
+		$preserved = array_merge($preserv, $content);
1641 1640
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1642 1641
 		if ($event['alarm'])
1643 1642
 		{
1644 1643
 			// makes keys of the alarm-array starting with 1
1645 1644
 			$content['alarm'] = array(false);
1646
-			foreach(array_values($event['alarm']) as $id => $alarm)
1645
+			foreach (array_values($event['alarm']) as $id => $alarm)
1647 1646
 			{
1648
-				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
1647
+				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
1649 1648
 				{
1650
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1649
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1651 1650
 				}
1652
-				$alarm['all'] = (int) $alarm['all'];
1651
+				$alarm['all'] = (int)$alarm['all'];
1653 1652
 				$after = false;
1654
-				if($alarm['offset'] < 0)
1653
+				if ($alarm['offset'] < 0)
1655 1654
 				{
1656 1655
 					$after = true;
1657 1656
 					$alarm['offset'] = -1 * $alarm['offset'];
1658 1657
 				}
1659
-				$days = (int) ($alarm['offset'] / DAY_s);
1660
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1661
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1658
+				$days = (int)($alarm['offset'] / DAY_s);
1659
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1660
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1662 1661
 				$label = array();
1663 1662
 				if ($days) $label[] = $days.' '.lang('days');
1664 1663
 				if ($hours) $label[] = $hours.' '.lang('hours');
1665 1664
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1666
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1665
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1667 1666
 				$content['alarm'][] = $alarm;
1668 1667
 
1669
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1668
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1670 1669
 			}
1671 1670
 			if (count($content['alarm']) == 1)
1672 1671
 			{
@@ -1681,20 +1680,20 @@  discard block
 block discarded – undo
1681 1680
 
1682 1681
 		if ($view)
1683 1682
 		{
1684
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1683
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1685 1684
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1686 1685
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1687 1686
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1688 1687
 
1689 1688
 			$content['participants']['no_add'] = true;
1690 1689
 
1691
-			if(!$event['whole_day'])
1690
+			if (!$event['whole_day'])
1692 1691
 			{
1693 1692
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1694 1693
 			}
1695 1694
 
1696 1695
 			// respect category permissions
1697
-			if(!empty($event['category']))
1696
+			if (!empty($event['category']))
1698 1697
 			{
1699 1698
 				$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
1700 1699
 			}
@@ -1705,7 +1704,7 @@  discard block
 block discarded – undo
1705 1704
 
1706 1705
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1707 1706
 			{
1708
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1707
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1709 1708
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1710 1709
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1711 1710
 			}
@@ -1715,9 +1714,9 @@  discard block
 block discarded – undo
1715 1714
 				$readonlys['recur_interval'] = $readonlys['recur_data'] = true;
1716 1715
 			}
1717 1716
 		}
1718
-		if($content['category'] && !is_array($content['category']))
1717
+		if ($content['category'] && !is_array($content['category']))
1719 1718
 		{
1720
-			$content['category'] = explode(',',$event['category']);
1719
+			$content['category'] = explode(',', $event['category']);
1721 1720
 		}
1722 1721
 		// disabling the custom fields tab, if there are none
1723 1722
 		$readonlys['tabs'] = array(
@@ -1734,13 +1733,13 @@  discard block
 block discarded – undo
1734 1733
 		{
1735 1734
 			$readonlys['action'] = true;
1736 1735
 		}
1737
-		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'])))
1736
+		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'])))
1738 1737
 		{
1739 1738
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1740 1739
 		}
1741
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1740
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event);
1742 1741
 
1743
-		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
1742
+		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
1744 1743
 		{
1745 1744
 			$sel_options['owner'][0] = lang('All participants');
1746 1745
 		}
@@ -1748,25 +1747,25 @@  discard block
 block discarded – undo
1748 1747
 		{
1749 1748
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1750 1749
 		}
1751
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1750
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1752 1751
 		{
1753
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
1752
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid))
1754 1753
 			{
1755 1754
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1756 1755
 			}
1757 1756
 		}
1758
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1757
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1759 1758
 		if (!$event['id'])
1760 1759
 		{
1761
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1760
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1762 1761
 		}
1763 1762
 		if ($preserved['no_popup'])
1764 1763
 		{
1765
-			$etpl->set_cell_attribute('button[cancel]','onclick','');
1764
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', '');
1766 1765
 		}
1767 1766
 
1768 1767
 		// Allow admins to restore deleted events
1769
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1768
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1770 1769
 		{
1771 1770
 			$content['deleted'] = $preserved['deleted'] = null;
1772 1771
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1778,7 +1777,7 @@  discard block
 block discarded – undo
1778 1777
 		// Setup history tab
1779 1778
 		$this->setup_history($content, $sel_options);
1780 1779
 
1781
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1780
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1782 1781
 			. (!$event['id'] ? lang('Add')
1783 1782
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1784 1783
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1788,15 +1787,15 @@  discard block
 block discarded – undo
1788 1787
 		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1789 1788
 
1790 1789
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1791
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1790
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1792 1791
 		{
1793
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1792
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1794 1793
 			$content['button']['save'] = true;
1795
-			$this->process_edit(array_merge($content,$preserved));
1794
+			$this->process_edit(array_merge($content, $preserved));
1796 1795
 		}
1797 1796
 		else
1798 1797
 		{
1799
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1798
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1800 1799
 		}
1801 1800
 	}
1802 1801
 
@@ -1806,14 +1805,14 @@  discard block
 block discarded – undo
1806 1805
 	 * @param int $id
1807 1806
 	 * @param string $token
1808 1807
 	 */
1809
-	function ajax_unlock($id,$token)
1808
+	function ajax_unlock($id, $token)
1810 1809
 	{
1811
-		$lock_path = Vfs::app_entry_lock_path('calendar',$id);
1810
+		$lock_path = Vfs::app_entry_lock_path('calendar', $id);
1812 1811
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1813 1812
 
1814 1813
 		if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1815 1814
 		{
1816
-			Vfs::unlock($lock_path,$token,false);
1815
+			Vfs::unlock($lock_path, $token, false);
1817 1816
 		}
1818 1817
 	}
1819 1818
 
@@ -1825,17 +1824,17 @@  discard block
 block discarded – undo
1825 1824
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1826 1825
 	 * @param string $msg = null
1827 1826
 	 */
1828
-	function meeting(array $event=null, $msg=null)
1827
+	function meeting(array $event = null, $msg = null)
1829 1828
 	{
1830 1829
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1831 1830
 		$readonlys['button[apply]'] = true;
1832
-		$_usesession=!is_array($event);
1831
+		$_usesession = !is_array($event);
1833 1832
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1834 1833
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1835
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1834
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1836 1835
 		{
1837
-			$event=null; // set to null
1838
-			$_usesession=true; // trigger session read
1836
+			$event = null; // set to null
1837
+			$_usesession = true; // trigger session read
1839 1838
 		}
1840 1839
 		if (!is_array($event))
1841 1840
 		{
@@ -1864,7 +1863,7 @@  discard block
 block discarded – undo
1864 1863
 
1865 1864
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1866 1865
 			{
1867
-				switch(strtolower($ical_method))
1866
+				switch (strtolower($ical_method))
1868 1867
 				{
1869 1868
 					case 'reply':
1870 1869
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -1918,19 +1917,19 @@  discard block
 block discarded – undo
1918 1917
 			}
1919 1918
 			else	// event not in calendar
1920 1919
 			{
1921
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
1920
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
1922 1921
 			}
1923 1922
 			$event['participant_types'] = array();
1924
-			foreach($event['participants'] as $uid => $status)
1923
+			foreach ($event['participants'] as $uid => $status)
1925 1924
 			{
1926 1925
 				$user_type = $user_id = null;
1927 1926
 				calendar_so::split_user($uid, $user_type, $user_id);
1928 1927
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
1929
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
1928
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
1930 1929
 			}
1931 1930
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
1932 1931
 			$event['recure'] = $this->bo->recure2string($event);
1933
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
1932
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
1934 1933
 
1935 1934
 			// ignore events in the past (for recurring events check enddate!)
1936 1935
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -1950,23 +1949,23 @@  discard block
 block discarded – undo
1950 1949
 			// clear notification errors
1951 1950
 			notifications::errors(true);
1952 1951
 
1953
-			switch($button)
1952
+			switch ($button)
1954 1953
 			{
1955 1954
 				case 'reject':
1956 1955
 					if (!$event['id'])
1957 1956
 					{
1958 1957
 						// send reply to organizer
1959
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
1960
-						break;	// no need to store rejected event
1958
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
1959
+						break; // no need to store rejected event
1961 1960
 					}
1962 1961
 					// fall-through
1963 1962
 				case 'accept':
1964 1963
 				case 'tentativ':
1965
-					$status = strtoupper($button[0]);	// A, R or T
1964
+					$status = strtoupper($button[0]); // A, R or T
1966 1965
 					if (!$event['id'])
1967 1966
 					{
1968 1967
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
1969
-						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
1968
+						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner']))
1970 1969
 						{
1971 1970
 							// --> make organize a participant with role chair and current user the owner
1972 1971
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -1974,7 +1973,7 @@  discard block
 block discarded – undo
1974 1973
 							$event['owner'] = $this->user;
1975 1974
 						}
1976 1975
 						// store event without notifications!
1977
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
1976
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
1978 1977
 						{
1979 1978
 							$msg[] = lang('Event saved');
1980 1979
 						}
@@ -2012,7 +2011,7 @@  discard block
 block discarded – undo
2012 2011
 		Framework::message(implode("\n", (array)$msg));
2013 2012
 		$readonlys['button[edit]'] = !$event['id'];
2014 2013
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2015
-		switch(strtolower($ical_method))
2014
+		switch (strtolower($ical_method))
2016 2015
 		{
2017 2016
 			case 'reply':
2018 2017
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2036,37 +2035,37 @@  discard block
 block discarded – undo
2036 2035
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2037 2036
 	 * @param array $preserv data to preserv
2038 2037
 	 */
2039
-	function conflicts($event,$conflicts,$preserv)
2038
+	function conflicts($event, $conflicts, $preserv)
2040 2039
 	{
2041 2040
 		$etpl = new Etemplate('calendar.conflicts');
2042 2041
 		$allConflicts = array();
2043 2042
 
2044
-		foreach($conflicts as $k => $conflict)
2043
+		foreach ($conflicts as $k => $conflict)
2045 2044
 		{
2046
-			$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
2045
+			$is_readable = $this->bo->check_perms(Acl::READ, $conflict);
2047 2046
 
2048 2047
 			$conflicts[$k] += array(
2049 2048
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2050
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2051
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2052
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2053
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2054
-				),true,true)),	// show group invitations too
2049
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2050
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2051
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2052
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2053
+				), true, true)), // show group invitations too
2055 2054
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2056 2055
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2057 2056
 			);
2058
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2057
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2059 2058
 			}
2060 2059
 		$content = $event + array(
2061
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2060
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2062 2061
 		);
2063
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2062
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2064 2063
 		$resources_config = Api\Config::read('resources');
2065 2064
 		$readonlys = array();
2066 2065
 
2067 2066
 		foreach (array_keys($allConflicts) as $pId)
2068 2067
 		{
2069
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2068
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2070 2069
 			{
2071 2070
 
2072 2071
 				switch ($resources_config['ignoreconflicts'])
@@ -2086,7 +2085,7 @@  discard block
 block discarded – undo
2086 2085
 				}
2087 2086
 			}
2088 2087
 		}
2089
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2088
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2090 2089
 	}
2091 2090
 
2092 2091
 	/**
@@ -2104,7 +2103,7 @@  discard block
 block discarded – undo
2104 2103
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2105 2104
 
2106 2105
 		// convert start/end date-time values to timestamps
2107
-		foreach(array('start', 'end') as $name)
2106
+		foreach (array('start', 'end') as $name)
2108 2107
 		{
2109 2108
 			if (!empty($edit_content[$name]))
2110 2109
 			{
@@ -2134,7 +2133,7 @@  discard block
 block discarded – undo
2134 2133
 			'recur_type'   => $edit_content['recur_type'],
2135 2134
 			'participants' => array(),
2136 2135
 		);
2137
-		foreach($edit_content['participants'] as $key => $data)
2136
+		foreach ($edit_content['participants'] as $key => $data)
2138 2137
 		{
2139 2138
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2140 2139
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2149,21 +2148,21 @@  discard block
 block discarded – undo
2149 2148
 		// default search parameters
2150 2149
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2151 2150
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2152
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2151
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2153 2152
 		{
2154
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2153
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2155 2154
 		}
2156 2155
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2157 2156
 
2158 2157
 		$content['search_window'] = 7 * DAY_s;
2159 2158
 
2160 2159
 		// store content in session
2161
-		Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2160
+		Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2162 2161
 
2163 2162
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2164
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2163
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2165 2164
 
2166
-		$response->call('app.calendar.freetime_search_popup',$link);
2165
+		$response->call('app.calendar.freetime_search_popup', $link);
2167 2166
 
2168 2167
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2169 2168
 
@@ -2186,26 +2185,26 @@  discard block
 block discarded – undo
2186 2185
 	{
2187 2186
 		$etpl = new Etemplate('calendar.freetimesearch');
2188 2187
 		$sel_options['search_window'] = array(
2189
-			7*DAY_s		=> lang('one week'),
2190
-			14*DAY_s	=> lang('two weeks'),
2191
-			31*DAY_s	=> lang('one month'),
2192
-			92*DAY_s	=> lang('three month'),
2193
-			365*DAY_s	=> lang('one year'),
2188
+			7 * DAY_s		=> lang('one week'),
2189
+			14 * DAY_s	=> lang('two weeks'),
2190
+			31 * DAY_s	=> lang('one month'),
2191
+			92 * DAY_s	=> lang('three month'),
2192
+			365 * DAY_s	=> lang('one year'),
2194 2193
 		);
2195 2194
 		if (!is_array($content))
2196 2195
 		{
2197 2196
 			// get content from session (and delete it immediatly)
2198
-			$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2199
-			Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2197
+			$content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2198
+			Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2200 2199
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2201 2200
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2202 2201
 			$sTime = $content['start_time'];
2203 2202
 			$eTime = $content['end_time'];
2204
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2205
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2203
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2204
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2206 2205
 
2207 2206
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2208
-			foreach(array_keys($sel_options['search_window']) as $window)
2207
+			foreach (array_keys($sel_options['search_window']) as $window)
2209 2208
 			{
2210 2209
 				if ($window > $content['duration'])
2211 2210
 				{
@@ -2232,19 +2231,19 @@  discard block
 block discarded – undo
2232 2231
 		{
2233 2232
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2234 2233
 		}
2235
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2236
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2234
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2235
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2237 2236
 
2238
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2237
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2239 2238
 
2240 2239
 		$sel_options['duration'] = $this->durations;
2241 2240
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2242 2241
 
2243
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2242
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2244 2243
 				'participants'	=> $content['participants'],
2245 2244
 				'cal_id'		=> $content['cal_id'],
2246 2245
 				'recur_type'	=> $content['recur_type'],
2247
-			),2);
2246
+			), 2);
2248 2247
 	}
2249 2248
 
2250 2249
 	/**
@@ -2257,15 +2256,15 @@  discard block
 block discarded – undo
2257 2256
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2258 2257
 	 * @return array of free time-slots: array with start and end values
2259 2258
 	 */
2260
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2259
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2261 2260
 	{
2262
-		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);
2261
+		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);
2263 2262
 
2264 2263
 		$busy = $this->bo->search(array(
2265 2264
 			'start' => $start,
2266 2265
 			'end'	=> $end,
2267 2266
 			'users'	=> $participants,
2268
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2267
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2269 2268
 		));
2270 2269
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2271 2270
 			'start'	=> $end,
@@ -2274,15 +2273,15 @@  discard block
 block discarded – undo
2274 2273
 		$ft_start = $start;
2275 2274
 		$freetime = array();
2276 2275
 		$n = 0;
2277
-		foreach($busy as $event)
2276
+		foreach ($busy as $event)
2278 2277
 		{
2279
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2278
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2280 2279
 
2281 2280
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2282 2281
 
2283 2282
 			// check if from all wanted participants at least one has a not rejected status in found event
2284 2283
 			$non_rejected_found = false;
2285
-			foreach($participants as $uid)
2284
+			foreach ($participants as $uid)
2286 2285
 			{
2287 2286
 				if ($event['participants'][$uid] == 'R') continue;
2288 2287
 
@@ -2298,10 +2297,10 @@  discard block
 block discarded – undo
2298 2297
 
2299 2298
 			if ($this->debug)
2300 2299
 			{
2301
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2300
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2302 2301
 				echo "event[title]=$event[title]<br>\n";
2303
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2304
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2302
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2303
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2305 2304
 			}
2306 2305
 			// $events ends before our actual position ==> ignore it
2307 2306
 			if ($event['end'] < $ft_start)
@@ -2325,11 +2324,11 @@  discard block
 block discarded – undo
2325 2324
 					'start'	=> $ft_start,
2326 2325
 					'end'	=> $ft_end,
2327 2326
 				);
2328
-				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";
2327
+				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";
2329 2328
 			}
2330 2329
 			$ft_start = $event['end'];
2331 2330
 		}
2332
-		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);
2331
+		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);
2333 2332
 
2334 2333
 		return $freetime;
2335 2334
 	}
@@ -2349,46 +2348,46 @@  discard block
 block discarded – undo
2349 2348
 	 */
2350 2349
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2351 2350
 	{
2352
-		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);
2351
+		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);
2353 2352
 
2354 2353
 		$freetime_daywise = array();
2355 2354
 		if (!is_array($sel_options)) $sel_options = array();
2356 2355
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2357 2356
 
2358
-		$start_time = (int) $_start_time;	// ignore leading zeros
2359
-		$end_time   = (int) $_end_time;
2357
+		$start_time = (int)$_start_time; // ignore leading zeros
2358
+		$end_time   = (int)$_end_time;
2360 2359
 
2361 2360
 		// ignore the end_time, if duration would never fit
2362
-		if (($end_time - $start_time)*HOUR_s < $duration)
2361
+		if (($end_time - $start_time) * HOUR_s < $duration)
2363 2362
 		{
2364 2363
 			$end_time = 0;
2365
-			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);
2364
+			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);
2366 2365
 		}
2367 2366
 		$n = 0;
2368
-		foreach($freetime as $ft)
2367
+		foreach ($freetime as $ft)
2369 2368
 		{
2370 2369
 			$adaybegin = $this->bo->date2array($ft['start']);
2371 2370
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2372 2371
 			unset($adaybegin['raw']);
2373 2372
 			$daybegin = $this->bo->date2ts($adaybegin);
2374 2373
 
2375
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2374
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2376 2375
 			{
2377
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2378
-				$mcal_dow = pow(2,$dow);
2379
-				if (!($weekdays & $mcal_dow))
2376
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2377
+				$mcal_dow = pow(2, $dow);
2378
+				if (!($weekdays&$mcal_dow))
2380 2379
 				{
2381 2380
 					//echo "wrong day of week $dow<br>\n";
2382
-					continue;	// wrong day of week
2381
+					continue; // wrong day of week
2383 2382
 				}
2384 2383
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2385 2384
 
2386
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2385
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2387 2386
 				{
2388
-					$start = $daybegin + $start_time*HOUR_s;
2387
+					$start = $daybegin + $start_time * HOUR_s;
2389 2388
 				}
2390 2389
 				// if end_time given use it, else the original slot's end
2391
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2390
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2392 2391
 				if ($end > $ft['end']) $end = $ft['end'];
2393 2392
 
2394 2393
 				// slot to small for duration
@@ -2402,11 +2401,11 @@  discard block
 block discarded – undo
2402 2401
 					'end'	=> $end,
2403 2402
 				);
2404 2403
 				$times = array();
2405
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2404
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2406 2405
 				{
2407 2406
 					$e = $s + $duration;
2408
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2409
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2407
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2408
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2410 2409
 				}
2411 2410
 				$sel_options[$n.'start'] = $times;
2412 2411
 			}
@@ -2421,13 +2420,13 @@  discard block
 block discarded – undo
2421 2420
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422 2421
      * @return string error-msg if $return_error
2423 2422
      */
2424
-    function export($content=0,$return_error=false)
2423
+    function export($content = 0, $return_error = false)
2425 2424
     {
2426 2425
 		$boical = new calendar_ical();
2427 2426
 		#error_log(__METHOD__.print_r($content,true));
2428 2427
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2429 2428
 		{
2430
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2429
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2431 2430
 			{
2432 2431
 				$msg = lang('Permission denied');
2433 2432
 
@@ -2435,20 +2434,20 @@  discard block
 block discarded – undo
2435 2434
 			}
2436 2435
 			else
2437 2436
 			{
2438
-				html::content_header('event.ics','text/calendar',bytes($ical));
2437
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2439 2438
 				echo $ical;
2440 2439
 				common::egw_exit();
2441 2440
 			}
2442 2441
 		}
2443 2442
 		if (is_array($content))
2444 2443
 		{
2445
-			$events =& $this->bo->search(array(
2444
+			$events = & $this->bo->search(array(
2446 2445
 				'start' => $content['start'],
2447 2446
 				'end'   => $content['end'],
2448 2447
 				'enum_recuring' => false,
2449 2448
 				'daywise'       => false,
2450 2449
 				'owner'         => $this->owner,
2451
-				'date_format'   => 'server',    // timestamp in server time for boical class
2450
+				'date_format'   => 'server', // timestamp in server time for boical class
2452 2451
 			));
2453 2452
 			if (!$events)
2454 2453
 			{
@@ -2456,8 +2455,8 @@  discard block
 block discarded – undo
2456 2455
 			}
2457 2456
 			else
2458 2457
 			{
2459
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2460
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2458
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2459
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2461 2460
 				echo $ical;
2462 2461
 				common::egw_exit();
2463 2462
 			}
@@ -2473,9 +2472,9 @@  discard block
 block discarded – undo
2473 2472
 		}
2474 2473
 		$content['msg'] = $msg;
2475 2474
 
2476
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2475
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2477 2476
 		$etpl = new etemplate_new('calendar.export');
2478
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2477
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2479 2478
     }
2480 2479
 	
2481 2480
 	/**
@@ -2483,7 +2482,7 @@  discard block
 block discarded – undo
2483 2482
 	 *
2484 2483
 	 * @param array $_content
2485 2484
 	 */
2486
-	function cat_acl(array $_content=null)
2485
+	function cat_acl(array $_content = null)
2487 2486
 	{
2488 2487
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2489 2488
 		{
@@ -2495,15 +2494,15 @@  discard block
 block discarded – undo
2495 2494
 			unset($_content['button']);
2496 2495
 			if ($button != 'cancel')	// store changed Acl
2497 2496
 			{
2498
-				foreach($_content as $data)
2497
+				foreach ($_content as $data)
2499 2498
 				{
2500 2499
 					if (!($cat_id = $data['cat_id'])) continue;
2501
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2500
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2502 2501
 					{
2503 2502
 						$rights = 0;
2504
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2505
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2506
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2503
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2504
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2505
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2507 2506
 					}
2508 2507
 				}
2509 2508
 			}
@@ -2515,20 +2514,20 @@  discard block
 block discarded – undo
2515 2514
 				), 'admin');
2516 2515
 			}
2517 2516
 		}
2518
-		$content= $preserv = array();
2517
+		$content = $preserv = array();
2519 2518
 		$n = 1;
2520
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2519
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2521 2520
 		{
2522
-			$cat_id = substr($Lcat_id,1);
2521
+			$cat_id = substr($Lcat_id, 1);
2523 2522
 			$row = array(
2524 2523
 				'cat_id' => $cat_id,
2525 2524
 				'add' => array(),
2526 2525
 				'status' => array(),
2527 2526
 			);
2528
-			foreach($data as $account_id => $rights)
2527
+			foreach ($data as $account_id => $rights)
2529 2528
 			{
2530
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2531
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2529
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2530
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2532 2531
 			}
2533 2532
 			$content[$n] = $row;
2534 2533
 			$preserv[$n] = array(
@@ -2544,7 +2543,7 @@  discard block
 block discarded – undo
2544 2543
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2545 2544
 		$tmp = new Etemplate('calendar.cat_acl');
2546 2545
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2547
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2546
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2548 2547
 	}
2549 2548
 
2550 2549
 	/**
@@ -2594,18 +2593,18 @@  discard block
 block discarded – undo
2594 2593
 
2595 2594
 
2596 2595
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2597
-		if($content['recur_type'] || $content['recurrence'])
2596
+		if ($content['recur_type'] || $content['recurrence'])
2598 2597
 		{
2599 2598
 			$content['history']['filter'] = array(
2600 2599
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2601
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2602
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2600
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2601
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2603 2602
 			);
2604 2603
 		}
2605 2604
 
2606 2605
 		// Translate labels
2607 2606
 		$tracking = new calendar_tracking();
2608
-		foreach($tracking->field2label as $field => $label)
2607
+		foreach ($tracking->field2label as $field => $label)
2609 2608
 		{
2610 2609
 			$sel_options[$status][$field] = lang($label);
2611 2610
 		}
@@ -2624,44 +2623,44 @@  discard block
 block discarded – undo
2624 2623
 	 *	which particular instance was dragged
2625 2624
 	 * @return string XML response if no error occurs
2626 2625
 	 */
2627
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2626
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2628 2627
 	{
2629
-		list($eventId, $date) = explode(':', $_eventId,2);
2628
+		list($eventId, $date) = explode(':', $_eventId, 2);
2630 2629
 		$ignore_conflicts = false;
2631 2630
 
2632 2631
 		// we do not allow dragging into another users calendar ATM
2633
-		if($targetOwner < 0)
2632
+		if ($targetOwner < 0)
2634 2633
 		{
2635 2634
 			$targetOwner = array($targetOwner);
2636 2635
 		}
2637
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2636
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2638 2637
 		{
2639 2638
 			$targetOwner = $calendarOwner;
2640 2639
 		}
2641 2640
 		// But you may be viewing multiple users, or a group calendar and
2642 2641
 		// dragging your event - dragging across calendars does not change owner
2643
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2642
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2644 2643
 		{
2645 2644
 			$return = true;
2646
-			foreach($targetOwner as $owner)
2645
+			foreach ($targetOwner as $owner)
2647 2646
 			{
2648
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2647
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2649 2648
 				{
2650 2649
 					$return = false;
2651 2650
 					break;
2652 2651
 				}
2653
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2652
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2654 2653
 				{
2655 2654
 					$return = false;
2656 2655
 					break;
2657 2656
 				}
2658 2657
 			}
2659
-			if($return) return;
2658
+			if ($return) return;
2660 2659
 		}
2661
-		$old_event=$event=$this->bo->read($eventId);
2660
+		$old_event = $event = $this->bo->read($eventId);
2662 2661
 		if (!$durationT)
2663 2662
 		{
2664
-			$duration=$event['end']-$event['start'];
2663
+			$duration = $event['end'] - $event['start'];
2665 2664
 		}
2666 2665
 		else
2667 2666
 		{
@@ -2674,18 +2673,18 @@  discard block
 block discarded – undo
2674 2673
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2675 2674
 			if (!empty($event['whole_day']))
2676 2675
 			{
2677
-				$d =& $this->bo->so->startOfDay($d);
2676
+				$d = & $this->bo->so->startOfDay($d);
2678 2677
 				$d->setUser();
2679 2678
 			}
2680 2679
 			$event = $this->bo->read($eventId, $d, true);
2681 2680
 
2682 2681
 			// For DnD, create an exception if they gave the date
2683 2682
 			$preserv = null;
2684
-			$this->_create_exception($event,$preserv);
2683
+			$this->_create_exception($event, $preserv);
2685 2684
 			unset($event['id']);
2686 2685
 
2687 2686
 			$messages = null;
2688
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2687
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2689 2688
 			if (!is_array($conflicts) && $conflicts)
2690 2689
 			{
2691 2690
 				// now we need to add the original start as recur-execption to the series
@@ -2693,28 +2692,28 @@  discard block
 block discarded – undo
2693 2692
 				$recur_event['recur_exception'][] = $d->format('ts');
2694 2693
 				// check if we need to move the alarms, because they are next on that exception
2695 2694
 				$this->bo->check_move_alarms($recur_event, null, $d);
2696
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2697
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2698
-				$this->bo->update($recur_event,true);	// no conflict check here
2695
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2696
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2697
+				$this->bo->update($recur_event, true); // no conflict check here
2699 2698
 
2700 2699
 				// Sending null will trigger a removal of the original for that date
2701 2700
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2702 2701
 
2703 2702
 				unset($recur_event);
2704
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2703
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2705 2704
 				unset($preserv['edit_single']);
2706 2705
 			}
2707 2706
 		}
2708 2707
 
2709 2708
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2710 2709
 		$event['start'] = $d->format('ts');
2711
-		$event['end'] = $event['start']+$duration;
2710
+		$event['end'] = $event['start'] + $duration;
2712 2711
 
2713 2712
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2714 2713
 		{
2715 2714
 			// calculate offset against clicked recurrance,
2716 2715
 			// depending on which is smaller
2717
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2716
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2718 2717
 			$event['start'] = $old_event['start'] + $offset;
2719 2718
 			$event['duration'] = $duration;
2720 2719
 
@@ -2725,23 +2724,23 @@  discard block
 block discarded – undo
2725 2724
 			// Can't handle conflict.  Just ignore it.
2726 2725
 			$ignore_conflicts = true;
2727 2726
 		}
2728
-		if(!$event['recur_type'])
2727
+		if (!$event['recur_type'])
2729 2728
 		{
2730 2729
 			$this->bo->check_move_alarms($event, $old_event);
2731 2730
 		}
2732 2731
 
2733 2732
 		// Drag a whole day to a time
2734
-		if($durationT && $durationT != 'whole_day')
2733
+		if ($durationT && $durationT != 'whole_day')
2735 2734
 		{
2736 2735
 			$event['whole_day'] = ($duration == DAY_s);
2737 2736
 			$event['non_blocking'] = false;
2738 2737
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2739 2738
 			// so save the change now, and then let the conflict check happen.
2740 2739
 			$message = null;
2741
-			$this->bo->update($event,true, true, false, true, $message,true);
2740
+			$this->bo->update($event, true, true, false, true, $message, true);
2742 2741
 
2743 2742
 			// Whole day non blocking with DAY_s would add a day
2744
-			if($duration==DAY_s) $duration=0;
2743
+			if ($duration == DAY_s) $duration = 0;
2745 2744
 		}
2746 2745
 		// Drag a normal event to whole day non-blocking
2747 2746
 		else if ($durationT == 'whole_day')
@@ -2752,13 +2751,13 @@  discard block
 block discarded – undo
2752 2751
 
2753 2752
 		$status_reset_to_unknown = false;
2754 2753
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2755
-		foreach((array)$event['participants'] as $uid => $status)
2754
+		foreach ((array)$event['participants'] as $uid => $status)
2756 2755
 		{
2757 2756
 			$q = $r = null;
2758
-			calendar_so::split_status($status,$q,$r);
2757
+			calendar_so::split_status($status, $q, $r);
2759 2758
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2760 2759
 			{
2761
-				$preferences = CreateObject('phpgwapi.preferences',$uid);
2760
+				$preferences = CreateObject('phpgwapi.preferences', $uid);
2762 2761
 				$part_prefs = $preferences->read_repository();
2763 2762
 				switch ($part_prefs['calendar']['reset_stati'])
2764 2763
 				{
@@ -2768,23 +2767,23 @@  discard block
 block discarded – undo
2768 2767
 						if ($sameday) break;
2769 2768
 					default:
2770 2769
 						$status_reset_to_unknown = true;
2771
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2770
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2772 2771
 						// todo: report reset status to user
2773 2772
 				}
2774 2773
 			}
2775 2774
 		}
2776 2775
 
2777 2776
 		$message = false;
2778
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2777
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2779 2778
 
2780
-		$this->update_client($event['id'],$d);
2779
+		$this->update_client($event['id'], $d);
2781 2780
 		$response = Api\Json\Response::get();
2782
-		if(!is_array($conflicts) && $conflicts)
2781
+		if (!is_array($conflicts) && $conflicts)
2783 2782
 		{
2784
-			if(is_int($conflicts))
2783
+			if (is_int($conflicts))
2785 2784
 			{
2786 2785
 				$event['id'] = $conflicts;
2787
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2786
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2788 2787
 			}
2789 2788
 		}
2790 2789
 		else if ($conflicts)
@@ -2797,21 +2796,21 @@  discard block
 block discarded – undo
2797 2796
 					.'&end='.$event['end']
2798 2797
 					.'&non_interactive=true'
2799 2798
 					.'&cancel_needs_refresh=true',
2800
-				'',750,410);
2799
+				'', 750, 410);
2801 2800
 		}
2802 2801
 		else if ($message)
2803 2802
 		{
2804
-			$response->call('egw.message',  implode('<br />', $message));
2803
+			$response->call('egw.message', implode('<br />', $message));
2805 2804
 		}
2806
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2805
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2807 2806
 		if ($status_reset_to_unknown)
2808 2807
 		{
2809
-			foreach((array)$event['participants'] as $uid => $status)
2808
+			foreach ((array)$event['participants'] as $uid => $status)
2810 2809
 			{
2811 2810
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2812 2811
 				{
2813
-					calendar_so::split_status($status,$q,$r);
2814
-					$status = calendar_so::combine_status('U',$q,$r);
2812
+					calendar_so::split_status($status, $q, $r);
2813
+					$status = calendar_so::combine_status('U', $q, $r);
2815 2814
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2816 2815
 				}
2817 2816
 			}
@@ -2828,7 +2827,7 @@  discard block
 block discarded – undo
2828 2827
 	{
2829 2828
 		list($eventId, $date) = explode(':', $_eventId);
2830 2829
 		$event = $this->bo->read($eventId);
2831
-		if($date)
2830
+		if ($date)
2832 2831
 		{
2833 2832
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2834 2833
 		}
@@ -2838,29 +2837,29 @@  discard block
 block discarded – undo
2838 2837
 		{
2839 2838
 			if (!empty($event['whole_day']))
2840 2839
 			{
2841
-				$d =& $this->bo->so->startOfDay($date);
2840
+				$d = & $this->bo->so->startOfDay($date);
2842 2841
 				$d->setUser();
2843 2842
 			}
2844 2843
 			$event = $this->bo->read($eventId, $d, true);
2845 2844
 			$date = $d->format('ts');
2846 2845
 		}
2847
-		if($event['participants'][$uid])
2846
+		if ($event['participants'][$uid])
2848 2847
 		{
2849 2848
 			$q = $r = null;
2850
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2851
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2852
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2849
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2850
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2851
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2853 2852
 		}
2854 2853
 		else
2855 2854
 		{
2856 2855
 			// Group membership
2857
-			foreach($event['participants'] as $id => $status)
2856
+			foreach ($event['participants'] as $id => $status)
2858 2857
 			{
2859
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2858
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2860 2859
 				{
2861
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2862
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2863
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2860
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2861
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2862
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2864 2863
 					break;
2865 2864
 				}
2866 2865
 			}
@@ -2868,7 +2867,7 @@  discard block
 block discarded – undo
2868 2867
 
2869 2868
 		// Directly update stored data.  If event is still visible, it will
2870 2869
 		// be notified & update itself.
2871
-		$this->update_client($eventId,$d);
2870
+		$this->update_client($eventId, $d);
2872 2871
 	}
2873 2872
 
2874 2873
 	/**
@@ -2876,8 +2875,8 @@  discard block
 block discarded – undo
2876 2875
 	 */
2877 2876
 	public function ajax_delete($eventId)
2878 2877
 	{
2879
-		list($id, $date) = explode(':',$eventId);
2880
-		$event=$this->bo->read($id);
2878
+		list($id, $date) = explode(':', $eventId);
2879
+		$event = $this->bo->read($id);
2881 2880
 		$response = Api\Json\Response::get();
2882 2881
 
2883 2882
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2890,11 +2889,11 @@  discard block
 block discarded – undo
2890 2889
 			{
2891 2890
 				$msg = lang('Event deleted');
2892 2891
 			}
2893
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2892
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2894 2893
 		}
2895 2894
 		else
2896 2895
 		{
2897
-			$response->apply('egw.message', Array(lang('Error')),'error');
2896
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2898 2897
 		}
2899 2898
 	}
2900 2899
 
@@ -2907,27 +2906,27 @@  discard block
 block discarded – undo
2907 2906
 	 */
2908 2907
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
2909 2908
 	{
2910
-		list($eventId, $date) = explode(':', $_eventId,2);
2909
+		list($eventId, $date) = explode(':', $_eventId, 2);
2911 2910
 
2912
-		$old_event=$event=$this->bo->read($eventId);
2913
-		foreach($remove as $participant)
2911
+		$old_event = $event = $this->bo->read($eventId);
2912
+		foreach ($remove as $participant)
2914 2913
 		{
2915 2914
 			unset($event['participants'][$participant]);
2916 2915
 		}
2917
-		foreach($invite as $participant)
2916
+		foreach ($invite as $participant)
2918 2917
 		{
2919 2918
 			$event['participants'][$participant] = 'U';
2920 2919
 		}
2921
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
2920
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
2922 2921
 
2923
-		$this->update_client($event['id'],$d);
2922
+		$this->update_client($event['id'], $d);
2924 2923
 		$response = Api\Json\Response::get();
2925
-		if(!is_array($conflicts) && $conflicts)
2924
+		if (!is_array($conflicts) && $conflicts)
2926 2925
 		{
2927
-			if(is_int($conflicts))
2926
+			if (is_int($conflicts))
2928 2927
 			{
2929 2928
 				$event['id'] = $conflicts;
2930
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2929
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2931 2930
 			}
2932 2931
 		}
2933 2932
 		else if ($conflicts)
@@ -2940,11 +2939,11 @@  discard block
 block discarded – undo
2940 2939
 					.'&end='.$event['end']
2941 2940
 					.'&non_interactive=true'
2942 2941
 					.'&cancel_needs_refresh=true',
2943
-				'',750,410);
2942
+				'', 750, 410);
2944 2943
 		}
2945 2944
 		else if ($message)
2946 2945
 		{
2947
-			$response->call('egw.message',  implode('<br />', $message));
2946
+			$response->call('egw.message', implode('<br />', $message));
2948 2947
 		}
2949 2948
 	}
2950 2949
 
@@ -2954,13 +2953,13 @@  discard block
 block discarded – undo
2954 2953
 	 * @param array $mailContent = null mail content
2955 2954
 	 * @return  array
2956 2955
 	 */
2957
-	function mail_import(array $mailContent=null)
2956
+	function mail_import(array $mailContent = null)
2958 2957
 	{
2959 2958
 		// It would get called from compose as a popup with egw_data
2960 2959
 		if (!is_array($mailContent) && ($_GET['egw_data']))
2961 2960
 		{
2962 2961
 			// get raw mail data
2963
-			Link::get_data ($_GET['egw_data']);
2962
+			Link::get_data($_GET['egw_data']);
2964 2963
 			return false;
2965 2964
 		}
2966 2965
 
@@ -2970,7 +2969,7 @@  discard block
 block discarded – undo
2970 2969
 			$AB = new Api\Contacts();
2971 2970
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
2972 2971
 
2973
-			$participants[0] = array (
2972
+			$participants[0] = array(
2974 2973
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
2975 2974
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
2976 2975
 				'status' => 'A',
@@ -2978,23 +2977,23 @@  discard block
 block discarded – undo
2978 2977
 				'app' => 'User',
2979 2978
 				'role' => 'REQ-PARTICIPANT'
2980 2979
 			);
2981
-			foreach($mailContent['addresses'] as $address)
2980
+			foreach ($mailContent['addresses'] as $address)
2982 2981
 			{
2983 2982
 				// Get available contacts from the email
2984 2983
 				$contacts = $AB->search(array(
2985 2984
 						'email' => $address['email'],
2986 2985
 						'email_home' => $address['email']
2987
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
2986
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
2988 2987
 				if (is_array($contacts))
2989 2988
 				{
2990
-					foreach($contacts as $account)
2989
+					foreach ($contacts as $account)
2991 2990
 					{
2992 2991
 						$accounts[] = $account['account_id'];
2993 2992
 					}
2994 2993
 				}
2995 2994
 				else
2996 2995
 				{
2997
-					$participants []= array (
2996
+					$participants [] = array(
2998 2997
 						'app' => 'email',
2999 2998
 						'uid' => 'e'.$address['email'],
3000 2999
 						'status' => 'U',
@@ -3002,7 +3001,7 @@  discard block
 block discarded – undo
3002 3001
 					);
3003 3002
 				}
3004 3003
 			}
3005
-			$participants = array_merge($participants , array(
3004
+			$participants = array_merge($participants, array(
3006 3005
 				"participant" => $accounts,
3007 3006
 				"role" => "REQ-PARTICIPANT",
3008 3007
 				"add" => "pressed"
@@ -3026,14 +3025,14 @@  discard block
 block discarded – undo
3026 3025
 			{
3027 3026
 				foreach ($mailContent['attachments'] as $attachment)
3028 3027
 				{
3029
-					if($attachment['egw_data'])
3028
+					if ($attachment['egw_data'])
3030 3029
 					{
3031
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3030
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3032 3031
 					}
3033
-					else if(is_readable($attachment['tmp_name']) ||
3032
+					else if (is_readable($attachment['tmp_name']) ||
3034 3033
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3035 3034
 					{
3036
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3035
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3037 3036
 					}
3038 3037
 				}
3039 3038
 			}
Please login to merge, or discard this patch.
Braces   +288 added lines, -74 removed lines patch added patch discarded remove patch
@@ -110,11 +110,14 @@  discard block
 block discarded – undo
110 110
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
111 111
 			!$this->bo->check_perms(Acl::ADD,0,$owner))
112 112
 		{
113
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
113
+			if ($owner)
114
+			{
115
+				// make an owner who is no user or we have no add-rights a participant
114 116
 			{
115 117
 				if(!is_array($owner))
116 118
 				{
117 119
 					$owner = explode(',',$owner);
120
+			}
118 121
 				}
119 122
 				// if we come from ressources we don't need any users selected in calendar
120 123
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -150,9 +153,17 @@  discard block
 block discarded – undo
150 153
 		$participant_types['u'] = $participant_types = $participants = array();
151 154
 		foreach($extra_participants as $uid)
152 155
 		{
153
-			if (isset($participants[$uid])) continue;	// already included
156
+			if (isset($participants[$uid]))
157
+			{
158
+				continue;
159
+			}
160
+			// already included
154 161
 
155
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
162
+			if (!$this->bo->check_acl_invite($uid))
163
+			{
164
+				continue;
165
+			}
166
+			// no right to invite --> ignored
156 167
 
157 168
 			if (is_numeric($uid))
158 169
 			{
@@ -180,10 +191,13 @@  discard block
 block discarded – undo
180 191
 				}
181 192
 			}
182 193
 		}
183
-		if (!$participants)	// if all participants got removed, include current user
194
+		if (!$participants)
195
+		{
196
+			// if all participants got removed, include current user
184 197
 		{
185 198
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
186 199
 		}
200
+		}
187 201
 		if(isset($_GET['cat_id']))
188 202
 		{
189 203
 			$cat_id = explode(',',$_GET['cat_id']);
@@ -231,10 +245,13 @@  discard block
 block discarded – undo
231 245
 	 */
232 246
 	function process_edit($content)
233 247
 	{
234
-		if (!is_array($content))	// redirect from etemplate, if POST empty
248
+		if (!is_array($content))
249
+		{
250
+			// redirect from etemplate, if POST empty
235 251
 		{
236 252
 			return $this->edit(null,null,strip_tags($_GET['msg']));
237 253
 		}
254
+		}
238 255
 		// clear notification errors
239 256
 		notifications::errors(true);
240 257
 		$messages = null;
@@ -247,7 +264,11 @@  discard block
 block discarded – undo
247 264
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
248 265
 
249 266
 		list($button) = @each($content['button']);
250
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
267
+		if (!$button && $content['action'])
268
+		{
269
+			$button = $content['action'];
270
+		}
271
+		// action selectbox
251 272
 		unset($content['button']); unset($content['action']);
252 273
 
253 274
 		$view = $content['view'];
@@ -260,7 +281,10 @@  discard block
 block discarded – undo
260 281
 		{
261 282
 			list($date) = each($content['recur_exception']['delete_exception']);
262 283
 			// eT2 converts time to
263
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
284
+			if (!is_numeric($date))
285
+			{
286
+				$date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
287
+			}
264 288
 			unset($content['recur_exception']['delete_exception']);
265 289
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
266 290
 			{
@@ -269,7 +293,10 @@  discard block
 block discarded – undo
269 293
 				foreach ($recur_exceptions as $id)
270 294
 				{
271 295
 					if (!($exception = $this->bo->read($id)) ||
272
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
296
+							$exception['recurrence'] != $content['recur_exception'][$key])
297
+					{
298
+						continue;
299
+					}
273 300
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
274 301
 					$exception['reference'] = $exception['recurrence'] = 0;
275 302
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -344,7 +371,10 @@  discard block
 block discarded – undo
344 371
 				$event['end'] = $this->bo->date2ts($event['end']);
345 372
 			}
346 373
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
347
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
374
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
375
+			{
376
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
377
+			}
348 378
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
349 379
 			{
350 380
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -371,7 +401,8 @@  discard block
 block discarded – undo
371 401
 							break;
372 402
 						case 'participant':
373 403
 							foreach($data as $participant)
374
-							{								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
404
+							{
405
+// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
375 406
 								$email = array();
376 407
 								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
377 408
 								{
@@ -451,7 +482,11 @@  discard block
 block discarded – undo
451 482
 							break;
452 483
 
453 484
 						default:		// existing participant row
454
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
485
+							if (!is_array($data))
486
+							{
487
+								continue;
488
+							}
489
+							// widgets in participant tab, above participant list
455 490
 							foreach(array('uid','status','quantity','role') as $name)
456 491
 							{
457 492
 								$$name = $data[$name];
@@ -580,7 +615,10 @@  discard block
 block discarded – undo
580 615
 			{
581 616
 				foreach($participants as $id => &$p_response)
582 617
 				{
583
-					if($type == 'u' && $id == $event['owner']) continue;
618
+					if($type == 'u' && $id == $event['owner'])
619
+					{
620
+						continue;
621
+					}
584 622
 					calendar_so::split_status($p_response, $quantity, $role);
585 623
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586 624
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -662,17 +700,23 @@  discard block
 block discarded – undo
662 700
 			{
663 701
 				foreach (array_keys($event['participants']) as $uid)
664 702
 				{
665
-					if ($uid[0] == 'r') //ressource detection
703
+					if ($uid[0] == 'r')
704
+					{
705
+						//ressource detection
666 706
 					{
667 707
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
708
+					}
668 709
 						$button = '';
669 710
 						break 2; //break foreach and case
670 711
 					}
671 712
 				}
672 713
 			}
673
-			if ($content['edit_single'])	// we edited a single event from a series
714
+			if ($content['edit_single'])
715
+			{
716
+				// we edited a single event from a series
674 717
 			{
675 718
 				$event['reference'] = $event['id'];
719
+			}
676 720
 				$event['recurrence'] = $content['edit_single'];
677 721
 				unset($event['id']);
678 722
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -768,7 +812,10 @@  discard block
 block discarded – undo
768 812
 										case 'no':
769 813
 											break;
770 814
 										case 'startday':
771
-											if ($sameday) break;
815
+											if ($sameday)
816
+											{
817
+												break;
818
+											}
772 819
 										default:
773 820
 											$status_reset_to_unknown = true;
774 821
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -925,7 +972,10 @@  discard block
 block discarded – undo
925 972
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
926 973
 				{
927 974
 					$msg = lang('Series deleted');
928
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
975
+					if ($exceptions_kept)
976
+					{
977
+						$msg .= lang(', exceptions preserved');
978
+					}
929 979
 				}
930 980
 				else
931 981
 				{
@@ -961,11 +1011,14 @@  discard block
 block discarded – undo
961 1011
 				{
962 1012
 					$msg = lang("Can't add alarms in the past !!!");
963 1013
 				}
964
-				elseif ($event['id'])	// save the alarm immediatly
1014
+				elseif ($event['id'])
1015
+				{
1016
+					// save the alarm immediatly
965 1017
 				{
966 1018
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
967 1019
 					{
968 1020
 						$alarm['id'] = $alarm_id;
1021
+				}
969 1022
 						$event['alarm'][$alarm_id] = $alarm;
970 1023
 
971 1024
 						$msg = lang('Alarm added');
@@ -978,7 +1031,9 @@  discard block
 block discarded – undo
978 1031
 				}
979 1032
 				else
980 1033
 				{
981
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1034
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1035
+					{
1036
+}	// get a temporary non-conflicting, numeric id
982 1037
 					$event['alarm'][$alarm['id']] = $alarm;
983 1038
 				}
984 1039
 			}
@@ -1001,10 +1056,13 @@  discard block
 block discarded – undo
1001 1056
 		}
1002 1057
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1003 1058
 		{
1004
-			if ($content['lock_token'])	// remove an existing lock
1059
+			if ($content['lock_token'])
1060
+			{
1061
+				// remove an existing lock
1005 1062
 			{
1006 1063
 				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1007 1064
 			}
1065
+			}
1008 1066
 			if ($content['no_popup'])
1009 1067
 			{
1010 1068
 				Egw::redirect_link('/index.php',array(
@@ -1108,8 +1166,7 @@  discard block
 block discarded – undo
1108 1166
 		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1109 1167
 			// Adjust for requested date in the past
1110 1168
 			Api\DateTime::to($as_of_date,'ts') < time()
1111
-		)
1112
-		{
1169
+		) {
1113 1170
 
1114 1171
 			unset($orig_event);
1115 1172
 			// copy event by unsetting the id(s)
@@ -1197,32 +1254,50 @@  discard block
 block discarded – undo
1197 1254
 		foreach($event['participants'] as $uid => $status)
1198 1255
 		{
1199 1256
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1200
-			if (empty($status)) continue;
1257
+			if (empty($status))
1258
+			{
1259
+				continue;
1260
+			}
1201 1261
 			$toadd = '';
1202
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1262
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1263
+			{
1264
+				continue;
1265
+			}
1203 1266
 
1204 1267
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1205 1268
 			{
1206
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1269
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1270
+				{
1271
+					continue;
1272
+				}
1207 1273
 
1208 1274
 				$lid = $firstname = $lastname = null;
1209 1275
 				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1210 1276
 
1211 1277
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1212
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1278
+				if (!in_array($toadd,$to))
1279
+				{
1280
+					$to[] = $toadd;
1281
+				}
1213 1282
 				//error_log(__METHOD__.__LINE__.array2string($to));
1214 1283
 			}
1215 1284
 			elseif ($uid < 0)
1216 1285
 			{
1217 1286
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1218 1287
 				{
1219
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1288
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1289
+					{
1290
+						continue;
1291
+					}
1220 1292
 
1221 1293
 					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1222 1294
 
1223 1295
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1224 1296
 					// dont add groupmembers if they already rejected the event, or are the current user
1225
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1297
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1298
+					{
1299
+						$to[] = $toadd;
1300
+					}
1226 1301
 					//error_log(__METHOD__.__LINE__.array2string($to));
1227 1302
 				}
1228 1303
 			}
@@ -1275,7 +1350,10 @@  discard block
 block discarded – undo
1275 1350
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1276 1351
 			'preset[size]'    => filesize($ics_file),
1277 1352
 		);
1278
-		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.');
1353
+		if ($asrequest)
1354
+		{
1355
+			$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.');
1356
+		}
1279 1357
 		$response = Api\Json\Response::get();
1280 1358
 		$response->call('app.calendar.custom_mail', $vars);
1281 1359
 	}
@@ -1461,9 +1539,15 @@  discard block
 block discarded – undo
1461 1539
 				}
1462 1540
 			}
1463 1541
 			// set new start and end if given by $_GET
1464
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1465
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1466
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1542
+			if(isset($_GET['start']))
1543
+			{
1544
+$event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1545
+			if(isset($_GET['end']))
1546
+			{
1547
+$event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1548
+			if(isset($_GET['non_blocking']))
1549
+			{
1550
+$event['non_blocking'] = (bool)$_GET['non_blocking']; }
1467 1551
 			// check if the event is the whole day
1468 1552
 			$start = $this->bo->date2array($event['start']);
1469 1553
 			$end = $this->bo->date2array($event['end']);
@@ -1476,10 +1560,13 @@  discard block
 block discarded – undo
1476 1560
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1477 1561
 				{
1478 1562
 					$link_id = $link_ids[$n];
1479
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1563
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1564
+					{
1565
+						// guard against XSS
1480 1566
 					{
1481 1567
 						continue;
1482 1568
 					}
1569
+					}
1483 1570
 					if(!$n)
1484 1571
 					{
1485 1572
 						$event['title'] = Link::title($link_app,$link_id);
@@ -1488,7 +1575,10 @@  discard block
 block discarded – undo
1488 1575
 						{
1489 1576
 							foreach((array)$set['link_app'] as $i => $l_app)
1490 1577
 							{
1491
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1578
+								if (($l_id=$set['link_id'][$i]))
1579
+								{
1580
+									Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1581
+								}
1492 1582
 							}
1493 1583
 							unset($set['link_app']);
1494 1584
 							unset($set['link_id']);
@@ -1514,10 +1604,13 @@  discard block
 block discarded – undo
1514 1604
 			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1515 1605
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1516 1606
 
1517
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1607
+			if (($preserv['lock_token'] = $event['lock_token']))
1608
+			{
1609
+				// already locked --> refresh the lock
1518 1610
 			{
1519 1611
 				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1520 1612
 			}
1613
+			}
1521 1614
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1522 1615
 			{
1523 1616
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1550,14 +1643,20 @@  discard block
 block discarded – undo
1550 1643
 		));
1551 1644
 		Framework::message($msg, $msg_type);
1552 1645
 		$content['duration'] = $content['end'] - $content['start'];
1553
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1646
+		if (isset($this->durations[$content['duration']]))
1647
+		{
1648
+			$content['end'] = '';
1649
+		}
1554 1650
 
1555 1651
 		$row = 3;
1556 1652
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1557 1653
 		// preserve some ui elements, if set eg. under error-conditions
1558 1654
 		foreach(array('quantity','resource','role') as $n)
1559 1655
 		{
1560
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1656
+			if (isset($event['participants'][$n]))
1657
+			{
1658
+				$content['participants'][$n] = $event['participants'][$n];
1659
+			}
1561 1660
 		}
1562 1661
 		foreach($event['participant_types'] as $type => $participants)
1563 1662
 		{
@@ -1599,9 +1698,13 @@  discard block
 block discarded – undo
1599 1698
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1600 1699
 
1601 1700
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1602
-					$readonlys['participants'][$row]['status'] = $no_status;
1701
+				{
1702
+									$readonlys['participants'][$row]['status'] = $no_status;
1703
+				}
1603 1704
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1604
-					$readonlys['participants']['delete'][$uid] = true;
1705
+				{
1706
+									$readonlys['participants']['delete'][$uid] = true;
1707
+				}
1605 1708
 				// todo: make the participants available as links with email as title
1606 1709
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1607 1710
 				// enumerate group-invitations, so people can accept/reject them
@@ -1632,7 +1735,11 @@  discard block
 block discarded – undo
1632 1735
 			$content['participants']['cal_resources'] = '';
1633 1736
 			foreach($this->bo->resources as $data)
1634 1737
 			{
1635
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1738
+				if ($data['app'] == 'email')
1739
+				{
1740
+					continue;
1741
+				}
1742
+				// make no sense, as we cant search for email
1636 1743
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1637 1744
 			}
1638 1745
 		}
@@ -1660,9 +1767,18 @@  discard block
 block discarded – undo
1660 1767
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1661 1768
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1662 1769
 				$label = array();
1663
-				if ($days) $label[] = $days.' '.lang('days');
1664
-				if ($hours) $label[] = $hours.' '.lang('hours');
1665
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1770
+				if ($days)
1771
+				{
1772
+					$label[] = $days.' '.lang('days');
1773
+				}
1774
+				if ($hours)
1775
+				{
1776
+					$label[] = $hours.' '.lang('hours');
1777
+				}
1778
+				if ($minutes)
1779
+				{
1780
+					$label[] = $minutes.' '.lang('Minutes');
1781
+				}
1666 1782
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1667 1783
 				$content['alarm'][] = $alarm;
1668 1784
 
@@ -1725,25 +1841,34 @@  discard block
 block discarded – undo
1725 1841
 			'participants' => $this->accountsel->account_selection == 'none',
1726 1842
 			'history' => !$event['id'],
1727 1843
 		);
1728
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1844
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1845
+		{
1846
+			// no mail without mail-app
1729 1847
 		{
1730 1848
 			unset($sel_options['action']['mail']);
1849
+		}
1731 1850
 			unset($sel_options['action']['sendmeetingrequest']);
1732 1851
 		}
1733
-		if (!$event['id'])	// no ical export for new (not saved) events
1852
+		if (!$event['id'])
1853
+		{
1854
+			// no ical export for new (not saved) events
1734 1855
 		{
1735 1856
 			$readonlys['action'] = true;
1736 1857
 		}
1858
+		}
1737 1859
 		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'])))
1738 1860
 		{
1739 1861
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1740 1862
 		}
1741 1863
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1742 1864
 
1743
-		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
1865
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))
1866
+		{
1867
+			// new event or edit rights to the event ==> allow to add alarm for all users
1744 1868
 		{
1745 1869
 			$sel_options['owner'][0] = lang('All participants');
1746 1870
 		}
1871
+		}
1747 1872
 		if (isset($event['participant_types']['u'][$this->user]))
1748 1873
 		{
1749 1874
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1785,7 +1910,10 @@  discard block
 block discarded – undo
1785 1910
 
1786 1911
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1787 1912
 
1788
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1913
+		if (!empty($preserved['lock_token']))
1914
+		{
1915
+			$content['lock_token'] = $preserved['lock_token'];
1916
+		}
1789 1917
 
1790 1918
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1791 1919
 		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
@@ -1987,7 +2115,10 @@  discard block
 block discarded – undo
1987 2115
 					// set status and send notification / meeting response
1988 2116
 					if ($this->bo->set_status($event['id'], $user, $status))
1989 2117
 					{
1990
-						if (!$msg) $msg = lang('Status changed');
2118
+						if (!$msg)
2119
+						{
2120
+							$msg = lang('Status changed');
2121
+						}
1991 2122
 					}
1992 2123
 					break;
1993 2124
 
@@ -2066,13 +2197,16 @@  discard block
 block discarded – undo
2066 2197
 
2067 2198
 		foreach (array_keys($allConflicts) as $pId)
2068 2199
 		{
2069
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2200
+			if(substr($pId,0,1) == 'r' && $resources_config )
2201
+			{
2202
+				// resources Allow ignore conflicts
2070 2203
 			{
2071 2204
 
2072 2205
 				switch ($resources_config['ignoreconflicts'])
2073 2206
 				{
2074 2207
 					case 'no':
2075 2208
 						$readonlys['button[ignore]'] = true;
2209
+			}
2076 2210
 						break;
2077 2211
 					case 'allusers':
2078 2212
 						$readonlys['button[ignore]'] = false;
@@ -2216,7 +2350,10 @@  discard block
 block discarded – undo
2216 2350
 		}
2217 2351
 		else
2218 2352
 		{
2219
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2353
+			if (!$content['duration'])
2354
+			{
2355
+				$content['duration'] = $content['end'] - $content['start'];
2356
+			}
2220 2357
 			$weekds = 0;
2221 2358
 			foreach ($content['weekdays'] as &$wdays)
2222 2359
 			{
@@ -2238,7 +2375,10 @@  discard block
 block discarded – undo
2238 2375
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2239 2376
 
2240 2377
 		$sel_options['duration'] = $this->durations;
2241
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2378
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2379
+		{
2380
+			$content['end'] = '';
2381
+		}
2242 2382
 
2243 2383
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2244 2384
 				'participants'	=> $content['participants'],
@@ -2259,7 +2399,10 @@  discard block
 block discarded – undo
2259 2399
 	 */
2260 2400
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2261 2401
 	{
2262
-		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);
2402
+		if ($this->debug > 2)
2403
+		{
2404
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2405
+		}
2263 2406
 
2264 2407
 		$busy = $this->bo->search(array(
2265 2408
 			'start' => $start,
@@ -2276,15 +2419,26 @@  discard block
 block discarded – undo
2276 2419
 		$n = 0;
2277 2420
 		foreach($busy as $event)
2278 2421
 		{
2279
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2422
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2423
+			{
2424
+				continue;
2425
+			}
2426
+			// ignore our own event
2280 2427
 
2281
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2428
+ 			if ($event['non_blocking'])
2429
+ 			{
2430
+ 				continue;
2431
+ 			}
2432
+ 			// ignore non_blocking events
2282 2433
 
2283 2434
 			// check if from all wanted participants at least one has a not rejected status in found event
2284 2435
 			$non_rejected_found = false;
2285 2436
 			foreach($participants as $uid)
2286 2437
 			{
2287
-				if ($event['participants'][$uid] == 'R') continue;
2438
+				if ($event['participants'][$uid] == 'R')
2439
+				{
2440
+					continue;
2441
+				}
2288 2442
 
2289 2443
 				if (isset($event['participants'][$uid]) ||
2290 2444
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2294,7 +2448,10 @@  discard block
 block discarded – undo
2294 2448
 					break;
2295 2449
 				}
2296 2450
 			}
2297
-			if (!$non_rejected_found) continue;
2451
+			if (!$non_rejected_found)
2452
+			{
2453
+				continue;
2454
+			}
2298 2455
 
2299 2456
 			if ($this->debug)
2300 2457
 			{
@@ -2325,11 +2482,17 @@  discard block
 block discarded – undo
2325 2482
 					'start'	=> $ft_start,
2326 2483
 					'end'	=> $ft_end,
2327 2484
 				);
2328
-				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";
2485
+				if ($this->debug > 1)
2486
+				{
2487
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2488
+				}
2329 2489
 			}
2330 2490
 			$ft_start = $event['end'];
2331 2491
 		}
2332
-		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);
2492
+		if ($this->debug > 0)
2493
+		{
2494
+			$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);
2495
+		}
2333 2496
 
2334 2497
 		return $freetime;
2335 2498
 	}
@@ -2349,10 +2512,16 @@  discard block
 block discarded – undo
2349 2512
 	 */
2350 2513
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2351 2514
 	{
2352
-		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);
2515
+		if ($this->debug > 1)
2516
+		{
2517
+			$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);
2518
+		}
2353 2519
 
2354 2520
 		$freetime_daywise = array();
2355
-		if (!is_array($sel_options)) $sel_options = array();
2521
+		if (!is_array($sel_options))
2522
+		{
2523
+			$sel_options = array();
2524
+		}
2356 2525
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2357 2526
 
2358 2527
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2362,7 +2531,10 @@  discard block
 block discarded – undo
2362 2531
 		if (($end_time - $start_time)*HOUR_s < $duration)
2363 2532
 		{
2364 2533
 			$end_time = 0;
2365
-			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);
2534
+			if ($this->debug > 1)
2535
+			{
2536
+				$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);
2537
+			}
2366 2538
 		}
2367 2539
 		$n = 0;
2368 2540
 		foreach($freetime as $ft)
@@ -2383,13 +2555,19 @@  discard block
 block discarded – undo
2383 2555
 				}
2384 2556
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2385 2557
 
2386
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2558
+				if ($start-$daybegin < $start_time*HOUR_s)
2559
+				{
2560
+					// start earlier then start_time
2387 2561
 				{
2388 2562
 					$start = $daybegin + $start_time*HOUR_s;
2389 2563
 				}
2564
+				}
2390 2565
 				// if end_time given use it, else the original slot's end
2391 2566
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2392
-				if ($end > $ft['end']) $end = $ft['end'];
2567
+				if ($end > $ft['end'])
2568
+				{
2569
+					$end = $ft['end'];
2570
+				}
2393 2571
 
2394 2572
 				// slot to small for duration
2395 2573
 				if ($end - $start < $duration)
@@ -2431,7 +2609,10 @@  discard block
 block discarded – undo
2431 2609
 			{
2432 2610
 				$msg = lang('Permission denied');
2433 2611
 
2434
-				if ($return_error) return $msg;
2612
+				if ($return_error)
2613
+				{
2614
+					return $msg;
2615
+				}
2435 2616
 			}
2436 2617
 			else
2437 2618
 			{
@@ -2493,27 +2674,42 @@  discard block
 block discarded – undo
2493 2674
 		{
2494 2675
 			list($button) = each($_content['button']);
2495 2676
 			unset($_content['button']);
2496
-			if ($button != 'cancel')	// store changed Acl
2677
+			if ($button != 'cancel')
2678
+			{
2679
+				// store changed Acl
2497 2680
 			{
2498 2681
 				foreach($_content as $data)
2499 2682
 				{
2500 2683
 					if (!($cat_id = $data['cat_id'])) continue;
2684
+			}
2501 2685
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2502 2686
 					{
2503 2687
 						$rights = 0;
2504
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2505
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2506
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2688
+						if (in_array($account_id,(array)$data['add']))
2689
+						{
2690
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2691
+						}
2692
+						if (in_array($account_id,(array)$data['status']))
2693
+						{
2694
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2695
+						}
2696
+						if ($account_id)
2697
+						{
2698
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2699
+						}
2507 2700
 					}
2508 2701
 				}
2509 2702
 			}
2510
-			if ($button != 'apply')	// end dialog
2703
+			if ($button != 'apply')
2704
+			{
2705
+				// end dialog
2511 2706
 			{
2512 2707
 				Egw::redirect_link('/index.php', array(
2513 2708
 					'menuaction' => 'admin.admin_ui.index',
2514 2709
 					'ajax' => 'true'
2515 2710
 				), 'admin');
2516 2711
 			}
2712
+			}
2517 2713
 		}
2518 2714
 		$content= $preserv = array();
2519 2715
 		$n = 1;
@@ -2527,8 +2723,14 @@  discard block
 block discarded – undo
2527 2723
 			);
2528 2724
 			foreach($data as $account_id => $rights)
2529 2725
 			{
2530
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2531
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2726
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2727
+				{
2728
+					$row['add'][] = $account_id;
2729
+				}
2730
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2731
+				{
2732
+					$row['status'][] = $account_id;
2733
+				}
2532 2734
 			}
2533 2735
 			$content[$n] = $row;
2534 2736
 			$preserv[$n] = array(
@@ -2656,7 +2858,10 @@  discard block
 block discarded – undo
2656 2858
 					break;
2657 2859
 				}
2658 2860
 			}
2659
-			if($return) return;
2861
+			if($return)
2862
+			{
2863
+				return;
2864
+			}
2660 2865
 		}
2661 2866
 		$old_event=$event=$this->bo->read($eventId);
2662 2867
 		if (!$durationT)
@@ -2741,7 +2946,10 @@  discard block
 block discarded – undo
2741 2946
 			$this->bo->update($event,true, true, false, true, $message,true);
2742 2947
 
2743 2948
 			// Whole day non blocking with DAY_s would add a day
2744
-			if($duration==DAY_s) $duration=0;
2949
+			if($duration==DAY_s)
2950
+			{
2951
+				$duration=0;
2952
+			}
2745 2953
 		}
2746 2954
 		// Drag a normal event to whole day non-blocking
2747 2955
 		else if ($durationT == 'whole_day')
@@ -2765,7 +2973,10 @@  discard block
 block discarded – undo
2765 2973
 					case 'no':
2766 2974
 						break;
2767 2975
 					case 'startday':
2768
-						if ($sameday) break;
2976
+						if ($sameday)
2977
+						{
2978
+							break;
2979
+						}
2769 2980
 					default:
2770 2981
 						$status_reset_to_unknown = true;
2771 2982
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2803,7 +3014,10 @@  discard block
 block discarded – undo
2803 3014
 		{
2804 3015
 			$response->call('egw.message',  implode('<br />', $message));
2805 3016
 		}
2806
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
3017
+		if($event['id'] != $eventId )
3018
+		{
3019
+			$this->update_client($_eventId);
3020
+		}
2807 3021
 		if ($status_reset_to_unknown)
2808 3022
 		{
2809 3023
 			foreach((array)$event['participants'] as $uid => $status)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2890,11 +2890,11 @@
 block discarded – undo
2890 2890
 			{
2891 2891
 				$msg = lang('Event deleted');
2892 2892
 			}
2893
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2893
+			$response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete'));
2894 2894
 		}
2895 2895
 		else
2896 2896
 		{
2897
-			$response->apply('egw.message', Array(lang('Error')),'error');
2897
+			$response->apply('egw.message', array(lang('Error')),'error');
2898 2898
 		}
2899 2899
 	}
2900 2900
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_uilist.inc.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -539,8 +539,9 @@
 block discarded – undo
539 539
 	 * @param int &$success number of succeded actions
540 540
 	 * @param int &$failed number of failed actions (not enought permissions)
541 541
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 events 'deleted'
542
-	 * @param string/array $session_name 'calendar_list'
543
-	 * @return boolean true if all actions succeded, false otherwise
542
+	 * @param string $session_name 'calendar_list'
543
+	 * @param null|string $msg
544
+	 * @return null|boolean true if all actions succeded, false otherwise
544 545
 	 */
545 546
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
546 547
 	{
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @var mixed
41 41
 	 */
42
-	var $debug=false;
42
+	var $debug = false;
43 43
 	/**
44 44
 	 * Filternames
45 45
 	 *
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST
62 62
 	 */
63
-	function __construct($set_states=null)
63
+	function __construct($set_states = null)
64 64
 	{
65
-		parent::__construct(true,$set_states);	// call the parent's constructor
65
+		parent::__construct(true, $set_states); // call the parent's constructor
66 66
 
67
-		foreach($this->date_filters as $name => $label)
67
+		foreach ($this->date_filters as $name => $label)
68 68
 		{
69 69
 			$this->date_filters[$name] = lang($label);
70 70
 		}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * Show the listview
77 77
 	 */
78
-	function listview($_content=null,$msg='',$home=false)
78
+	function listview($_content = null, $msg = '', $home = false)
79 79
 	{
80 80
 		if ($_GET['msg']) $msg .= $_GET['msg'];
81 81
 		if ($this->group_warning) $msg .= $this->group_warning;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$etpl = new Etemplate('calendar.list');
84 84
 
85 85
 		// Handle merge from sidebox
86
-		if($_GET['merge'])
86
+		if ($_GET['merge'])
87 87
 		{
88 88
 			$_content['nm']['action'] = 'document_'.$_GET['merge'];
89 89
 			$_content['nm']['select_all'] = true;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		if (is_array($_content))
93 93
 		{
94 94
 			// handle a single button like actions
95
-			foreach(array('delete','timesheet','document') as $button)
95
+			foreach (array('delete', 'timesheet', 'document') as $button)
96 96
 			{
97 97
 				if ($_content['nm']['rows'][$button])
98 98
 				{
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			if ($_content['nm']['action'])
106 106
 			{
107 107
 				// Allow merge using the date range filter
108
-				if(strpos($_content['nm']['action'],'document') !== false &&
108
+				if (strpos($_content['nm']['action'], 'document') !== false &&
109 109
 					!count($_content['nm']['selected']) && !$_content['nm']['select_all']) {
110 110
 					$_content['nm']['selected'][] = $this->get_merge_range($_content['nm']);
111 111
 				}
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 				else
117 117
 				{
118 118
 					$success = $failed = $action_msg = null;
119
-					if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'],
120
-						$success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications']))
119
+					if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'],
120
+						$success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications']))
121 121
 					{
122
-						$msg .= lang('%1 event(s) %2',$success,$action_msg);
122
+						$msg .= lang('%1 event(s) %2', $success, $action_msg);
123 123
 					}
124
-					elseif(is_null($msg))
124
+					elseif (is_null($msg))
125 125
 					{
126
-						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
126
+						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
127 127
 					}
128 128
 				}
129 129
 			}
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 		{
136 136
 			$content['nm'] = array(
137 137
 				'get_rows'        =>	'calendar.calendar_uilist.get_rows',
138
-	 			'filter_no_lang'  => True,	// I  set no_lang for filter (=dont translate the options)
139
-				'no_filter2'      => True,	// I  disable the 2. filter (params are the same as for filter)
140
-				'no_cat'          => True,	// I  disable the cat-selectbox
138
+	 			'filter_no_lang'  => True, // I  set no_lang for filter (=dont translate the options)
139
+				'no_filter2'      => True, // I  disable the 2. filter (params are the same as for filter)
140
+				'no_cat'          => True, // I  disable the cat-selectbox
141 141
 				'filter'          => 'after',
142
-				'order'           => 'cal_start',// IO name of the column to sort after (optional for the sortheaders)
143
-				'sort'            => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
142
+				'order'           => 'cal_start', // IO name of the column to sort after (optional for the sortheaders)
143
+				'sort'            => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
144 144
 				'default_cols'    => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id',
145 145
 				'filter_onchange' => "app.calendar.filter_change",
146
-				'row_id'          => 'row_id',	// set in get rows "$event[id]:$event[recur_date]"
146
+				'row_id'          => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
147 147
 				'row_modified'    => 'modified',
148 148
 				'favorites'       => true,
149 149
 				'placeholder_actions' => array('add')
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		$content['nm']['actions'] = $this->get_actions();
153 153
 
154
-		if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters)))
154
+		if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters)))
155 155
 		{
156 156
 			$content['nm']['filter'] = $_GET['filter'];
157 157
 		}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			!empty($json_data['request']['parameters'][0]))
165 165
 		{
166 166
 			$params = null;
167
-			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
167
+			parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
168 168
 			if (isset($params['keywords']))	// new search => set filters so every match is shown
169 169
 			{
170 170
 				$this->adjust_for_search($params['keywords'], $content['nm']);
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
174 174
 		{
175
-			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
175
+			$this->adjust_for_search($_REQUEST['keywords'], $content['nm']);
176 176
 		}
177 177
 		$sel_options['filter'] = &$this->date_filters;
178 178
 
179 179
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
180 180
 		$sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar');
181 181
 		// Prevent double encoding - widget does this on its own, but we're just grabbing the options
182
-		foreach($sel_options['category'] as &$label)
182
+		foreach ($sel_options['category'] as &$label)
183 183
 		{
184
-			if(!is_array($label))
184
+			if (!is_array($label))
185 185
 			{
186
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
186
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
187 187
 			}
188
-			elseif($label['label'])
188
+			elseif ($label['label'])
189 189
 			{
190
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
190
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
191 191
 			}
192 192
 		}
193 193
 
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 		if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '')
196 196
 		{
197 197
 			$content['css'] .= '<style type="text/css">@media screen { .listDescription {  max-height: '.
198
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	   // dono why em is not real lines
198
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
199 199
 				'em; overflow: auto; }}</style>';
200 200
 		}
201 201
 
202
-		if($msg)
202
+		if ($msg)
203 203
 		{
204 204
 			Framework::message($msg);
205 205
 		}
206
-		$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0);
206
+		$html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0);
207 207
 
208 208
 		// Not sure why this has to be echoed instead of appended, but that's what works.
209 209
 		//echo calendar_uiviews::edit_series();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * set filter for search, so that everything is shown
216 216
 	 */
217
-	function adjust_for_search($keywords,&$params)
217
+	function adjust_for_search($keywords, &$params)
218 218
 	{
219 219
 		$params['search'] = $keywords;
220 220
 		$params['start']  = 0;
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 * @param array &$rows returned rows/events
241 241
 	 * @param array &$readonlys eg. to disable buttons based on Acl
242 242
 	 */
243
-	function get_rows(&$params,&$rows,&$readonlys)
243
+	function get_rows(&$params, &$rows, &$readonlys)
244 244
 	{
245
-		unset($readonlys);	// not used;
245
+		unset($readonlys); // not used;
246 246
 		//echo "uilist::get_rows() params="; _debug_array($params);
247 247
 		if ($params['filter'] == 'custom')
248 248
 		{
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 			}
272 272
 			if ($old_params['search'] != $params['search'])
273 273
 			{
274
-				$this->adjust_for_search($params['search'],$params);
274
+				$this->adjust_for_search($params['search'], $params);
275 275
 			}
276 276
 		}
277 277
 		if (!$params['csv_export']) Api\Cache::setSession('calendar', 'calendar_list', $params);
@@ -279,23 +279,23 @@  discard block
 block discarded – undo
279 279
 		// do we need to query custom fields and which
280 280
 		// Check stored preference if selectcols isn't available (ie: first call)
281 281
 		$select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows'];
282
-		if(!is_array($params['selectcols']))
282
+		if (!is_array($params['selectcols']))
283 283
 		{
284
-			$select_cols = explode(',',$select_cols);
284
+			$select_cols = explode(',', $select_cols);
285 285
 		}
286
-		if (in_array('cfs',$select_cols))
286
+		if (in_array('cfs', $select_cols))
287 287
 		{
288 288
 			$cfs = array();
289
-			foreach($select_cols as $col)
289
+			foreach ($select_cols as $col)
290 290
 			{
291
-				if ($col[0] == '#') $cfs[] = substr($col,1);
291
+				if ($col[0] == '#') $cfs[] = substr($col, 1);
292 292
 			}
293 293
 		}
294 294
 		$search_params = array(
295 295
 			'cat_id'  => $params['cat_id'] ? $params['cat_id'] : 0,
296 296
 			'filter'  => isset($params['filter']) ? $params['filter'] : $this->filter,
297 297
 			'query'   => $params['search'],
298
-			'offset'  => (int) $params['start'],
298
+			'offset'  => (int)$params['start'],
299 299
 			'num_rows'=> $params['num_rows'],
300 300
 			'order'   => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC',
301 301
 			'cfs'	 => $params['csv_export'] ? array() : $cfs,
@@ -303,24 +303,24 @@  discard block
 block discarded – undo
303 303
 		// Non-blocking events above blocking
304 304
 		$search_params['order'] .= ', cal_non_blocking DESC';
305 305
 
306
-		switch($params['filter'])
306
+		switch ($params['filter'])
307 307
 		{
308 308
 			case 'all':
309 309
 				break;
310 310
 			case 'before':
311
-				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date;
312
-				$label = lang('Before %1',$this->bo->long_date($search_params['end']));
311
+				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date;
312
+				$label = lang('Before %1', $this->bo->long_date($search_params['end']));
313 313
 				break;
314 314
 			case 'custom':
315
-				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts');
316
-				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
317
-				$label = $this->bo->long_date($this->first,$this->last);
315
+				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts');
316
+				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1;
317
+				$label = $this->bo->long_date($this->first, $this->last);
318 318
 				break;
319 319
 			case 'today':
320 320
 				$today = new Api\DateTime();
321 321
 				$today->setTime(0, 0, 0);
322 322
 				$this->first = $search_params['start'] = $today->format('ts');
323
-				$today->setTime(23,59,59);
323
+				$today->setTime(23, 59, 59);
324 324
 				$this->last  = $search_params['end'] = $today->format('ts');
325 325
 				break;
326 326
 			case 'week':
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
333 333
 				unset($this->last['raw']);
334 334
 				$this->last = $this->bo->date2ts($this->last);
335
-				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
335
+				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last);
336 336
 				$search_params['start'] = $this->first;
337 337
 				$search_params['end'] = $this->last;
338 338
 				$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				unset($this->first['raw']);
346 346
 				$this->last = $this->first;
347 347
 				$this->last['month'] += 1;
348
-				$this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year'];
348
+				$this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year'];
349 349
 				$this->first = $this->bo->date2ts($this->first);
350 350
 				$this->last = $this->bo->date2ts($this->last);
351 351
 				$this->last--;
@@ -358,29 +358,29 @@  discard block
 block discarded – undo
358 358
 				// fall through to after given date
359 359
 			case 'after':
360 360
 			default:
361
-				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date;
362
-				$label = lang('After %1',$this->bo->long_date($this->date));
361
+				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date;
362
+				$label = lang('After %1', $this->bo->long_date($this->date));
363 363
 				$search_params['start'] = $this->date;
364 364
 				break;
365 365
 		}
366
-		if($params['status_filter'])
366
+		if ($params['status_filter'])
367 367
 		{
368 368
 			$search_params['filter'] = $params['status_filter'];
369 369
 		}
370 370
 		if ($params['col_filter']['participant'])
371 371
 		{
372
-			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']);
372
+			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']);
373 373
 		}
374 374
 		elseif (!$params['col_filter'] || !$params['col_filter']['participant'])
375 375
 		{
376
-			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner);
376
+			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner);
377 377
 		}
378 378
 		if ($params['col_filter'])
379 379
 		{
380 380
 			$col_filter = array();
381
-			foreach($params['col_filter'] as $name => $val)
381
+			foreach ($params['col_filter'] as $name => $val)
382 382
 			{
383
-				if (!in_array($name, array('participant','row_id')) && (string)$val !== '')
383
+				if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '')
384 384
 				{
385 385
 					$col_filter[$name] = $val;
386 386
 				}
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 
391 391
 		// App header is mostly taken care of on the client side, but here we update
392 392
 		// it to match changing list filters
393
-		if($params['view'] && $params['view'] == 'listview')
393
+		if ($params['view'] && $params['view'] == 'listview')
394 394
 		{
395 395
 			Api\Json\Response::get()->call('app.calendar.set_app_header',
396
-				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') .
396
+				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '').
397 397
 				$label);
398 398
 		}
399
-		error_log(__METHOD__ . ' ' .array2string($search_params));
400
-		foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
399
+		error_log(__METHOD__.' '.array2string($search_params));
400
+		foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
401 401
 		{
402 402
 
403 403
 			if ($params['csv_export'])
404 404
 			{
405
-				$event['participants'] = implode(",\n",$this->bo->participants($event,true));
405
+				$event['participants'] = implode(",\n", $this->bo->participants($event, true));
406 406
 			}
407 407
 			else
408 408
 			{
@@ -410,23 +410,23 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 
412 412
 			$matches = null;
413
-			if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
413
+			if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
414 414
 			{
415 415
 				$app = $matches[1];
416 416
 				$app_id = $matches[2];
417 417
 				$icons = array();
418
-				if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
418
+				if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
419 419
 				{
420
-					$icons[] = Api\Html::image('calendar','private');
420
+					$icons[] = Api\Html::image('calendar', 'private');
421 421
 				}
422 422
 				else
423 423
 				{
424
-					$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
424
+					$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
425 425
 				}
426 426
 			}
427 427
 			else
428 428
 			{
429
-				$is_private = !$this->bo->check_perms(Acl::READ,$event);
429
+				$is_private = !$this->bo->check_perms(Acl::READ, $event);
430 430
 			}
431 431
 			if ($is_private)
432 432
 			{
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 			$event['app_id'] = $event['id'];
438 438
 
439 439
 			// Edit link
440
-			if($app && $app_id)
440
+			if ($app && $app_id)
441 441
 			{
442
-				$popup = calendar_uiviews::integration_get_popup($app,$app_id);
442
+				$popup = calendar_uiviews::integration_get_popup($app, $app_id);
443 443
 
444 444
 				// Need to strip off 'onclick'
445 445
 				$event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup);
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 				// populate js_integration_data, if not already set
451 451
 				if (!isset($js_integration_data[$app]))
452 452
 				{
453
-					$js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link');
453
+					$js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link');
454 454
 				}
455 455
 			}
456 456
 			elseif ($event['recur_type'] != MCAL_RECUR_NONE)
457 457
 			{
458
-				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
458
+				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
459 459
 			}
460 460
 
461 461
 			// Format start and end with timezone
462
-			foreach(array('start','end') as $time)
462
+			foreach (array('start', 'end') as $time)
463 463
 			{
464
-				$event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z');
464
+				$event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z');
465 465
 			}
466 466
 
467 467
 			$rows[] = $event;
@@ -471,35 +471,35 @@  discard block
 block discarded – undo
471 471
 		// set js_calendar_integration object, to use it in app.js cal_open() function
472 472
 		$params['js_integration_data'] = json_encode($js_integration_data);
473 473
 
474
-		$wv=0;
475
-		$dv=0;
474
+		$wv = 0;
475
+		$dv = 0;
476 476
 
477 477
 		// Add in some select options
478
-		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']);
478
+		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']);
479 479
 
480 480
 		$this->bo->warnings['groupmembers'] = '';
481
-		if(($message = $this->check_owners_access($users)))
481
+		if (($message = $this->check_owners_access($users)))
482 482
 		{
483 483
 			Api\Json\Response::get()->error($message);
484 484
 		}
485
-		else if($this->bo->warnings['groupmembers'])
485
+		else if ($this->bo->warnings['groupmembers'])
486 486
 		{
487 487
 			Api\Json\Response::get()->error($this->bo->warnings['groupmembers']);
488 488
 		}
489 489
 		$rows['sel_options']['filter'] = $this->date_filters;
490
-		if($label)
490
+		if ($label)
491 491
 		{
492 492
 			$rows['sel_options']['filter'][$params['filter']] = $label;
493 493
 		}
494
-		foreach($users as $owner)
494
+		foreach ($users as $owner)
495 495
 		{
496
-			if(!is_int($owner) && $this->bo->resources[$owner[0]])
496
+			if (!is_int($owner) && $this->bo->resources[$owner[0]])
497 497
 			{
498 498
 				$app = $this->bo->resources[$owner[0]]['app'];
499
-				$_owner = substr($owner,1);
499
+				$_owner = substr($owner, 1);
500 500
 				// Try link first
501
-				$title = Link::title($app, $_owner );
502
-				if($title)
501
+				$title = Link::title($app, $_owner);
502
+				if ($title)
503 503
 				{
504 504
 					$rows['sel_options']['owner'][$owner] = $title;
505 505
 				}
@@ -507,15 +507,15 @@  discard block
 block discarded – undo
507 507
 		}
508 508
 		$params['options-selectcols']['week'] = lang('Week');
509 509
 		$params['options-selectcols']['weekday'] = lang('Weekday');
510
-		if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,')
510
+		if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,')
511 511
 		{
512
-			$rows['format'] = '32';	// prefix date with week-number
513
-			$wv=1;
512
+			$rows['format'] = '32'; // prefix date with week-number
513
+			$wv = 1;
514 514
 		}
515
-		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE))
515
+		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE))
516 516
 		{
517 517
 			$rows['format'] = '16';
518
-			$dv=1;
518
+			$dv = 1;
519 519
 		}
520 520
 		if ($wv && $dv)
521 521
 		{
@@ -542,36 +542,36 @@  discard block
 block discarded – undo
542 542
 	 * @param string/array $session_name 'calendar_list'
543 543
 	 * @return boolean true if all actions succeded, false otherwise
544 544
 	 */
545
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
545
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false)
546 546
 	{
547 547
 		//error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
548 548
 		$success = $failed = 0;
549 549
 		$msg = null;
550 550
 
551 551
 		// Split out combined values
552
-		if(strpos($action, 'status') !== false)
552
+		if (strpos($action, 'status') !== false)
553 553
 		{
554 554
 			list($action, $status) = explode('-', $action);
555 555
 		}
556 556
 		elseif (strpos($action, '_') !== false)
557 557
 		{
558
-			list($action, $settings) = explode('_', $action,2);
558
+			list($action, $settings) = explode('_', $action, 2);
559 559
 		}
560 560
 
561 561
 		if ($use_all)
562 562
 		{
563 563
 			// get the whole selection
564 564
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
565
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
566
-			$query['num_rows'] = -1;		// all
565
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
566
+			$query['num_rows'] = -1; // all
567 567
 			$readonlys = null;
568
-			$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document')));	   // true = only return the id's
568
+			$this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's
569 569
 			// Get rid of any extras (rows that aren't events)
570
-			if(in_array($action,array('ical','document')))
570
+			if (in_array($action, array('ical', 'document')))
571 571
 			{
572
-				foreach($checked as $key => $event)
572
+				foreach ($checked as $key => $event)
573 573
 				{
574
-					if(!is_numeric($key))
574
+					if (!is_numeric($key))
575 575
 					{
576 576
 						unset($checked[$key]);
577 577
 					}
@@ -579,27 +579,27 @@  discard block
 block discarded – undo
579 579
 			}
580 580
 		}
581 581
 		// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
582
-		elseif($action == 'document')
582
+		elseif ($action == 'document')
583 583
 		{
584 584
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
585
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
585
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
586 586
 			$events = null;
587
-			$this->get_rows($query,$events,$readonlys);
588
-			foreach($events as $key => $event)
587
+			$this->get_rows($query, $events, $readonlys);
588
+			foreach ($events as $key => $event)
589 589
 			{
590
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
590
+				if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
591 591
 			}
592 592
 			$checked = array_values($events); // Clear keys
593 593
 		}
594 594
 
595 595
 		// Actions where one action is done to the group
596
-		switch($action)
596
+		switch ($action)
597 597
 		{
598 598
 			case 'ical':
599 599
 				// compile list of unique cal_id's, as iCal should contain whole series, not recurrences
600 600
 				// calendar_ical->exportVCal needs to read events again, to get them in server-time
601 601
 				$ids = array();
602
-				foreach($checked as $id)
602
+				foreach ($checked as $id)
603 603
 				{
604 604
 					if (is_array($id)) $id = $id['id'];
605 605
 					// get rid of recurrences, doublicate series and calendar-integration events
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 					}
610 610
 				}
611 611
 				$boical = new calendar_ical();
612
-				$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
612
+				$ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH');
613 613
 				Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical));
614 614
 				echo $ical;
615 615
 				exit();
@@ -624,19 +624,19 @@  discard block
 block discarded – undo
624 624
 		}
625 625
 
626 626
 		// Actions where the action is applied to each entry
627
-		if(strpos($action, 'timesheet') !== false)
627
+		if (strpos($action, 'timesheet') !== false)
628 628
 		{
629 629
 			$timesheet_bo = new timesheet_bo();
630 630
 		}
631
-		foreach($checked as &$id)
631
+		foreach ($checked as &$id)
632 632
 		{
633 633
 			$recur_date = $app = $app_id = null;
634
-			if(is_array($id) && $id['id'])
634
+			if (is_array($id) && $id['id'])
635 635
 			{
636 636
 				$id = $id['id'];
637 637
 			}
638 638
 			$matches = null;
639
-			if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
639
+			if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches))
640 640
 			{
641 641
 				$app = $matches[1];
642 642
 				$app_id = $matches[2];
@@ -644,36 +644,36 @@  discard block
 block discarded – undo
644 644
 			}
645 645
 			else
646 646
 			{
647
-				list($id,$recur_date) = explode(':',$id);
647
+				list($id, $recur_date) = explode(':', $id);
648 648
 			}
649
-			switch($action)
649
+			switch ($action)
650 650
 			{
651 651
 				case 'delete':
652 652
 					$action_msg = lang('deleted');
653
-					if($settings == 'series')
653
+					if ($settings == 'series')
654 654
 					{
655 655
 						// Delete the whole thing
656 656
 						$recur_date = 0;
657 657
 					}
658
-					if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
658
+					if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification))
659 659
 					{
660 660
 						$success++;
661
-						if(!$recur_date && $settings == 'series')
661
+						if (!$recur_date && $settings == 'series')
662 662
 						{
663 663
 							// If there are multiple events in a series selected, the next one could purge
664
-							foreach($checked as $key => $c_id)
664
+							foreach ($checked as $key => $c_id)
665 665
 							{
666
-								list($c_id,$recur_date) = explode(':',$c_id);
667
-								if($c_id == $id)
666
+								list($c_id, $recur_date) = explode(':', $c_id);
667
+								if ($c_id == $id)
668 668
 								{
669 669
 									unset($checked[$key]);
670 670
 								}
671 671
 							}
672 672
 						}
673 673
 
674
-						if(Api\Json\Response::isJSONResponse())
674
+						if (Api\Json\Response::isJSONResponse())
675 675
 						{
676
-							Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete');
676
+							Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete');
677 677
 						}
678 678
 					}
679 679
 					else
@@ -683,23 +683,23 @@  discard block
 block discarded – undo
683 683
 					break;
684 684
 				case 'undelete':
685 685
 					$action_msg = lang('recovered');
686
-					if($settings == 'series')
686
+					if ($settings == 'series')
687 687
 					{
688 688
 						// unDelete the whole thing
689 689
 						$recur_date = 0;
690 690
 					}
691
-					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) &&
691
+					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) &&
692 692
 						is_array($event) && $event['deleted'])
693 693
 					{
694 694
 						$event['deleted'] = null;
695
-						if($this->bo->save($event))
695
+						if ($this->bo->save($event))
696 696
 						{
697 697
 							$success++;
698 698
 
699
-							if(Api\Json\Response::isJSONResponse())
699
+							if (Api\Json\Response::isJSONResponse())
700 700
 							{
701
-								Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
702
-								Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
701
+								Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
702
+								Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit');
703 703
 							}
704 704
 							break;
705 705
 						}
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 					break;
709 709
 				case 'status':
710 710
 					$action_msg = lang('Status changed');
711
-					if($id && ($event = $this->bo->read($id, $recur_date)))
711
+					if ($id && ($event = $this->bo->read($id, $recur_date)))
712 712
 					{
713 713
 						$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
714 714
 						$quantity = $role = null;
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
 						{
718 718
 							//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
719 719
 							$new_status = calendar_so::combine_status($status, $quantity, $role);
720
-							if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
721
-								false,true,$skip_notification))
720
+							if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date,
721
+								false, true, $skip_notification))
722 722
 							{
723
-								if(Api\Json\Response::isJSONResponse())
723
+								if (Api\Json\Response::isJSONResponse())
724 724
 								{
725
-									Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
725
+									Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
726 726
 								}
727 727
 								$success++;
728 728
 								//$msg = lang('Status changed');
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 					}
740 740
 					break;
741 741
 				case 'timesheet-add':
742
-					if($id && !$app)
742
+					if ($id && !$app)
743 743
 					{
744 744
 						$event = $this->bo->read($id, $recur_date);
745 745
 					}
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 						$result = $this->bo->search($query);
752 752
 						$event = $result[$app.$app_id];
753 753
 					}
754
-					if(!$event)
754
+					if (!$event)
755 755
 					{
756 756
 						$failed++;
757 757
 						continue;
@@ -768,16 +768,16 @@  discard block
 block discarded – undo
768 768
 					);
769 769
 
770 770
 					// Add global categories
771
-					$categories = explode(',',$event['category']);
771
+					$categories = explode(',', $event['category']);
772 772
 					$global_categories = array();
773
-					foreach($categories as $cat_id)
773
+					foreach ($categories as $cat_id)
774 774
 					{
775
-						if($GLOBALS['egw']->categories->is_global($cat_id))
775
+						if ($GLOBALS['egw']->categories->is_global($cat_id))
776 776
 						{
777 777
 							$global_categories[] = $cat_id;
778 778
 						}
779 779
 					}
780
-					if(count($global_categories))
780
+					if (count($global_categories))
781 781
 					{
782 782
 						$timesheet['cat_id'] = implode(',', $global_categories);
783 783
 					}
@@ -797,12 +797,12 @@  discard block
 block discarded – undo
797 797
 						}
798 798
 					}
799 799
 
800
-					if(!$err)
800
+					if (!$err)
801 801
 					{
802 802
 						$success++;
803 803
 
804 804
 						// Can't link to just one of a recurring series of events
805
-						if(!$recur_date || $app) {
805
+						if (!$recur_date || $app) {
806 806
 							// Create link
807 807
 							$link_id = $app ? $app_id : $id;
808 808
 							Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	protected function get_merge_range($nm)
831 831
 	{
832 832
 		$checked = array();
833
-		if($nm['filter'] == 'fixed')
833
+		if ($nm['filter'] == 'fixed')
834 834
 		{
835 835
 			$checked['start'] = $nm['startdate'];
836 836
 			$last = $this->bo->date2array($nm['enddate']);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 		}
840 840
 		else
841 841
 		{
842
-			switch($nm['filter'])
842
+			switch ($nm['filter'])
843 843
 			{
844 844
 				case 'after':
845 845
 					$checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today');
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 					$checked['end'] = $nm['enddate'];
853 853
 					break;
854 854
 				default:
855
-					$date = date_create_from_format('Ymd',$this->date);
856
-					$checked['start']= $date->format('U');
855
+					$date = date_create_from_format('Ymd', $this->date);
856
+					$checked['start'] = $date->format('U');
857 857
 			}
858 858
 		}
859 859
 		return $checked;
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 				'allowOnMultiple' => false,
879 879
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
880 880
 				'popup' => Link::get_registry('calendar', 'view_popup'),
881
-				'group' => $group=1,
881
+				'group' => $group = 1,
882 882
 				'onExecute' => 'javaScript:app.calendar.cal_open',
883 883
 				'disableClass' => 'rowNoView',
884 884
 			),
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 				'group' => $group,
904 904
 			),
905 905
 		);
906
-		$status = array_map('lang',$this->bo->verbose_status);
906
+		$status = array_map('lang', $this->bo->verbose_status);
907 907
 		unset($status['G']);
908 908
 		$actions['status'] = array(
909 909
 			'caption' => 'Change your status',
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 			'children' => $status,
913 913
 			'group' => ++$group,
914 914
 		);
915
-		++$group;	// integration with other apps: infolog, calendar, filemanager
915
+		++$group; // integration with other apps: infolog, calendar, filemanager
916 916
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
917 917
 		{
918 918
 			$actions['filemanager'] = array(
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id',
945 945
 				'group' => $group,
946 946
 				'allowOnMultiple' => false,
947
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
947
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
948 948
 				'onExecute' => 'javaScript:app.calendar.cal_fix_app_id',
949 949
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
950 950
 			);
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 				'caption' => 'Timesheet',
954 954
 				'group' => $group,
955 955
 				'allowOnMultiple' => 'only',
956
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
956
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
957 957
 			);
958 958
 		}
959 959
 		$actions['ical'] = array(
@@ -962,11 +962,11 @@  discard block
 block discarded – undo
962 962
 			'group' => ++$group,
963 963
 			'hint' => 'Download this event as iCal',
964 964
 			'disableClass' => 'rowNoView',
965
-			'postSubmit' => true,	// download needs post submit (not Ajax) to work
965
+			'postSubmit' => true, // download needs post submit (not Ajax) to work
966 966
 		);
967 967
 		$actions['documents'] = calendar_merge::document_action(
968 968
 			$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
969
-			$this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar')
969
+			$this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar')
970 970
 		);
971 971
 		++$group;
972 972
 		$actions['delete'] = array(
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 			'disableClass' => 'rowNoDelete',
977 977
 		);
978 978
 		// Add in deleted for admins
979
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
979
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
980 980
 		{
981 981
 			$actions['undelete'] = array(
982 982
 				'caption' => 'Un-delete',
Please login to merge, or discard this patch.
Braces   +48 added lines, -13 removed lines patch added patch discarded remove patch
@@ -77,8 +77,14 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	function listview($_content=null,$msg='',$home=false)
79 79
 	{
80
-		if ($_GET['msg']) $msg .= $_GET['msg'];
81
-		if ($this->group_warning) $msg .= $this->group_warning;
80
+		if ($_GET['msg'])
81
+		{
82
+			$msg .= $_GET['msg'];
83
+		}
84
+		if ($this->group_warning)
85
+		{
86
+			$msg .= $this->group_warning;
87
+		}
82 88
 
83 89
 		$etpl = new Etemplate('calendar.list');
84 90
 
@@ -106,7 +112,8 @@  discard block
 block discarded – undo
106 112
 			{
107 113
 				// Allow merge using the date range filter
108 114
 				if(strpos($_content['nm']['action'],'document') !== false &&
109
-					!count($_content['nm']['selected']) && !$_content['nm']['select_all']) {
115
+					!count($_content['nm']['selected']) && !$_content['nm']['select_all'])
116
+				{
110 117
 					$_content['nm']['selected'][] = $this->get_merge_range($_content['nm']);
111 118
 				}
112 119
 				if (!count($_content['nm']['selected']) && !$_content['nm']['select_all'])
@@ -165,15 +172,21 @@  discard block
 block discarded – undo
165 172
 		{
166 173
 			$params = null;
167 174
 			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
168
-			if (isset($params['keywords']))	// new search => set filters so every match is shown
175
+			if (isset($params['keywords']))
176
+			{
177
+				// new search => set filters so every match is shown
169 178
 			{
170 179
 				$this->adjust_for_search($params['keywords'], $content['nm']);
171 180
 			}
181
+			}
172 182
 		}
173
-		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
183
+		if (isset($_REQUEST['keywords']))
184
+		{
185
+			// new search => set filters so every match is shown
174 186
 		{
175 187
 			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
176 188
 		}
189
+		}
177 190
 		$sel_options['filter'] = &$this->date_filters;
178 191
 
179 192
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
@@ -264,9 +277,12 @@  discard block
 block discarded – undo
264 277
 		$old_params = Api\Cache::getSession('calendar', 'calendar_list');
265 278
 		if (is_array($old_params))
266 279
 		{
267
-			if ($old_params['filter'] && $old_params['filter'] != $params['filter'])	// filter changed => order accordingly
280
+			if ($old_params['filter'] && $old_params['filter'] != $params['filter'])
281
+			{
282
+				// filter changed => order accordingly
268 283
 			{
269 284
 				$params['order'] = 'cal_start';
285
+			}
270 286
 				$params['sort'] = $params['filter'] == 'before' ? 'DESC' : 'ASC';
271 287
 			}
272 288
 			if ($old_params['search'] != $params['search'])
@@ -274,7 +290,10 @@  discard block
 block discarded – undo
274 290
 				$this->adjust_for_search($params['search'],$params);
275 291
 			}
276 292
 		}
277
-		if (!$params['csv_export']) Api\Cache::setSession('calendar', 'calendar_list', $params);
293
+		if (!$params['csv_export'])
294
+		{
295
+			Api\Cache::setSession('calendar', 'calendar_list', $params);
296
+		}
278 297
 
279 298
 		// do we need to query custom fields and which
280 299
 		// Check stored preference if selectcols isn't available (ie: first call)
@@ -288,7 +307,10 @@  discard block
 block discarded – undo
288 307
 			$cfs = array();
289 308
 			foreach($select_cols as $col)
290 309
 			{
291
-				if ($col[0] == '#') $cfs[] = substr($col,1);
310
+				if ($col[0] == '#')
311
+				{
312
+					$cfs[] = substr($col,1);
313
+				}
292 314
 			}
293 315
 		}
294 316
 		$search_params = array(
@@ -521,7 +543,10 @@  discard block
 block discarded – undo
521 543
 		{
522 544
 			$rows['format'] = '64';
523 545
 		}
524
-		if ($this->cat_id) $rows['no_cat_id'] = true;
546
+		if ($this->cat_id)
547
+		{
548
+			$rows['no_cat_id'] = true;
549
+		}
525 550
 		if (!$GLOBALS['egw_info']['user']['apps']['projectmanager'])
526 551
 		{
527 552
 			$params['options-selectcols']['pm_id'] = false;
@@ -587,7 +612,10 @@  discard block
 block discarded – undo
587 612
 			$this->get_rows($query,$events,$readonlys);
588 613
 			foreach($events as $key => $event)
589 614
 			{
590
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
615
+				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked))
616
+				{
617
+					unset($events[$key]);
618
+				}
591 619
 			}
592 620
 			$checked = array_values($events); // Clear keys
593 621
 		}
@@ -601,7 +629,10 @@  discard block
 block discarded – undo
601 629
 				$ids = array();
602 630
 				foreach($checked as $id)
603 631
 				{
604
-					if (is_array($id)) $id = $id['id'];
632
+					if (is_array($id))
633
+					{
634
+						$id = $id['id'];
635
+					}
605 636
 					// get rid of recurrences, doublicate series and calendar-integration events
606 637
 					if (($id = (int)$id))
607 638
 					{
@@ -615,7 +646,10 @@  discard block
 block discarded – undo
615 646
 				exit();
616 647
 
617 648
 			case 'document':
618
-				if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];
649
+				if (!$settings)
650
+				{
651
+					$settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];
652
+				}
619 653
 				$document_merge = new calendar_merge();
620 654
 				$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
621 655
 				$failed = count($checked);
@@ -802,7 +836,8 @@  discard block
 block discarded – undo
802 836
 						$success++;
803 837
 
804 838
 						// Can't link to just one of a recurring series of events
805
-						if(!$recur_date || $app) {
839
+						if(!$recur_date || $app)
840
+						{
806 841
 							// Create link
807 842
 							$link_id = $app ? $app_id : $id;
808 843
 							Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
Please login to merge, or discard this patch.
calendar/inc/class.calendar_uiviews.inc.php 3 patches
Doc Comments   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	/**
413 413
 	 * Displays the planner view
414 414
 	 *
415
-	 * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page
415
+	 * @param null|Etemplate $home = false if etemplate return content suitable for home-page
416 416
 	 */
417 417
 	function &planner($content = array(), $home=false)
418 418
 	{
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 * Used for home app
498 498
 	 *
499 499
 	 * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown
500
-	 * @param boolean|etemplate2 $home = false if not false return content suitable for home-page
500
+	 * @param null|Etemplate $home = false if not false return content suitable for home-page
501 501
 	 */
502 502
 	function &month($weeks=0,$home=false)
503 503
 	{
@@ -580,6 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @param int &$first timestamp 0h of first day of week containing the first of the current month
581 581
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
582 582
 	 * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
583
+	 * @param integer $first
584
+	 * @param integer $last
583 585
 	 */
584 586
 	function _week_align_month(&$first,&$last,$day=1)
585 587
 	{
@@ -604,7 +606,7 @@  discard block
 block discarded – undo
604 606
 	 * Displays the weekview, with 5 or 7 days
605 607
 	 *
606 608
 	 * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used
607
-	 * @param boolean|etemplate2 $home = false if not false return content suitable for home-page
609
+	 * @param null|Etemplate $home = false if not false return content suitable for home-page
608 610
 	 */
609 611
 	function week($days=0,$home=false)
610 612
 	{
@@ -740,7 +742,7 @@  discard block
 block discarded – undo
740 742
 	/**
741 743
 	 * Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider
742 744
 	 *
743
-	 * @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
745
+	 * @param string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
744 746
 	 *	On return $todo_label contains the label for the todo-box
745 747
 	 * @return string/boolean Api\Html with a table of open todo's or false if no hook availible
746 748
 	 */
@@ -824,7 +826,7 @@  discard block
 block discarded – undo
824 826
 	 * - 'edit_popup' => '400x300' (optional)
825 827
 	 *
826 828
 	 * @param string $app
827
-	 * @param int|string $id
829
+	 * @param string $id
828 830
 	 * @return string
829 831
 	 */
830 832
 	public static function integration_get_popup($app,$id)
@@ -864,7 +866,7 @@  discard block
 block discarded – undo
864 866
 	 * Icons specified in $events['icons'] are always displayed!
865 867
 	 *
866 868
 	 * @param string $app
867
-	 * @param int|string $id
869
+	 * @param string $id
868 870
 	 * @param array $event
869 871
 	 * @return array
870 872
 	 */
Please login to merge, or discard this patch.
Spacing   +129 added lines, -130 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @var mixed
43 43
 	 */
44
-	var $debug=false;
44
+	var $debug = false;
45 45
 
46 46
 	/**
47 47
 	 * extra rows above and below the workday
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @var boolean
94 94
 	 */
95
-	var $use_time_grid=true;
95
+	var $use_time_grid = true;
96 96
 
97 97
 	/**
98 98
 	 * Pref value of use_time_grid preference
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @var boolean
107 107
 	 */
108
-	var $scroll_to_wdstart=false;
108
+	var $scroll_to_wdstart = false;
109 109
 
110 110
 	/**
111 111
 	 * counter for the current whole day event of a single day
112 112
 	 *
113 113
 	 * @var int
114 114
 	 */
115
-	var $wholeDayPosCounter=1;
115
+	var $wholeDayPosCounter = 1;
116 116
 
117 117
 	/**
118 118
 	 * Switch to disable private data and possibility to view and edit events
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST
137 137
 	 */
138
-	function __construct($set_states=null)
138
+	function __construct($set_states = null)
139 139
 	{
140
-		parent::__construct(false,$set_states);	// call the parent's constructor
140
+		parent::__construct(false, $set_states); // call the parent's constructor
141 141
 		$this->extraRowsOriginal = $this->extraRows; //save original extraRows value
142 142
 
143 143
 		$GLOBALS['egw_info']['flags']['nonavbar'] = False;
144 144
 
145 145
 		// Check for GET message (from merge)
146
-		if($_GET['msg'])
146
+		if ($_GET['msg'])
147 147
 		{
148 148
 			Framework::message($_GET['msg']);
149 149
 			unset($_GET['msg']);
150 150
 		}
151 151
 		// standard params for calling bocal::search for all views
152
-		$this->owner = str_replace('%2C',',',$this->owner);
152
+		$this->owner = str_replace('%2C', ',', $this->owner);
153 153
 		$this->search_params = array(
154 154
 			'start'   => $this->date,
155
-			'cat_id'  => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0,
156
-			'users'   => explode(',',$this->owner),
155
+			'cat_id'  => $this->cat_id ? (is_array($this->cat_id) ? $this->cat_id : explode(',', $this->cat_id)) : 0,
156
+			'users'   => explode(',', $this->owner),
157 157
 			'filter'  => $this->filter,
158 158
 			'daywise' => True,
159 159
 			'use_so_events' => $this->test === 'true',
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function week_number($time)
181 181
 	{
182
-		if (!is_a($time,'DateTime')) $time = new Api\DateTime($time);
182
+		if (!is_a($time, 'DateTime')) $time = new Api\DateTime($time);
183 183
 
184 184
 		// if week does not start Monday and $time is Sunday --> add one day
185 185
 		if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
@@ -197,19 +197,19 @@  discard block
 block discarded – undo
197 197
 	/**
198 198
 	 * Load all views used by calendar, client side switches between them as needed
199 199
 	 */
200
-	function index($content=array())
200
+	function index($content = array())
201 201
 	{
202
-		if($content['merge'])
202
+		if ($content['merge'])
203 203
 		{
204 204
 			// View from sidebox is JSON encoded
205
-			$this->manage_states(array_merge($content,json_decode($content['view'],true)));
206
-			if($content['first'])
205
+			$this->manage_states(array_merge($content, json_decode($content['view'], true)));
206
+			if ($content['first'])
207 207
 			{
208
-				$this->first = Api\DateTime::to($content['first'],'ts');
208
+				$this->first = Api\DateTime::to($content['first'], 'ts');
209 209
 			}
210
-			if($content['last'])
210
+			if ($content['last'])
211 211
 			{
212
-				$this->last = Api\DateTime::to($content['last'],'ts');
212
+				$this->last = Api\DateTime::to($content['last'], 'ts');
213 213
 			}
214 214
 			$_GET['merge'] = $content['merge'];
215 215
 			$this->merge();
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view));
226 226
 
227 227
 		// Sidebox & iframe for old views
228
-		if(in_array($this->view,array('year')) && $_GET['view'])
228
+		if (in_array($this->view, array('year')) && $_GET['view'])
229 229
 		{
230 230
 			$GLOBALS['egw_info']['flags']['nonavbar'] = true;
231 231
 			$this->manage_states($_GET);
@@ -237,24 +237,24 @@  discard block
 block discarded – undo
237 237
 		$tmpl = new Etemplate('calendar.toolbar');
238 238
 		$tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content));
239 239
 		// Adjust toolbar for mobile
240
-		if(Api\Header\UserAgent::mobile()){
241
-			$tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar');
242
-			$tmpl->setElementAttribute('toolbar','view_range', '3');
240
+		if (Api\Header\UserAgent::mobile()) {
241
+			$tmpl->setElementAttribute('toolbar', 'class', 'et2_head_toolbar');
242
+			$tmpl->setElementAttribute('toolbar', 'view_range', '3');
243 243
 		}
244
-		$tmpl->exec('calendar_uiviews::index',array());
244
+		$tmpl->exec('calendar_uiviews::index', array());
245 245
 
246 246
 		// Load the different views once, we'll switch between them on the client side
247 247
 		$todo = new Etemplate('calendar.todo');
248 248
 		$label = '';
249
-		$todo->exec('calendar_uiviews::index',array('todos'=>$this->get_todos($label), 'label' => $label));
249
+		$todo->exec('calendar_uiviews::index', array('todos'=>$this->get_todos($label), 'label' => $label));
250 250
 
251 251
 		// Actually, this takes care of most of it...
252 252
 		$this->week();
253 253
 
254 254
 		$planner = new Etemplate('calendar.planner');
255 255
 		// Get the actions
256
-		$planner->setElementAttribute('planner','actions',$this->get_actions());
257
-		$planner->exec('calendar_uiviews::index',array());
256
+		$planner->setElementAttribute('planner', 'actions', $this->get_actions());
257
+		$planner->exec('calendar_uiviews::index', array());
258 258
 
259 259
 		// List view in a separate file
260 260
 		$list_ui = new calendar_uilist();
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		{
397 397
 			foreach (array_keys($actions) as $key)
398 398
 			{
399
-				if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) {
399
+				if (!in_array($key, array('day_view', 'week_view', 'next', 'today', 'previous'))) {
400 400
 					$actions[$key]['toolbarDefault'] = false;
401 401
 				}
402 402
 				else {
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page
416 416
 	 */
417
-	function &planner($content = array(), $home=false)
417
+	function &planner($content = array(), $home = false)
418 418
 	{
419 419
 		if ($this->sortby == 'month')	// yearly planner with month rows
420 420
 		{
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
 			unset($this->first['raw']);
424 424
 			$this->last = $this->first;
425 425
 			$this->last['year']++;
426
-			$this->last = $this->bo->date2ts($this->last)-1;
426
+			$this->last = $this->bo->date2ts($this->last) - 1;
427 427
 		}
428 428
 		elseif (!$this->planner_view || $this->planner_view == 'month')	// planner monthview
429 429
 		{
430 430
 			if ($this->day < 15)	// show one complete month
431 431
 			{
432
-				$this->_week_align_month($this->first,$this->last);
432
+				$this->_week_align_month($this->first, $this->last);
433 433
 			}
434 434
 			else	// show 2 half month
435 435
 			{
436
-				$this->_week_align_month($this->first,$this->last,15);
436
+				$this->_week_align_month($this->first, $this->last, 15);
437 437
 			}
438 438
 		}
439 439
 		elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN')	// weeekview
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			$start->setWeekstart();
443 443
 			$this->first = $start->format('ts');
444 444
 			$this->last = $this->bo->date2array($this->first);
445
-			$this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1;
445
+			$this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks']) - 1;
446 446
 			$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
447 447
 			unset($this->last['raw']);
448 448
 			$this->last = $this->bo->date2ts($this->last);
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 		}
459 459
 
460 460
 		$merge = $this->merge();
461
-		if($merge)
461
+		if ($merge)
462 462
 		{
463
-			Egw::redirect_link('/index.php',array(
463
+			Egw::redirect_link('/index.php', array(
464 464
 				'menuaction' => 'calendar.calendar_uiviews.index',
465 465
 				'msg'        => $merge,
466 466
 			));
@@ -472,21 +472,21 @@  discard block
 block discarded – undo
472 472
 		$search_params['end'] = $this->last;
473 473
 		$search_params['enum_groups'] = $this->sortby == 'user';
474 474
 		$content['planner'] = $this->bo->search($search_params);
475
-		foreach($content['planner'] as &$event)
475
+		foreach ($content['planner'] as &$event)
476 476
 		{
477 477
 			$this->to_client($event);
478 478
 		}
479 479
 
480
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
480
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3', False, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last));
481 481
 
482 482
 		$tmpl = $home ? $home : new Etemplate('calendar.planner');
483 483
 
484
-		$tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($this->first, Api\DateTime::ET2));
485
-		$tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($this->last, Api\DateTime::ET2));
486
-		$tmpl->setElementAttribute('planner','owner', $search_params['users']);
487
-		$tmpl->setElementAttribute('planner','group_by', $this->sortby);
484
+		$tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($this->first, Api\DateTime::ET2));
485
+		$tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($this->last, Api\DateTime::ET2));
486
+		$tmpl->setElementAttribute('planner', 'owner', $search_params['users']);
487
+		$tmpl->setElementAttribute('planner', 'group_by', $this->sortby);
488 488
 		// Get the actions
489
-		$tmpl->setElementAttribute('planner','actions',$this->get_actions());
489
+		$tmpl->setElementAttribute('planner', 'actions', $this->get_actions());
490 490
 
491 491
 		$tmpl->exec(__METHOD__, $content);
492 492
 	}
@@ -499,30 +499,30 @@  discard block
 block discarded – undo
499 499
 	 * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown
500 500
 	 * @param boolean|etemplate2 $home = false if not false return content suitable for home-page
501 501
 	 */
502
-	function &month($weeks=0,$home=false)
502
+	function &month($weeks = 0, $home = false)
503 503
 	{
504
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
504
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2', True, $weeks, $this->date);
505 505
 
506 506
 		if (!$home)
507 507
 		{
508
-			trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED);
508
+			trigger_error(__METHOD__.' only used by home app', E_USER_DEPRECATED);
509 509
 			return;
510 510
 		}
511 511
 
512
-		$this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all';	// all views
512
+		$this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views
513 513
 		$granularity = 0;
514
-		if($weeks)
514
+		if ($weeks)
515 515
 		{
516 516
 			$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
517 517
 
518 518
 			$list = $this->cal_prefs['use_time_grid'];
519
-			if(!is_array($list))
519
+			if (!is_array($list))
520 520
 			{
521
-				$list = explode(',',$list);
521
+				$list = explode(',', $list);
522 522
 			}
523
-			if(is_array($list))
523
+			if (is_array($list))
524 524
 			{
525
-				$granularity = in_array('weekN',$list) ? 0 : $granularity;
525
+				$granularity = in_array('weekN', $list) ? 0 : $granularity;
526 526
 			}
527 527
 		}
528 528
 		$content = array('view' => array());
@@ -532,23 +532,23 @@  discard block
 block discarded – undo
532 532
 			$start = new Api\DateTime($this->date);
533 533
 			$start->setWeekstart();
534 534
 			$this->first = $start->format('ts');
535
-			$this->last = strtotime("+$weeks weeks",$this->first) - 1;
535
+			$this->last = strtotime("+$weeks weeks", $this->first) - 1;
536 536
 			$weekNavH = "$weeks weeks";
537 537
 			$navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '.
538
-				$this->bo->long_date($this->first,$this->last);
538
+				$this->bo->long_date($this->first, $this->last);
539 539
 		}
540 540
 		else
541 541
 		{
542
-			$this->_week_align_month($this->first,$this->last);
542
+			$this->_week_align_month($this->first, $this->last);
543 543
 			$weekNavH = "1 month";
544
-			$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
544
+			$navHeader = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year;
545 545
 		}
546
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
546
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4', False, $weeks, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last));
547 547
 
548 548
 		// Loop through, using Api\DateTime to handle DST
549 549
 		$week = 0;
550 550
 		$week_start = new EGroupware\Api\DateTime($this->first);
551
-		$week_start->setTime(0,0,0);
551
+		$week_start->setTime(0, 0, 0);
552 552
 		$week_end = new Api\DateTime($week_start);
553 553
 		$week_end->add(new DateInterval('P6DT23H59M59S'));
554 554
 		$last = new EGroupware\Api\DateTime($this->last);
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
 			array(
563 563
 				'id' => $week_start->format('Ymd')
564 564
 			);
565
-			$home->setElementAttribute("view[$week]",'onchange',false);
566
-			$home->setElementAttribute("view[$week]",'granularity',$granularity);
567
-			$home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']);
565
+			$home->setElementAttribute("view[$week]", 'onchange', false);
566
+			$home->setElementAttribute("view[$week]", 'granularity', $granularity);
567
+			$home->setElementAttribute("view[$week]", 'show_weekend', $this->search_params['weekend']);
568 568
 			$week++;
569 569
 		}
570 570
 
571 571
 		// Get the actions
572
-		$home->setElementAttribute('view','actions',$this->get_actions());
572
+		$home->setElementAttribute('view', 'actions', $this->get_actions());
573 573
 
574 574
 		$home->exec(__METHOD__, $content);
575 575
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
582 582
 	 * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
583 583
 	 */
584
-	function _week_align_month(&$first,&$last,$day=1)
584
+	function _week_align_month(&$first, &$last, $day = 1)
585 585
 	{
586 586
 		$start = new Api\DateTime($this->date);
587
-		$start->setDate($this->year,$this->month,$this->day=$day);
587
+		$start->setDate($this->year, $this->month, $this->day = $day);
588 588
 		$start->setWeekstart();
589 589
 		$first = $start->format('ts');
590
-		$start->setDate($this->year,$this->month+1,$day);
590
+		$start->setDate($this->year, $this->month + 1, $day);
591 591
 		if ($day == 1) $start->add('-1day');
592 592
 		$start->setWeekstart();
593 593
 		// now we need to calculate the end of the last day of that week
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 		$arr['day'] += 6;
597 597
 		$arr['hour'] = 23;
598 598
 		$arr['min'] = $arr['sec'] = 59;
599
-		unset($arr['raw']);	// otherwise date2ts does not calc raw new, but uses it
599
+		unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it
600 600
 		$last = $this->bo->date2ts($arr);
601 601
 	}
602 602
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	 * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used
607 607
 	 * @param boolean|etemplate2 $home = false if not false return content suitable for home-page
608 608
 	 */
609
-	function week($days=0,$home=false)
609
+	function week($days = 0, $home = false)
610 610
 	{
611 611
 		if (!$days)
612 612
 		{
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 			if ($days != 5) $days = 7;
615 615
 			if ($days != $this->cal_prefs['days_in_weekview'])	// save the preference
616 616
 			{
617
-				$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
617
+				$GLOBALS['egw']->preferences->add('calendar', 'days_in_weekview', $days);
618 618
 				$GLOBALS['egw']->preferences->save_repository();
619 619
 				$this->cal_prefs['days_in_weekview'] = $days;
620 620
 			}
621 621
 		}
622
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
622
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2', True, $days, $this->date);
623 623
 
624 624
 		if ($days <= 4)		// next 4 days view
625 625
 		{
626 626
 			$wd_start = $this->first = $this->bo->date2ts($this->date);
627
-			$this->last = strtotime("+$days days",$this->first) - 1;
627
+			$this->last = strtotime("+$days days", $this->first) - 1;
628 628
 			$view = $days == 1 ? 'day' : 'day4';
629 629
 		}
630 630
 		else
@@ -634,30 +634,30 @@  discard block
 block discarded – undo
634 634
 			$wd_start = $this->first = $start->format('ts');
635 635
 			if ($days <= 5)		// no weekend-days
636 636
 			{
637
-				switch($this->cal_prefs['weekdaystarts'])
637
+				switch ($this->cal_prefs['weekdaystarts'])
638 638
 				{
639 639
 					case 'Saturday':
640
-						$this->first = strtotime("+2 days",$this->first);
640
+						$this->first = strtotime("+2 days", $this->first);
641 641
 						break;
642 642
 					case 'Sunday':
643
-						$this->first = strtotime("+1 day",$this->first);
643
+						$this->first = strtotime("+1 day", $this->first);
644 644
 						break;
645 645
 				}
646 646
 			}
647
-			$this->last = strtotime("+$days days",$this->first) - 1;
647
+			$this->last = strtotime("+$days days", $this->first) - 1;
648 648
 			$view = 'week';
649 649
 		}
650 650
 
651 651
 		$granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30);
652 652
 
653 653
 		$list = $this->cal_prefs['use_time_grid'];
654
-		if(!is_array($list))
654
+		if (!is_array($list))
655 655
 		{
656
-			$list = explode(',',$list);
656
+			$list = explode(',', $list);
657 657
 		}
658
-		if(is_array($list))
658
+		if (is_array($list))
659 659
 		{
660
-			$granularity = in_array($view,$list) ? 0 : $granularity;
660
+			$granularity = in_array($view, $list) ? 0 : $granularity;
661 661
 		}
662 662
 
663 663
 		$search_params = array(
@@ -670,15 +670,15 @@  discard block
 block discarded – undo
670 670
 
671 671
 		$content = array('view' => array());
672 672
 
673
-		if(!$home)
673
+		if (!$home)
674 674
 		{
675 675
 			// Fill with the minimum needed 'weeks'
676 676
 			$min = max(
677 677
 				6, // Some months need 6 weeks for full display
678
-				$this->cal_prefs['multiple_weeks'],  // WeekN view
678
+				$this->cal_prefs['multiple_weeks'], // WeekN view
679 679
 				$this->cal_prefs['week_consolidate'] // We collapse after this many users
680 680
 			);
681
-			for($i = 0; $i < $min; $i++)
681
+			for ($i = 0; $i < $min; $i++)
682 682
 			{
683 683
 				$content['view'][] = array();
684 684
 			}
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 		else
687 687
 		{
688 688
 			// Always do 7 days for a week so scrolling works properly
689
-			$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
690
-			if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate']	||// for more then X users, show all in one row
689
+			$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days", $this->first) - 1);
690
+			if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] || // for more then X users, show all in one row
691 691
 				$days == 1 // Showing just 1 day
692 692
 			)
693 693
 			{
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 			}
697 697
 			else
698 698
 			{
699
-				foreach(array_keys($this->_get_planner_users(false)) as $uid)
699
+				foreach (array_keys($this->_get_planner_users(false)) as $uid)
700 700
 				{
701 701
 					$search_params['users'] = $uid;
702 702
 					$content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params))
@@ -704,15 +704,15 @@  discard block
 block discarded – undo
704 704
 				}
705 705
 			}
706 706
 		}
707
-		$tmpl = $home ? $home :new Etemplate('calendar.view');
708
-		foreach(array_keys($content['view']) as $index)
707
+		$tmpl = $home ? $home : new Etemplate('calendar.view');
708
+		foreach (array_keys($content['view']) as $index)
709 709
 		{
710
-			$tmpl->setElementAttribute("view[$index]",'granularity',$granularity);
711
-			$tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']);
710
+			$tmpl->setElementAttribute("view[$index]", 'granularity', $granularity);
711
+			$tmpl->setElementAttribute("view[$index]", 'show_weekend', $this->search_params['weekend']);
712 712
 		}
713 713
 
714 714
 		// Get the actions
715
-		$tmpl->setElementAttribute('view','actions',$this->get_actions());
715
+		$tmpl->setElementAttribute('view', 'actions', $this->get_actions());
716 716
 
717 717
 		$tmpl->exec(__METHOD__, $content);
718 718
 	}
@@ -754,57 +754,56 @@  discard block
 block discarded – undo
754 754
 			'owner'     => $this->owner	// num. id of the user, not necessary current user
755 755
 		));
756 756
 
757
-		if(is_array($todo_label))
757
+		if (is_array($todo_label))
758 758
 		{
759
-			list($label,$showall)=$todo_label;
759
+			list($label, $showall) = $todo_label;
760 760
 		}
761 761
 		else
762 762
 		{
763
-			$label=$todo_label;
764
-			$showall=true;
763
+			$label = $todo_label;
764
+			$showall = true;
765 765
 		}
766 766
 		$maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow'];
767
-		if($maxshow <= 0)
767
+		if ($maxshow <= 0)
768 768
 		{
769
-			$maxshow=10;
769
+			$maxshow = 10;
770 770
 		}
771 771
 		//print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow");
772 772
 
773 773
 		$content = $todo_label = '';
774 774
 		if (is_array($todos_from_hook) && count($todos_from_hook))
775 775
 		{
776
-			foreach($todos_from_hook as $todos)
776
+			foreach ($todos_from_hook as $todos)
777 777
 			{
778 778
 				$i = 0;
779 779
 				if (is_array($todos))
780 780
 				{
781 781
 					$todo_label = !empty($label) ? $label : lang("open ToDo's:");
782 782
 
783
-					foreach($todos as &$todo)
783
+					foreach ($todos as &$todo)
784 784
 					{
785
-						if(!$showall && ($i++ > $maxshow))
785
+						if (!$showall && ($i++ > $maxshow))
786 786
 						{
787 787
 							break;
788 788
 						}
789 789
 						$icons = '';
790
-						foreach($todo['icons'] as $name => $alt)
790
+						foreach ($todo['icons'] as $name => $alt)
791 791
 						{
792
-							$icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"');
792
+							$icons .= ($icons ? ' ' : '').Api\Html::image('infolog', $name, lang($alt), 'border="0" width="15" height="15"');
793 793
 						}
794 794
 						$todo['icons'] = $icons;
795 795
 						$class = $class == 'row_on' ? 'row_off' : 'row_on';
796
-						if($todo['edit']) {
796
+						if ($todo['edit']) {
797 797
 							$todo['edit_size'] = $todo['edit']['size'];
798 798
 							unset($todo['edit']['size']);
799
-							$edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" ');
800
-							$edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
801
-							$todo['edit'] = Framework::link('/index.php',$todo['edit'],true);
799
+							$edit_icon_href = Api\Html::a_href($icons, $todo['edit'], '', ' data-todo="app|750x590" ');
800
+							$edit_href = Api\Html::a_href($todo['title'], $todo['edit'], '', ' data-todo="app|750x590" ');
801
+							$todo['edit'] = Framework::link('/index.php', $todo['edit'], true);
802 802
 						}
803
-						$icon_href = Api\Html::a_href($icons,$todo['view']);
803
+						$icon_href = Api\Html::a_href($icons, $todo['view']);
804 804
 						$content .= " <tr class=\"$class\">\n  <td valign=\"top\" width=\"15%\" nowrap>".
805
-							($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)).
806
-							"</td>\n  <td>".($this->printer_friendly?$todo['title']:
807
-							$edit_href)."</td>\n </tr>\n";
805
+							($this->bo->printer_friendly ? $icons : ($edit_icon_href ? $edit_icon_href : $icon_href)).
806
+							"</td>\n  <td>".($this->printer_friendly ? $todo['title'] : $edit_href)."</td>\n </tr>\n";
808 807
 						/**
809 808
 						 * ToDo: add delete and closing action
810 809
 						 */
@@ -827,9 +826,9 @@  discard block
 block discarded – undo
827 826
 	 * @param int|string $id
828 827
 	 * @return string
829 828
 	 */
830
-	public static function integration_get_popup($app,$id)
829
+	public static function integration_get_popup($app, $id)
831 830
 	{
832
-		$app_data = calendar_bo::integration_get_data($app,'edit_link');
831
+		$app_data = calendar_bo::integration_get_data($app, 'edit_link');
833 832
 
834 833
 		if (is_array($app_data) && isset($app_data['edit']))
835 834
 		{
@@ -839,7 +838,7 @@  discard block
 block discarded – undo
839 838
 		}
840 839
 		else
841 840
 		{
842
-			$edit = Link::edit($app,$id,$popup_size);
841
+			$edit = Link::edit($app, $id, $popup_size);
843 842
 		}
844 843
 		if ($edit)
845 844
 		{
@@ -868,28 +867,28 @@  discard block
 block discarded – undo
868 867
 	 * @param array $event
869 868
 	 * @return array
870 869
 	 */
871
-	static function integration_get_icons($app,$id,$event)
870
+	static function integration_get_icons($app, $id, $event)
872 871
 	{
873 872
 		$icons = array();
874 873
 		if ($event['icons'])
875 874
 		{
876
-			foreach(explode(',',$event['icons']) as $icon)
875
+			foreach (explode(',', $event['icons']) as $icon)
877 876
 			{
878
-				list($icon_app,$icon) = explode(':',$icon);
879
-				if (Api\Image::find($icon_app,$icon))
877
+				list($icon_app, $icon) = explode(':', $icon);
878
+				if (Api\Image::find($icon_app, $icon))
880 879
 				{
881
-					$icons[] = Api\Html::image($icon_app,$icon);
880
+					$icons[] = Api\Html::image($icon_app, $icon);
882 881
 				}
883 882
 			}
884 883
 		}
885
-		$app_data = calendar_bo::integration_get_data($app,'icons');
884
+		$app_data = calendar_bo::integration_get_data($app, 'icons');
886 885
 		if (is_null($app_data))
887 886
 		{
888
-			$icons[] = Api\Html::image($app,'navbar');	// use navbar icon
887
+			$icons[] = Api\Html::image($app, 'navbar'); // use navbar icon
889 888
 		}
890 889
 		elseif ($app_data)
891 890
 		{
892
-			$icons += (array)ExecMethod2($app_data,$id,$event);
891
+			$icons += (array)ExecMethod2($app_data, $id, $event);
893 892
 		}
894 893
 		return $icons;
895 894
 	}
@@ -912,20 +911,20 @@  discard block
 block discarded – undo
912 911
 		unset($actions['select_all']);
913 912
 
914 913
 		// This disables the event actions for the grid rows (calendar weeks/owners)
915
-		foreach($actions as $id => &$action)
914
+		foreach ($actions as $id => &$action)
916 915
 		{
917
-			if($id=='add') continue;
918
-			if(!$action['enabled'])
916
+			if ($id == 'add') continue;
917
+			if (!$action['enabled'])
919 918
 			{
920 919
 				$action['enabled'] = 'javaScript:app.calendar.is_event';
921 920
 			}
922 921
 		}
923 922
 		$actions['add']['open'] = '{"app":"calendar","type":"add"}';
924
-		$actions['add']['onExecute'] =  'javaScript:app.calendar.action_open';
923
+		$actions['add']['onExecute'] = 'javaScript:app.calendar.action_open';
925 924
 		$actions['copy']['open'] = '{"app": "calendar", "type": "add", "extra": "cal_id=$id&action=copy"}';
926 925
 		$actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open';
927 926
 
928
-		foreach($actions['status']['children'] as $id => &$status)
927
+		foreach ($actions['status']['children'] as $id => &$status)
929 928
 		{
930 929
 			$status = array(
931 930
 				'id' => $id,
@@ -936,7 +935,7 @@  discard block
 block discarded – undo
936 935
 
937 936
 		if ($actions['filemanager'])
938 937
 		{
939
-			$actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url'];
938
+			$actions['filemanager']['url'] = '/index.php?'.$actions['filemanager']['url'];
940 939
 			$actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open';
941 940
 		}
942 941
 		if ($actions['infolog_app'])
@@ -981,26 +980,26 @@  discard block
 block discarded – undo
981 980
 				{
982 981
 					$start = $this->bo->date2array($event['start']);
983 982
 					$end = $this->bo->date2array($event['end']);
984
-					if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
983
+					if (!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
985 984
 					{
986
-						if($event['non_blocking'])
985
+						if ($event['non_blocking'])
987 986
 						{
988
-							$dayEvents[$day][$num]['whole_day_on_top']=true;
989
-							$this->whole_day_positions[$num]=($this->rowHeight*($num+2));
987
+							$dayEvents[$day][$num]['whole_day_on_top'] = true;
988
+							$this->whole_day_positions[$num] = ($this->rowHeight * ($num + 2));
990 989
 							$extraRowsToAdd++;
991 990
 						}
992 991
 						else
993 992
 						{
994
-							$dayEvents[$day][$num]['whole_day']=true;
993
+							$dayEvents[$day][$num]['whole_day'] = true;
995 994
 						}
996 995
 					}
997 996
 					$this->to_client($dayEvents[$day][$num]);
998 997
 				}
999 998
 				// check after every day if we have to increase $this->extraRows
1000
-				if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows)
999
+				if (($this->extraRowsOriginal + $extraRowsToAdd) > $this->extraRows)
1001 1000
 				{
1002 1001
 					$this->remBotExtraRows = $extraRowsToAdd;
1003
-					$this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd);
1002
+					$this->extraRows = ($this->extraRowsOriginal + $extraRowsToAdd);
1004 1003
 				}
1005 1004
 			}
1006 1005
 		}
Please login to merge, or discard this patch.
Braces   +69 added lines, -21 removed lines patch added patch discarded remove patch
@@ -179,7 +179,10 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function week_number($time)
181 181
 	{
182
-		if (!is_a($time,'DateTime')) $time = new Api\DateTime($time);
182
+		if (!is_a($time,'DateTime'))
183
+		{
184
+			$time = new Api\DateTime($time);
185
+		}
183 186
 
184 187
 		// if week does not start Monday and $time is Sunday --> add one day
185 188
 		if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
@@ -237,7 +240,8 @@  discard block
 block discarded – undo
237 240
 		$tmpl = new Etemplate('calendar.toolbar');
238 241
 		$tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content));
239 242
 		// Adjust toolbar for mobile
240
-		if(Api\Header\UserAgent::mobile()){
243
+		if(Api\Header\UserAgent::mobile())
244
+		{
241 245
 			$tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar');
242 246
 			$tmpl->setElementAttribute('toolbar','view_range', '3');
243 247
 		}
@@ -396,10 +400,12 @@  discard block
 block discarded – undo
396 400
 		{
397 401
 			foreach (array_keys($actions) as $key)
398 402
 			{
399
-				if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) {
403
+				if (!in_array($key, array('day_view','week_view','next', 'today','previous')))
404
+				{
400 405
 					$actions[$key]['toolbarDefault'] = false;
401 406
 				}
402
-				else {
407
+				else
408
+				{
403 409
 					$actions[$key]['toolbarDefault'] = true;
404 410
 				}
405 411
 			}
@@ -416,29 +422,38 @@  discard block
 block discarded – undo
416 422
 	 */
417 423
 	function &planner($content = array(), $home=false)
418 424
 	{
419
-		if ($this->sortby == 'month')	// yearly planner with month rows
425
+		if ($this->sortby == 'month')
426
+		{
427
+			// yearly planner with month rows
420 428
 		{
421 429
 			$this->first = $this->bo->date2array($this->date);
430
+		}
422 431
 			$this->first['day'] = 1;
423 432
 			unset($this->first['raw']);
424 433
 			$this->last = $this->first;
425 434
 			$this->last['year']++;
426 435
 			$this->last = $this->bo->date2ts($this->last)-1;
427 436
 		}
428
-		elseif (!$this->planner_view || $this->planner_view == 'month')	// planner monthview
437
+		elseif (!$this->planner_view || $this->planner_view == 'month')
438
+		{
439
+			// planner monthview
429 440
 		{
430 441
 			if ($this->day < 15)	// show one complete month
431 442
 			{
432 443
 				$this->_week_align_month($this->first,$this->last);
444
+		}
433 445
 			}
434 446
 			else	// show 2 half month
435 447
 			{
436 448
 				$this->_week_align_month($this->first,$this->last,15);
437 449
 			}
438 450
 		}
439
-		elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN')	// weeekview
451
+		elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN')
452
+		{
453
+			// weeekview
440 454
 		{
441 455
 			$start = new Api\DateTime($this->date);
456
+		}
442 457
 			$start->setWeekstart();
443 458
 			$this->first = $start->format('ts');
444 459
 			$this->last = $this->bo->date2array($this->first);
@@ -477,7 +492,10 @@  discard block
 block discarded – undo
477 492
 			$this->to_client($event);
478 493
 		}
479 494
 
480
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
495
+		if ($this->debug > 0)
496
+		{
497
+			$this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
498
+		}
481 499
 
482 500
 		$tmpl = $home ? $home : new Etemplate('calendar.planner');
483 501
 
@@ -501,7 +519,10 @@  discard block
 block discarded – undo
501 519
 	 */
502 520
 	function &month($weeks=0,$home=false)
503 521
 	{
504
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
522
+		if ($this->debug > 0)
523
+		{
524
+			$this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
525
+		}
505 526
 
506 527
 		if (!$home)
507 528
 		{
@@ -543,7 +564,10 @@  discard block
 block discarded – undo
543 564
 			$weekNavH = "1 month";
544 565
 			$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
545 566
 		}
546
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
567
+		if ($this->debug > 0)
568
+		{
569
+			$this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
570
+		}
547 571
 
548 572
 		// Loop through, using Api\DateTime to handle DST
549 573
 		$week = 0;
@@ -588,7 +612,10 @@  discard block
 block discarded – undo
588 612
 		$start->setWeekstart();
589 613
 		$first = $start->format('ts');
590 614
 		$start->setDate($this->year,$this->month+1,$day);
591
-		if ($day == 1) $start->add('-1day');
615
+		if ($day == 1)
616
+		{
617
+			$start->add('-1day');
618
+		}
592 619
 		$start->setWeekstart();
593 620
 		// now we need to calculate the end of the last day of that week
594 621
 		// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
@@ -611,19 +638,31 @@  discard block
 block discarded – undo
611 638
 		if (!$days)
612 639
 		{
613 640
 			$days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview'];
614
-			if ($days != 5) $days = 7;
615
-			if ($days != $this->cal_prefs['days_in_weekview'])	// save the preference
641
+			if ($days != 5)
642
+			{
643
+				$days = 7;
644
+			}
645
+			if ($days != $this->cal_prefs['days_in_weekview'])
646
+			{
647
+				// save the preference
616 648
 			{
617 649
 				$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
650
+			}
618 651
 				$GLOBALS['egw']->preferences->save_repository();
619 652
 				$this->cal_prefs['days_in_weekview'] = $days;
620 653
 			}
621 654
 		}
622
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
655
+		if ($this->debug > 0)
656
+		{
657
+			$this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
658
+		}
623 659
 
624
-		if ($days <= 4)		// next 4 days view
660
+		if ($days <= 4)
661
+		{
662
+			// next 4 days view
625 663
 		{
626 664
 			$wd_start = $this->first = $this->bo->date2ts($this->date);
665
+		}
627 666
 			$this->last = strtotime("+$days days",$this->first) - 1;
628 667
 			$view = $days == 1 ? 'day' : 'day4';
629 668
 		}
@@ -632,12 +671,15 @@  discard block
 block discarded – undo
632 671
 			$start = new Api\DateTime($this->date);
633 672
 			$start->setWeekstart();
634 673
 			$wd_start = $this->first = $start->format('ts');
635
-			if ($days <= 5)		// no weekend-days
674
+			if ($days <= 5)
675
+			{
676
+				// no weekend-days
636 677
 			{
637 678
 				switch($this->cal_prefs['weekdaystarts'])
638 679
 				{
639 680
 					case 'Saturday':
640 681
 						$this->first = strtotime("+2 days",$this->first);
682
+			}
641 683
 						break;
642 684
 					case 'Sunday':
643 685
 						$this->first = strtotime("+1 day",$this->first);
@@ -666,7 +708,10 @@  discard block
 block discarded – undo
666 708
 			) + $this->search_params;
667 709
 
668 710
 		$users = $this->search_params['users'];
669
-		if (!is_array($users)) $users = array($users);
711
+		if (!is_array($users))
712
+		{
713
+			$users = array($users);
714
+		}
670 715
 
671 716
 		$content = array('view' => array());
672 717
 
@@ -689,8 +734,7 @@  discard block
 block discarded – undo
689 734
 			$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
690 735
 			if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate']	||// for more then X users, show all in one row
691 736
 				$days == 1 // Showing just 1 day
692
-			)
693
-			{
737
+			) {
694 738
 				$content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
695 739
 					array('owner' => $users);
696 740
 			}
@@ -793,7 +837,8 @@  discard block
 block discarded – undo
793 837
 						}
794 838
 						$todo['icons'] = $icons;
795 839
 						$class = $class == 'row_on' ? 'row_off' : 'row_on';
796
-						if($todo['edit']) {
840
+						if($todo['edit'])
841
+						{
797 842
 							$todo['edit_size'] = $todo['edit']['size'];
798 843
 							unset($todo['edit']['size']);
799 844
 							$edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" ');
@@ -914,7 +959,10 @@  discard block
 block discarded – undo
914 959
 		// This disables the event actions for the grid rows (calendar weeks/owners)
915 960
 		foreach($actions as $id => &$action)
916 961
 		{
917
-			if($id=='add') continue;
962
+			if($id=='add')
963
+			{
964
+				continue;
965
+			}
918 966
 			if(!$action['enabled'])
919 967
 			{
920 968
 				$action['enabled'] = 'javaScript:app.calendar.is_event';
Please login to merge, or discard this patch.
calendar/inc/class.calendar_zpush.inc.php 4 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @param int $truncsize
273 273
 	 * @param int $bodypreference
274 274
 	 * @param $optionbodypreference
275
-	 * @param bool $mimesupport
275
+	 * @param integer $mimesupport
276 276
 	 * @return SyncMail
277 277
 	 */
278 278
 	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	 * @param string $displayname => new folder name (to be created, or to be renamed to)
876 876
 	 * @param string $type folder type, ignored in IMAP
877 877
 	 *
878
-	 * @return array|boolean stat array or false on error
878
+	 * @return boolean stat array or false on error
879 879
 	 */
880 880
 	public function ChangeFolder($id, $oldid, $displayname, $type)
881 881
 	{
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 * @param string $id of the folder to delete
891 891
 	 *
892 892
 	 * @return
893
-	 * @TODO check what is to be returned
893
+	 boolean @TODO check what is to be returned
894 894
 	 */
895 895
 	public function DeleteFolder($parentid, $id)
896 896
 	{
@@ -1578,6 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	 * Unpack timezone info from Sync
1579 1579
 	 *
1580 1580
 	 * copied from backend/ics.php
1581
+	 * @param string $data
1581 1582
 	 */
1582 1583
 	static public function _getTZFromSyncBlob($data)
1583 1584
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 	 * @param int $cutoffdate =null
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180
-  	 */
180
+	 */
181 181
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
Please login to merge, or discard this patch.
Spacing   +178 added lines, -179 removed lines patch added patch discarded remove patch
@@ -84,19 +84,19 @@  discard block
 block discarded – undo
84 84
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
85 85
 
86 86
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
87
-		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
87
+		$cals = $cals_pref ? explode(',', $cals_pref) : array('P'); // implicit default of 'P'
88 88
 		$folderlist = array();
89 89
 
90 90
 		foreach ($this->calendar->list_cals() as $entry)
91 91
 		{
92 92
 			$account_id = $entry['grantor'];
93
-			if (in_array('A',$cals) || in_array($account_id,$cals) ||
94
-				$account_id == $GLOBALS['egw_info']['user']['account_id'] ||	// always incl. own calendar!
95
-				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals))
93
+			if (in_array('A', $cals) || in_array($account_id, $cals) ||
94
+				$account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar!
95
+				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals))
96 96
 			{
97 97
 				$folderlist[] = $f = array(
98
-					'id'	=>	$this->backend->createID('calendar',$account_id),
99
-					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'),
98
+					'id'	=>	$this->backend->createID('calendar', $account_id),
99
+					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'),
100 100
 					'parent'=>	'0',
101 101
 				);
102 102
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$folderObj = new SyncFolder();
121 121
 		$folderObj->serverid = $id;
122 122
 		$folderObj->parentid = '0';
123
-		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname');
123
+		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname');
124 124
 		if ($owner == $GLOBALS['egw_info']['user']['account_id'])
125 125
 		{
126 126
 			$folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		$stat = array(
156 156
 			'id'	 => $id,
157
-			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'),
157
+			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'),
158 158
 			'parent' => '0',
159 159
 		);
160 160
 		//error_log(__METHOD__."('$id') folderObj=".array2string($stat));
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180 180
   	 */
181
-	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
181
+	function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
184 184
 
185 185
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
186 186
 		$type = $user = null;
187
-		$this->backend->splitID($id,$type,$user);
187
+		$this->backend->splitID($id, $type, $user);
188 188
 
189
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
189
+		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences
190 190
 
191 191
 		$filter = array(
192 192
 			'users' => $user,
193
-			'start' => $cutoffdate,	// default one month back -30 breaks all sync recurrences
193
+			'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences
194 194
 			'enum_recuring' => false,
195 195
 			'daywise' => false,
196 196
 			'date_format' => 'server',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default',
200 200
 			// @todo return only etag relevant information (seems not to work ...)
201 201
 			//'cols'		=> array('egw_cal.cal_id', 'cal_start',	'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'),
202
-			'query' => array('cal_recurrence' => 0),	// do NOT return recurrence exceptions
202
+			'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions
203 203
 		);
204 204
 
205 205
 		$messagelist = array();
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @param int $cutoffdate =null
231 231
 	 * @return array
232 232
 	 */
233
-	function GetMeetingRequests(array $not_uids, $cutoffdate=NULL)
233
+	function GetMeetingRequests(array $not_uids, $cutoffdate = NULL)
234 234
 	{
235 235
 		unset($not_uids, $cutoffdate);
236 236
 		return array();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	function StatMeetingRequest($id)
258 258
 	{
259
-		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']);	// users personal calendar
259
+		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar
260 260
 
261 261
 		$ret = $this->StatMessage($folderid, abs($id));
262 262
 		$ret['id'] = $id;
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 * @param bool $mimesupport
276 276
 	 * @return SyncMail
277 277
 	 */
278
-	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
278
+	function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
279 279
 	{
280
-		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
280
+		unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature
281 281
 
282 282
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
283 283
 
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 			$message = new SyncMail();
291 291
 			$message->read = false;
292 292
 			$message->subject = $event['title'];
293
-			$message->importance = 1;	// 0=Low, 1=Normal, 2=High
293
+			$message->importance = 1; // 0=Low, 1=Normal, 2=High
294 294
 			$message->datereceived = $event['created'];
295 295
 			$message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email'];
296
-			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname').
297
-				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>';
296
+			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname').
297
+				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>';
298 298
 			$message->internetcpid = 65001;
299
-			$message->contentclass="urn:content-classes:message";
299
+			$message->contentclass = "urn:content-classes:message";
300 300
 
301 301
 			$message->meetingrequest = self::meetingRequest($event);
302 302
 			$message->messageclass = "IPM.Schedule.Meeting.Request";
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 			else
312 312
 			{
313 313
 				$message->airsyncbasebody = new SyncAirSyncBaseBody();
314
-				$message->airsyncbasenativebodytype=1;
314
+				$message->airsyncbasenativebodytype = 1;
315 315
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody);
316 316
 			}
317 317
 		}
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 			$as_tz = self::tz2as($event['tzid']);
347 347
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
348 348
 		}
349
-		catch(Exception $e) {
349
+		catch (Exception $e) {
350 350
 			unset($e);
351 351
 			// ignore exception, simply set no timezone, as it is optional
352 352
 		}
353 353
 		// copying timestamps (they are already read in servertime, so non tz conversation)
354
-		foreach(array(
354
+		foreach (array(
355 355
 			'start' => 'starttime',
356 356
 			'end'   => 'endtime',
357 357
 			'created' => 'dtstamp',
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 		}
362 362
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
363 363
 		{
364
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
364
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
365 365
 		}
366 366
 		// copying strings
367
-		foreach(array(
367
+		foreach (array(
368 368
 			'title' => 'subject',
369 369
 			'location' => 'location',
370 370
 		) as $key => $attr)
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 		}
374 374
 		$message->organizer = $event['organizer'];
375 375
 
376
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
376
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
377 377
 
378 378
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
379 379
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
380 380
 
381 381
 		// ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ...
382
-		$message->instancetype = 0;	// 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
382
+		$message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
383 383
 
384
-		$message->responserequested = 1;	//0=No, 1=Yes
385
-		$message->disallownewtimeproposal = 1;	//1=forbidden, 0=allowed
384
+		$message->responserequested = 1; //0=No, 1=Yes
385
+		$message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed
386 386
 		//$message->messagemeetingtype;	// email2
387 387
 
388 388
 		// ToDo: alarme: Reminder
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 			// check if event already exist (invitation of or already imported by other user)
429 429
 			if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server')))
430 430
 			{
431
-				$event = $parsed_event;	// create new event from external invitation
431
+				$event = $parsed_event; // create new event from external invitation
432 432
 			}
433
-			elseif(!isset($event['participants'][$uid]))
433
+			elseif (!isset($event['participants'][$uid]))
434 434
 			{
435 435
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event));
436 436
 				// maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ...
437 437
 			}
438
-			elseif($event['deleted'])
438
+			elseif ($event['deleted'])
439 439
 			{
440 440
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false");
441 441
 				return false;
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		else
459 459
 		{
460 460
 			$event['participants'][$uid] = $status;
461
-			$ret = $this->calendar->update($event, true);	// true = ignore conflicts, as there seems no conflict handling in AS
461
+			$ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS
462 462
 		}
463 463
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret));
464 464
 		return $ret;
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
 	 * @var array
471 471
 	 */
472 472
 	static $status2as = array(
473
-		'U' => 0,	// unknown
474
-		'T' => 2,	// tentative
475
-		'A' => 3,	// accepted
476
-		'R' => 4,	// decline
473
+		'U' => 0, // unknown
474
+		'T' => 2, // tentative
475
+		'A' => 3, // accepted
476
+		'R' => 4, // decline
477 477
 		// 5 = not responded
478 478
 	);
479 479
 	/**
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 	 * @var array
483 483
 	 */
484 484
 	static $role2as = array(
485
-		'REQ-PARTICIPANT' => 1,	// required
486
-		'CHAIR' => 1,			// required
487
-		'OPT-PARTICIPANT' => 2,	// optional
485
+		'REQ-PARTICIPANT' => 1, // required
486
+		'CHAIR' => 1, // required
487
+		'OPT-PARTICIPANT' => 2, // optional
488 488
 		'NON-PARTICIPANT' => 2,
489 489
 		// 3 = ressource
490 490
 	);
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 	static $recur_type2as = array(
497 497
 		calendar_rrule::DAILY => 0,
498 498
 		calendar_rrule::WEEKLY => 1,
499
-		calendar_rrule::MONTHLY_MDAY => 2,	// monthly
500
-		calendar_rrule::MONTHLY_WDAY => 3,	// monthly on nth day
499
+		calendar_rrule::MONTHLY_MDAY => 2, // monthly
500
+		calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day
501 501
 		calendar_rrule::YEARLY => 5,
502 502
 		// 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears)
503 503
 	);
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 */
525 525
 	public function ChangeMessage($folderid, $_id, $message, $contentParameters)
526 526
 	{
527
-		unset($contentParameters);	// unused, but required by function signature
527
+		unset($contentParameters); // unused, but required by function signature
528 528
 
529 529
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
530 530
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 
535 535
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account");
536 536
 
537
-		list($id,$recur_date) = explode(':', $_id);
537
+		list($id, $recur_date) = explode(':', $_id);
538 538
 
539 539
 		if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server')))
540 540
 		{
@@ -547,21 +547,21 @@  discard block
 block discarded – undo
547 547
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
548 548
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
549 549
 		}
550
-		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
550
+		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0, $account))
551 551
 		{
552 552
 			// @todo: write in users calendar and make account only a participant
553 553
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!");
554 554
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
555 555
 			return false;
556 556
 		}
557
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
557
+		if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events
558 558
 
559 559
 		$event = $this->message2event($message, $account, $old_event);
560 560
 
561 561
 		// store event, ignore conflicts and skip notifications, as AS clients do their own notifications
562 562
 		$skip_notification = false;
563 563
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
564
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send')
564
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'send')
565 565
 		{
566 566
 			$skip_notification = true; // to avoid double notification from client AND Server
567 567
 		}
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
 		// store non-delete exceptions
575 575
 		if ($message->exceptions)
576 576
 		{
577
-			foreach($message->exceptions as $exception)
577
+			foreach ($message->exceptions as $exception)
578 578
 			{
579 579
 				if (!$exception->deleted)
580 580
 				{
581 581
 					$ex_event = $event;
582 582
 					unset($ex_event['id']);
583 583
 					unset($ex_event['etag']);
584
-					foreach(array_keys($ex_event) as $name)
584
+					foreach (array_keys($ex_event) as $name)
585 585
 					{
586
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
586
+						if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]);
587 587
 					}
588 588
 					$ex_event['recur_type'] = calendar_rrule::NONE;
589 589
 
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
 						'user' => $account,
592 592
 						'enum_recuring' => false,
593 593
 						'daywise' => false,
594
-						'filter' => 'owner',  // return all possible entries
594
+						'filter' => 'owner', // return all possible entries
595 595
 						'query' => array(
596 596
 							'cal_uid' => $event['uid'],
597
-							'cal_recurrence' => $exception->exceptionstarttime,	// in servertime
597
+							'cal_recurrence' => $exception->exceptionstarttime, // in servertime
598 598
 						),
599 599
 					))))
600 600
 					{
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 						$participants = $event['participants'];
607 607
 					}
608 608
 					$save_event = $this->message2event($exception, $account, $ex_event);
609
-					$save_event['participants'] = $participants;	// not contained in $exception
609
+					$save_event['participants'] = $participants; // not contained in $exception
610 610
 					$save_event['reference'] = $event['id'];
611 611
 					$save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime);
612 612
 					$ex_ok = $this->calendar->save($save_event);
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
 	 * @param array $event =array()
629 629
 	 * @return array
630 630
 	 */
631
-	private function message2event(SyncAppointment $message, $account, $event=array())
631
+	private function message2event(SyncAppointment $message, $account, $event = array())
632 632
 	{
633 633
 		// timestamps (created & modified are updated automatically)
634
-		foreach(array(
634
+		foreach (array(
635 635
 			'start' => 'starttime',
636 636
 			'end' => 'endtime',
637 637
 		) as $key => $attr)
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
640 640
 		}
641 641
 		// copying strings
642
-		foreach(array(
642
+		foreach (array(
643 643
 			'title' => 'subject',
644 644
 			'uid'   => 'uid',
645 645
 			'location' => 'location',
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		{
655 655
 			$event['description'] = $description;
656 656
 		}
657
-		$event['public'] = (int)($message->sensitivity < 1);	// 0=normal, 1=personal, 2=private, 3=confidential
657
+		$event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential
658 658
 
659 659
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
660 660
 		if (isset($message->busystatus))
@@ -664,21 +664,21 @@  discard block
 block discarded – undo
664 664
 
665 665
 		if (($event['whole_day'] = $message->alldayevent))
666 666
 		{
667
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
668
-			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
667
+			if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day
668
+			$event['end']--; // otherwise our whole-day event code in save makes it one more day!
669 669
 		}
670 670
 
671 671
 		$participants = array();
672
-		foreach((array)$message->attendees as $attendee)
672
+		foreach ((array)$message->attendees as $attendee)
673 673
 		{
674
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
674
+			if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later
675 675
 
676 676
 			$matches = null;
677
-			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
677
+			if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches))
678 678
 			{
679 679
 				$uid = $matches[1];
680 680
 			}
681
-			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email')))
681
+			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email')))
682 682
 			{
683 683
 				$search = array(
684 684
 					'email' => $attendee->email,
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
 				// search addressbook for participant
689 689
 				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
690 690
 				if ((list($data) = $this->addressbook->search($search,
691
-					array('id','egw_addressbook.account_id as account_id','n_fn'),
691
+					array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
692 692
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
693
-					'','',false,'OR')))
693
+					'', '', false, 'OR')))
694 694
 				{
695 695
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
696 696
 				}
697
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
697
+				elseif ($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
698 698
 				{
699 699
 					$uid = 'e'.$attendee->email;
700 700
 				}
@@ -712,8 +712,8 @@  discard block
 block discarded – undo
712 712
 				//ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role");
713 713
 			}
714 714
 			// check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set
715
-			elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) ||
716
-				(isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>']))))
715
+			elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) ||
716
+				(isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>']))))
717 717
 			{
718 718
 				$status = $event['participants'][$u];
719 719
 				calendar_so::split_status($status, $quantity, $role);
@@ -726,9 +726,9 @@  discard block
 block discarded – undo
726 726
 				$role = 'REQ-PARTICIPANT';
727 727
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
728 728
 			}
729
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
729
+			if ($role == 'CHAIR') $chair_set = true; // by role from existing participant
730 730
 
731
-			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
731
+			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as)))
732 732
 			{
733 733
 				$status = $s;
734 734
 			}
@@ -738,29 +738,29 @@  discard block
 block discarded – undo
738 738
 				$chair_set = true;
739 739
 			}
740 740
 			elseif (isset($attendee->attendeetype) &&
741
-				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
742
-				($r = array_search($attendee->attendeetype,self::$role2as)) &&
741
+				!($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER
742
+				($r = array_search($attendee->attendeetype, self::$role2as)) &&
743 743
 				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
744 744
 			{
745 745
 				$role = $r;
746 746
 			}
747 747
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
748
-			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
748
+			$participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role);
749 749
 		}
750 750
 		// if organizer is not already participant, add him as chair
751
-		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid]))
751
+		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid]))
752 752
 		{
753 753
 			$participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ?
754
-				'A' : 'U',1,'CHAIR');
754
+				'A' : 'U', 1, 'CHAIR');
755 755
 			$chair_set = true;
756 756
 		}
757 757
 		// preserve all resource types not account, contact or email (eg. resources) for existing events
758 758
 		// $account is also preserved, as AS does not add him as participant!
759
-		foreach((array)$event['participant_types'] as $type => $parts)
759
+		foreach ((array)$event['participant_types'] as $type => $parts)
760 760
 		{
761
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
761
+			if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS
762 762
 
763
-			foreach($parts as $id => $status)
763
+			foreach ($parts as $id => $status)
764 764
 			{
765 765
 				// accounts are represented correctly, but the event owner which is no participant in AS
766 766
 				if ($type == 'u' && $id != $account) continue;
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
 		if (!$event['id'] || !$participants || !isset($participants[$account]))
777 777
 		{
778 778
 			$participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ?
779
-				'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
779
+				'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
780 780
 		}
781 781
 		$event['participants'] = $participants;
782 782
 
783 783
 		if (isset($message->categories))
784 784
 		{
785
-			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen'));
785
+			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen'));
786 786
 		}
787 787
 
788 788
 		// check if event is recurring and import recur information (incl. timezone)
@@ -792,8 +792,7 @@  discard block
 block discarded – undo
792 792
 			{
793 793
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
794 794
 			}
795
-			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
796
-				array_search($message->recurrence->type, self::$recur_type2as);
795
+			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as);
797 796
 			$event['recur_interval'] = $message->recurrence->interval;
798 797
 
799 798
 			switch ($event['recur_type'])
@@ -802,7 +801,7 @@  discard block
 block discarded – undo
802 801
 					// $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date
803 802
 					// fall throught
804 803
 				case calendar_rrule::WEEKLY:
805
-					$event['recur_data'] = $message->recurrence->dayofweek;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
804
+					$event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
806 805
 					break;
807 806
 				case calendar_rrule::MONTHLY_MDAY:
808 807
 					// $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date
@@ -818,7 +817,7 @@  discard block
 block discarded – undo
818 817
 			$event['recur_exceptions'] = array();
819 818
 			if ($message->exceptions)
820 819
 			{
821
-				foreach($message->exceptions as $exception)
820
+				foreach ($message->exceptions as $exception)
822 821
 				{
823 822
 					$event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime);
824 823
 				}
@@ -828,7 +827,7 @@  discard block
 block discarded – undo
828 827
 			{
829 828
 				// calculate enddate from occurences count, as we only support enddate
830 829
 				$count = $message->recurrence->occurrences;
831
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
830
+				foreach (calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
832 831
 				{
833 832
 					if (--$count <= 0) break;
834 833
 				}
@@ -838,11 +837,11 @@  discard block
 block discarded – undo
838 837
 		// only import alarms in own calendar
839 838
 		if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id'])
840 839
 		{
841
-			foreach((array)$event['alarm'] as $alarm)
840
+			foreach ((array)$event['alarm'] as $alarm)
842 841
 			{
843
-				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder)
842
+				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder)
844 843
 				{
845
-					$alarm = true;	// alarm already exists --> do nothing
844
+					$alarm = true; // alarm already exists --> do nothing
846 845
 					break;
847 846
 				}
848 847
 			}
@@ -851,16 +850,16 @@  discard block
 block discarded – undo
851 850
 				// delete all earlier alarms of that user
852 851
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
853 852
 				// --> if a later alarm is returned, user probably modifed an existing alarm
854
-				foreach((array)$event['alarm'] as $key => $alarm)
853
+				foreach ((array)$event['alarm'] as $key => $alarm)
855 854
 				{
856
-					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
855
+					if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder)
857 856
 					{
858 857
 						unset($event['alarm'][$key]);
859 858
 					}
860 859
 				}
861 860
 				$event['alarm'][] = $alarm = array(
862 861
 					'owner' => $account,
863
-					'offset' => 60*$message->reminder,
862
+					'offset' => 60 * $message->reminder,
864 863
 				);
865 864
 			}
866 865
 		}
@@ -934,7 +933,7 @@  discard block
 block discarded – undo
934 933
 	 */
935 934
 	public function DeleteMessage($folderid, $id, $contentParameters)
936 935
 	{
937
-		unset($contentParameters);	// not used, but required by function signature
936
+		unset($contentParameters); // not used, but required by function signature
938 937
 
939 938
 		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
940 939
 
@@ -962,7 +961,7 @@  discard block
 block discarded – undo
962 961
 	 */
963 962
 	function SetReadFlag($folderid, $id, $flags, $contentParameters)
964 963
 	{
965
-		unset($contentParameters);	// not used, but required by function signature
964
+		unset($contentParameters); // not used, but required by function signature
966 965
 
967 966
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, ".array2string($flags)." NOT supported!");
968 967
 		return false;
@@ -1013,17 +1012,17 @@  discard block
 block discarded – undo
1013 1012
 		}
1014 1013
 		else
1015 1014
 		{
1016
-			list($id,$recur_date) = explode(':',$id);
1017
-			if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account)))
1015
+			list($id, $recur_date) = explode(':', $id);
1016
+			if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account)))
1018 1017
 			{
1019 1018
 				error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false");
1020 1019
 				return false;
1021 1020
 			}
1022 1021
 		}
1023
-		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence']));
1024
-		foreach((array)$event['recur_exception'] as $ex)
1022
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence']));
1023
+		foreach ((array)$event['recur_exception'] as $ex)
1025 1024
 		{
1026
-			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s',$ex));
1025
+			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s', $ex));
1027 1026
 		}
1028 1027
 		$message = new SyncAppointment();
1029 1028
 
@@ -1032,13 +1031,13 @@  discard block
 block discarded – undo
1032 1031
 			$as_tz = self::tz2as($event['tzid']);
1033 1032
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
1034 1033
 		}
1035
-		catch(Exception $e) {
1034
+		catch (Exception $e) {
1036 1035
 			unset($e);
1037 1036
 			// ignore exception, simply set no timezone, as it is optional
1038 1037
 		}
1039 1038
 
1040 1039
 		// copying timestamps (they are already read in servertime, so non tz conversation)
1041
-		foreach(array(
1040
+		foreach (array(
1042 1041
 			'start' => 'starttime',
1043 1042
 			'end'   => 'endtime',
1044 1043
 			'created' => 'dtstamp',
@@ -1049,10 +1048,10 @@  discard block
 block discarded – undo
1049 1048
 		}
1050 1049
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1051 1050
 		{
1052
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
1051
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
1053 1052
 		}
1054 1053
 		// copying strings
1055
-		foreach(array(
1054
+		foreach (array(
1056 1055
 			'title' => 'subject',
1057 1056
 			'uid'   => 'uid',
1058 1057
 			'location' => 'location',
@@ -1074,22 +1073,22 @@  discard block
 block discarded – undo
1074 1073
 			{
1075 1074
 				ZLog::Write(LOGLEVEL_DEBUG, "airsyncbasebody!");
1076 1075
 				$message->asbody = new SyncBaseBody();
1077
-				$message->nativebodytype=1;
1076
+				$message->nativebodytype = 1;
1078 1077
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->asbody);
1079 1078
 			}
1080 1079
 		}
1081 1080
 		$message->md5body = md5($event['description']);
1082 1081
 
1083
-		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname');
1084
-		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
1082
+		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname');
1083
+		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
1085 1084
 
1086
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
1085
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
1087 1086
 
1088 1087
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
1089 1088
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
1090 1089
 
1091 1090
 		$message->attendees = array();
1092
-		foreach($event['participants'] as $uid => $status)
1091
+		foreach ($event['participants'] as $uid => $status)
1093 1092
 		{
1094 1093
 			// AS does NOT want calendar owner as participant
1095 1094
 			if ($uid == $account) continue;
@@ -1101,19 +1100,19 @@  discard block
 block discarded – undo
1101 1100
 			$attendee->attendeetype = (int)self::$role2as[$role];
1102 1101
 			if (is_numeric($uid))
1103 1102
 			{
1104
-				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname');
1105
-				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid,'account_email');
1103
+				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname');
1104
+				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email');
1106 1105
 			}
1107 1106
 			else
1108 1107
 			{
1109 1108
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1110
-					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1109
+					ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false);
1111 1110
 
1112 1111
 				if (!$info) continue;
1113 1112
 
1114 1113
 				if (!$info['email'] && $info['responsible'])
1115 1114
 				{
1116
-					$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1115
+					$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1117 1116
 				}
1118 1117
 				$attendee->name = empty($info['cn']) ? $info['name'] : $info['cn'];
1119 1118
 				$attendee->email = $info['email'];
@@ -1125,7 +1124,7 @@  discard block
 block discarded – undo
1125 1124
 					$message->organizeremail = $attendee->email;
1126 1125
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1127 1126
 				}
1128
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1127
+				if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource
1129 1128
 			}
1130 1129
 			// email must NOT be empty, but MAY be an arbitrary text
1131 1130
 			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
@@ -1133,7 +1132,7 @@  discard block
 block discarded – undo
1133 1132
 			$message->attendees[] = $attendee;
1134 1133
 		}
1135 1134
 		$message->categories = array();
1136
-		foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id)
1135
+		foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id)
1137 1136
 		{
1138 1137
 			$message->categories[] = Api\Categories::id2name($cat_id);
1139 1138
 		}
@@ -1142,25 +1141,25 @@  discard block
 block discarded – undo
1142 1141
 		if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date)
1143 1142
 		{
1144 1143
 			$message->recurrence = $recurrence = new SyncRecurrence();
1145
-			$rrule = calendar_rrule::event2rrule($event,false);	// false = timestamps in $event are servertime
1144
+			$rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime
1146 1145
 			$recurrence->type = (int)self::$recur_type2as[$rrule->type];
1147 1146
 			$recurrence->interval = $rrule->interval;
1148 1147
 			switch ($rrule->type)
1149 1148
 			{
1150 1149
 				case calendar_rrule::MONTHLY_WDAY:
1151 1150
 					$recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ?
1152
-						$rrule->monthly_byday_num : 5;	// 1..5=last week of month, not -1
1151
+						$rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1
1153 1152
 					// fall throught
1154 1153
 				case calendar_rrule::WEEKLY:
1155
-					$recurrence->dayofweek = $rrule->weekdays;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1154
+					$recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1156 1155
 					break;
1157 1156
 				case calendar_rrule::MONTHLY_MDAY:
1158
-					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ?	// 1..31
1159
-						$rrule->monthly_bymonthday : 31;	// not -1 for last day of month!
1157
+					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31
1158
+						$rrule->monthly_bymonthday : 31; // not -1 for last day of month!
1160 1159
 					break;
1161 1160
 				case calendar_rrule::YEARLY:
1162
-					$recurrence->dayofmonth = (int)$rrule->time->format('d');	// 1..31
1163
-					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1161
+					$recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31
1162
+					$recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12
1164 1163
 					break;
1165 1164
 			}
1166 1165
 			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
@@ -1176,9 +1175,9 @@  discard block
 block discarded – undo
1176 1175
 				// search real / non-virtual exceptions
1177 1176
 				if (!empty($event['uid']))
1178 1177
 				{
1179
-					$ex_events =& $this->calendar->search(array(
1178
+					$ex_events = & $this->calendar->search(array(
1180 1179
 						'query' => array('cal_uid' => $event['uid']),
1181
-						'filter' => 'owner',  // return all possible entries
1180
+						'filter' => 'owner', // return all possible entries
1182 1181
 						'daywise' => false,
1183 1182
 						'date_format' => 'server',
1184 1183
 					));
@@ -1187,36 +1186,36 @@  discard block
 block discarded – undo
1187 1186
 				{
1188 1187
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1189 1188
 				}
1190
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1189
+				if (count($ex_events) >= 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1191 1190
 
1192 1191
 				$message->exceptions = array();
1193
-				foreach($ex_events as $ex_event)
1192
+				foreach ($ex_events as $ex_event)
1194 1193
 				{
1195
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1194
+					if ($ex_event['id'] == $event['id']) continue; // ignore series master
1196 1195
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters);
1197 1196
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1198
-					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
1197
+					foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported)
1199 1198
 					{
1200
-						$exception->$not_supported = null;	// not allowed in exceptions :-(
1199
+						$exception->$not_supported = null; // not allowed in exceptions :-(
1201 1200
 					}
1202 1201
 					$exception->deleted = 0;
1203
-					if (($key = array_search($exception_time,$event['recur_exception'])) !== false)
1202
+					if (($key = array_search($exception_time, $event['recur_exception'])) !== false)
1204 1203
 					{
1205 1204
 						unset($event['recur_exception'][$key]);
1206 1205
 					}
1207
-					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1206
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1208 1207
 					$message->exceptions[] = $exception;
1209 1208
 				}
1210 1209
 				// add rest of exceptions as deleted
1211
-				foreach($event['recur_exception'] as $exception_time)
1210
+				foreach ($event['recur_exception'] as $exception_time)
1212 1211
 				{
1213 1212
 					if (!empty($exception_time))
1214 1213
 					{
1215 1214
 						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1216
-						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1215
+						$exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required
1217 1216
 						$exception->deleted = 1;
1218 1217
 						$exception->exceptionstarttime = $exception_time;
1219
-						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1218
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1220 1219
 						$message->exceptions[] = $exception;
1221 1220
 					}
1222 1221
 				}
@@ -1238,12 +1237,12 @@  discard block
 block discarded – undo
1238 1237
 		// only return alarms if in own calendar
1239 1238
 		if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm'])
1240 1239
 		{
1241
-			foreach($event['alarm'] as $alarm)
1240
+			foreach ($event['alarm'] as $alarm)
1242 1241
 			{
1243 1242
 				if ($alarm['all'] || $alarm['owner'] == $account)
1244 1243
 				{
1245
-					$message->reminder = $alarm['offset']/60;	// is in minutes, not seconds as in EGw
1246
-					break;	// AS supports only one alarm! (we use the next/earliest one)
1244
+					$message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw
1245
+					break; // AS supports only one alarm! (we use the next/earliest one)
1247 1246
 				}
1248 1247
 			}
1249 1248
 		}
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
 	 */
1267 1266
 	public function StatMessage($folderid, $id)
1268 1267
 	{
1269
-		unset($folderid);	// not used ($id is unique), but required by function signature
1268
+		unset($folderid); // not used ($id is unique), but required by function signature
1270 1269
 
1271 1270
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1272 1271
 
@@ -1277,7 +1276,7 @@  discard block
 block discarded – undo
1277 1276
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1278 1277
 			$backup = $this->calendar->debug;
1279 1278
 			//$this->calendar->debug = 2;
1280
-			list($id) = explode(':',$id);
1279
+			list($id) = explode(':', $id);
1281 1280
 			$this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server');
1282 1281
 			$this->calendar->debug = $backup;
1283 1282
 		}
@@ -1311,7 +1310,7 @@  discard block
 block discarded – undo
1311 1310
 
1312 1311
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1313 1312
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1314
-		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1313
+		$syncstate = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too
1315 1314
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1316 1315
 		if ($syncstate == 0) $syncstate = 1;
1317 1316
 
@@ -1384,8 +1383,8 @@  discard block
 block discarded – undo
1384 1383
 			'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0,
1385 1384
 		);
1386 1385
 
1387
-		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1388
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1386
+		$name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz;
1387
+		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component');
1389 1388
 		// parse ical timezone defintion
1390 1389
 		$ical = self::ical2array($component);
1391 1390
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1394,11 +1393,11 @@  discard block
 block discarded – undo
1394 1393
 		if (!isset($standard))
1395 1394
 		{
1396 1395
 			$matches = null;
1397
-			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches))
1396
+			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches))
1398 1397
 			{
1399 1398
 				$standard = array(
1400
-					'TZOFFSETTO'   => sprintf('%s%02d00',$matches[1],$matches[2]),
1401
-					'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]),
1399
+					'TZOFFSETTO'   => sprintf('%s%02d00', $matches[1], $matches[2]),
1400
+					'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]),
1402 1401
 				);
1403 1402
 				unset($daylight);
1404 1403
 			}
@@ -1409,15 +1408,15 @@  discard block
 block discarded – undo
1409 1408
 		}
1410 1409
 		// get bias and dstbias from standard component, which is present in all tz's
1411 1410
 		// (dstbias is relative to bias and almost always 60 or 0)
1412
-		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2));
1413
-		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']);
1411
+		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2));
1412
+		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']);
1414 1413
 
1415 1414
 		// check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving
1416 1415
 		if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE']))
1417 1416
 		{
1418
-			foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp)
1417
+			foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp)
1419 1418
 			{
1420
-				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches))
1419
+				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches))
1421 1420
 				{
1422 1421
 					$data[$prefix.'month'] = (int)$matches[2];
1423 1422
 					$data[$prefix.'week'] = (int)$matches[1];
@@ -1434,20 +1433,20 @@  discard block
 block discarded – undo
1434 1433
 						$data[$prefix.'week'] = 5;
1435 1434
 						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1436 1435
 					}
1437
-					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1438
-					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
1436
+					static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6);
1437
+					$data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)];
1439 1438
 				}
1440
-				if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches))
1439
+				if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches))
1441 1440
 				{
1442
-					$data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60;
1443
-					$data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60;
1444
-					$data[$prefix.'second'] = (int)substr($matches[1],4,2);
1441
+					$data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60;
1442
+					$data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60;
1443
+					$data[$prefix.'second'] = (int)substr($matches[1], 4, 2);
1445 1444
 				}
1446 1445
 			}
1447 1446
 			// for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute
1448 1447
 			if ($data['dststartmonth'] > $data['dstendmonth'])
1449 1448
 			{
1450
-				$start = $data['dststarthour'];   $data['dststarthour'] = $data['dstendhour'];     $data['dstendhour'] = $start;
1449
+				$start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start;
1451 1450
 				$end = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $end;
1452 1451
 			}
1453 1452
 		}
@@ -1505,20 +1504,20 @@  discard block
 block discarded – undo
1505 1504
 	 * @param string|array $ical lines of ical file
1506 1505
 	 * @return array with parsed ical components
1507 1506
 	 */
1508
-	static public function ical2array(&$ical,$section=null)
1507
+	static public function ical2array(&$ical, $section = null)
1509 1508
 	{
1510 1509
 		$arr = array();
1511 1510
 		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1512 1511
 		while (($line = array_shift($ical)))
1513 1512
 		{
1514
-			list($name,$value) = explode(':',$line,2);
1513
+			list($name, $value) = explode(':', $line, 2);
1515 1514
 			if ($name == 'BEGIN')
1516 1515
 			{
1517
-				$arr[$value] = self::ical2array($ical,$value);
1516
+				$arr[$value] = self::ical2array($ical, $value);
1518 1517
 			}
1519
-			elseif($name == 'END')
1518
+			elseif ($name == 'END')
1520 1519
 			{
1521
-				if ($section && $section==$value) return $arr;
1520
+				if ($section && $section == $value) return $arr;
1522 1521
 				break;
1523 1522
 			}
1524 1523
 			else
@@ -1541,13 +1540,13 @@  discard block
 block discarded – undo
1541 1540
 	 */
1542 1541
 	public static function as2tz(array $data)
1543 1542
 	{
1544
-		static $cache=null;	// some caching withing the request
1543
+		static $cache = null; // some caching withing the request
1545 1544
 
1546
-		unset($data['name']);	// not used, but can stall the match
1545
+		unset($data['name']); // not used, but can stall the match
1547 1546
 
1548 1547
 		$key = serialize($data);
1549 1548
 
1550
-		for($n = 0; !isset($cache[$key]); ++$n)
1549
+		for ($n = 0; !isset($cache[$key]); ++$n)
1551 1550
 		{
1552 1551
 			if (!$n)	// check users timezone first
1553 1552
 			{
@@ -1566,7 +1565,7 @@  discard block
 block discarded – undo
1566 1565
 					break;
1567 1566
 				}
1568 1567
 			}
1569
-			catch(Exception $e) {
1568
+			catch (Exception $e) {
1570 1569
 				unset($e);
1571 1570
 				// simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component
1572 1571
 			}
@@ -1581,8 +1580,8 @@  discard block
 block discarded – undo
1581 1580
 	 */
1582 1581
 	static public function _getTZFromSyncBlob($data)
1583 1582
 	{
1584
-		$tz = unpack(	"lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" .
1585
-						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" .
1583
+		$tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/".
1584
+						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/".
1586 1585
 						"ldstbias", $data);
1587 1586
 
1588 1587
 		return $tz;
@@ -1595,7 +1594,7 @@  discard block
 block discarded – undo
1595 1594
 	 */
1596 1595
 	static public function _getSyncBlobFromTZ($tz)
1597 1596
 	{
1598
-		$packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l",
1597
+		$packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l",
1599 1598
 				$tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"],
1600 1599
 				$tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"],
1601 1600
 				$tz["dstbias"]);
@@ -1619,7 +1618,7 @@  discard block
 block discarded – undo
1619 1618
 				$account_id = $entry['grantor'];
1620 1619
 				$cals[$account_id] = $entry['name'];
1621 1620
 			}
1622
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1621
+			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user
1623 1622
 		}
1624 1623
 		$cals['G'] = lang('Primary group');
1625 1624
 		$cals['A'] = lang('All');
@@ -1655,8 +1654,8 @@  discard block
 block discarded – undo
1655 1654
 		)
1656 1655
 	);
1657 1656
 	require_once('../../header.inc.php');
1658
-	ini_set('display_errors',1);
1659
-	error_reporting(E_ALL & ~E_NOTICE);
1657
+	ini_set('display_errors', 1);
1658
+	error_reporting(E_ALL&~E_NOTICE);
1660 1659
 
1661 1660
 	echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n";
1662 1661
 	echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\n";
@@ -1670,7 +1669,7 @@  discard block
 block discarded – undo
1670 1669
 	</script>\n";
1671 1670
 
1672 1671
 	// TZID => AS timezone blobs reported by various devices
1673
-	foreach(array(
1672
+	foreach (array(
1674 1673
 		'Europe/Berlin'    => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==',
1675 1674
 		'Europe/Helsinki'  => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==',
1676 1675
 		'Asia/Tokyo'       => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==',
@@ -1683,9 +1682,9 @@  discard block
 block discarded – undo
1683 1682
 	) as $tz => $sync_blob)
1684 1683
 	{
1685 1684
 		// get as timezone data for a given timezone
1686
-		$ical = calendar_timezones::tz2id($tz,'component');
1685
+		$ical = calendar_timezones::tz2id($tz, 'component');
1687 1686
 		//echo "<pre>".print_r($ical,true)."</pre>\n";
1688
-		$ical_arr = calendar_zpush::ical2array($ical_tz=$ical);
1687
+		$ical_arr = calendar_zpush::ical2array($ical_tz = $ical);
1689 1688
 		//echo "<pre>".print_r($ical_arr,true)."</pre>\n";
1690 1689
 		$as_tz = calendar_zpush::tz2as($tz);
1691 1690
 		//echo "$tz=<pre>".print_r($as_tz,true)."</pre>\n";
@@ -1699,22 +1698,22 @@  discard block
 block discarded – undo
1699 1698
 		//echo array2string($matched);
1700 1699
 
1701 1700
 		echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n";
1702
-		foreach(array('dststart','dstend') as $prefix)
1701
+		foreach (array('dststart', 'dstend') as $prefix)
1703 1702
 		{
1704 1703
 			echo "<td>\n";
1705
-			foreach(array($as_tz_org,$as_tz) as $n => $arr)
1704
+			foreach (array($as_tz_org, $as_tz) as $n => $arr)
1706 1705
 			{
1707 1706
 				$parts = array();
1708
-				foreach(array('year','month','day','week','hour','minute','second') as $postfix)
1707
+				foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix)
1709 1708
 				{
1710 1709
 					$failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix];
1711
-					$parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':'');
1710
+					$parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : '');
1712 1711
 				}
1713
-				echo implode(' ', $parts).(!$n?'<br/>':'');
1712
+				echo implode(' ', $parts).(!$n ? '<br/>' : '');
1714 1713
 			}
1715 1714
 			echo "</td>\n";
1716 1715
 		}
1717
-		echo "<td>&nbsp;<br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n";
1716
+		echo "<td>&nbsp;<br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n";
1718 1717
 	}
1719 1718
 	echo "</tbody></table>\n";
1720 1719
 	echo "</body></html>\n";
Please login to merge, or discard this patch.
Braces   +223 added lines, -54 removed lines patch added patch discarded remove patch
@@ -20,8 +20,12 @@  discard block
 block discarded – undo
20 20
  */
21 21
 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
22 22
 {
23
-	interface activesync_plugin_write {}
24
-	interface activesync_plugin_meeting_requests {}
23
+	interface activesync_plugin_write
24
+	{
25
+}
26
+	interface activesync_plugin_meeting_requests
27
+	{
28
+}
25 29
 }
26 30
 
27 31
 /**
@@ -81,7 +85,10 @@  discard block
 block discarded – undo
81 85
 	 */
82 86
 	public function GetFolderList()
83 87
 	{
84
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
88
+		if (!isset($this->calendar))
89
+		{
90
+			$this->calendar = new calendar_boupdate();
91
+		}
85 92
 
86 93
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
87 94
 		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
@@ -180,13 +187,20 @@  discard block
 block discarded – undo
180 187
   	 */
181 188
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 189
 	{
183
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
190
+		if (!isset($this->calendar))
191
+		{
192
+			$this->calendar = new calendar_boupdate();
193
+		}
184 194
 
185 195
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
186 196
 		$type = $user = null;
187 197
 		$this->backend->splitID($id,$type,$user);
188 198
 
189
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
199
+		if (!$cutoffdate)
200
+		{
201
+			$cutoffdate = $this->bo->now - 100*24*3600;
202
+		}
203
+		// default three month back -30 breaks all sync recurrences
190 204
 
191 205
 		$filter = array(
192 206
 			'users' => $user,
@@ -205,7 +219,10 @@  discard block
 block discarded – undo
205 219
 		$messagelist = array();
206 220
 		foreach ($this->calendar->search($filter) as $event)
207 221
 		{
208
-			if ($not_uids && in_array($event['uid'], $not_uids)) continue;
222
+			if ($not_uids && in_array($event['uid'], $not_uids))
223
+			{
224
+				continue;
225
+			}
209 226
 			$messagelist[] = $this->StatMessage($id, $event);
210 227
 
211 228
 			// add virtual exceptions for recuring events too
@@ -279,7 +296,10 @@  discard block
 block discarded – undo
279 296
 	{
280 297
 		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
281 298
 
282
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
299
+		if (!isset($this->calendar))
300
+		{
301
+			$this->calendar = new calendar_boupdate();
302
+		}
283 303
 
284 304
 		if (!($event = $this->calendar->read(abs($id), 0, false, 'server')))
285 305
 		{
@@ -357,7 +377,10 @@  discard block
 block discarded – undo
357 377
 			'created' => 'dtstamp',
358 378
 		) as $key => $attr)
359 379
 		{
360
-			if (!empty($event[$key])) $message->$attr = $event[$key];
380
+			if (!empty($event[$key]))
381
+			{
382
+				$message->$attr = $event[$key];
383
+			}
361 384
 		}
362 385
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
363 386
 		{
@@ -369,7 +392,10 @@  discard block
 block discarded – undo
369 392
 			'location' => 'location',
370 393
 		) as $key => $attr)
371 394
 		{
372
-			if (!empty($event[$key])) $message->$attr = $event[$key];
395
+			if (!empty($event[$key]))
396
+			{
397
+				$message->$attr = $event[$key];
398
+			}
373 399
 		}
374 400
 		$message->organizer = $event['organizer'];
375 401
 
@@ -404,7 +430,10 @@  discard block
 block discarded – undo
404 430
 	 */
405 431
 	function MeetingResponse($folderid, $requestid, $response)
406 432
 	{
407
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
433
+		if (!isset($this->calendar))
434
+		{
435
+			$this->calendar = new calendar_boupdate();
436
+		}
408 437
 
409 438
 		static $as2status = array(	// different from self::$status2as!
410 439
 			1 => 'A',
@@ -414,9 +443,12 @@  discard block
 block discarded – undo
414 443
 		$status_in = isset($as2status[$response]) ? $as2status[$response] : 'U';
415 444
 		$uid = $GLOBALS['egw_info']['user']['account_id'];
416 445
 
417
-		if (!is_numeric($requestid))	// iCal from fmail
446
+		if (!is_numeric($requestid))
447
+		{
448
+			// iCal from fmail
418 449
 		{
419 450
 			$ical = new calendar_ical();
451
+		}
420 452
 			if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1)
421 453
 			{
422 454
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!");
@@ -526,7 +558,10 @@  discard block
 block discarded – undo
526 558
 	{
527 559
 		unset($contentParameters);	// unused, but required by function signature
528 560
 
529
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
561
+		if (!isset($this->calendar))
562
+		{
563
+			$this->calendar = new calendar_boupdate();
564
+		}
530 565
 
531 566
 		$old_event = array();
532 567
 		$type = $account = null;
@@ -541,10 +576,13 @@  discard block
 block discarded – undo
541 576
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing");
542 577
 			return false;
543 578
 		}
544
-		if ($recur_date)	// virtual exception
579
+		if ($recur_date)
580
+		{
581
+			// virtual exception
545 582
 		{
546 583
 			// @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed
547 584
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
585
+		}
548 586
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
549 587
 		}
550 588
 		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
@@ -554,7 +592,11 @@  discard block
 block discarded – undo
554 592
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
555 593
 			return false;
556 594
 		}
557
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
595
+		if (!$id)
596
+		{
597
+			$old_event['owner'] = $account;
598
+		}
599
+		// we do NOT allow to change the owner of existing events
558 600
 
559 601
 		$event = $this->message2event($message, $account, $old_event);
560 602
 
@@ -583,7 +625,10 @@  discard block
 block discarded – undo
583 625
 					unset($ex_event['etag']);
584 626
 					foreach(array_keys($ex_event) as $name)
585 627
 					{
586
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
628
+						if (substr($name,0,6) == 'recur_')
629
+						{
630
+							unset($ex_event[$name]);
631
+						}
587 632
 					}
588 633
 					$ex_event['recur_type'] = calendar_rrule::NONE;
589 634
 
@@ -636,7 +681,10 @@  discard block
 block discarded – undo
636 681
 			'end' => 'endtime',
637 682
 		) as $key => $attr)
638 683
 		{
639
-			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
684
+			if (isset($message->$attr))
685
+			{
686
+				$event[$key] = Api\DateTime::server2user($message->$attr);
687
+			}
640 688
 		}
641 689
 		// copying strings
642 690
 		foreach(array(
@@ -645,7 +693,10 @@  discard block
 block discarded – undo
645 693
 			'location' => 'location',
646 694
 		) as $key => $attr)
647 695
 		{
648
-			if (isset($message->$attr)) $event[$key] = $message->$attr;
696
+			if (isset($message->$attr))
697
+			{
698
+				$event[$key] = $message->$attr;
699
+			}
649 700
 		}
650 701
 
651 702
 		// only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse
@@ -664,14 +715,22 @@  discard block
 block discarded – undo
664 715
 
665 716
 		if (($event['whole_day'] = $message->alldayevent))
666 717
 		{
667
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
718
+			if ($event['end'] == $event['start'])
719
+			{
720
+				$event['end'] += 24*3600;
721
+			}
722
+			// some clients send equal start&end for 1day
668 723
 			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
669 724
 		}
670 725
 
671 726
 		$participants = array();
672 727
 		foreach((array)$message->attendees as $attendee)
673 728
 		{
674
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
729
+			if ($attendee->type == 3)
730
+			{
731
+				continue;
732
+			}
733
+			// we can not identify resources and re-add them anyway later
675 734
 
676 735
 			$matches = null;
677 736
 			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
@@ -686,7 +745,10 @@  discard block
 block discarded – undo
686 745
 					//'n_fn' => $attendee->name,	// not sure if we want matches without email
687 746
 				);
688 747
 				// search addressbook for participant
689
-				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
748
+				if (!isset($this->addressbook))
749
+				{
750
+					$this->addressbook = new Api\Contacts();
751
+				}
690 752
 				if ((list($data) = $this->addressbook->search($search,
691 753
 					array('id','egw_addressbook.account_id as account_id','n_fn'),
692 754
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
@@ -694,10 +756,13 @@  discard block
 block discarded – undo
694 756
 				{
695 757
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
696 758
 				}
697
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
759
+				elseif($attendee->name === $attendee->email || empty($attendee->name))
760
+				{
761
+					// dont store empty or email as name
698 762
 				{
699 763
 					$uid = 'e'.$attendee->email;
700 764
 				}
765
+				}
701 766
 				else	// store just the email
702 767
 				{
703 768
 					$uid = 'e'.$attendee->name.' <'.$attendee->email.'>';
@@ -726,7 +791,11 @@  discard block
 block discarded – undo
726 791
 				$role = 'REQ-PARTICIPANT';
727 792
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
728 793
 			}
729
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
794
+			if ($role == 'CHAIR')
795
+			{
796
+				$chair_set = true;
797
+			}
798
+			// by role from existing participant
730 799
 
731 800
 			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
732 801
 			{
@@ -740,10 +809,13 @@  discard block
 block discarded – undo
740 809
 			elseif (isset($attendee->attendeetype) &&
741 810
 				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
742 811
 				($r = array_search($attendee->attendeetype,self::$role2as)) &&
743
-				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
812
+				(int)self::$role2as[$role] != $attendee->attendeetype)
813
+			{
814
+				// if old role gives same type, use old role, as we have a lot more roles then AS
744 815
 			{
745 816
 				$role = $r;
746 817
 			}
818
+			}
747 819
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
748 820
 			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
749 821
 		}
@@ -758,12 +830,19 @@  discard block
 block discarded – undo
758 830
 		// $account is also preserved, as AS does not add him as participant!
759 831
 		foreach((array)$event['participant_types'] as $type => $parts)
760 832
 		{
761
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
833
+			if (in_array($type,array('c','e')))
834
+			{
835
+				continue;
836
+			}
837
+			// they are correctly representable in AS
762 838
 
763 839
 			foreach($parts as $id => $status)
764 840
 			{
765 841
 				// accounts are represented correctly, but the event owner which is no participant in AS
766
-				if ($type == 'u' && $id != $account) continue;
842
+				if ($type == 'u' && $id != $account)
843
+				{
844
+					continue;
845
+				}
767 846
 
768 847
 				$uid = calendar_so::combine_user($type, $id);
769 848
 				if (!isset($participants[$uid]))
@@ -788,10 +867,13 @@  discard block
 block discarded – undo
788 867
 		// check if event is recurring and import recur information (incl. timezone)
789 868
 		if ($message->recurrence)
790 869
 		{
791
-			if ($message->timezone && !$event['id'])	// dont care for timezone, if no new and recurring event
870
+			if ($message->timezone && !$event['id'])
871
+			{
872
+				// dont care for timezone, if no new and recurring event
792 873
 			{
793 874
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
794 875
 			}
876
+			}
795 877
 			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
796 878
 				array_search($message->recurrence->type, self::$recur_type2as);
797 879
 			$event['recur_interval'] = $message->recurrence->interval;
@@ -828,10 +910,13 @@  discard block
 block discarded – undo
828 910
 			{
829 911
 				// calculate enddate from occurences count, as we only support enddate
830 912
 				$count = $message->recurrence->occurrences;
831
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
913
+				foreach(calendar_rrule::event2rrule($event, true) as $rtime)
914
+				{
915
+					// true = timestamps are user time here, because of save!
832 916
 				{
833 917
 					if (--$count <= 0) break;
834 918
 				}
919
+				}
835 920
 				$event['recur_enddate'] = $rtime->format('ts');
836 921
 			}
837 922
 		}
@@ -846,7 +931,9 @@  discard block
 block discarded – undo
846 931
 					break;
847 932
 				}
848 933
 			}
849
-			if ($alarm !== true)	// new alarm
934
+			if ($alarm !== true)
935
+			{
936
+				// new alarm
850 937
 			{
851 938
 				// delete all earlier alarms of that user
852 939
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
@@ -856,6 +943,7 @@  discard block
 block discarded – undo
856 943
 					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
857 944
 					{
858 945
 						unset($event['alarm'][$key]);
946
+			}
859 947
 					}
860 948
 				}
861 949
 				$event['alarm'][] = $alarm = array(
@@ -936,7 +1024,10 @@  discard block
 block discarded – undo
936 1024
 	{
937 1025
 		unset($contentParameters);	// not used, but required by function signature
938 1026
 
939
-		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
1027
+		if (!isset($this->caledar))
1028
+		{
1029
+			$this->calendar = new calendar_boupdate();
1030
+		}
940 1031
 
941 1032
 		$ret = $this->calendar->delete($id);
942 1033
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -997,7 +1088,10 @@  discard block
 block discarded – undo
997 1088
 	 */
998 1089
 	public function GetMessage($folderid, $id, $contentparameters)
999 1090
 	{
1000
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1091
+		if (!isset($this->calendar))
1092
+		{
1093
+			$this->calendar = new calendar_boupdate();
1094
+		}
1001 1095
 		//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace());
1002 1096
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
1003 1097
 		$mimesupport = $contentparameters->GetMimeSupport();
@@ -1045,7 +1139,10 @@  discard block
 block discarded – undo
1045 1139
 			'modified' => 'dtstamp',
1046 1140
 		) as $key => $attr)
1047 1141
 		{
1048
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1142
+			if (!empty($event[$key]))
1143
+			{
1144
+				$message->$attr = $event[$key];
1145
+			}
1049 1146
 		}
1050 1147
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1051 1148
 		{
@@ -1058,7 +1155,10 @@  discard block
 block discarded – undo
1058 1155
 			'location' => 'location',
1059 1156
 		) as $key => $attr)
1060 1157
 		{
1061
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1158
+			if (!empty($event[$key]))
1159
+			{
1160
+				$message->$attr = $event[$key];
1161
+			}
1062 1162
 		}
1063 1163
 
1064 1164
 		// appoint description
@@ -1092,7 +1192,10 @@  discard block
 block discarded – undo
1092 1192
 		foreach($event['participants'] as $uid => $status)
1093 1193
 		{
1094 1194
 			// AS does NOT want calendar owner as participant
1095
-			if ($uid == $account) continue;
1195
+			if ($uid == $account)
1196
+			{
1197
+				continue;
1198
+			}
1096 1199
 			$quantity = $role = null;
1097 1200
 			calendar_so::split_status($status, $quantity, $role);
1098 1201
 
@@ -1109,7 +1212,10 @@  discard block
 block discarded – undo
1109 1212
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1110 1213
 					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1111 1214
 
1112
-				if (!$info) continue;
1215
+				if (!$info)
1216
+				{
1217
+					continue;
1218
+				}
1113 1219
 
1114 1220
 				if (!$info['email'] && $info['responsible'])
1115 1221
 				{
@@ -1125,10 +1231,17 @@  discard block
 block discarded – undo
1125 1231
 					$message->organizeremail = $attendee->email;
1126 1232
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1127 1233
 				}
1128
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1234
+				if ($uid[0] == 'r')
1235
+				{
1236
+					$attendee->type = 3;
1237
+				}
1238
+				// 3 = resource
1129 1239
 			}
1130 1240
 			// email must NOT be empty, but MAY be an arbitrary text
1131
-			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
1241
+			if (empty($attendee->email))
1242
+			{
1243
+				$attendee->email = 'noreply-'.$uid.'[email protected]';
1244
+			}
1132 1245
 
1133 1246
 			$message->attendees[] = $attendee;
1134 1247
 		}
@@ -1163,9 +1276,12 @@  discard block
 block discarded – undo
1163 1276
 					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1164 1277
 					break;
1165 1278
 			}
1166
-			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
1279
+			if ($rrule->enddate)
1280
+			{
1281
+				// enddate is only a date, but AS needs a time incl. correct starttime!
1167 1282
 			{
1168 1283
 				$enddate = clone $rrule->time;
1284
+			}
1169 1285
 				$enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'),
1170 1286
 					$rrule->enddate->format('d'));
1171 1287
 				$recurrence->until = $enddate->format('server');
@@ -1187,12 +1303,19 @@  discard block
 block discarded – undo
1187 1303
 				{
1188 1304
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1189 1305
 				}
1190
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1306
+				if (count($ex_events)>=1)
1307
+				{
1308
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1309
+				}
1191 1310
 
1192 1311
 				$message->exceptions = array();
1193 1312
 				foreach($ex_events as $ex_event)
1194 1313
 				{
1195
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1314
+					if ($ex_event['id'] == $event['id'])
1315
+					{
1316
+						continue;
1317
+					}
1318
+					// ignore series master
1196 1319
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters);
1197 1320
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1198 1321
 					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
@@ -1212,7 +1335,10 @@  discard block
 block discarded – undo
1212 1335
 				{
1213 1336
 					if (!empty($exception_time))
1214 1337
 					{
1215
-						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1338
+						if (empty($event['uid']))
1339
+						{
1340
+							ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1341
+						}
1216 1342
 						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1217 1343
 						$exception->deleted = 1;
1218 1344
 						$exception->exceptionstarttime = $exception_time;
@@ -1268,12 +1394,18 @@  discard block
 block discarded – undo
1268 1394
 	{
1269 1395
 		unset($folderid);	// not used ($id is unique), but required by function signature
1270 1396
 
1271
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1397
+		if (!isset($this->calendar))
1398
+		{
1399
+			$this->calendar = new calendar_boupdate();
1400
+		}
1272 1401
 
1273 1402
 		$nul = null;
1274
-		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))	// last true: $only_master=true
1403
+		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))
1404
+		{
1405
+			// last true: $only_master=true
1275 1406
 		{
1276 1407
 			$stat = false;
1408
+		}
1277 1409
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1278 1410
 			$backup = $this->calendar->debug;
1279 1411
 			//$this->calendar->debug = 2;
@@ -1307,13 +1439,22 @@  discard block
 block discarded – undo
1307 1439
 		$type = $owner = null;
1308 1440
 		$this->backend->splitID($folderid, $type, $owner);
1309 1441
 
1310
-		if ($type != 'calendar') return false;
1442
+		if ($type != 'calendar')
1443
+		{
1444
+			return false;
1445
+		}
1311 1446
 
1312
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1447
+		if (!isset($this->calendar))
1448
+		{
1449
+			$this->calendar = new calendar_boupdate();
1450
+		}
1313 1451
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1314 1452
 		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1315 1453
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1316
-		if ($syncstate == 0) $syncstate = 1;
1454
+		if ($syncstate == 0)
1455
+		{
1456
+			$syncstate = 1;
1457
+		}
1317 1458
 
1318 1459
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'");
1319 1460
 	}
@@ -1385,7 +1526,10 @@  discard block
 block discarded – undo
1385 1526
 		);
1386 1527
 
1387 1528
 		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1388
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1529
+		if (strpos($component, 'VTIMEZONE') === false)
1530
+		{
1531
+			$component = calendar_timezones::tz2id($name,'component');
1532
+		}
1389 1533
 		// parse ical timezone defintion
1390 1534
 		$ical = self::ical2array($component);
1391 1535
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1428,11 +1572,17 @@  discard block
 block discarded – undo
1428 1572
 						$data[$prefix.'week'] = 5;
1429 1573
 					}
1430 1574
 					// if both start and end use 1SU use week=5 and decrement month
1431
-					if ($prefix == 'dststart') $start_byday = $matches[1];
1575
+					if ($prefix == 'dststart')
1576
+					{
1577
+						$start_byday = $matches[1];
1578
+					}
1432 1579
 					if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU')
1433 1580
 					{
1434 1581
 						$data[$prefix.'week'] = 5;
1435
-						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1582
+						if ($prefix == 'dstend')
1583
+						{
1584
+							$data[$prefix.'month'] -= 1;
1585
+						}
1436 1586
 					}
1437 1587
 					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1438 1588
 					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
@@ -1508,7 +1658,10 @@  discard block
 block discarded – undo
1508 1658
 	static public function ical2array(&$ical,$section=null)
1509 1659
 	{
1510 1660
 		$arr = array();
1511
-		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1661
+		if (!is_array($ical))
1662
+		{
1663
+			$ical = preg_split("/[\r\n]+/m", $ical);
1664
+		}
1512 1665
 		while (($line = array_shift($ical)))
1513 1666
 		{
1514 1667
 			list($name,$value) = explode(':',$line,2);
@@ -1518,7 +1671,10 @@  discard block
 block discarded – undo
1518 1671
 			}
1519 1672
 			elseif($name == 'END')
1520 1673
 			{
1521
-				if ($section && $section==$value) return $arr;
1674
+				if ($section && $section==$value)
1675
+				{
1676
+					return $arr;
1677
+				}
1522 1678
 				break;
1523 1679
 			}
1524 1680
 			else
@@ -1549,13 +1705,19 @@  discard block
 block discarded – undo
1549 1705
 
1550 1706
 		for($n = 0; !isset($cache[$key]); ++$n)
1551 1707
 		{
1552
-			if (!$n)	// check users timezone first
1708
+			if (!$n)
1709
+			{
1710
+				// check users timezone first
1553 1711
 			{
1554 1712
 				$tz = Api\DateTime::$user_timezone->getName();
1555 1713
 			}
1556
-			elseif (!($tz = calendar_timezones::id2tz($n)))	// no further timezones to check
1714
+			}
1715
+			elseif (!($tz = calendar_timezones::id2tz($n)))
1716
+			{
1717
+				// no further timezones to check
1557 1718
 			{
1558 1719
 				$cache[$key] = 'UTC';
1720
+			}
1559 1721
 				error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!');
1560 1722
 				break;
1561 1723
 			}
@@ -1619,7 +1781,11 @@  discard block
 block discarded – undo
1619 1781
 				$account_id = $entry['grantor'];
1620 1782
 				$cals[$account_id] = $entry['name'];
1621 1783
 			}
1622
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1784
+			if ($hook_data['account_id'] > 0)
1785
+			{
1786
+				unset($cals[$hook_data['account_id']]);
1787
+			}
1788
+			// skip current user
1623 1789
 		}
1624 1790
 		$cals['G'] = lang('Primary group');
1625 1791
 		$cals['A'] = lang('All');
@@ -1647,13 +1813,16 @@  discard block
 block discarded – undo
1647 1813
  *
1648 1814
  * You need to comment implements activesync_plugin_write
1649 1815
  */
1650
-if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)	// some tests
1816
+if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
1817
+{
1818
+	// some tests
1651 1819
 {
1652 1820
 	$GLOBALS['egw_info'] = array(
1653 1821
 		'flags' => array(
1654 1822
 			'currentapp' => 'login'
1655 1823
 		)
1656 1824
 	);
1825
+}
1657 1826
 	require_once('../../header.inc.php');
1658 1827
 	ini_set('display_errors',1);
1659 1828
 	error_reporting(E_ALL & ~E_NOTICE);
Please login to merge, or discard this patch.
calendar/setup/tables_update.inc.php 5 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,10 @@  discard block
 block discarded – undo
11 11
 
12 12
 use EGroupware\Api;
13 13
 
14
+/**
15
+ * @param string $table
16
+ * @param string $field
17
+ */
14 18
 function calendar_v0_9_2to0_9_3update_owner($table, $field)
15 19
 {
16 20
 	$GLOBALS['egw_setup']->oProc->query("select distinct($field) from $table");
@@ -2306,7 +2310,7 @@  discard block
 block discarded – undo
2306 2310
  *
2307 2311
  * Also fix recurring events containing a reference to an other master, created when an exception is made a recurring event.
2308 2312
  *
2309
- * @return type
2313
+ * @return string
2310 2314
  */
2311 2315
 function calendar_upgrade14_1()
2312 2316
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1909,7 +1909,7 @@
 block discarded – undo
1909 1909
 			WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__);
1910 1910
 	}
1911 1911
 
1912
-    $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1
1912
+	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1
1913 1913
 			WHERE recur_interval=0',__LINE__,__FILE__);
1914 1914
 
1915 1915
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007';
Please login to merge, or discard this patch.
Spacing   +437 added lines, -437 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		{
21 21
 			$owner[count($owner)] = $GLOBALS['egw_setup']->oProc->f($field);
22 22
 		}
23
-		if($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'],'0.9.10pre4'))
23
+		if ($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.10pre4'))
24 24
 		{
25 25
 			$acctstbl = 'accounts';
26 26
 		}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		{
29 29
 			$acctstbl = 'phpgw_accounts';
30 30
 		}
31
-		for($i=0;$i<count($owner);$i++)
31
+		for ($i = 0; $i < count($owner); $i++)
32 32
 		{
33 33
 			$GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'");
34 34
 			$GLOBALS['egw_setup']->oProc->next_record();
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 
42 42
 function calendar_upgrade0_9_3pre1()
43 43
 {
44
-	calendar_v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by');
45
-	calendar_v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login');
44
+	calendar_v0_9_2to0_9_3update_owner('webcal_entry', 'cal_create_by');
45
+	calendar_v0_9_2to0_9_3update_owner('webcal_entry_user', 'cal_login');
46 46
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3pre2';
47 47
 	return $GLOBALS['setup_info']['calendar']['currentver'];
48 48
 }
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 		)
210 210
 	);
211 211
 
212
-	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__);
212
+	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry', __LINE__, __FILE__);
213 213
 	$GLOBALS['egw_setup']->oProc->next_record();
214
-	if($GLOBALS['egw_setup']->oProc->f(0))
214
+	if ($GLOBALS['egw_setup']->oProc->f(0))
215 215
 	{
216
-		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__);
217
-		while($GLOBALS['egw_setup']->oProc->next_record())
216
+		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id', __LINE__, __FILE__);
217
+		while ($GLOBALS['egw_setup']->oProc->next_record())
218 218
 		{
219 219
 			$cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id');
220 220
 			$cal_owner = $GLOBALS['egw_setup']->oProc->f('cal_owner');
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 			$cal_access = $GLOBALS['egw_setup']->oProc->f('cal_access');
225 225
 			$cal_name = $GLOBALS['egw_setup']->oProc->f('cal_name');
226 226
 			$cal_description = $GLOBALS['egw_setup']->oProc->f('cal_description');
227
-			$datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),0,4)));
228
-			$moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),0,4)));
229
-			$db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id,__LINE__,__FILE__);
227
+			$datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 0, 4)));
228
+			$moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 0, 4)));
229
+			$db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id, __LINE__, __FILE__);
230 230
 			$db2->next_record();
231 231
 			$cal_group = $db2->f('groups');
232 232
 			$db2->query('INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) '
233
-				.'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
233
+				.'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')", __LINE__, __FILE__);
234 234
 		}
235 235
 	}
236 236
 
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
 		)
252 252
 	);
253 253
 
254
-	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__);
254
+	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user', __LINE__, __FILE__);
255 255
 	$GLOBALS['egw_setup']->oProc->next_record();
256
-	if($GLOBALS['egw_setup']->oProc->f(0))
256
+	if ($GLOBALS['egw_setup']->oProc->f(0))
257 257
 	{
258
-		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__);
259
-		while($GLOBALS['egw_setup']->oProc->next_record())
258
+		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id', __LINE__, __FILE__);
259
+		while ($GLOBALS['egw_setup']->oProc->next_record())
260 260
 		{
261 261
 			$cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id');
262 262
 			$cal_login = $GLOBALS['egw_setup']->oProc->f('cal_login');
263 263
 			$cal_status = $GLOBALS['egw_setup']->oProc->f('cal_status');
264
-			$db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')",__LINE__,__FILE__);
264
+			$db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')", __LINE__, __FILE__);
265 265
 		}
266 266
 	}
267 267
 
@@ -284,18 +284,18 @@  discard block
 block discarded – undo
284 284
 		)
285 285
 	);
286 286
 
287
-	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__);
287
+	$GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats', __LINE__, __FILE__);
288 288
 	$GLOBALS['egw_setup']->oProc->next_record();
289
-	if($GLOBALS['egw_setup']->oProc->f(0))
289
+	if ($GLOBALS['egw_setup']->oProc->f(0))
290 290
 	{
291
-		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__);
292
-		while($GLOBALS['egw_setup']->oProc->next_record())
291
+		$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id', __LINE__, __FILE__);
292
+		while ($GLOBALS['egw_setup']->oProc->next_record())
293 293
 		{
294 294
 			$cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id');
295 295
 			$cal_type = $GLOBALS['egw_setup']->oProc->f('cal_type');
296
-			if(isset($GLOBALS['egw_setup']->oProc->Record['cal_end']))
296
+			if (isset($GLOBALS['egw_setup']->oProc->Record['cal_end']))
297 297
 			{
298
-				$enddate = mktime(0,0,0,intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),0,4)));
298
+				$enddate = mktime(0, 0, 0, intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 0, 4)));
299 299
 				$useend = 1;
300 300
 			}
301 301
 			else
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 			}
306 306
 			$cal_frequency = $GLOBALS['egw_setup']->oProc->f('cal_frequency');
307 307
 			$cal_days = $GLOBALS['egw_setup']->oProc->f('cal_days');
308
-			$db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__);
308
+			$db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')", __LINE__, __FILE__);
309 309
 		}
310 310
 	}
311 311
 
312 312
 	$GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats');
313
-	$GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
313
+	$GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'", __LINE__, __FILE__);
314 314
 
315 315
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2';
316 316
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
 	$db2 = $GLOBALS['egw_setup']->db;
323 323
 
324 324
 	$GLOBALS['egw_setup']->oProc->RenameColumn('calendar_entry', 'cal_duration', 'cal_edatetime');
325
-	$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__);
326
-	if($GLOBALS['egw_setup']->oProc->num_rows())
325
+	$GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id', __LINE__, __FILE__);
326
+	if ($GLOBALS['egw_setup']->oProc->num_rows())
327 327
 	{
328
-		while($GLOBALS['egw_setup']->oProc->next_record())
328
+		while ($GLOBALS['egw_setup']->oProc->next_record())
329 329
 		{
330
-			$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'),__LINE__,__FILE__);
330
+			$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'), __LINE__, __FILE__);
331 331
 			$db2->next_record();
332 332
 			$tz = $db2->f('preference_value');
333 333
 			$cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id');
334 334
 			$datetime = $GLOBALS['egw_setup']->oProc->f('cal_datetime') - ((60 * 60) * $tz);
335 335
 			$mdatetime = $GLOBALS['egw_setup']->oProc->f('cal_mdatetime') - ((60 * 60) * $tz);
336 336
 			$edatetime = $datetime + (60 * $GLOBALS['egw_setup']->oProc->f('cal_edatetime'));
337
-			$db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id,__LINE__,__FILE__);
337
+			$db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id, __LINE__, __FILE__);
338 338
 		}
339 339
 	}
340 340
 
@@ -582,22 +582,22 @@  discard block
 block discarded – undo
582 582
 {
583 583
 	$db2 = $GLOBALS['egw_setup']->db;
584 584
 
585
-	if(extension_loaded('mcal') == False)
585
+	if (extension_loaded('mcal') == False)
586 586
 	{
587
-		define(RECUR_NONE,0);
588
-		define(RECUR_DAILY,1);
589
-		define(RECUR_WEEKLY,2);
590
-		define(RECUR_MONTHLY_MDAY,3);
591
-		define(RECUR_MONTHLY_WDAY,4);
592
-		define(RECUR_YEARLY,5);
593
-
594
-		define(M_SUNDAY,1);
595
-		define(M_MONDAY,2);
596
-		define(M_TUESDAY,4);
597
-		define(M_WEDNESDAY,8);
598
-		define(M_THURSDAY,16);
599
-		define(M_FRIDAY,32);
600
-		define(M_SATURDAY,64);
587
+		define(RECUR_NONE, 0);
588
+		define(RECUR_DAILY, 1);
589
+		define(RECUR_WEEKLY, 2);
590
+		define(RECUR_MONTHLY_MDAY, 3);
591
+		define(RECUR_MONTHLY_WDAY, 4);
592
+		define(RECUR_YEARLY, 5);
593
+
594
+		define(M_SUNDAY, 1);
595
+		define(M_MONDAY, 2);
596
+		define(M_TUESDAY, 4);
597
+		define(M_WEDNESDAY, 8);
598
+		define(M_THURSDAY, 16);
599
+		define(M_FRIDAY, 32);
600
+		define(M_SATURDAY, 64);
601 601
 	}
602 602
 
603 603
 // calendar_entry => phpgw_cal
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 		)
625 625
 	);
626 626
 
627
-	$GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry',__LINE__,__FILE__);
628
-	while($GLOBALS['egw_setup']->oProc->next_record())
627
+	$GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry', __LINE__, __FILE__);
628
+	while ($GLOBALS['egw_setup']->oProc->next_record())
629 629
 	{
630 630
 		$id = $GLOBALS['egw_setup']->oProc->f('cal_id');
631 631
 		$owner = $GLOBALS['egw_setup']->oProc->f('cal_owner');
632 632
 		$access = $GLOBALS['egw_setup']->oProc->f('cal_access');
633
-		switch($access)
633
+		switch ($access)
634 634
 		{
635 635
 			case 'private':
636 636
 				$is_public = 0;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 		$description = $GLOBALS['egw_setup']->oProc->f('cal_description');
653 653
 
654 654
 		$db2->query("INSERT INTO phpgw_cal(cal_id,owner,groups,datetime,mdatetime,edatetime,priority,cal_type,is_public,title,description) "
655
-			. "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')",__LINE__,__FILE__);
655
+			. "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')", __LINE__, __FILE__);
656 656
 	}
657 657
 	$GLOBALS['egw_setup']->oProc->DropTable('calendar_entry');
658 658
 
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats',
661 661
 		Array(
662 662
 			'fd' => array(
663
-				'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False),
664
-				'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False),
665
-				'recur_use_end' => array('type' => 'int', 'precision' => 8,'nullable' => True),
666
-				'recur_enddate' => array('type' => 'int', 'precision' => 8,'nullable' => True),
667
-				'recur_interval' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1'),
668
-				'recur_data' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1')
663
+				'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False),
664
+				'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False),
665
+				'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True),
666
+				'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True),
667
+				'recur_interval' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1'),
668
+				'recur_data' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1')
669 669
 			),
670 670
 			'pk' => array(),
671 671
 			'fk' => array(),
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
 			'uc' => array()
674 674
 		)
675 675
 	);
676
-	$GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__);
677
-	while($GLOBALS['egw_setup']->oProc->next_record())
676
+	$GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats', __LINE__, __FILE__);
677
+	while ($GLOBALS['egw_setup']->oProc->next_record())
678 678
 	{
679 679
 		$id = $GLOBALS['egw_setup']->oProc->f('cal_id');
680 680
 		$recur_type = $GLOBALS['egw_setup']->oProc->f('cal_type');
681
-		switch($recur_type)
681
+		switch ($recur_type)
682 682
 		{
683 683
 			case 'daily':
684 684
 				$recur_type_num = RECUR_DAILY;
@@ -701,20 +701,20 @@  discard block
 block discarded – undo
701 701
 		$recur_interval = $GLOBALS['egw_setup']->oProc->f('cal_frequency');
702 702
 		$days = strtoupper($GLOBALS['egw_setup']->oProc->f('cal_days'));
703 703
 		$recur_data = 0;
704
-		$recur_data += (substr($days,0,1)=='Y'?M_SUNDAY:0);
705
-		$recur_data += (substr($days,1,1)=='Y'?M_MONDAY:0);
706
-		$recur_data += (substr($days,2,1)=='Y'?M_TUESDAY:0);
707
-		$recur_data += (substr($days,3,1)=='Y'?M_WEDNESDAY:0);
708
-		$recur_data += (substr($days,4,1)=='Y'?M_THURSDAY:0);
709
-		$recur_data += (substr($days,5,1)=='Y'?M_FRIDAY:0);
710
-		$recur_data += (substr($days,6,1)=='Y'?M_SATURDAY:0);
704
+		$recur_data += (substr($days, 0, 1) == 'Y' ? M_SUNDAY : 0);
705
+		$recur_data += (substr($days, 1, 1) == 'Y' ? M_MONDAY : 0);
706
+		$recur_data += (substr($days, 2, 1) == 'Y' ? M_TUESDAY : 0);
707
+		$recur_data += (substr($days, 3, 1) == 'Y' ? M_WEDNESDAY : 0);
708
+		$recur_data += (substr($days, 4, 1) == 'Y' ? M_THURSDAY : 0);
709
+		$recur_data += (substr($days, 5, 1) == 'Y' ? M_FRIDAY : 0);
710
+		$recur_data += (substr($days, 6, 1) == 'Y' ? M_SATURDAY : 0);
711 711
 		$db2->query("INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_use_end,recur_enddate,recur_interval,recur_data) "
712
-			. "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)",__LINE__,__FILE__);
712
+			. "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)", __LINE__, __FILE__);
713 713
 	}
714 714
 	$GLOBALS['egw_setup']->oProc->DropTable('calendar_entry_repeats');
715 715
 
716 716
 // calendar_entry_user => phpgw_cal_user
717
-	$GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user','phpgw_cal_user');
717
+	$GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user', 'phpgw_cal_user');
718 718
 
719 719
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.002';
720 720
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays',
734 734
 		Array(
735 735
 			'fd' => array(
736
-				'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False),
737
-				'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False),
738
-				'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')
736
+				'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False),
737
+				'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False),
738
+				'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')
739 739
 			),
740
-			'pk' => array('locale','name'),
740
+			'pk' => array('locale', 'name'),
741 741
 			'fk' => array(),
742 742
 			'ix' => array(),
743 743
 			'uc' => array()
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays',
770 770
 		Array(
771 771
 			'fd' => array(
772
-				'hol_id' => array('type' => 'auto','nullable' => False),
773
-				'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False),
774
-				'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False),
775
-				'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')
772
+				'hol_id' => array('type' => 'auto', 'nullable' => False),
773
+				'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False),
774
+				'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False),
775
+				'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')
776 776
 			),
777 777
 			'pk' => array('hol_id'),
778 778
 			'fk' => array(),
@@ -789,10 +789,10 @@  discard block
 block discarded – undo
789 789
 function calendar_upgrade0_9_11_007()
790 790
 {
791 791
 	$GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays');
792
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','mday',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
793
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','month_num',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
794
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','occurence',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
795
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','dow',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
792
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'mday', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
793
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'month_num', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
794
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'occurence', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
795
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'dow', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
796 796
 
797 797
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.008';
798 798
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 function calendar_upgrade0_9_11_009()
810 810
 {
811 811
 	$GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays');
812
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','observance_rule',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
812
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'observance_rule', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
813 813
 
814 814
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.010';
815 815
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 
845 845
 function calendar_upgrade0_9_13_002()
846 846
 {
847
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
847
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'reference', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0'));
848 848
 
849 849
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.003';
850 850
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm',
857 857
 		Array(
858 858
 			'fd' => array(
859
-				'alarm_id' => array('type' => 'auto','nullable' => False),
859
+				'alarm_id' => array('type' => 'auto', 'nullable' => False),
860 860
 				'cal_id'   => array('type' => 'int', 'precision' => 8, 'nullable' => False),
861 861
 				'cal_owner'	=> array('type' => 'int', 'precision' => 8, 'nullable' => False),
862 862
 				'cal_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False),
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 		)
870 870
 	);
871 871
 
872
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','uid',array('type' => 'varchar', 'precision' => 255,'nullable' => False));
873
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','location',array('type' => 'varchar', 'precision' => 255,'nullable' => True));
872
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'uid', array('type' => 'varchar', 'precision' => 255, 'nullable' => False));
873
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'location', array('type' => 'varchar', 'precision' => 255, 'nullable' => True));
874 874
 
875 875
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.004';
876 876
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 
880 880
 function calendar_upgrade0_9_13_004()
881 881
 {
882
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm','alarm_enabled',array('type' => 'int', 'precision' => 4,'nullable' => False, 'default' => '1'));
882
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm', 'alarm_enabled', array('type' => 'int', 'precision' => 4, 'nullable' => False, 'default' => '1'));
883 883
 
884 884
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.005';
885 885
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -889,18 +889,18 @@  discard block
 block discarded – undo
889 889
 function calendar_upgrade0_9_13_005()
890 890
 {
891 891
 	$calendar_data = Array();
892
-	$GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__);
893
-	while($GLOBALS['egw_setup']->oProc->next_record())
892
+	$GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal', __LINE__, __FILE__);
893
+	while ($GLOBALS['egw_setup']->oProc->next_record())
894 894
 	{
895 895
 		$calendar_data[$GLOBALS['egw_setup']->oProc->f('cal_id')] = $GLOBALS['egw_setup']->oProc->f('category');
896 896
 	}
897 897
 
898
-	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','category',array('type' => 'varchar', 'precision' => 30,'nullable' => True));
898
+	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'category', array('type' => 'varchar', 'precision' => 30, 'nullable' => True));
899 899
 
900 900
 	@reset($calendar_data);
901
-	while($calendar_data && list($cal_id,$category) = each($calendar_data))
901
+	while ($calendar_data && list($cal_id, $category) = each($calendar_data))
902 902
 	{
903
-		$GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id,__LINE__,__FILE__);
903
+		$GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id, __LINE__, __FILE__);
904 904
 	}
905 905
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.006';
906 906
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 
910 910
 function calendar_upgrade0_9_13_006()
911 911
 {
912
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_exception',array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => ''));
912
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats', 'recur_exception', array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => ''));
913 913
 
914 914
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007';
915 915
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -919,20 +919,20 @@  discard block
 block discarded – undo
919 919
 
920 920
 function calendar_upgrade0_9_13_007()
921 921
 {
922
-	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user','cal_type',array(
922
+	$GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user', 'cal_type', array(
923 923
 		'type' => 'varchar',
924 924
 		'precision' => '1',
925 925
 		'nullable' => False,
926 926
 		'default' => 'u'
927 927
 	));
928 928
 
929
-	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra',array(
929
+	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra', array(
930 930
 		'fd' => array(
931
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
932
-			'cal_extra_name' => array('type' => 'varchar','precision' => '40','nullable' => False),
933
-			'cal_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '')
931
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
932
+			'cal_extra_name' => array('type' => 'varchar', 'precision' => '40', 'nullable' => False),
933
+			'cal_extra_value' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '')
934 934
 		),
935
-		'pk' => array('cal_id','cal_extra_name'),
935
+		'pk' => array('cal_id', 'cal_extra_name'),
936 936
 		'fk' => array(),
937 937
 		'ix' => array(),
938 938
 		'uc' => array()
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 function calendar_upgrade0_9_16_001()
950 950
 {
951 951
 	// this is to set the default as schema_proc was not setting an empty default
952
-	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user','cal_type',array(
952
+	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user', 'cal_type', array(
953 953
 		'type' => 'varchar',
954 954
 		'precision' => '1',
955 955
 		'nullable' => False,
@@ -966,15 +966,15 @@  discard block
 block discarded – undo
966 966
 
967 967
 function calendar_upgrade0_9_16_002()
968 968
 {
969
-	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array(
969
+	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array(
970 970
 		'fd' => array(
971
-			'cal_id' => array('type' => 'int','precision' => '8','nullable' => False),
972
-			'recur_type' => array('type' => 'int','precision' => '8','nullable' => False),
973
-			'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'),
974
-			'recur_enddate' => array('type' => 'int','precision' => '8'),
975
-			'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'),
976
-			'recur_data' => array('type' => 'int','precision' => '8','default' => '1'),
977
-			'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '')
971
+			'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
972
+			'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
973
+			'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'),
974
+			'recur_enddate' => array('type' => 'int', 'precision' => '8'),
975
+			'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
976
+			'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
977
+			'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '')
978 978
 		),
979 979
 		'pk' => array(),
980 980
 		'fk' => array(),
@@ -990,14 +990,14 @@  discard block
 block discarded – undo
990 990
 
991 991
 function calendar_upgrade0_9_16_003()
992 992
 {
993
-	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user',array(
993
+	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user', array(
994 994
 		'fd' => array(
995
-			'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
996
-			'cal_login' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
997
-			'cal_status' => array('type' => 'char','precision' => '1','default' => 'A'),
998
-			'cal_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u')
995
+			'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
996
+			'cal_login' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
997
+			'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A'),
998
+			'cal_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u')
999 999
 		),
1000
-		'pk' => array('cal_id','cal_login','cal_type'),
1000
+		'pk' => array('cal_id', 'cal_login', 'cal_type'),
1001 1001
 		'fk' => array(),
1002 1002
 		'ix' => array(),
1003 1003
 		'uc' => array()
@@ -1011,16 +1011,16 @@  discard block
 block discarded – undo
1011 1011
 
1012 1012
 function calendar_upgrade0_9_16_004()
1013 1013
 {
1014
-	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays',array(
1014
+	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays', array(
1015 1015
 		'fd' => array(
1016
-			'hol_id' => array('type' => 'auto','nullable' => False),
1017
-			'locale' => array('type' => 'char','precision' => '2','nullable' => False),
1018
-			'name' => array('type' => 'varchar','precision' => '50','nullable' => False),
1019
-			'mday' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1020
-			'month_num' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1021
-			'occurence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1022
-			'dow' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1023
-			'observance_rule' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0')
1016
+			'hol_id' => array('type' => 'auto', 'nullable' => False),
1017
+			'locale' => array('type' => 'char', 'precision' => '2', 'nullable' => False),
1018
+			'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False),
1019
+			'mday' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1020
+			'month_num' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1021
+			'occurence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1022
+			'dow' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1023
+			'observance_rule' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0')
1024 1024
 		),
1025 1025
 		'pk' => array('hol_id'),
1026 1026
 		'fk' => array(),
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
 {
1039 1039
 	// creates uid's for all entries which do not have unique ones, they are '[email protected]'
1040 1040
 	// very old entries even have an empty uid, see 0.9.16.006 update
1041
-	$GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'",__LINE__,__FILE__);
1041
+	$GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'", __LINE__, __FILE__);
1042 1042
 	while ($GLOBALS['egw_setup']->oProc->next_record())
1043 1043
 	{
1044 1044
 		$config[$GLOBALS['egw_setup']->oProc->f(0)] = $GLOBALS['egw_setup']->oProc->f(1);
1045 1045
 	}
1046 1046
 	$GLOBALS['egw_setup']->oProc->query('UPDATE phpgw_cal SET uid='.
1047
-		$GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'),'cal_id',
1047
+		$GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'), 'cal_id',
1048 1048
 			$GLOBALS['egw_setup']->db->quote('-'.$config['install_id'].'@'.
1049 1049
 			($config['mail_suffix'] ? $config['mail_suffix'] : 'local'))).
1050 1050
 		" WHERE uid LIKE '-@%' OR uid=''");
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 function calendar_upgrade0_9_16_007()
1068 1068
 {
1069 1069
 	// update the sequenzes for refreshed tables (postgres only)
1070
-	$GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays','hol_id');
1070
+	$GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays', 'hol_id');
1071 1071
 
1072 1072
 	$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0';
1073 1073
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -1077,19 +1077,19 @@  discard block
 block discarded – undo
1077 1077
 
1078 1078
 function calendar_upgrade1_0_0()
1079 1079
 {
1080
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','uid','cal_uid');
1081
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','owner','cal_owner');
1082
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','category','cal_category');
1083
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','groups','cal_groups');
1084
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','datetime','cal_starttime');
1085
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','mdatetime','cal_modified');
1086
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','edatetime','cal_endtime');
1087
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','priority','cal_priority');
1088
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','is_public','cal_public');
1089
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','title','cal_title');
1090
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','description','cal_description');
1091
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','location','cal_location');
1092
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','reference','cal_reference');
1080
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'uid', 'cal_uid');
1081
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'owner', 'cal_owner');
1082
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'category', 'cal_category');
1083
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'groups', 'cal_groups');
1084
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'datetime', 'cal_starttime');
1085
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'mdatetime', 'cal_modified');
1086
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'edatetime', 'cal_endtime');
1087
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'priority', 'cal_priority');
1088
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'is_public', 'cal_public');
1089
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'title', 'cal_title');
1090
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'description', 'cal_description');
1091
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'location', 'cal_location');
1092
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'reference', 'cal_reference');
1093 1093
 
1094 1094
 	$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.001';
1095 1095
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -1099,13 +1099,13 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 function calendar_upgrade1_0_0_001()
1101 1101
 {
1102
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','locale','hol_locale');
1103
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','name','hol_name');
1104
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','mday','hol_mday');
1105
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','month_num','hol_month_num');
1106
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','occurence','hol_occurence');
1107
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','dow','hol_dow');
1108
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','observance_rule','hol_observance_rule');
1102
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'locale', 'hol_locale');
1103
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'name', 'hol_name');
1104
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'mday', 'hol_mday');
1105
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'month_num', 'hol_month_num');
1106
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'occurence', 'hol_occurence');
1107
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'dow', 'hol_dow');
1108
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'observance_rule', 'hol_observance_rule');
1109 1109
 
1110 1110
 	$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.002';
1111 1111
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 function calendar_upgrade1_0_0_002()
1117 1117
 {
1118
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_login','cal_user_id');
1119
-	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_type','cal_user_type');
1118
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_login', 'cal_user_id');
1119
+	$GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_type', 'cal_user_type');
1120 1120
 
1121 1121
 	$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.003';
1122 1122
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 
1127 1127
 function calendar_upgrade1_0_0_003()
1128 1128
 {
1129
-	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','cal_title',array(
1129
+	$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'cal_title', array(
1130 1130
 		'type' => 'varchar',
1131 1131
 		'precision' => '255',
1132 1132
 		'nullable' => False,
@@ -1141,15 +1141,15 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 function calendar_upgrade1_0_0_004()
1143 1143
 {
1144
-	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array(
1144
+	$GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array(
1145 1145
 		'fd' => array(
1146
-			'cal_id' => array('type' => 'int','precision' => '8','nullable' => False),
1147
-			'recur_type' => array('type' => 'int','precision' => '8','nullable' => False),
1148
-			'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'),
1149
-			'recur_enddate' => array('type' => 'int','precision' => '8'),
1150
-			'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'),
1151
-			'recur_data' => array('type' => 'int','precision' => '8','default' => '1'),
1152
-			'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '')
1146
+			'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1147
+			'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1148
+			'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'),
1149
+			'recur_enddate' => array('type' => 'int', 'precision' => '8'),
1150
+			'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
1151
+			'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
1152
+			'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '')
1153 1153
 		),
1154 1154
 		'pk' => array('cal_id'),
1155 1155
 		'fk' => array(),
@@ -1166,19 +1166,19 @@  discard block
 block discarded – undo
1166 1166
 function calendar_upgrade1_0_0_005()
1167 1167
 {
1168 1168
 	// change prefix of all calendar tables to egw_
1169
-	foreach(array('cal_user','cal_repeats','cal_extra','cal_holidays','cal') as $name)
1169
+	foreach (array('cal_user', 'cal_repeats', 'cal_extra', 'cal_holidays', 'cal') as $name)
1170 1170
 	{
1171
-		$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name,'egw_'.$name);
1171
+		$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name, 'egw_'.$name);
1172 1172
 	}
1173 1173
 
1174 1174
 	// create new dates table, with content from the egw_cal table
1175
-	$GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates',array(
1175
+	$GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates', array(
1176 1176
 		'fd' => array(
1177
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
1178
-			'cal_start' => array('type' => 'int','precision' => '8','nullable' => False),
1179
-			'cal_end' => array('type' => 'int','precision' => '8','nullable' => False)
1177
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
1178
+			'cal_start' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1179
+			'cal_end' => array('type' => 'int', 'precision' => '8', 'nullable' => False)
1180 1180
 		),
1181
-		'pk' => array('cal_id','cal_start'),
1181
+		'pk' => array('cal_id', 'cal_start'),
1182 1182
 		'fk' => array(),
1183 1183
 		'ix' => array(),
1184 1184
 		'uc' => array()
@@ -1186,49 +1186,49 @@  discard block
 block discarded – undo
1186 1186
 	$GLOBALS['egw_setup']->oProc->query("INSERT INTO egw_cal_dates SELECT cal_id,cal_starttime,cal_endtime FROM egw_cal");
1187 1187
 
1188 1188
 	// drop the fields transfered to the dates table
1189
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1189
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1190 1190
 		'fd' => array(
1191
-			'cal_id' => array('type' => 'auto','nullable' => False),
1192
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1193
-			'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False),
1194
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1195
-			'cal_groups' => array('type' => 'varchar','precision' => '255'),
1196
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1197
-			'cal_endtime' => array('type' => 'int','precision' => '8'),
1198
-			'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'),
1199
-			'cal_type' => array('type' => 'varchar','precision' => '10'),
1200
-			'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'),
1201
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1191
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1192
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1193
+			'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1194
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1195
+			'cal_groups' => array('type' => 'varchar', 'precision' => '255'),
1196
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1197
+			'cal_endtime' => array('type' => 'int', 'precision' => '8'),
1198
+			'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'),
1199
+			'cal_type' => array('type' => 'varchar', 'precision' => '10'),
1200
+			'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'),
1201
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1202 1202
 			'cal_description' => array('type' => 'text'),
1203
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1204
-			'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0')
1203
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1204
+			'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0')
1205 1205
 		),
1206 1206
 		'pk' => array('cal_id'),
1207 1207
 		'fk' => array(),
1208 1208
 		'ix' => array(),
1209 1209
 		'uc' => array()
1210
-	),'cal_starttime');
1211
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1210
+	), 'cal_starttime');
1211
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1212 1212
 		'fd' => array(
1213
-			'cal_id' => array('type' => 'auto','nullable' => False),
1214
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1215
-			'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False),
1216
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1217
-			'cal_groups' => array('type' => 'varchar','precision' => '255'),
1218
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1219
-			'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'),
1220
-			'cal_type' => array('type' => 'varchar','precision' => '10'),
1221
-			'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'),
1222
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1213
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1214
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1215
+			'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1216
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1217
+			'cal_groups' => array('type' => 'varchar', 'precision' => '255'),
1218
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1219
+			'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'),
1220
+			'cal_type' => array('type' => 'varchar', 'precision' => '10'),
1221
+			'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'),
1222
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1223 1223
 			'cal_description' => array('type' => 'text'),
1224
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1225
-			'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0')
1224
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1225
+			'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0')
1226 1226
 		),
1227 1227
 		'pk' => array('cal_id'),
1228 1228
 		'fk' => array(),
1229 1229
 		'ix' => array(),
1230 1230
 		'uc' => array()
1231
-	),'cal_endtime');
1231
+	), 'cal_endtime');
1232 1232
 
1233 1233
 	$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.001';
1234 1234
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -1244,15 +1244,15 @@  discard block
 block discarded – undo
1244 1244
 		'precision' => '8',
1245 1245
 		'default' => '0'
1246 1246
 	));*/
1247
-	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array(
1247
+	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array(
1248 1248
 		'fd' => array(
1249
-			'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1250
-			'cal_recur_date' => array('type' => 'int','precision' => '8','default' => '0'),
1251
-			'cal_user_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u'),
1252
-			'cal_user_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
1253
-			'cal_status' => array('type' => 'char','precision' => '1','default' => 'A')
1249
+			'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1250
+			'cal_recur_date' => array('type' => 'int', 'precision' => '8', 'default' => '0'),
1251
+			'cal_user_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u'),
1252
+			'cal_user_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'),
1253
+			'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A')
1254 1254
 		),
1255
-		'pk' => array('cal_id','cal_recur_date','cal_user_type','cal_user_id'),
1255
+		'pk' => array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'),
1256 1256
 		'fk' => array(),
1257 1257
 		'ix' => array(),
1258 1258
 		'uc' => array()
@@ -1266,50 +1266,50 @@  discard block
 block discarded – undo
1266 1266
 
1267 1267
 function calendar_upgrade1_0_1_002()
1268 1268
 {
1269
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1269
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1270 1270
 		'fd' => array(
1271
-			'cal_id' => array('type' => 'auto','nullable' => False),
1272
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1273
-			'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False),
1274
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1275
-			'cal_groups' => array('type' => 'varchar','precision' => '255'),
1276
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1277
-			'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'),
1278
-			'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'),
1279
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1271
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1272
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1273
+			'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1274
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1275
+			'cal_groups' => array('type' => 'varchar', 'precision' => '255'),
1276
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1277
+			'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'),
1278
+			'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'),
1279
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1280 1280
 			'cal_description' => array('type' => 'text'),
1281
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1282
-			'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0')
1281
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1282
+			'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0')
1283 1283
 		),
1284 1284
 		'pk' => array('cal_id'),
1285 1285
 		'fk' => array(),
1286 1286
 		'ix' => array(),
1287 1287
 		'uc' => array()
1288
-	),'cal_type');
1289
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_owner',array(
1288
+	), 'cal_type');
1289
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_owner', array(
1290 1290
 		'type' => 'int',
1291 1291
 		'precision' => '4',
1292 1292
 		'nullable' => False
1293 1293
 	));
1294
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_priority',array(
1294
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_priority', array(
1295 1295
 		'type' => 'int',
1296 1296
 		'precision' => '2',
1297 1297
 		'nullable' => False,
1298 1298
 		'default' => '2'
1299 1299
 	));
1300
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_public',array(
1300
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_public', array(
1301 1301
 		'type' => 'int',
1302 1302
 		'precision' => '2',
1303 1303
 		'nullable' => False,
1304 1304
 		'default' => '1'
1305 1305
 	));
1306
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_reference',array(
1306
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_reference', array(
1307 1307
 		'type' => 'int',
1308 1308
 		'precision' => '4',
1309 1309
 		'nullable' => False,
1310 1310
 		'default' => '0'
1311 1311
 	));
1312
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_modifier',array(
1312
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_modifier', array(
1313 1313
 		'type' => 'int',
1314 1314
 		'precision' => '4'
1315 1315
 	));
@@ -1322,36 +1322,36 @@  discard block
 block discarded – undo
1322 1322
 
1323 1323
 function calendar_upgrade1_0_1_003()
1324 1324
 {
1325
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array(
1325
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array(
1326 1326
 		'fd' => array(
1327
-			'cal_id' => array('type' => 'int','precision' => '8','nullable' => False),
1328
-			'recur_type' => array('type' => 'int','precision' => '8','nullable' => False),
1329
-			'recur_enddate' => array('type' => 'int','precision' => '8'),
1330
-			'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'),
1331
-			'recur_data' => array('type' => 'int','precision' => '8','default' => '1'),
1332
-			'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '')
1327
+			'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1328
+			'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False),
1329
+			'recur_enddate' => array('type' => 'int', 'precision' => '8'),
1330
+			'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
1331
+			'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'),
1332
+			'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '')
1333 1333
 		),
1334 1334
 		'pk' => array('cal_id'),
1335 1335
 		'fk' => array(),
1336 1336
 		'ix' => array(),
1337 1337
 		'uc' => array()
1338
-	),'recur_use_end');
1339
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','cal_id',array(
1338
+	), 'recur_use_end');
1339
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'cal_id', array(
1340 1340
 		'type' => 'int',
1341 1341
 		'precision' => '4',
1342 1342
 		'nullable' => False
1343 1343
 	));
1344
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_type',array(
1344
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_type', array(
1345 1345
 		'type' => 'int',
1346 1346
 		'precision' => '2',
1347 1347
 		'nullable' => False
1348 1348
 	));
1349
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_interval',array(
1349
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_interval', array(
1350 1350
 		'type' => 'int',
1351 1351
 		'precision' => '2',
1352 1352
 		'default' => '1'
1353 1353
 	));
1354
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_data',array(
1354
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_data', array(
1355 1355
 		'type' => 'int',
1356 1356
 		'precision' => '2',
1357 1357
 		'default' => '1'
@@ -1365,13 +1365,13 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
 function calendar_upgrade1_0_1_004()
1367 1367
 {
1368
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array(
1368
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array(
1369 1369
 		'type' => 'int',
1370 1370
 		'precision' => '4',
1371 1371
 		'nullable' => False,
1372 1372
 		'default' => '0'
1373 1373
 	));
1374
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array(
1374
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array(
1375 1375
 		'type' => 'int',
1376 1376
 		'precision' => '4',
1377 1377
 		'nullable' => False,
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 function calendar_upgrade1_0_1_005()
1388 1388
 {
1389
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_quantity',array(
1389
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_quantity', array(
1390 1390
 		'type' => 'int',
1391 1391
 		'precision' => '4',
1392 1392
 		'default' => '1'
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 
1401 1401
 function calendar_upgrade1_0_1_006()
1402 1402
 {
1403
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_non_blocking',array(
1403
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_non_blocking', array(
1404 1404
 		'type' => 'int',
1405 1405
 		'precision' => '2',
1406 1406
 		'default' => '0'
@@ -1414,9 +1414,9 @@  discard block
 block discarded – undo
1414 1414
 
1415 1415
 function calendar_upgrade1_0_1_007()
1416 1416
 {
1417
-	$GLOBALS['egw_setup']->db->update('egw_cal_repeats',array('recur_exception' => null),array('recur_exception' => ''),__LINE__,__FILE__,'calendar');
1417
+	$GLOBALS['egw_setup']->db->update('egw_cal_repeats', array('recur_exception' => null), array('recur_exception' => ''), __LINE__, __FILE__, 'calendar');
1418 1418
 
1419
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_exception',array(
1419
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_exception', array(
1420 1420
 		'type' => 'text'
1421 1421
 	));
1422 1422
 
@@ -1433,11 +1433,11 @@  discard block
 block discarded – undo
1433 1433
 	{
1434 1434
 		$customfields = array();
1435 1435
 		$order = 0;
1436
-		foreach($config_data['fields'] as $name => $data)
1436
+		foreach ($config_data['fields'] as $name => $data)
1437 1437
 		{
1438 1438
 			if ($name{0} == '#' && !$data['disabled'])	// real not-disabled custom field
1439 1439
 			{
1440
-				$customfields[substr($name,1)] = array(
1440
+				$customfields[substr($name, 1)] = array(
1441 1441
 					'type'  => 'text',
1442 1442
 					'len'   => $data['length'].($data['shown'] ? ','.$data['shown'] : ''),
1443 1443
 					'label' => $data['name'],
@@ -1460,38 +1460,38 @@  discard block
 block discarded – undo
1460 1460
 function calendar_upgrade1_0_1_009()
1461 1461
 {
1462 1462
 	$db2 = clone($GLOBALS['egw_setup']->db);
1463
-	$GLOBALS['egw_setup']->db->select('egw_cal','DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date',"cal_groups != ''",__LINE__,__FILE__,
1464
-		False,'','calendar',0,',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id');
1465
-	while(($row = $GLOBALS['egw_setup']->db->row(true)))
1463
+	$GLOBALS['egw_setup']->db->select('egw_cal', 'DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date', "cal_groups != ''", __LINE__, __FILE__,
1464
+		False, '', 'calendar', 0, ',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id');
1465
+	while (($row = $GLOBALS['egw_setup']->db->row(true)))
1466 1466
 	{
1467 1467
 		$row['cal_user_type'] = 'u';
1468
-		foreach(explode(',',$row['cal_groups']) as $group)
1468
+		foreach (explode(',', $row['cal_groups']) as $group)
1469 1469
 		{
1470 1470
 			$row['cal_user_id'] = $group;
1471
-			$db2->insert('egw_cal_user',array('cal_status' => 'U'),$row,__LINE__,__FILE__,'calendar');
1471
+			$db2->insert('egw_cal_user', array('cal_status' => 'U'), $row, __LINE__, __FILE__, 'calendar');
1472 1472
 		}
1473 1473
 	}
1474
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1474
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1475 1475
 		'fd' => array(
1476
-			'cal_id' => array('type' => 'auto','nullable' => False),
1477
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1478
-			'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False),
1479
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1480
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1481
-			'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'),
1482
-			'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'),
1483
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1476
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1477
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1478
+			'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
1479
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1480
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1481
+			'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'),
1482
+			'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'),
1483
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1484 1484
 			'cal_description' => array('type' => 'text'),
1485
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1486
-			'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
1487
-			'cal_modifier' => array('type' => 'int','precision' => '4'),
1488
-			'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0')
1485
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1486
+			'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'),
1487
+			'cal_modifier' => array('type' => 'int', 'precision' => '4'),
1488
+			'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0')
1489 1489
 		),
1490 1490
 		'pk' => array('cal_id'),
1491 1491
 		'fk' => array(),
1492 1492
 		'ix' => array(),
1493 1493
 		'uc' => array()
1494
-	),'cal_groups');
1494
+	), 'cal_groups');
1495 1495
 
1496 1496
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2';
1497 1497
 }
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 function calendar_upgrade1_2()
1502 1502
 {
1503 1503
 	// get old alarms (saved before 1.2) working again
1504
-	$GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'",__LINE__,__FILE__);
1504
+	$GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'", __LINE__, __FILE__);
1505 1505
 
1506 1506
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2.001';
1507 1507
 }
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 
1510 1510
 function calendar_upgrade1_2_001()
1511 1511
 {
1512
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_special',array(
1512
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_special', array(
1513 1513
 		'type' => 'int',
1514 1514
 		'precision' => '2',
1515 1515
 		'default' => '0'
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 
1528 1528
 function calendar_upgrade1_4()
1529 1529
 {
1530
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_etag',array(
1530
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_etag', array(
1531 1531
 		'type' => 'int',
1532 1532
 		'precision' => '4',
1533 1533
 		'default' => '0'
@@ -1539,59 +1539,59 @@  discard block
 block discarded – undo
1539 1539
 
1540 1540
 function calendar_upgrade1_5()
1541 1541
 {
1542
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1542
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1543 1543
 		'fd' => array(
1544
-			'cal_id' => array('type' => 'auto','nullable' => False),
1545
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1546
-			'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False),
1547
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1548
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1549
-			'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'),
1550
-			'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'),
1551
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1544
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1545
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1546
+			'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
1547
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1548
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1549
+			'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'),
1550
+			'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'),
1551
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1552 1552
 			'cal_description' => array('type' => 'text'),
1553
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1554
-			'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
1555
-			'cal_modifier' => array('type' => 'int','precision' => '4'),
1556
-			'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'),
1557
-			'cal_special' => array('type' => 'int','precision' => '2','default' => '0'),
1558
-			'cal_etag' => array('type' => 'int','precision' => '4'),
1559
-			'cal_edit_time' => array('type' => 'int','precision' => '8')
1553
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1554
+			'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'),
1555
+			'cal_modifier' => array('type' => 'int', 'precision' => '4'),
1556
+			'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
1557
+			'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
1558
+			'cal_etag' => array('type' => 'int', 'precision' => '4'),
1559
+			'cal_edit_time' => array('type' => 'int', 'precision' => '8')
1560 1560
 		),
1561 1561
 		'pk' => array('cal_id'),
1562 1562
 		'fk' => array(),
1563 1563
 		'ix' => array(),
1564 1564
 		'uc' => array()
1565
-	),'cal_edit_user');
1566
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array(
1565
+	), 'cal_edit_user');
1566
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array(
1567 1567
 		'fd' => array(
1568
-			'cal_id' => array('type' => 'auto','nullable' => False),
1569
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False),
1570
-			'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False),
1571
-			'cal_category' => array('type' => 'varchar','precision' => '30'),
1572
-			'cal_modified' => array('type' => 'int','precision' => '8'),
1573
-			'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'),
1574
-			'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'),
1575
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
1568
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
1569
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
1570
+			'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
1571
+			'cal_category' => array('type' => 'varchar', 'precision' => '30'),
1572
+			'cal_modified' => array('type' => 'int', 'precision' => '8'),
1573
+			'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'),
1574
+			'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'),
1575
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
1576 1576
 			'cal_description' => array('type' => 'text'),
1577
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
1578
-			'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
1579
-			'cal_modifier' => array('type' => 'int','precision' => '4'),
1580
-			'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'),
1581
-			'cal_special' => array('type' => 'int','precision' => '2','default' => '0'),
1582
-			'cal_etag' => array('type' => 'int','precision' => '4')
1577
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
1578
+			'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'),
1579
+			'cal_modifier' => array('type' => 'int', 'precision' => '4'),
1580
+			'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
1581
+			'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
1582
+			'cal_etag' => array('type' => 'int', 'precision' => '4')
1583 1583
 		),
1584 1584
 		'pk' => array('cal_id'),
1585 1585
 		'fk' => array(),
1586 1586
 		'ix' => array(),
1587 1587
 		'uc' => array()
1588
-	),'cal_edit_time');
1589
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_etag',array(
1588
+	), 'cal_edit_time');
1589
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_etag', array(
1590 1590
 		'type' => 'int',
1591 1591
 		'precision' => '4',
1592 1592
 		'default' => '0'
1593 1593
 	));
1594
-	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL',__LINE__,__FILE__);
1594
+	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL', __LINE__, __FILE__);
1595 1595
 
1596 1596
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.5.001';
1597 1597
 }
@@ -1599,12 +1599,12 @@  discard block
 block discarded – undo
1599 1599
 
1600 1600
 function calendar_upgrade1_5_001()
1601 1601
 {
1602
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array(
1602
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array(
1603 1603
 		'type' => 'int',
1604 1604
 		'precision' => '4',
1605 1605
 		'nullable' => False
1606 1606
 	));
1607
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array(
1607
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array(
1608 1608
 		'type' => 'varchar',
1609 1609
 		'precision' => '128',
1610 1610
 		'nullable' => False
@@ -1618,12 +1618,12 @@  discard block
 block discarded – undo
1618 1618
 {
1619 1619
 	// update the alarm methods
1620 1620
 	$async = new Api\Asyncservice();
1621
-	foreach((array)$async->read('cal:%') as $job)
1621
+	foreach ((array)$async->read('cal:%') as $job)
1622 1622
 	{
1623 1623
 		if ($job['method'] == 'calendar.bocalupdate.send_alarm')
1624 1624
 		{
1625 1625
 			$job['method'] = 'calendar.calendar_boupdate.send_alarm';
1626
-			$async->write($job,true);
1626
+			$async->write($job, true);
1627 1627
 		}
1628 1628
 	}
1629 1629
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.6';
@@ -1640,48 +1640,48 @@  discard block
 block discarded – undo
1640 1640
 {
1641 1641
 	// Set UID of series exception to UID of series master
1642 1642
 	// update cal_etag, cal_modified and cal_modifier to distribute changes on GroupDAV devices
1643
-	foreach($GLOBALS['egw_setup']->db->query('
1643
+	foreach ($GLOBALS['egw_setup']->db->query('
1644 1644
 		SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master
1645 1645
 		FROM egw_cal cal_ex
1646 1646
 		JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id
1647
-		WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row)
1647
+		WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row)
1648 1648
 	{
1649 1649
 		if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master'])
1650 1650
 		{
1651 1651
 			$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master'].
1652 1652
 				'\',cal_etag=cal_etag+1,cal_modified='.time().
1653
-				',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__);
1653
+				',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__);
1654 1654
 		}
1655 1655
 	}
1656 1656
 
1657 1657
 	// Search series exception for nearest exception in series master and add that RECURRENCE-ID
1658 1658
 	// as cal_reference (for 1.6.003 and move it to new field cal_recurrence in 1.7.001)
1659 1659
 	$diff = null;
1660
-	foreach($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal
1660
+	foreach ($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal
1661 1661
 		JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id
1662 1662
 		JOIN egw_cal_repeats ON cal_reference=egw_cal_repeats.cal_id
1663
-		WHERE cal_reference != 0',__LINE__,__FILE__) as $row)
1663
+		WHERE cal_reference != 0',__LINE__, __FILE__) as $row)
1664 1664
 	{
1665 1665
 		$recurrence = null;
1666
-		foreach(explode(',',$row['recur_exception']) as $ts)
1666
+		foreach (explode(',', $row['recur_exception']) as $ts)
1667 1667
 		{
1668
-			if (is_null($recurrence) || abs($ts-$row['cal_start']) < $diff)
1668
+			if (is_null($recurrence) || abs($ts - $row['cal_start']) < $diff)
1669 1669
 			{
1670 1670
 				$recurrence = $ts;
1671
-				$diff = abs($ts-$row['cal_start']);
1671
+				$diff = abs($ts - $row['cal_start']);
1672 1672
 			}
1673 1673
 		}
1674 1674
 		if ($recurrence)
1675 1675
 		{
1676 1676
 			$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$recurrence.
1677
-				' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__);
1677
+				' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__);
1678 1678
 		}
1679 1679
 		else
1680 1680
 		{
1681 1681
 			// if we cannot determine the RECURRENCE-ID use cal_start
1682 1682
 			// because RECURRENCE-ID must be present
1683 1683
 			$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$row['cal_start'].
1684
-				' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__);
1684
+				' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__);
1685 1685
 		}
1686 1686
 	}
1687 1687
 
@@ -1696,33 +1696,33 @@  discard block
 block discarded – undo
1696 1696
  */
1697 1697
 function calendar_upgrade1_6_003()
1698 1698
 {
1699
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_creator',array(
1699
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_creator', array(
1700 1700
 		'type' => 'int',
1701 1701
 		'precision' => '4',
1702 1702
 		'comment' => 'creating user'
1703 1703
 	));
1704
-	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner',__LINE__,__FILE__);
1705
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_creator',array(
1704
+	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner', __LINE__, __FILE__);
1705
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_creator', array(
1706 1706
 		'type' => 'int',
1707 1707
 		'precision' => '4',
1708 1708
 		'nullable' => False,
1709 1709
 		'comment' => 'creating user'
1710 1710
 	));
1711 1711
 
1712
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_created',array(
1712
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_created', array(
1713 1713
 		'type' => 'int',
1714 1714
 		'precision' => '8',
1715 1715
 		'comment' => 'creation time of event'
1716 1716
 	));
1717
-	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified',__LINE__,__FILE__);
1718
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_created',array(
1717
+	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified', __LINE__, __FILE__);
1718
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_created', array(
1719 1719
 		'type' => 'int',
1720 1720
 		'precision' => '8',
1721 1721
 		'nullable' => False,
1722 1722
 		'comment' => 'creation time of event'
1723 1723
 	));
1724 1724
 
1725
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_recurrence',array(
1725
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_recurrence', array(
1726 1726
 		'type' => 'int',
1727 1727
 		'precision' => '8',
1728 1728
 		'nullable' => False,
@@ -1733,14 +1733,14 @@  discard block
 block discarded – undo
1733 1733
 	// move RECURRENCE-ID from temporarily (1.6.003)
1734 1734
 	// used field cal_reference to new field cal_recurrence
1735 1735
 	// and restore cal_reference field of series exceptions with id of the series master
1736
-	foreach($GLOBALS['egw_setup']->db->query('
1736
+	foreach ($GLOBALS['egw_setup']->db->query('
1737 1737
 		SELECT cal_ex.cal_id AS cal_id_ex,cal_master.cal_id AS cal_id_master,
1738 1738
 		cal_ex.cal_reference AS cal_reference_ex,cal_ex.cal_uid AS cal_uid_ex,
1739 1739
 		cal_master.cal_uid AS cal_uid_master
1740 1740
 		FROM egw_cal cal_ex
1741 1741
 		JOIN egw_cal cal_master
1742 1742
 		ON cal_ex.cal_uid=cal_master.cal_uid AND cal_master.cal_reference = 0 AND cal_ex.cal_owner = cal_master.cal_owner
1743
-		WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__,__FILE__) as $row)
1743
+		WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__, __FILE__) as $row)
1744 1744
 	{
1745 1745
 		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_recurrence='.(int)$row['cal_reference_ex'].
1746 1746
 			', cal_reference='.(int)$row['cal_id_master'].
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
  */
1758 1758
 function calendar_upgrade1_7_001()
1759 1759
 {
1760
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_role',array(
1760
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_role', array(
1761 1761
 		'type' => 'varchar',
1762 1762
 		'precision' => '64',
1763 1763
 		'default' => 'REQ-PARTICIPANT'
@@ -1773,14 +1773,14 @@  discard block
 block discarded – undo
1773 1773
  */
1774 1774
 function calendar_upgrade1_7_002()
1775 1775
 {
1776
-	$GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones',array(
1776
+	$GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones', array(
1777 1777
 		'fd' => array(
1778
-			'tz_id' => array('type' => 'auto','nullable' => False),
1779
-			'tz_tzid' => array('type' => 'varchar','precision' => '128','nullable' => False),
1780
-			'tz_alias' => array('type' => 'int','precision' => '4','comment' => 'tz_id for data'),
1781
-			'tz_latitude' => array('type' => 'int','precision' => '4'),
1782
-			'tz_longitude' => array('type' => 'int','precision' => '4'),
1783
-			'tz_component' => array('type' => 'text','comment' => 'iCal VTIMEZONE component')
1778
+			'tz_id' => array('type' => 'auto', 'nullable' => False),
1779
+			'tz_tzid' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False),
1780
+			'tz_alias' => array('type' => 'int', 'precision' => '4', 'comment' => 'tz_id for data'),
1781
+			'tz_latitude' => array('type' => 'int', 'precision' => '4'),
1782
+			'tz_longitude' => array('type' => 'int', 'precision' => '4'),
1783
+			'tz_component' => array('type' => 'text', 'comment' => 'iCal VTIMEZONE component')
1784 1784
 		),
1785 1785
 		'pk' => array('tz_id'),
1786 1786
 		'fk' => array(),
@@ -1800,38 +1800,38 @@  discard block
 block discarded – undo
1800 1800
  */
1801 1801
 function calendar_upgrade1_7_003()
1802 1802
 {
1803
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_type',array(
1803
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_type', array(
1804 1804
 		'type' => 'varchar',
1805 1805
 		'precision' => '1',
1806 1806
 		'nullable' => False,
1807 1807
 		'default' => 'u',
1808 1808
 		'comment' => 'u=user, g=group, c=contact, r=resource, e=email'
1809 1809
 	));
1810
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array(
1810
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array(
1811 1811
 		'type' => 'varchar',
1812 1812
 		'precision' => '128',
1813 1813
 		'nullable' => False,
1814 1814
 		'comment' => 'id or email-address for type=e'
1815 1815
 	));
1816
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_status',array(
1816
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_status', array(
1817 1817
 		'type' => 'char',
1818 1818
 		'precision' => '1',
1819 1819
 		'default' => 'A',
1820 1820
 		'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'
1821 1821
 	));
1822
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_quantity',array(
1822
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_quantity', array(
1823 1823
 		'type' => 'int',
1824 1824
 		'precision' => '4',
1825 1825
 		'default' => '1',
1826 1826
 		'comment' => 'only for certain types (eg. resources)'
1827 1827
 	));
1828
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_role',array(
1828
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_role', array(
1829 1829
 		'type' => 'varchar',
1830 1830
 		'precision' => '64',
1831 1831
 		'default' => 'REQ-PARTICIPANT',
1832 1832
 		'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'
1833 1833
 	));
1834
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_modified',array(
1834
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_modified', array(
1835 1835
 		'type' => 'timestamp',
1836 1836
 		'default' => 'current_timestamp',
1837 1837
 		'comment' => 'automatic timestamp of last update'
@@ -1847,19 +1847,19 @@  discard block
 block discarded – undo
1847 1847
  */
1848 1848
 function calendar_upgrade1_7_004()
1849 1849
 {
1850
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_start',array(
1850
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_start', array(
1851 1851
 		'type' => 'int',
1852 1852
 		'precision' => '8',
1853 1853
 		'nullable' => False,
1854 1854
 		'comment' => 'starttime in server time'
1855 1855
 	));
1856
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_end',array(
1856
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_end', array(
1857 1857
 		'type' => 'int',
1858 1858
 		'precision' => '8',
1859 1859
 		'nullable' => False,
1860 1860
 		'comment' => 'endtime in server time'
1861 1861
 	));
1862
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','tz_id',array(
1862
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'tz_id', array(
1863 1863
 		'type' => 'int',
1864 1864
 		'precision' => '4',
1865 1865
 		'comment' => 'key into egw_cal_timezones'
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
 	// set id of server timezone for existing events, as that's the timezone their recurrences are using
1869 1869
 	if (($tzid = date_default_timezone_get()) && ($tz_id = calendar_timezones::tz2id($tzid)))
1870 1870
 	{
1871
-		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id,__LINE__,__FILE__);
1871
+		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id, __LINE__, __FILE__);
1872 1872
 	}
1873 1873
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.005';
1874 1874
 }
@@ -1895,22 +1895,22 @@  discard block
 block discarded – undo
1895 1895
  */
1896 1896
 function calendar_upgrade1_7_006()
1897 1897
 {
1898
-	foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates
1899
-		WHERE (cal_end-cal_start)%86400=86340',__LINE__,__FILE__) as $row)
1898
+	foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates
1899
+		WHERE (cal_end-cal_start)%86400=86340',__LINE__, __FILE__) as $row)
1900 1900
 	{
1901 1901
 		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end+59
1902
-			WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__);
1902
+			WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__);
1903 1903
 	}
1904 1904
 
1905
-	foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates
1906
-		WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__,__FILE__) as $row)
1905
+	foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates
1906
+		WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__, __FILE__) as $row)
1907 1907
 	{
1908 1908
 		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end-1
1909
-			WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__);
1909
+			WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__);
1910 1910
 	}
1911 1911
 
1912 1912
     $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1
1913
-			WHERE recur_interval=0',__LINE__,__FILE__);
1913
+			WHERE recur_interval=0',__LINE__, __FILE__);
1914 1914
 
1915 1915
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007';
1916 1916
 }
@@ -1926,17 +1926,17 @@  discard block
 block discarded – undo
1926 1926
 {
1927 1927
 	// Set UID of series exception to UID of series master
1928 1928
 	// update cal_etag,cal_modified and cal_modifier to distribute changes on GroupDAV devices
1929
-	foreach($GLOBALS['egw_setup']->db->query('
1929
+	foreach ($GLOBALS['egw_setup']->db->query('
1930 1930
 		SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master
1931 1931
 		FROM egw_cal cal_ex
1932 1932
 		JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id
1933
-		WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row)
1933
+		WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row)
1934 1934
 	{
1935 1935
 		if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master'])
1936 1936
 		{
1937 1937
 			$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master'].
1938 1938
 				'\',cal_etag=cal_etag+1,cal_modified='.time().
1939
-				',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__);
1939
+				',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__);
1940 1940
 		}
1941 1941
 	}
1942 1942
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.008';
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
  */
1950 1950
 function calendar_upgrade1_7_008()
1951 1951
 {
1952
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user',array('cal_user_type','cal_user_id'));
1952
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', array('cal_user_type', 'cal_user_id'));
1953 1953
 
1954 1954
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.009';
1955 1955
 }
@@ -1961,22 +1961,22 @@  discard block
 block discarded – undo
1961 1961
  */
1962 1962
 function calendar_upgrade1_7_009()
1963 1963
 {
1964
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_uid');
1965
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_owner');
1964
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_uid');
1965
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_owner');
1966 1966
 
1967 1967
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010';
1968 1968
 }
1969 1969
 
1970 1970
 function calendar_upgrade1_7_010()
1971 1971
 {
1972
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_deleted',array(
1972
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_deleted', array(
1973 1973
 		'type' => 'bool',
1974 1974
 		'nullable' => False,
1975 1975
 		'default' => '0',
1976 1976
 		'comment' => '1 if the event has been deleted, but you want to keep it around'
1977 1977
 	));
1978 1978
 
1979
-	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001';	// was 1.7.011
1979
+	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011
1980 1980
 }
1981 1981
 
1982 1982
 function calendar_upgrade1_7_011()
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 function calendar_upgrade1_9_001()
2002 2002
 {
2003 2003
 	// delete in the past wrongly created entries for a single recurrence, which mess up the update, beside being wrong anyway
2004
-	$GLOBALS['egw_setup']->db->delete('egw_api_content_history',array(
2004
+	$GLOBALS['egw_setup']->db->delete('egw_api_content_history', array(
2005 2005
 		'sync_appname' => 'calendar',
2006 2006
 		"sync_contentid LIKE '%:%'",
2007 2007
 	), __LINE__, __FILE__);
@@ -2012,36 +2012,36 @@  discard block
 block discarded – undo
2012 2012
 		'precision' => '8',
2013 2013
 		'comment' => 'ts when event was deleted'
2014 2014
 	));*/
2015
-	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal',array(
2015
+	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal', array(
2016 2016
 		'fd' => array(
2017
-			'cal_id' => array('type' => 'auto','nullable' => False),
2018
-			'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'unique id of event(-series)'),
2019
-			'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'event owner / calendar'),
2020
-			'cal_category' => array('type' => 'varchar','precision' => '30','comment' => 'category id'),
2021
-			'cal_modified' => array('type' => 'int','precision' => '8','comment' => 'ts of last modification'),
2022
-			'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'),
2023
-			'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1','comment' => '1=public, 0=private event'),
2024
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'),
2017
+			'cal_id' => array('type' => 'auto', 'nullable' => False),
2018
+			'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'unique id of event(-series)'),
2019
+			'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'event owner / calendar'),
2020
+			'cal_category' => array('type' => 'varchar', 'precision' => '30', 'comment' => 'category id'),
2021
+			'cal_modified' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts of last modification'),
2022
+			'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'),
2023
+			'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1', 'comment' => '1=public, 0=private event'),
2024
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'),
2025 2025
 			'cal_description' => array('type' => 'text'),
2026
-			'cal_location' => array('type' => 'varchar','precision' => '255'),
2027
-			'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0','comment' => 'cal_id of series for exception'),
2028
-			'cal_modifier' => array('type' => 'int','precision' => '4','comment' => 'user who last modified event'),
2029
-			'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0','comment' => '1 for non-blocking events'),
2030
-			'cal_special' => array('type' => 'int','precision' => '2','default' => '0'),
2031
-			'cal_etag' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'etag for optimistic locking'),
2032
-			'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'),
2033
-			'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'),
2034
-			'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'),
2035
-			'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'),
2036
-			'cal_deleted' => array('type' => 'int','precision' => '8','comment' => 'ts when event was deleted')
2026
+			'cal_location' => array('type' => 'varchar', 'precision' => '255'),
2027
+			'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0', 'comment' => 'cal_id of series for exception'),
2028
+			'cal_modifier' => array('type' => 'int', 'precision' => '4', 'comment' => 'user who last modified event'),
2029
+			'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'comment' => '1 for non-blocking events'),
2030
+			'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
2031
+			'cal_etag' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'etag for optimistic locking'),
2032
+			'cal_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'creating user'),
2033
+			'cal_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'comment' => 'creation time of event'),
2034
+			'cal_recurrence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'cal_start of original recurrence for exception'),
2035
+			'tz_id' => array('type' => 'int', 'precision' => '4', 'comment' => 'key into egw_cal_timezones'),
2036
+			'cal_deleted' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts when event was deleted')
2037 2037
 		),
2038 2038
 		'pk' => array('cal_id'),
2039 2039
 		'fk' => array(),
2040
-		'ix' => array('cal_uid','cal_owner','cal_deleted'),
2040
+		'ix' => array('cal_uid', 'cal_owner', 'cal_deleted'),
2041 2041
 		'uc' => array()
2042
-	),array(
2042
+	), array(
2043 2043
 		// for deleted rows use cal_modified as deleted date, NULL for not deleted ones
2044
-		'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN cal_modified ELSE NULL END',
2044
+		'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true, 'bool').' THEN cal_modified ELSE NULL END',
2045 2045
 	));
2046 2046
 
2047 2047
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.002';
@@ -2053,16 +2053,16 @@  discard block
 block discarded – undo
2053 2053
  */
2054 2054
 function calendar_upgrade1_9_002()
2055 2055
 {
2056
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','caldav_name',array(
2056
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'caldav_name', array(
2057 2057
 		'type' => 'varchar',
2058 2058
 		'precision' => '64',
2059 2059
 		'comment' => 'name part of CalDAV URL, if specified by client'
2060 2060
 	));
2061
-	$GLOBALS['egw_setup']->db->query($sql='UPDATE egw_cal SET caldav_name='.
2061
+	$GLOBALS['egw_setup']->db->query($sql = 'UPDATE egw_cal SET caldav_name='.
2062 2062
 		$GLOBALS['egw_setup']->db->concat(
2063
-			$GLOBALS['egw_setup']->db->to_varchar('cal_id'),"'.ics'"),__LINE__,__FILE__);
2063
+			$GLOBALS['egw_setup']->db->to_varchar('cal_id'), "'.ics'"), __LINE__, __FILE__);
2064 2064
 
2065
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','caldav_name');
2065
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'caldav_name');
2066 2066
 
2067 2067
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.003';
2068 2068
 }
@@ -2073,8 +2073,8 @@  discard block
 block discarded – undo
2073 2073
  */
2074 2074
 function calendar_upgrade1_9_003()
2075 2075
 {
2076
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_modified');
2077
-	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user','cal_user_modified');
2076
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_modified');
2077
+	$GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', 'cal_user_modified');
2078 2078
 
2079 2079
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.004';
2080 2080
 }
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
  */
2087 2087
 function calendar_upgrade1_9_004()
2088 2088
 {
2089
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates','recur_exception',array(
2089
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates', 'recur_exception', array(
2090 2090
 		'type' => 'bool',
2091 2091
 		'default' => '',
2092 2092
 		'null' => false,
@@ -2094,16 +2094,16 @@  discard block
 block discarded – undo
2094 2094
 	));
2095 2095
 
2096 2096
 	// migrate existing exceptions to egw_cal_dates
2097
-	foreach($GLOBALS['egw_setup']->db->select('egw_cal_repeats',
2097
+	foreach ($GLOBALS['egw_setup']->db->select('egw_cal_repeats',
2098 2098
 		'egw_cal_repeats.cal_id AS cal_id,egw_cal_repeats.recur_exception AS recur_exception,MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
2099 2099
 		'egw_cal_repeats.recur_exception IS NOT NULL', __LINE__, __FILE__, false,
2100 2100
 		'GROUP BY egw_cal_repeats.cal_id,egw_cal_repeats.recur_exception', 'calendar', '',
2101 2101
 		'JOIN egw_cal_dates ON egw_cal_repeats.cal_id=egw_cal_dates.cal_id') as $row)
2102 2102
 	{
2103
-		foreach($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception)
2103
+		foreach ($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception)
2104 2104
 		{
2105 2105
 			$GLOBALS['egw_setup']->db->insert('egw_cal_dates', array(
2106
-				'cal_end' => $recur_exception+$row['cal_end']-$row['cal_start'],
2106
+				'cal_end' => $recur_exception + $row['cal_end'] - $row['cal_start'],
2107 2107
 				'recur_exception' => true,
2108 2108
 			), array(
2109 2109
 				'cal_id' => $row['cal_id'],
@@ -2115,11 +2115,11 @@  discard block
 block discarded – undo
2115 2115
 
2116 2116
 	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array(
2117 2117
 		'fd' => array(
2118
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
2119
-			'recur_type' => array('type' => 'int','precision' => '2','nullable' => False),
2120
-			'recur_enddate' => array('type' => 'int','precision' => '8'),
2121
-			'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'),
2122
-			'recur_data' => array('type' => 'int','precision' => '2','default' => '1'),
2118
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
2119
+			'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False),
2120
+			'recur_enddate' => array('type' => 'int', 'precision' => '8'),
2121
+			'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'),
2122
+			'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1'),
2123 2123
 		),
2124 2124
 		'pk' => array('cal_id'),
2125 2125
 		'fk' => array(),
@@ -2140,19 +2140,19 @@  discard block
 block discarded – undo
2140 2140
 	// returns NULL, if there are no rows!
2141 2141
 	if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384)
2142 2142
 	{
2143
-		$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_description',array(
2143
+		$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_description', array(
2144 2144
 			'type' => 'varchar',
2145 2145
 			'precision' => '16384'
2146 2146
 		));
2147 2147
 	}
2148 2148
 	// allow more categories
2149
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array(
2149
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array(
2150 2150
 		'type' => 'varchar',
2151 2151
 		'precision' => '64',
2152 2152
 		'comment' => 'category id(s)'
2153 2153
 	));
2154 2154
 	// remove silly default of 1
2155
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_title',array(
2155
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_title', array(
2156 2156
 		'type' => 'varchar',
2157 2157
 		'precision' => '255',
2158 2158
 		'nullable' => False
@@ -2167,14 +2167,14 @@  discard block
 block discarded – undo
2167 2167
 {
2168 2168
 	// PostgreSQL needs temporary a nullable column, to not stall on broken events without dates!
2169 2169
 	// We add that constrain in 1.9.007, after deleting all rows with range_start=0 OR range_start IS NULL
2170
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_start',array(
2170
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_start', array(
2171 2171
 		'type' => 'int',
2172 2172
 		'precision' => '8',
2173 2173
 		'comment' => 'startdate (of range)'
2174 2174
 	));
2175 2175
 	$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_start = (SELECT MIN(cal_start) FROM egw_cal_dates WHERE egw_cal_dates.cal_id=egw_cal.cal_id)', __LINE__, __FILE__);
2176 2176
 
2177
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_end',array(
2177
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_end', array(
2178 2178
 		'type' => 'int',
2179 2179
 		'precision' => '8',
2180 2180
 		'comment' => 'enddate (of range, UNTIL of RRULE)'
@@ -2190,18 +2190,18 @@  discard block
 block discarded – undo
2190 2190
 	{
2191 2191
 		$GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_end=recur_enddate FROM egw_cal_repeats WHERE egw_cal.cal_id=egw_cal_repeats.cal_id', __LINE__, __FILE__);
2192 2192
 	}
2193
-	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array(
2193
+	$GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array(
2194 2194
 		'fd' => array(
2195
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
2196
-			'recur_type' => array('type' => 'int','precision' => '2','nullable' => False),
2197
-			'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'),
2198
-			'recur_data' => array('type' => 'int','precision' => '2','default' => '1')
2195
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
2196
+			'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False),
2197
+			'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'),
2198
+			'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1')
2199 2199
 		),
2200 2200
 		'pk' => array('cal_id'),
2201 2201
 		'fk' => array(),
2202 2202
 		'ix' => array(),
2203 2203
 		'uc' => array()
2204
-	),'recur_enddate');
2204
+	), 'recur_enddate');
2205 2205
 
2206 2206
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.007';
2207 2207
 }
@@ -2213,14 +2213,14 @@  discard block
 block discarded – undo
2213 2213
  */
2214 2214
 function calendar_upgrade1_9_007()
2215 2215
 {
2216
-	foreach(array('egw_cal_repeats','egw_cal_dates','egw_cal_user','egw_cal_extra') as $table)
2216
+	foreach (array('egw_cal_repeats', 'egw_cal_dates', 'egw_cal_user', 'egw_cal_extra') as $table)
2217 2217
 	{
2218 2218
 		$GLOBALS['egw_setup']->db->query("DELETE FROM $table WHERE cal_id IN (SELECT cal_id FROM egw_cal WHERE range_start=0 OR range_start IS NULL)", __LINE__, __FILE__);
2219 2219
 	}
2220 2220
 	$GLOBALS['egw_setup']->db->query("DELETE FROM egw_cal WHERE range_start=0 OR range_start IS NULL", __LINE__, __FILE__);
2221 2221
 
2222 2222
 	// now we can remove temporary default of 0 from range_start and set it NOT NULL
2223
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','range_start',array(
2223
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'range_start', array(
2224 2224
 		'type' => 'int',
2225 2225
 		'precision' => '8',
2226 2226
 		'nullable' => False,
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 
2286 2286
 function calendar_upgrade1_9_010()
2287 2287
 {
2288
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array(
2288
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array(
2289 2289
 		'type' => 'varchar',
2290 2290
 		'precision' => '200',
2291 2291
 		'comment' => 'name part of CalDAV URL, if specified by client'
@@ -2315,7 +2315,7 @@  discard block
 block discarded – undo
2315 2315
 SET cal_reference=0,cal_recurrence=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time()."
2316 2316
 WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__);
2317 2317
 
2318
-	foreach($GLOBALS['egw_setup']->db->query(
2318
+	foreach ($GLOBALS['egw_setup']->db->query(
2319 2319
 "SELECT DISTINCT master.cal_id,egw_cal_user.cal_user_type,egw_cal_user.cal_user_id,'E' AS cal_status
2320 2320
 FROM egw_cal_user
2321 2321
 JOIN egw_cal ON egw_cal_user.cal_id=egw_cal.cal_id
@@ -2342,7 +2342,7 @@  discard block
 block discarded – undo
2342 2342
  */
2343 2343
 function calendar_upgrade14_1_001()
2344 2344
 {
2345
-	foreach($GLOBALS['egw_setup']->db->query(
2345
+	foreach ($GLOBALS['egw_setup']->db->query(
2346 2346
 "SELECT egw_cal.cal_id AS cal_id,cal_start,cal_end,range_start,range_end,egw_cal_repeats.*,tz_tzid AS tzid
2347 2347
 FROM egw_cal
2348 2348
 JOIN egw_cal_repeats ON egw_cal_repeats.cal_id=egw_cal.cal_id
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
 		$enddate->modify(($event['end'] - $event['start']).' second');
2365 2365
 		if (($range_end = $enddate->format('server')) != $event['range_end'])
2366 2366
 		{
2367
-			$GLOBALS['egw_setup']->db->update('egw_cal',array(
2367
+			$GLOBALS['egw_setup']->db->update('egw_cal', array(
2368 2368
 				'range_end' => $range_end,
2369 2369
 				'cal_etag=cal_etag+1',
2370 2370
 				'cal_modified' => time(),
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 			//error_log(__FUNCTION__."() #$event[id], start=".date('Y-m-d H:i:s', $event['start']).', end='.date('Y-m-d H:i:s', $event['end']).', range_end='.date('Y-m-d H:i:s', $event['recur_enddate']).' --> '.date('Y-m-d H:i:s', $range_end));
2375 2375
 		}
2376 2376
 	}
2377
-	return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002';	// skip 14.2.001 update, as query is fixed now
2377
+	return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now
2378 2378
 }
2379 2379
 
2380 2380
 /**
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 	// if maximum is bigger then 3
2399 2399
 	if ($values[1] > 3)
2400 2400
 	{
2401
-		switch($GLOBALS['egw_setup']->db->Type)
2401
+		switch ($GLOBALS['egw_setup']->db->Type)
2402 2402
 		{
2403 2403
 			case 'mysql':
2404 2404
 				$sql = "UPDATE egw_cal
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 
2449 2449
 function calendar_upgrade14_2_003()
2450 2450
 {
2451
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_uid',array(
2451
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_uid', array(
2452 2452
 		'type' => 'ascii',
2453 2453
 		'precision' => '128',
2454 2454
 		'nullable' => False,
@@ -2460,13 +2460,13 @@  discard block
 block discarded – undo
2460 2460
 	{
2461 2461
 		$GLOBALS['egw_setup']->db->query("UPDATE egw_cal SET cal_category='' WHERE cal_category NOT REGEXP '^[0-9,]*$'", __LINE__, __FILE__);
2462 2462
 	}
2463
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array(
2463
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array(
2464 2464
 		'type' => 'ascii',
2465 2465
 		'meta' => 'category',
2466 2466
 		'precision' => '64',
2467 2467
 		'comment' => 'category id(s)'
2468 2468
 	));
2469
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array(
2469
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array(
2470 2470
 		'type' => 'ascii',
2471 2471
 		'precision' => '128',
2472 2472
 		'comment' => 'name part of CalDAV URL, if specified by client'
@@ -2523,22 +2523,22 @@  discard block
 block discarded – undo
2523 2523
 		'type' => 'auto',
2524 2524
 		'nullable' => False
2525 2525
 	));*/
2526
-	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array(
2526
+	$GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array(
2527 2527
 		'fd' => array(
2528
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
2529
-			'cal_recur_date' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0'),
2530
-			'cal_user_type' => array('type' => 'ascii','precision' => '1','nullable' => False,'default' => 'u','comment' => 'u=user, g=group, c=contact, r=resource, e=email'),
2531
-			'cal_user_id' => array('type' => 'varchar','meta' => array("cal_user_type='u'" => 'account'),'precision' => '128','nullable' => False,'comment' => 'id or email-address for type=e'),
2532
-			'cal_status' => array('type' => 'ascii','precision' => '1','default' => 'A','comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'),
2533
-			'cal_quantity' => array('type' => 'int','precision' => '4','default' => '1','comment' => 'only for certain types (eg. resources)'),
2534
-			'cal_role' => array('type' => 'ascii','precision' => '64','default' => 'REQ-PARTICIPANT','comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'),
2535
-			'cal_user_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'automatic timestamp of last update'),
2536
-			'cal_user_auto' => array('type' => 'auto','nullable' => False)
2528
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
2529
+			'cal_recur_date' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0'),
2530
+			'cal_user_type' => array('type' => 'ascii', 'precision' => '1', 'nullable' => False, 'default' => 'u', 'comment' => 'u=user, g=group, c=contact, r=resource, e=email'),
2531
+			'cal_user_id' => array('type' => 'varchar', 'meta' => array("cal_user_type='u'" => 'account'), 'precision' => '128', 'nullable' => False, 'comment' => 'id or email-address for type=e'),
2532
+			'cal_status' => array('type' => 'ascii', 'precision' => '1', 'default' => 'A', 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'),
2533
+			'cal_quantity' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'comment' => 'only for certain types (eg. resources)'),
2534
+			'cal_role' => array('type' => 'ascii', 'precision' => '64', 'default' => 'REQ-PARTICIPANT', 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'),
2535
+			'cal_user_modified' => array('type' => 'timestamp', 'default' => 'current_timestamp', 'comment' => 'automatic timestamp of last update'),
2536
+			'cal_user_auto' => array('type' => 'auto', 'nullable' => False)
2537 2537
 		),
2538 2538
 		'pk' => array('cal_user_auto'),
2539 2539
 		'fk' => array(),
2540
-		'ix' => array('cal_user_modified',array('cal_user_type','cal_user_id')),
2541
-		'uc' => array(array('cal_id','cal_recur_date','cal_user_type','cal_user_id'))
2540
+		'ix' => array('cal_user_modified', array('cal_user_type', 'cal_user_id')),
2541
+		'uc' => array(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'))
2542 2542
 	));
2543 2543
 
2544 2544
 	return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.005';
@@ -2547,12 +2547,12 @@  discard block
 block discarded – undo
2547 2547
 
2548 2548
 function calendar_upgrade14_2_005()
2549 2549
 {
2550
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_tzid',array(
2550
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_tzid', array(
2551 2551
 		'type' => 'ascii',
2552 2552
 		'precision' => '128',
2553 2553
 		'nullable' => False
2554 2554
 	));
2555
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_component',array(
2555
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_component', array(
2556 2556
 		'type' => 'ascii',
2557 2557
 		'precision' => '8192',
2558 2558
 		'comment' => 'iCal VTIMEZONE component'
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
  */
2569 2569
 function calendar_upgrade14_3()
2570 2570
 {
2571
-	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_attendee',array(
2571
+	$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_attendee', array(
2572 2572
 		'type' => 'varchar',
2573 2573
 		'precision' => '255',
2574 2574
 		'comment' => 'email or json object with attr. cn, url, ...'
@@ -2579,12 +2579,12 @@  discard block
 block discarded – undo
2579 2579
 
2580 2580
 	// delete all but one row, which would give a doublicate key, after above normalising of email addresses
2581 2581
 	// by ordering by status we prever accepted over tentative over unknow over deleted
2582
-	foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array(
2582
+	foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array(
2583 2583
 		'cal_user_type' => 'e',
2584 2584
 	), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1", 'calendar') as $row)
2585 2585
 	{
2586 2586
 		$n = 0;
2587
-		foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array(
2587
+		foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array(
2588 2588
 			'cal_id' => $row['cal_id'],
2589 2589
 			'cal_recur_date' => $row['cal_recur_date'],
2590 2590
 			'cal_user_type' => 'e',
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 		), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user)	// order A, T, U, X
2593 2593
 		{
2594 2594
 			if (strpos($user['email'], '@') !== false && !$n++) continue;
2595
-			$GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))));
2595
+			$GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id', 'cal_status'))));
2596 2596
 		}
2597 2597
 	}
2598 2598
 
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
 		"UPDATE egw_cal_user SET cal_user_attendee=cal_user_id,cal_user_id=MD5($email) WHERE cal_user_type='e'",
2602 2602
 		__LINE__, __FILE__);
2603 2603
 
2604
-	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array(
2604
+	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array(
2605 2605
 		'type' => 'ascii',
2606 2606
 		'meta' => array(
2607 2607
 			"cal_user_type='u'" => 'account'
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 {
2624 2624
 	$GLOBALS['calendar_upgrade14_3_001-run'] = true;
2625 2625
 
2626
-	foreach($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee
2626
+	foreach ($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee
2627 2627
 FROM egw_cal_user
2628 2628
 JOIN egw_cal_user euser ON euser.cal_id=egw_cal_user.cal_id AND euser.cal_user_type='e' AND euser.cal_user_id=egw_cal_user.cal_user_id AND euser.cal_user_attendee IS NULL
2629 2629
 WHERE egw_cal_user.cal_user_type='e' AND egw_cal_user.cal_user_attendee IS NOT NULL
@@ -2674,8 +2674,8 @@  discard block
 block discarded – undo
2674 2674
 {
2675 2675
 	Api\Preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner)
2676 2676
 	{
2677
-		unset($attr, $owner);	// not used, but required by function signature
2678
-		if($old_value['state'] && is_array($old_value['state']))
2677
+		unset($attr, $owner); // not used, but required by function signature
2678
+		if ($old_value['state'] && is_array($old_value['state']))
2679 2679
 		{
2680 2680
 			unset($old_value['state']['date']);
2681 2681
 			unset($old_value['state']['startdate']);
@@ -2695,15 +2695,15 @@  discard block
 block discarded – undo
2695 2695
 {
2696 2696
 	Api\Preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner)
2697 2697
 	{
2698
-		unset($attr, $owner);	// not used, but required by function signature
2699
-		switch($old_value)
2698
+		unset($attr, $owner); // not used, but required by function signature
2699
+		switch ($old_value)
2700 2700
 		{
2701 2701
 			case 'all':
2702 2702
 				return 0;
2703 2703
 			case 'day_week':
2704
-				return ['day','day4','week'];
2704
+				return ['day', 'day4', 'week'];
2705 2705
 			case 'day4':
2706
-				return ['day','day4'];
2706
+				return ['day', 'day4'];
2707 2707
 		}
2708 2708
 		return null;
2709 2709
 	});
@@ -2728,7 +2728,7 @@  discard block
 block discarded – undo
2728 2728
 function calendar_upgrade16_1_001()
2729 2729
 {
2730 2730
 	$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_extra', 'cal_extra_value',
2731
-		array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => ''));
2731
+		array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => ''));
2732 2732
 
2733 2733
 	Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'forced');
2734 2734
 	Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'default');
Please login to merge, or discard this patch.
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1429,13 +1429,18 @@  discard block
 block discarded – undo
1429 1429
 function calendar_upgrade1_0_1_008()
1430 1430
 {
1431 1431
 	$config_data = Api\Config::read('calendar');
1432
-	if (isset($config_data['fields']))	// old custom fields
1432
+	if (isset($config_data['fields']))
1433
+	{
1434
+		// old custom fields
1433 1435
 	{
1434 1436
 		$customfields = array();
1437
+	}
1435 1438
 		$order = 0;
1436 1439
 		foreach($config_data['fields'] as $name => $data)
1437 1440
 		{
1438
-			if ($name{0} == '#' && !$data['disabled'])	// real not-disabled custom field
1441
+			if ($name{0} == '#' && !$data['disabled'])
1442
+			{
1443
+				// real not-disabled custom field
1439 1444
 			{
1440 1445
 				$customfields[substr($name,1)] = array(
1441 1446
 					'type'  => 'text',
@@ -1444,6 +1449,7 @@  discard block
 block discarded – undo
1444 1449
 					'order' => ($order += 10),
1445 1450
 				);
1446 1451
 			}
1452
+			}
1447 1453
 		}
1448 1454
 		if (count($customfields))
1449 1455
 		{
@@ -2589,9 +2595,12 @@  discard block
 block discarded – undo
2589 2595
 			'cal_recur_date' => $row['cal_recur_date'],
2590 2596
 			'cal_user_type' => 'e',
2591 2597
 			$email.'='.$GLOBALS['egw_setup']->db->quote($row['email']),
2592
-		), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user)	// order A, T, U, X
2598
+		), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user)
2599
+		{
2600
+			// order A, T, U, X
2593 2601
 		{
2594 2602
 			if (strpos($user['email'], '@') !== false && !$n++) continue;
2603
+		}
2595 2604
 			$GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))));
2596 2605
 		}
2597 2606
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		{
33 33
 			$GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'");
34 34
 			$GLOBALS['egw_setup']->oProc->next_record();
35
-			$GLOBALS['egw_setup']->oProc->query("UPDATE $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'");
35
+			$GLOBALS['egw_setup']->oProc->query("update $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'");
36 36
 		}
37 37
 	}
38 38
 	$GLOBALS['egw_setup']->oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0));
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	$db2 = clone($GLOBALS['egw_setup']->db);
189 189
 
190 190
 	$GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry',
191
-		Array(
191
+		array(
192 192
 			'fd' => array(
193 193
 				'cal_id' => array('type' => 'auto', 'nullable' => false),
194 194
 				'cal_owner' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'),
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	$GLOBALS['egw_setup']->oProc->DropTable('webcal_entry');
239 239
 
240 240
 	$GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_user',
241
-		Array(
241
+		array(
242 242
 			'fd' => array(
243 243
 				'cal_id' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'),
244 244
 				'cal_login' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	$GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_user');
269 269
 
270 270
 	$GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_repeats',
271
-		Array(
271
+		array(
272 272
 			'fd' => array(
273 273
 				'cal_id' => array('type' => 'int', 'precision' => 4, 'default' => '0', 'nullable' => false),
274 274
 				'cal_type' => array('type' => 'varchar', 'precision' => 20, 'default' => 'daily', 'nullable' => false),
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 
312 312
 	$GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats');
313
-	$GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
313
+	$GLOBALS['egw_setup']->oProc->query("update {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
314 314
 
315 315
 	$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2';
316 316
 	return $GLOBALS['setup_info']['calendar']['currentver'];
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
 // calendar_entry => phpgw_cal
604 604
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal',
605
-		Array(
605
+		array(
606 606
 			'fd' => array(
607 607
 				'cal_id' => array('type' => 'auto', 'nullable' => False),
608 608
 				'owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False),
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
 // calendar_entry_repeats => phpgw_cal_repeats
660 660
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats',
661
-		Array(
661
+		array(
662 662
 			'fd' => array(
663 663
 				'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False),
664 664
 				'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False),
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 function calendar_upgrade0_9_11_003()
732 732
 {
733 733
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays',
734
-		Array(
734
+		array(
735 735
 			'fd' => array(
736 736
 				'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False),
737 737
 				'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False),
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 {
768 768
 	$GLOBALS['egw_setup']->oProc->DropTable('phpgw_cal_holidays');
769 769
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays',
770
-		Array(
770
+		array(
771 771
 			'fd' => array(
772 772
 				'hol_id' => array('type' => 'auto','nullable' => False),
773 773
 				'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False),
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 function calendar_upgrade0_9_13_003()
855 855
 {
856 856
 	$GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm',
857
-		Array(
857
+		array(
858 858
 			'fd' => array(
859 859
 				'alarm_id' => array('type' => 'auto','nullable' => False),
860 860
 				'cal_id'   => array('type' => 'int', 'precision' => 8, 'nullable' => False),
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 
889 889
 function calendar_upgrade0_9_13_005()
890 890
 {
891
-	$calendar_data = Array();
891
+	$calendar_data = array();
892 892
 	$GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__);
893 893
 	while($GLOBALS['egw_setup']->oProc->next_record())
894 894
 	{
Please login to merge, or discard this patch.
doc/fix_api.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
  *
188 188
  * @param string $file filename
189 189
  * @param boolean $dry_run =false true: only echo fixed file, not fix it
190
- * @return boolean false on error
190
+ * @return boolean|null false on error
191 191
  */
192 192
 function fix_api($file, $dry_run=false)
193 193
 {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 // raw replacements
19 19
 $add_use_api = array(
20
-	"#use EGroupware\\\\Api;\n#" => '',	// remove evtl. use EGroupware\Api, as we add it again below
20
+	"#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below
21 21
 	"#<\?php\n+\s*/\*+?(.*)\*/#msU" => "<?php\n/**$1*/\n\nuse EGroupware\\Api;",
22 22
 );
23 23
 $replace = array(
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 // enclose class-names and static methods with some syntax check
47 47
 $class_start = '#(?<!function)([\[\s,;().!=])';
48 48
 $class_end = '(::|\\(|\\)|;|\?|:|\\s|,|$)#';
49
-foreach(array(
49
+foreach (array(
50 50
 	'accounts' => 'Api\\Accounts',
51 51
 	'acl' => 'Api\\Acl',
52 52
 	'EGW_ACL_READ' => 'Api\\Acl::READ',
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
  * @param boolean $dry_run =false true: only echo fixed file, not fix it
190 190
  * @return boolean false on error
191 191
  */
192
-function fix_api($file, $dry_run=false)
192
+function fix_api($file, $dry_run = false)
193 193
 {
194 194
 	global $prog, $replace, $add_use_api;
195
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
195
+	if (basename($file) == $prog) return true; // dont fix ourself ;-)
196 196
 
197 197
 	if (($content = $content_in = file_get_contents($file)) === false) return false;
198 198
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 	$content2 = preg_replace(array_keys($replace), array_values($replace), $content);
205 205
 
206
-	if ($content2 == $content_in) return true;	// nothing changed
206
+	if ($content2 == $content_in) return true; // nothing changed
207 207
 
208 208
 	$content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2);
209 209
 
210 210
 	// shorten some classes, if used, with further use declarations
211
-	foreach(array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace)
211
+	foreach (array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace)
212 212
 	{
213 213
 		if (strpos($content, $namespace) !== false && strpos($content, 'use EGroupware\\'.$namespace) === false)
214 214
 		{
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
  * @param boolean $dry_run =false true: only echo fixed file, not fix it
248 248
  * @return boolean false on error
249 249
  */
250
-function fix_api_recursive($dir, $dry_run=false)
250
+function fix_api_recursive($dir, $dry_run = false)
251 251
 {
252 252
 	if (!is_dir($dir)) return false;
253 253
 
254
-	foreach(scandir($dir) as $file)
254
+	foreach (scandir($dir) as $file)
255 255
 	{
256 256
 		if ($file == '.' || $file == '..') continue;
257 257
 
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 		{
260 260
 			fix_api_recursive($dir.'/'.$file, $dry_run);
261 261
 		}
262
-		elseif(substr($file,-4) == '.php')
262
+		elseif (substr($file, -4) == '.php')
263 263
 		{
264
-			echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': ';
264
+			echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': ';
265 265
 			fix_api($dir.'/'.$file, $dry_run);
266 266
 		}
267 267
 	}
268
-	echo "\r".str_repeat(' ',100)."\r";
268
+	echo "\r".str_repeat(' ', 100)."\r";
269 269
 	return true;
270 270
 }
271 271
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  *
275 275
  * @param string $error =null
276 276
  */
277
-function usage($error=null)
277
+function usage($error = null)
278 278
 {
279 279
 	global $prog;
280 280
 	echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n";
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 if (!$args) usage();
289 289
 
290 290
 $dry_run = false;
291
-while(($arg = array_shift($args)) && $arg[0] == '-')
291
+while (($arg = array_shift($args)) && $arg[0] == '-')
292 292
 {
293
-	switch($arg)
293
+	switch ($arg)
294 294
 	{
295 295
 		case '-h':
296 296
 		case '--help':
@@ -323,4 +323,4 @@  discard block
 block discarded – undo
323 323
 		fix_api_recursive($arg, $dry_run);
324 324
 	}
325 325
 }
326
-while(($arg = array_shift($args)));
326
+while (($arg = array_shift($args)));
Please login to merge, or discard this patch.
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling as web-page
13
+if (php_sapi_name() !== 'cli')
14
+{
15
+	// security precaution: forbit calling as web-page
14 16
 {
15 17
 	die('<h1>fix_api.php must NOT be called as web-page --> exiting !!!</h1>');
16 18
 }
19
+}
17 20
 
18 21
 // raw replacements
19 22
 $add_use_api = array(
@@ -192,9 +195,16 @@  discard block
 block discarded – undo
192 195
 function fix_api($file, $dry_run=false)
193 196
 {
194 197
 	global $prog, $replace, $add_use_api;
195
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
198
+	if (basename($file) == $prog)
199
+	{
200
+		return true;
201
+	}
202
+	// dont fix ourself ;-)
196 203
 
197
-	if (($content = $content_in = file_get_contents($file)) === false) return false;
204
+	if (($content = $content_in = file_get_contents($file)) === false)
205
+	{
206
+		return false;
207
+	}
198 208
 
199 209
 	if (!preg_match("|<\?php\n+\s*/\*\*?.*\*/|msU", $content))
200 210
 	{
@@ -203,7 +213,11 @@  discard block
 block discarded – undo
203 213
 	}
204 214
 	$content2 = preg_replace(array_keys($replace), array_values($replace), $content);
205 215
 
206
-	if ($content2 == $content_in) return true;	// nothing changed
216
+	if ($content2 == $content_in)
217
+	{
218
+		return true;
219
+	}
220
+	// nothing changed
207 221
 
208 222
 	$content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2);
209 223
 
@@ -249,11 +263,17 @@  discard block
 block discarded – undo
249 263
  */
250 264
 function fix_api_recursive($dir, $dry_run=false)
251 265
 {
252
-	if (!is_dir($dir)) return false;
266
+	if (!is_dir($dir))
267
+	{
268
+		return false;
269
+	}
253 270
 
254 271
 	foreach(scandir($dir) as $file)
255 272
 	{
256
-		if ($file == '.' || $file == '..') continue;
273
+		if ($file == '.' || $file == '..')
274
+		{
275
+			continue;
276
+		}
257 277
 
258 278
 		if (is_dir($dir.'/'.$file))
259 279
 		{
@@ -278,14 +298,20 @@  discard block
 block discarded – undo
278 298
 {
279 299
 	global $prog;
280 300
 	echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n";
281
-	if ($error) echo $error."\n\n";
301
+	if ($error)
302
+	{
303
+		echo $error."\n\n";
304
+	}
282 305
 	exit($error ? 1 : 0);
283 306
 }
284 307
 
285 308
 $args = $_SERVER['argv'];
286 309
 $prog = basename(array_shift($args));
287 310
 
288
-if (!$args) usage();
311
+if (!$args)
312
+{
313
+	usage();
314
+}
289 315
 
290 316
 $dry_run = false;
291 317
 while(($arg = array_shift($args)) && $arg[0] == '-')
@@ -303,16 +329,22 @@  discard block
 block discarded – undo
303 329
 			break;
304 330
 
305 331
 		default:
306
-			if ($args)	// not last argument
332
+			if ($args)
333
+			{
334
+				// not last argument
307 335
 			{
308 336
 				usage("Unknown argument '$arg'!");
309 337
 			}
338
+			}
310 339
 			break 2;
311 340
 	}
312 341
 }
313 342
 
314 343
 do {
315
-	if (!file_exists($arg)) usage("Error: $arg not found!");
344
+	if (!file_exists($arg))
345
+	{
346
+		usage("Error: $arg not found!");
347
+	}
316 348
 
317 349
 	if (!is_dir($arg))
318 350
 	{
Please login to merge, or discard this patch.
doc/fix_depricated.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * Fix depricated stuff in a given file
24 24
  *
25 25
  * @param string $file filename
26
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
26
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29 29
 function fix_depricated($file,$replace_file=false)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
  * Loop recursive through directory and call fix_depricated for each php file
147 147
  *
148 148
  * @param string $dir
149
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
149
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152 152
 function fix_depricated_recursive($dir,$replace_file=false)
@@ -174,7 +174,6 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * Give usage
176 176
  *
177
- * @param string $error=null
178 177
  */
179 178
 function usage($error=null)
180 179
 {
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -26,47 +26,47 @@  discard block
 block discarded – undo
26 26
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29
-function fix_depricated($file,$replace_file=false)
29
+function fix_depricated($file, $replace_file = false)
30 30
 {
31 31
 	$orig = $lines = file_get_contents($file);
32 32
 	if ($lines === false) return false;
33 33
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
34
+	if (basename($file) == $prog) return true; // dont fix ourself ;-)
35 35
 
36 36
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37
-	if (preg_match('/= *& *new /m',$lines))
37
+	if (preg_match('/= *& *new /m', $lines))
38 38
 	{
39
-		$lines = preg_replace('/= *& *new /','= new ',$lines);
39
+		$lines = preg_replace('/= *& *new /', '= new ', $lines);
40 40
 	}
41 41
 	// PHP Deprecated:  Function split() is deprecated
42
-	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m',$lines,$matches))
42
+	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m', $lines, $matches))
43 43
 	{
44 44
 		$replace = array();
45 45
 		//print_r($matches);
46
-		foreach($matches[1] as $key => $pattern)
46
+		foreach ($matches[1] as $key => $pattern)
47 47
 		{
48 48
 			$full_pattern = $matches[0][$key];
49 49
 			// single char --> just explode
50
-			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern,0,2) == '"\\')
50
+			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern, 0, 2) == '"\\')
51 51
 			{
52
-				$replace[$full_pattern] = str_replace('split','explode',$full_pattern);
52
+				$replace[$full_pattern] = str_replace('split', 'explode', $full_pattern);
53 53
 			}
54 54
 			else
55 55
 			{
56
-				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
58
-				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
56
+				$preg_pattern = $pattern[0].'/'.str_replace('/', '\\\\/', substr($pattern, 1, -1)).'/'.$pattern[0];
57
+				if (strpos($full_pattern, 'spliti')) $preg_pattern = substr($preg_pattern, 0, -1).'i'.$pattern[0];
58
+				$replace[$full_pattern] = str_replace(array('spliti', 'split', $pattern), array('preg_split', 'preg_split', $preg_pattern), $full_pattern);
59 59
 			}
60 60
 		}
61 61
 		//print_r($replace);
62
-		$lines = strtr($lines,$replace);
62
+		$lines = strtr($lines, $replace);
63 63
 	}
64 64
 	// PHP Deprecated:  Function ereg() is deprecated
65
-	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m',$lines,$matches))
65
+	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m', $lines, $matches))
66 66
 	{
67 67
 		$replace = array();
68 68
 		//print_r($matches);
69
-		foreach($matches[1] as $key => $pattern)
69
+		foreach ($matches[1] as $key => $pattern)
70 70
 		{
71 71
 			$full_pattern = $matches[0][$key];
72 72
 			$what = $matches[2][$key];
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
 			if (preg_quote($pattern) == $pattern)
76 76
 			{
77 77
 
78
-				$replace[$full_pattern] = (strpos($full_pattern,'eregi')!==false?'strposi':'strpos').'('.$what.','.$pattern.
79
-					') '.($full_pattern[0]=='!'?'===':'!==').' false'.$matches[4][$key];
78
+				$replace[$full_pattern] = (strpos($full_pattern, 'eregi') !== false ? 'strposi' : 'strpos').'('.$what.','.$pattern.
79
+					') '.($full_pattern[0] == '!' ? '===' : '!==').' false'.$matches[4][$key];
80 80
 			}
81 81
 			else
82 82
 			{
83 83
 				// full ereg regular expression --> preg_match
84
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
85
-				$replace[$full_pattern] = str_replace(array('eregi','ereg',$pattern),array('preg_match','preg_match',$preg_pattern),$full_pattern);
84
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
85
+				$replace[$full_pattern] = str_replace(array('eregi', 'ereg', $pattern), array('preg_match', 'preg_match', $preg_pattern), $full_pattern);
86 86
 			}
87 87
 		}
88 88
 		//print_r($replace);
89
-		$lines = strtr($lines,$replace);
89
+		$lines = strtr($lines, $replace);
90 90
 	}
91 91
 	// PHP Deprecated:  Function ereg_replace() is deprecated
92
-	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m',$lines,$matches))
92
+	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m', $lines, $matches))
93 93
 	{
94 94
 		$replace = array();
95 95
 		//print_r($matches);
96
-		foreach($matches[1] as $key => $pattern)
96
+		foreach ($matches[1] as $key => $pattern)
97 97
 		{
98 98
 			$full_pattern = $matches[0][$key];
99 99
 			$other = $matches[2][$key];
@@ -101,41 +101,41 @@  discard block
 block discarded – undo
101 101
 			// simple replace --> use str_replace()
102 102
 			if (preg_quote($pattern) == $pattern)
103 103
 			{
104
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace'),array('stri_replace','str_replace'),$full_pattern);
104
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace'), array('stri_replace', 'str_replace'), $full_pattern);
105 105
 			}
106 106
 			else
107 107
 			{
108 108
 				// full ereg regular expression --> preg_replace
109
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
110
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace',$pattern),
111
-					array('preg_replace','preg_replace',$preg_pattern),$full_pattern);
109
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
110
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace', $pattern),
111
+					array('preg_replace', 'preg_replace', $preg_pattern), $full_pattern);
112 112
 			}
113 113
 		}
114 114
 		//print_r($replace);
115
-		$lines = strtr($lines,$replace);
115
+		$lines = strtr($lines, $replace);
116 116
 	}
117 117
 	// remove extra '/' from regular expressions
118
-	$lines = str_replace(array("'/'.'","'.'/'","'.'/i'"),array("'/","/'","/i'"),$lines);
118
+	$lines = str_replace(array("'/'.'", "'.'/'", "'.'/i'"), array("'/", "/'", "/i'"), $lines);
119 119
 
120 120
 	// fix call to not longer existing PDO method $result->fetchSingle()
121
-	$lines = str_replace('->fetchSingle(','->fetchColumn(',$lines);
121
+	$lines = str_replace('->fetchSingle(', '->fetchColumn(', $lines);
122 122
 
123 123
 	// fix calls to deprecated call_user_method(_array)?(method,object[,args])
124
-	if (preg_match('/call_user_method(_array)?\(/',$lines,$matches))
124
+	if (preg_match('/call_user_method(_array)?\(/', $lines, $matches))
125 125
 	{
126
-		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/','call_user_func(array(\\2,\\1)\\3',$lines);
127
-		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/','call_user_func_array(array(\\2,\\1)\\3',$lines);
126
+		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/', 'call_user_func(array(\\2,\\1)\\3', $lines);
127
+		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/', 'call_user_func_array(array(\\2,\\1)\\3', $lines);
128 128
 	}
129 129
 
130 130
 	if ($lines != $orig)
131 131
 	{
132
-		file_put_contents($file.'53',$lines);
133
-		system('/usr/bin/php -l '.$file.'53',$ret);
132
+		file_put_contents($file.'53', $lines);
133
+		system('/usr/bin/php -l '.$file.'53', $ret);
134 134
 		system('/usr/bin/diff -u '.$file.' '.$file.'53');
135 135
 		if (!$ret && $replace_file)
136 136
 		{
137 137
 			unlink($file);
138
-			rename($file.'53',$file);
138
+			rename($file.'53', $file);
139 139
 		}
140 140
 		return !$ret;
141 141
 	}
@@ -149,25 +149,25 @@  discard block
 block discarded – undo
149 149
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152
-function fix_depricated_recursive($dir,$replace_file=false)
152
+function fix_depricated_recursive($dir, $replace_file = false)
153 153
 {
154 154
 	if (!is_dir($dir)) return false;
155 155
 
156
-	foreach(scandir($dir) as $file)
156
+	foreach (scandir($dir) as $file)
157 157
 	{
158 158
 		if ($file == '.' || $file == '..') continue;
159 159
 
160 160
 		if (is_dir($dir.'/'.$file))
161 161
 		{
162
-			fix_depricated_recursive($dir.'/'.$file,$replace_file);
162
+			fix_depricated_recursive($dir.'/'.$file, $replace_file);
163 163
 		}
164
-		elseif(substr($file,-4) == '.php')
164
+		elseif (substr($file, -4) == '.php')
165 165
 		{
166
-			echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': ';
167
-			fix_depricated($dir.'/'.$file,$replace_file);
166
+			echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': ';
167
+			fix_depricated($dir.'/'.$file, $replace_file);
168 168
 		}
169 169
 	}
170
-	echo "\r".str_repeat(' ',100)."\r";
170
+	echo "\r".str_repeat(' ', 100)."\r";
171 171
 	return true;
172 172
 }
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @param string $error=null
178 178
  */
179
-function usage($error=null)
179
+function usage($error = null)
180 180
 {
181 181
 	global $prog;
182 182
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 if (!$args) usage();
191 191
 
192 192
 $replace_file = false;
193
-while(($arg = array_shift($args)))
193
+while (($arg = array_shift($args)))
194 194
 {
195
-	switch($arg)
195
+	switch ($arg)
196 196
 	{
197 197
 		case '-h':
198 198
 		case '--help':
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 if (!is_dir($arg))
218 218
 {
219
-	fix_depricated($arg,$replace_file);
219
+	fix_depricated($arg, $replace_file);
220 220
 }
221 221
 else
222 222
 {
223
-	fix_depricated_recursive($arg,$replace_file);
223
+	fix_depricated_recursive($arg, $replace_file);
224 224
 }
225 225
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +41 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,10 +14,13 @@  discard block
 block discarded – undo
14 14
  * @version $Id$
15 15
  */
16 16
 
17
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling as web-page
17
+if (php_sapi_name() !== 'cli')
18
+{
19
+	// security precaution: forbit calling as web-page
18 20
 {
19 21
 	die('<h1>fix_depricated.php must NOT be called as web-page --> exiting !!!</h1>');
20 22
 }
23
+}
21 24
 
22 25
 /**
23 26
  * Fix depricated stuff in a given file
@@ -29,9 +32,16 @@  discard block
 block discarded – undo
29 32
 function fix_depricated($file,$replace_file=false)
30 33
 {
31 34
 	$orig = $lines = file_get_contents($file);
32
-	if ($lines === false) return false;
35
+	if ($lines === false)
36
+	{
37
+		return false;
38
+	}
33 39
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
40
+	if (basename($file) == $prog)
41
+	{
42
+		return true;
43
+	}
44
+	// dont fix ourself ;-)
35 45
 
36 46
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37 47
 	if (preg_match('/= *& *new /m',$lines))
@@ -54,7 +64,10 @@  discard block
 block discarded – undo
54 64
 			else
55 65
 			{
56 66
 				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
67
+				if (strpos($full_pattern,'spliti'))
68
+				{
69
+					$preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
70
+				}
58 71
 				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
59 72
 			}
60 73
 		}
@@ -151,11 +164,17 @@  discard block
 block discarded – undo
151 164
  */
152 165
 function fix_depricated_recursive($dir,$replace_file=false)
153 166
 {
154
-	if (!is_dir($dir)) return false;
167
+	if (!is_dir($dir))
168
+	{
169
+		return false;
170
+	}
155 171
 
156 172
 	foreach(scandir($dir) as $file)
157 173
 	{
158
-		if ($file == '.' || $file == '..') continue;
174
+		if ($file == '.' || $file == '..')
175
+		{
176
+			continue;
177
+		}
159 178
 
160 179
 		if (is_dir($dir.'/'.$file))
161 180
 		{
@@ -180,14 +199,20 @@  discard block
 block discarded – undo
180 199
 {
181 200
 	global $prog;
182 201
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
183
-	if ($error) echo $error."\n\n";
202
+	if ($error)
203
+	{
204
+		echo $error."\n\n";
205
+	}
184 206
 	exit($error ? 1 : 0);
185 207
 }
186 208
 
187 209
 $args = $_SERVER['argv'];
188 210
 $prog = basename(array_shift($args));
189 211
 
190
-if (!$args) usage();
212
+if (!$args)
213
+{
214
+	usage();
215
+}
191 216
 
192 217
 $replace_file = false;
193 218
 while(($arg = array_shift($args)))
@@ -204,15 +229,21 @@  discard block
 block discarded – undo
204 229
 			break;
205 230
 
206 231
 		default:
207
-			if ($args)	// not last argument
232
+			if ($args)
233
+			{
234
+				// not last argument
208 235
 			{
209 236
 				usage("Unknown argument '$arg'!");
210 237
 			}
238
+			}
211 239
 			break 2;
212 240
 	}
213 241
 }
214 242
 
215
-if (!file_exists($arg)) usage("Error: $arg not found!");
243
+if (!file_exists($arg))
244
+{
245
+	usage("Error: $arg not found!");
246
+}
216 247
 
217 248
 if (!is_dir($arg))
218 249
 {
Please login to merge, or discard this patch.
doc/rpm-build/checkout-build-archives.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,6 +464,7 @@  discard block
 block discarded – undo
464 464
  *
465 465
  * @param string $name
466 466
  * @param string $value =null value to use, default $config[$name]
467
+ * @return string
467 468
  */
468 469
 function config_translate($name, $value=null)
469 470
 {
@@ -1194,7 +1195,7 @@  discard block
 block discarded – undo
1194 1195
  * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose)
1195 1196
  *
1196 1197
  * @param string $cmd
1197
- * @param array& $output=null $output of command, only if !$verbose !!!
1198
+ * @param array& $output $output of command, only if !$verbose !!!
1198 1199
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1199 1200
  * @return int exit code of $cmd
1200 1201
  */
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 {
15 15
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 16
 }
17
-date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
17
+date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings
18 18
 
19 19
 $verbose = 0;
20 20
 $config = array(
21 21
 	'packagename' => 'egroupware-epl',
22
-	'version' => '16.1',        // '14.3'
22
+	'version' => '16.1', // '14.3'
23 23
 	'packaging' => date('Ymd'), // '20160520'
24
-	'branch'  => 'master',        // checked out branch
25
-	'tag' => '$version.$packaging',	// name of tag
24
+	'branch'  => 'master', // checked out branch
25
+	'tag' => '$version.$packaging', // name of tag
26 26
 	'checkoutdir' => realpath(__DIR__.'/../..'),
27 27
 	'egw_buildroot' => '/tmp/build_root/epl_16.1_buildroot',
28 28
 	'sourcedir' => '/home/download/stylite-epl/egroupware-epl-16.1',
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	'svnalias' => 'aliases/default-ssh',    // default alias
35 35
 	'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'),
36 36
 	*/
37
-	'extra' => array('stylite', 'esyncpro', 'archive',	// create an extra archive for given apps
37
+	'extra' => array('stylite', 'esyncpro', 'archive', // create an extra archive for given apps
38 38
 		// these apps are placed in egroupware-epl-contrib archive
39 39
 		'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')),
40
-	'aliasdir' => 'egroupware',             // directory created by the alias
41
-	'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'),
40
+	'aliasdir' => 'egroupware', // directory created by the alias
41
+	'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'),
42 42
 	// add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive
43 43
 	'all-add' => array('contrib', '/home/stylite/epl-trunk/phpfreechat_data_public.tar'),
44 44
 	// diverse binaries we need
@@ -55,42 +55,42 @@  discard block
 block discarded – undo
55 55
 	'gpg' => trim(`which gpg`),
56 56
 	'editor' => trim(`which vi`),
57 57
 	'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"',
58
-	'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
58
+	'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
59 59
 	'after-checkout' => 'rm -rf */source */templates/*/source pixelegg/content-element-library',
60 60
 	'packager' => '[email protected]',
61 61
 	'obs' => '/home/stylite/obs/stylite-epl-trunk',
62
-	'obs_package_alias' => '',	// name used in obs package, if different from packagename
63
-	'changelog' => false,   // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
62
+	'obs_package_alias' => '', // name used in obs package, if different from packagename
63
+	'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
64 64
 	'changelog_packager' => 'Ralf Becker <[email protected]>',
65 65
 	'editchangelog' => '* ',
66 66
 	//'sfuser' => 'ralfbecker',
67 67
 	//'release' => '$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/',
68 68
 	'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README',
69 69
 	'skip' => array(),
70
-	'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'),
70
+	'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'),
71 71
 	'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"',
72
-	'github_user' => 'ralfbecker',	// Github user for following token
73
-	'github_token' => '',	// Github repo personal access token from above user
72
+	'github_user' => 'ralfbecker', // Github user for following token
73
+	'github_token' => '', // Github repo personal access token from above user
74 74
 );
75 75
 
76 76
 // process config from command line
77 77
 $argv = $_SERVER['argv'];
78 78
 $prog = array_shift($argv);
79 79
 
80
-while(($arg = array_shift($argv)))
80
+while (($arg = array_shift($argv)))
81 81
 {
82 82
 	if ($arg == '-v' || $arg == '--verbose')
83 83
 	{
84 84
 		++$verbose;
85 85
 	}
86
-	elseif($arg == '-h' || $arg == '--help')
86
+	elseif ($arg == '-h' || $arg == '--help')
87 87
 	{
88 88
 		usage();
89 89
 	}
90
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
90
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
91 91
 	{
92 92
 		$value = array_shift($argv);
93
-		switch($name)
93
+		switch ($name)
94 94
 		{
95 95
 			case 'extra':	// stored as array and allow to add/delete items with +/- prefix
96 96
 			case 'types':
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 			case 'run':
99 99
 				if ($value[0] == '+')
100 100
 				{
101
-					$config[$name] = array_unique(array_merge($config[$name],preg_split('/[ ,]+/',substr($value,1))));
101
+					$config[$name] = array_unique(array_merge($config[$name], preg_split('/[ ,]+/', substr($value, 1))));
102 102
 				}
103 103
 				elseif ($value[0] == '-')
104 104
 				{
105
-					$config[$name] = array_diff($config[$name],preg_split('/[ ,]+/',substr($value,1)));
105
+					$config[$name] = array_diff($config[$name], preg_split('/[ ,]+/', substr($value, 1)));
106 106
 				}
107 107
 				else
108 108
 				{
109
-					$config[$name] = array_unique(preg_split('/[ ,]+/',$value));
109
+					$config[$name] = array_unique(preg_split('/[ ,]+/', $value));
110 110
 				}
111 111
 				break;
112 112
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 			case 'release':
116 116
 			case 'copychangelog':
117 117
 				$config[$name] = $value;
118
-				if ($value) array_unshift($config['run'],$name);
118
+				if ($value) array_unshift($config['run'], $name);
119 119
 				break;
120 120
 
121 121
 			case 'editchangelog':
122 122
 				$config[$name] = $value ? $value : true;
123
-				if (!in_array('editchangelog',$config['run']))
123
+				if (!in_array('editchangelog', $config['run']))
124 124
 				{
125
-					array_unshift($config['run'],'editchangelog');
125
+					array_unshift($config['run'], 'editchangelog');
126 126
 				}
127 127
 				break;
128 128
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 				{
132 132
 					usage("Path '$value' not found!");
133 133
 				}
134
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
134
+				if (!in_array('obs', $config['run'])) $config['run'][] = 'obs';
135 135
 				// fall through
136 136
 			default:
137 137
 				$config[$name] = $value;
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 }
151 151
 $svn = $config['svn'];
152 152
 
153
-foreach(array_diff($config['run'],$config['skip']) as $func)
153
+foreach (array_diff($config['run'], $config['skip']) as $func)
154 154
 {
155
-	chdir(dirname(__FILE__));	// make relative filenames work, if other command changes dir
155
+	chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir
156 156
 	call_user_func('do_'.$func);
157 157
 }
158 158
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
168 168
  * @return string with changelog
169 169
  */
170
-function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ')
170
+function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ')
171 171
 {
172 172
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
173 173
 	global $config;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	run_cmd($cmd, $output);
189 189
 
190 190
 	$changelog = '';
191
-	foreach($output as $line)
191
+	foreach ($output as $line)
192 192
 	{
193 193
 		if (substr($line, 0, 4) == "    " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix)))
194 194
 		{
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	{
221 221
 		throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!");
222 222
 	}
223
-	if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig')))
223
+	if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig')))
224 224
 	{
225 225
 		throw new Exception("$path not found!");
226 226
 	}
227 227
 	$module = null;
228 228
 	$modules = array();
229
-	foreach(explode("\n", $mrconfig) as $line)
229
+	foreach (explode("\n", $mrconfig) as $line)
230 230
 	{
231 231
 		$matches = null;
232 232
 		if ($line && $line[0] == '[' && preg_match('/^\[([^]]*)\]/', $line, $matches))
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		$cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : '').
287 287
 			' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir'];
288 288
 		run_cmd($cmd);
289
-		run_cmd('mr up');	// need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
289
+		run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
290 290
 	}
291 291
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
292 292
 	{
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 	chdir($config['checkoutdir']);
312 312
 
313
-	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
313
+	$config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag
314 314
 
315
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
315
+	if (empty($config['tag'])) return; // otherwise we copy everything in svn root!
316 316
 
317 317
 	echo "Creating tag $config[tag]\n";
318 318
 
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
  */
326 326
 function do_release()
327 327
 {
328
-	global $config,$verbose;
328
+	global $config, $verbose;
329 329
 
330 330
 	// push local changes to Github incl. tags
331 331
 	if ($verbose) echo "Pushing changes and tags\n";
332 332
 	chdir($config['checkoutdir']);
333
-	run_cmd($config['mr']. ' up');		// in case someone else pushed something
333
+	run_cmd($config['mr'].' up'); // in case someone else pushed something
334 334
 	chdir($config['checkoutdir']);
335
-	run_cmd($config['git'].' push');	// regular commits like changelog
335
+	run_cmd($config['git'].' push'); // regular commits like changelog
336 336
 	$tag = config_translate('tag');
337
-	run_cmd($config['mr']. ' push origin '.$tag);	// pushing tags in all apps
337
+	run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps
338 338
 
339 339
 	if (empty($config['github_user']) || empty($config['github_token']))
340 340
 	{
@@ -351,26 +351,26 @@  discard block
 block discarded – undo
351 351
 		'body' => $config['changelog'],
352 352
 	);
353 353
 	$response = github_api("/repos/EGroupware/egroupware/releases", $data);
354
-	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']);	// remove {?name,label} template
354
+	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template
355 355
 
356 356
 	$archives = $config['sourcedir'].'/*egroupware-epl{,-contrib}-'.$config['version'].'.'.$config['packaging'].'*';
357 357
 
358
-	foreach(glob($archives) as $path)
358
+	foreach (glob($archives) as $path)
359 359
 	{
360 360
 		$label = null;
361 361
 		if (substr($path, -4) == '.zip')
362 362
 		{
363 363
 			$content_type = 'application/zip';
364 364
 		}
365
-		elseif(substr($path, -7) == '.tar.gz')
365
+		elseif (substr($path, -7) == '.tar.gz')
366 366
 		{
367 367
 			$content_type = 'application/x-gzip';
368 368
 		}
369
-		elseif(substr($path, -8) == '.tar.bz2')
369
+		elseif (substr($path, -8) == '.tar.bz2')
370 370
 		{
371 371
 			$content_type = 'application/x-bzip2';
372 372
 		}
373
-		elseif(substr($path, -8) == '.txt.asc')
373
+		elseif (substr($path, -8) == '.txt.asc')
374 374
 		{
375 375
 			$content_type = 'text/plain';
376 376
 			$label = 'Signed hashes of downloads';
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	if (!empty($config['release']))
390 390
 	{
391
-		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
391
+		$target = config_translate('release'); // allow to use config vars like $svnbranch in module
392 392
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
393 393
 		if ($verbose) echo $cmd."\n";
394 394
 		passthru($cmd);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
  * @throws Exception
407 407
  * @return array with response
408 408
  */
409
-function github_api($_url, $data, $method='POST', $upload=null, $content_type=null)
409
+function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null)
410 410
 {
411 411
 	global $config, $verbose;
412 412
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	curl_setopt($c, CURLOPT_TIMEOUT, 240);
420 420
 	curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
421 421
 
422
-	switch($method)
422
+	switch ($method)
423 423
 	{
424 424
 		case 'POST':
425 425
 			curl_setopt($c, CURLOPT_POST, true);
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
428 428
 			break;
429 429
 		case 'GET':
430
-			if(count($data)) $url .= '?' . http_build_query($data);
430
+			if (count($data)) $url .= '?'.http_build_query($data);
431 431
 			break;
432 432
 		case 'FILE':
433 433
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
434 434
 			curl_setopt($c, CURLOPT_POST, true);
435 435
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
436
-			if(count($data)) $url .= '?' . http_build_query($data);
436
+			if (count($data)) $url .= '?'.http_build_query($data);
437 437
 			break;
438 438
 		default:
439 439
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	curl_setopt($c, CURLOPT_URL, $url);
442 442
 
443 443
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
444
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
444
+	if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n";
445 445
 
446 446
 	if (($response = curl_exec($c)) === false)
447 447
 	{
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		curl_setopt($c, CURLOPT_HEADER, true);
450 450
 		curl_setopt($c, CURLOPT_RETURNTRANSFER, false);
451 451
 		curl_exec($c);
452
-		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
452
+		throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : ''));
453 453
 	}
454 454
 
455 455
 	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
  * @param string $name
466 466
  * @param string $value =null value to use, default $config[$name]
467 467
  */
468
-function config_translate($name, $value=null)
468
+function config_translate($name, $value = null)
469 469
 {
470 470
 	global $config;
471 471
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	if (is_string($value) && strpos($value, '$') !== false)
474 474
 	{
475 475
 		$translate = array();
476
-		foreach($config as $n => $val)
476
+		foreach ($config as $n => $val)
477 477
 		{
478 478
 			if (is_string($val)) $translate['$'.$n] = $val;
479 479
 		}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
  */
500 500
 function do_editchangelog()
501 501
 {
502
-	global $config,$svn;
502
+	global $config, $svn;
503 503
 
504 504
 	echo "Querying changelog from Git/SVN\n";
505 505
 	if (!isset($config['modules']))
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 	// query changelog per repo
510 510
 	$changelog = '';
511 511
 	$last_tag = null;
512
-	foreach($config['modules'] as $branch_url => $modules)
512
+	foreach ($config['modules'] as $branch_url => $modules)
513 513
 	{
514 514
 		$revision = null;
515 515
 		if (substr($branch_url, -4) == '.git')
@@ -522,15 +522,15 @@  discard block
 block discarded – undo
522 522
 			$changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision);
523 523
 		}
524 524
 	}
525
-	$logfile = tempnam('/tmp','checkout-build-archives');
526
-	file_put_contents($logfile,$changelog);
525
+	$logfile = tempnam('/tmp', 'checkout-build-archives');
526
+	file_put_contents($logfile, $changelog);
527 527
 	$cmd = $config['editor'].' '.escapeshellarg($logfile);
528 528
 	passthru($cmd);
529 529
 	$config['changelog'] = file_get_contents($logfile);
530 530
 	// remove trailing newlines
531
-	while (substr($config['changelog'],-1) == "\n")
531
+	while (substr($config['changelog'], -1) == "\n")
532 532
 	{
533
-		$config['changelog'] = substr($config['changelog'],0,-1);
533
+		$config['changelog'] = substr($config['changelog'], 0, -1);
534 534
 	}
535 535
 	// allow user to abort, by deleting the changelog
536 536
 	if (strlen($config['changelog']) <= 2)
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 	run_cmd($cmd);
556 556
 
557 557
 	// update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped)
558
-	do_obs(true);	// true: only update debian.changes in obs checkouts
558
+	do_obs(true); // true: only update debian.changes in obs checkouts
559 559
 }
560 560
 
561 561
 /**
@@ -569,41 +569,41 @@  discard block
 block discarded – undo
569 569
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
570 570
  * @return string with changelog
571 571
  */
572
-function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ')
572
+function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ')
573 573
 {
574 574
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
575
-	global $config,$verbose,$svn;
575
+	global $config, $verbose, $svn;
576 576
 
577 577
 	if (is_null($revision))
578 578
 	{
579
-		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
579
+		list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url);
580 580
 		if (empty($branch)) $branch = $config['version'];
581 581
 		$tags_url .= '/tags';
582
-		$pattern='/tags\/(14\.3\.[0-9.]+)/';//str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
582
+		$pattern = '/tags\/(14\.3\.[0-9.]+)/'; //str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
583 583
 		$matches = null;
584
-		$revision = get_last_svn_tag($tags_url,$pattern,$matches);
584
+		$revision = get_last_svn_tag($tags_url, $pattern, $matches);
585 585
 		$tag = $matches[1];
586 586
 	}
587
-	elseif(!is_numeric($revision))
587
+	elseif (!is_numeric($revision))
588 588
 	{
589
-		$revision = get_last_svn_tag($tags_url,$tag=$revision);
589
+		$revision = get_last_svn_tag($tags_url, $tag = $revision);
590 590
 	}
591 591
 	$cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url);
592 592
 	if (($v = $verbose))
593 593
 	{
594 594
 		echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n";
595
-		$verbose = false;	// otherwise no $output!
595
+		$verbose = false; // otherwise no $output!
596 596
 	}
597 597
 	$output = array();
598
-	run_cmd($cmd,$output);
598
+	run_cmd($cmd, $output);
599 599
 	$verbose = $v;
600
-	array_shift($output);	// remove the command
600
+	array_shift($output); // remove the command
601 601
 
602
-	$xml = simplexml_load_string($output=implode("\n",$output));
602
+	$xml = simplexml_load_string($output = implode("\n", $output));
603 603
 	$message = '';
604
-	foreach($xml as $log)
604
+	foreach ($xml as $log)
605 605
 	{
606
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
606
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore
607 607
 
608 608
 		$message .= $msg."\n";
609 609
 	}
@@ -620,25 +620,25 @@  discard block
 block discarded – undo
620 620
  * @param string $prefix ='* '
621 621
  * @return string
622 622
  */
623
-function _match_log_pattern($msg, $log_pattern, $prefix='* ')
623
+function _match_log_pattern($msg, $log_pattern, $prefix = '* ')
624 624
 {
625 625
 	$pattern_len = strlen($log_pattern);
626 626
 	$prefix_len = strlen($prefix);
627 627
 
628 628
 	$matches = null;
629
-	if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches))
629
+	if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches))
630 630
 	{
631 631
 		$msg = $matches[1];
632 632
 	}
633
-	elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern)
633
+	elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern)
634 634
 	{
635
-		list($msg) = explode("\n",$msg);
635
+		list($msg) = explode("\n", $msg);
636 636
 	}
637
-	elseif($log_pattern)
637
+	elseif ($log_pattern)
638 638
 	{
639 639
 		return null;
640 640
 	}
641
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
641
+	if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg;
642 642
 
643 643
 	return $msg;
644 644
 }
@@ -652,29 +652,29 @@  discard block
 block discarded – undo
652 652
  * @param array &$matches=null on return matches of preg_match
653 653
  * @return int revision of last svn tag matching pattern
654 654
  */
655
-function get_last_svn_tag($tags_url,$pattern,&$matches=null)
655
+function get_last_svn_tag($tags_url, $pattern, &$matches = null)
656 656
 {
657
-	global $verbose,$svn;
657
+	global $verbose, $svn;
658 658
 
659 659
 	$cmd = $svn.' log --xml --limit 40 '.escapeshellarg($tags_url);
660 660
 	if (($v = $verbose))
661 661
 	{
662 662
 		echo "Querying SVN for last tags\n$cmd\n";
663
-		$verbose = false;	// otherwise no $output!
663
+		$verbose = false; // otherwise no $output!
664 664
 	}
665 665
 	$output = array();
666
-	run_cmd($cmd,$output);
666
+	run_cmd($cmd, $output);
667 667
 	$verbose = $v;
668
-	array_shift($output);	// remove the command
668
+	array_shift($output); // remove the command
669 669
 
670
-	$xml = simplexml_load_string($output=implode("\n",$output));
671
-	foreach($xml as $log)
670
+	$xml = simplexml_load_string($output = implode("\n", $output));
671
+	foreach ($xml as $log)
672 672
 	{
673 673
 		//print_r($log);
674
-		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
675
-			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
674
+		if ($pattern[0] != '/' && strpos($log->msg, $pattern) !== false ||
675
+			$pattern[0] == '/' && preg_match($pattern, $log->msg, $matches))
676 676
 		{
677
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
677
+			if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n";
678 678
 			return (int)$log['revision'];
679 679
 		}
680 680
 	}
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
  *
687 687
  * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it
688 688
  */
689
-function do_obs($only_update_changelog=false)
689
+function do_obs($only_update_changelog = false)
690 690
 {
691
-	global $config,$verbose;
691
+	global $config, $verbose;
692 692
 
693 693
 	if (!is_dir($config['obs']))
694 694
 	{
@@ -698,25 +698,25 @@  discard block
 block discarded – undo
698 698
 	run_cmd('osc up '.$config['obs']);
699 699
 
700 700
 	$n = 0;
701
-	foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
701
+	foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
702 702
 	{
703 703
 		if (basename(dirname($path)) == '.osc' ||
704 704
 			!preg_match('/\/('.preg_quote($config['packagename']).
705 705
 				($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : '').
706
-				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path))
706
+				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path))
707 707
 		{
708 708
 			continue;
709 709
 		}
710 710
 		$matches = null;
711
-		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) &&
712
-			file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
711
+		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) &&
712
+			file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
713 713
 		{
714 714
 			if (basename($path) != basename($new_name))
715 715
 			{
716 716
 				unlink($path);
717 717
 				if ($verbose) echo "rm $path\n";
718 718
 			}
719
-			copy($new_name,dirname($path).'/'.basename($new_name));
719
+			copy($new_name, dirname($path).'/'.basename($new_name));
720 720
 			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
721 721
 			++$n;
722 722
 		}
@@ -726,35 +726,35 @@  discard block
 block discarded – undo
726 726
 			$config['changelog'] = parse_current_changelog();
727 727
 		}
728 728
 		// updating dsc, spec and changelog files
729
-		if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') ||
729
+		if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') ||
730 730
 			!empty($config['changelog']) && basename($path) == 'debian.changes')
731 731
 		{
732 732
 			$content = $content_was = file_get_contents($path);
733 733
 
734
-			if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec')
734
+			if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec')
735 735
 			{
736
-				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content);
736
+				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content);
737 737
 			}
738
-			if (substr($path,-4) == '.dsc')
738
+			if (substr($path, -4) == '.dsc')
739 739
 			{
740 740
 				$content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'.
741 741
 					preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m',
742
-					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content);
742
+					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content);
743 743
 			}
744
-			if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false)
744
+			if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false)
745 745
 			{
746 746
 				$content = update_changelog($content);
747 747
 			}
748
-			if (!empty($config['changelog']) && substr($path,-5) == '.spec' &&
749
-				($pos_changelog = strpos($content,'%changelog')) !== false)
748
+			if (!empty($config['changelog']) && substr($path, -5) == '.spec' &&
749
+				($pos_changelog = strpos($content, '%changelog')) !== false)
750 750
 			{
751 751
 				$pos_changelog += strlen("%changelog\n");
752
-				$content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
753
-					$config['changelog']."\n".substr($content,$pos_changelog);
752
+				$content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
753
+					$config['changelog']."\n".substr($content, $pos_changelog);
754 754
 			}
755 755
 			if ($content != $content_was)
756 756
 			{
757
-				file_put_contents($path,$content);
757
+				file_put_contents($path, $content);
758 758
 				if ($verbose) echo "Updated $path\n";
759 759
 				++$n;
760 760
 			}
@@ -780,21 +780,21 @@  discard block
 block discarded – undo
780 780
 
781 781
 	$changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes');
782 782
 	$lines = explode("\n", $changelog, 100);
783
-	foreach($lines as $n => $line)
783
+	foreach ($lines as $n => $line)
784 784
 	{
785
-		if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version'].'.'.$config['packaging']).'/', $line))
785
+		if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version'].'.'.$config['packaging']).'/', $line))
786 786
 		{
787
-			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
787
+			$n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header
788 788
 			$logentry = '';
789
-			while($lines[$n])	// entry is terminated by empty line
789
+			while ($lines[$n])	// entry is terminated by empty line
790 790
 			{
791 791
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
792 792
 				++$n;
793 793
 			}
794
-			return substr($logentry, 0, -1);	// remove training "\n"
794
+			return substr($logentry, 0, -1); // remove training "\n"
795 795
 		}
796 796
 	}
797
-	return null;	// paragraph for current version NOT found
797
+	return null; // paragraph for current version NOT found
798 798
 }
799 799
 
800 800
 /**
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	global $config;
809 809
 
810 810
 	list($header) = explode("\n", $content);
811
-	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
812
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
811
+	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
812
+	if (substr($config['changelog'], 0, 2) != '  ') $config['changelog'] = '  '.implode("\n  ", explode("\n", $config['changelog']));
813 813
 	$content = $new_header."\n\n".$config['changelog'].
814 814
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
815 815
 
@@ -823,9 +823,9 @@  discard block
 block discarded – undo
823 823
 {
824 824
 	global $config;
825 825
 
826
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
826
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
827 827
 	{
828
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
828
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
829 829
 	}
830 830
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
831 831
 
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
845 845
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
846 846
 	run_cmd($cmd);
847
-	unlink($sumsfile);	// delete the unsigned file
847
+	unlink($sumsfile); // delete the unsigned file
848 848
 }
849 849
 
850 850
 /**
@@ -854,22 +854,22 @@  discard block
 block discarded – undo
854 854
 {
855 855
 	global $config;
856 856
 
857
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
858
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
857
+	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true);
858
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
859 859
 	{
860
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
860
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
861 861
 	}
862 862
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
863 863
 	$sums = '';
864 864
 
865 865
 	chdir($config['egw_buildroot']);
866 866
 
867
-	if($config['extra'])
867
+	if ($config['extra'])
868 868
 	{
869 869
 		$exclude = $exclude_all = array();
870
-		foreach($config['extra'] as $name => $modules)
870
+		foreach ($config['extra'] as $name => $modules)
871 871
 		{
872
-			foreach((array)$modules as $module)
872
+			foreach ((array)$modules as $module)
873 873
 			{
874 874
 				$exclude[] = basename($module);
875 875
 				if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add'])))
@@ -879,24 +879,24 @@  discard block
 block discarded – undo
879 879
 			}
880 880
 		}
881 881
 		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude);
882
-		$exclude_all_extra =  $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
882
+		$exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
883 883
 	}
884
-	foreach($config['types'] as $type)
884
+	foreach ($config['types'] as $type)
885 885
 	{
886 886
 		echo "Creating $type archives\n";
887 887
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
888 888
 
889 889
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
890
-		switch($type)
890
+		switch ($type)
891 891
 		{
892 892
 			case 'all.tar.bz2':	// single tar-ball for debian builds not easily supporting to use multiple
893 893
 				$file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar';
894 894
 				$cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware';
895 895
 				if (!empty($config['all-add']))
896 896
 				{
897
-					foreach((array)$config['all-add'] as $add)
897
+					foreach ((array)$config['all-add'] as $add)
898 898
 					{
899
-						if (substr($add, -4) != '.tar') continue;	// probably a module
899
+						if (substr($add, -4) != '.tar') continue; // probably a module
900 900
 						if (!($tar = realpath($add))) throw new Exception("File '$add' not found!");
901 901
 						$cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar;
902 902
 					}
@@ -920,15 +920,15 @@  discard block
 block discarded – undo
920 920
 		run_cmd($cmd);
921 921
 		$sums .= sha1_file($file)."\t".basename($file)."\n";
922 922
 
923
-		foreach($config['extra'] as $name => $modules)
923
+		foreach ($config['extra'] as $name => $modules)
924 924
 		{
925 925
 			if (is_numeric($name)) $name = $modules;
926 926
 			$dirs = ' egroupware/'.implode(' egroupware/', (array)$modules);
927 927
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
928
-			switch($type)
928
+			switch ($type)
929 929
 			{
930 930
 				case 'all.tar.bz2':
931
-					break;	// nothing to do
931
+					break; // nothing to do
932 932
 				case 'tar.bz2':
933 933
 				case 'tar.gz':
934 934
 					$cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 		}
944 944
 	}
945 945
 	// writing sha1sum file
946
-	file_put_contents($sumsfile,$sums);
946
+	file_put_contents($sumsfile, $sums);
947 947
 }
948 948
 
949 949
 /**
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
  */
952 952
 function do_virusscan()
953 953
 {
954
-	global $config,$verbose;
954
+	global $config, $verbose;
955 955
 
956 956
 	if (!file_exists($config['clamscan']) || !is_executable($config['clamscan']))
957 957
 	{
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
966 966
 		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
967 967
 		$output = null;
968
-		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
968
+		run_cmd($cmd, $output, 1); // 1 = ignore already up to date database
969 969
 	}
970 970
 	echo "Starting virusscan\n";
971 971
 	$cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot'];
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
  */
1023 1023
 function do_svncheckout()
1024 1024
 {
1025
-	global $config,$svn;
1025
+	global $config, $svn;
1026 1026
 
1027 1027
 	echo "Starting svn checkout/update\n";
1028 1028
 	if (!file_exists($config['checkoutdir']))
1029 1029
 	{
1030
-		mkdir($config['checkoutdir'],0755,true);
1030
+		mkdir($config['checkoutdir'], 0755, true);
1031 1031
 	}
1032 1032
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
1033 1033
 	{
@@ -1042,17 +1042,17 @@  discard block
 block discarded – undo
1042 1042
 		{
1043 1043
 			get_modules_per_repo();
1044 1044
 		}
1045
-		$config['svntag'] = config_translate('svntag');	// in case svntag command did not run, translate tag name
1045
+		$config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name
1046 1046
 
1047 1047
 		if (file_exists($config['aliasdir']))
1048 1048
 		{
1049
-			system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout, as we dont implement switching tags
1049
+			system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags
1050 1050
 			clearstatcache();
1051 1051
 		}
1052
-		foreach($config['modules'] as $repo => $modules)
1052
+		foreach ($config['modules'] as $repo => $modules)
1053 1053
 		{
1054 1054
 			$cmd = $svn.' co ';
1055
-			foreach($modules as $path => $url)
1055
+			foreach ($modules as $path => $url)
1056 1056
 			{
1057 1057
 				if ($path == $config['aliasdir'])
1058 1058
 				{
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 					$cmd = $svn.' co ';
1063 1063
 					continue;
1064 1064
 				}
1065
-				if(file_exists($config['aliasdir']))
1065
+				if (file_exists($config['aliasdir']))
1066 1066
 				{
1067 1067
 					die("'egroupware' applications must be first one in externals!\n");
1068 1068
 				}
@@ -1080,16 +1080,16 @@  discard block
 block discarded – undo
1080 1080
 			// check if correct branch
1081 1081
 			$cmd = 'LANG=C '.$svn.' info';
1082 1082
 			$output = $ret = null;
1083
-			exec($cmd,$output,$ret);
1084
-			foreach($output as $line)
1083
+			exec($cmd, $output, $ret);
1084
+			foreach ($output as $line)
1085 1085
 			{
1086
-				if ($ret || substr($line,0,5) == 'URL: ')
1086
+				if ($ret || substr($line, 0, 5) == 'URL: ')
1087 1087
 				{
1088
-					$url = substr($line,5);
1089
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1088
+					$url = substr($line, 5);
1089
+					if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1090 1090
 					{
1091 1091
 						echo "Checkout is of wrong branch --> deleting it\n";
1092
-						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1092
+						system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout
1093 1093
 						clearstatcache();
1094 1094
 					}
1095 1095
 					break;
@@ -1101,10 +1101,10 @@  discard block
 block discarded – undo
1101 1101
 		run_cmd($cmd);
1102 1102
 
1103 1103
 		chdir($config['aliasdir']);
1104
-		foreach($config['extra'] as $module)
1104
+		foreach ($config['extra'] as $module)
1105 1105
 		{
1106
-			$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1107
-			$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1106
+			$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1107
+			$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1108 1108
 			$url .= $module;
1109 1109
 			$cmd = $svn.' co '.$url;
1110 1110
 			run_cmd($cmd);
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
  */
1130 1130
 function get_modules_per_svn_repo()
1131 1131
 {
1132
-	global $config,$svn,$verbose;
1132
+	global $config, $svn, $verbose;
1133 1133
 
1134 1134
 	// process alias/externals
1135 1135
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
@@ -1137,27 +1137,27 @@  discard block
 block discarded – undo
1137 1137
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1138 1138
 	if ($verbose) echo $cmd."\n";
1139 1139
 	$output = $ret = null;
1140
-	exec($cmd,$output,$ret);
1140
+	exec($cmd, $output, $ret);
1141 1141
 	$config['modules'] = array();
1142
-	foreach($output as $line)
1142
+	foreach ($output as $line)
1143 1143
 	{
1144 1144
 		$line = trim($line);
1145 1145
 		if (empty($line) || $line[0] == '#') continue;
1146
-		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1146
+		list($path, $url) = preg_split('/[ \t\r\n]+/', $line);
1147 1147
 		$matches = null;
1148
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1148
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1149 1149
 		$repo = $matches[1];
1150 1150
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1151 1151
 		$config['modules'][$repo][$path] = $url;
1152 1152
 	}
1153 1153
 	// process extra modules
1154
-	foreach($config['extra'] as $module)
1154
+	foreach ($config['extra'] as $module)
1155 1155
 	{
1156
-		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1157
-		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1156
+		$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1157
+		$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1158 1158
 		$url .= $module;
1159
-		if (strpos($module,'://') !== false) $module = basename($module);
1160
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1159
+		if (strpos($module, '://') !== false) $module = basename($module);
1160
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1161 1161
 		$repo = $matches[1];
1162 1162
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1163 1163
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
@@ -1171,11 +1171,11 @@  discard block
 block discarded – undo
1171 1171
  */
1172 1172
 function do_svntag()
1173 1173
 {
1174
-	global $config,$svn;
1174
+	global $config, $svn;
1175 1175
 
1176
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1176
+	if (empty($config['svntag'])) return; // otherwise we copy everything in svn root!
1177 1177
 
1178
-	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1178
+	$config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag
1179 1179
 
1180 1180
 	echo "Creating SVN tag $config[svntag]\n";
1181 1181
 	if (!isset($config['modules']))
@@ -1183,9 +1183,9 @@  discard block
 block discarded – undo
1183 1183
 		get_modules_per_repo();
1184 1184
 	}
1185 1185
 	// create tags (per repo)
1186
-	foreach($config['modules'] as $repo => $modules)
1186
+	foreach ($config['modules'] as $repo => $modules)
1187 1187
 	{
1188
-		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/';
1188
+		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/';
1189 1189
 		run_cmd($cmd);
1190 1190
 	}
1191 1191
 }
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1199 1199
  * @return int exit code of $cmd
1200 1200
  */
1201
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
1201
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
1202 1202
 {
1203 1203
 	global $verbose;
1204 1204
 
@@ -1206,18 +1206,18 @@  discard block
 block discarded – undo
1206 1206
 	{
1207 1207
 		echo $cmd."\n";
1208 1208
 		$ret = null;
1209
-		system($cmd,$ret);
1209
+		system($cmd, $ret);
1210 1210
 	}
1211 1211
 	else
1212 1212
 	{
1213 1213
 		$output[] = $cmd;
1214
-		exec($cmd,$output,$ret);
1215
-		if ($verbose) echo implode("\n",$output)."\n";
1214
+		exec($cmd, $output, $ret);
1215
+		if ($verbose) echo implode("\n", $output)."\n";
1216 1216
 	}
1217
-	if ($ret && !in_array($ret,(array)$no_bailout))
1217
+	if ($ret && !in_array($ret, (array)$no_bailout))
1218 1218
 	{
1219
-		if (!$verbose) echo implode("\n",$output)."\n";
1220
-		throw new Exception("Error during '$cmd' --> aborting",$ret);
1219
+		if (!$verbose) echo implode("\n", $output)."\n";
1220
+		throw new Exception("Error during '$cmd' --> aborting", $ret);
1221 1221
 	}
1222 1222
 	return $ret;
1223 1223
 }
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 			return 'NULL';
1245 1245
 		case 'object':
1246 1246
 		case 'array':
1247
-			return str_replace(array("\n",'    '/*,'Array'*/),'',print_r($var,true));
1247
+			return str_replace(array("\n", '    '/*,'Array'*/), '', print_r($var, true));
1248 1248
 	}
1249 1249
 	return 'UNKNOWN TYPE!';
1250 1250
 }
@@ -1254,17 +1254,17 @@  discard block
 block discarded – undo
1254 1254
  *
1255 1255
  * @param string $error =null optional error-message
1256 1256
  */
1257
-function usage($error=null)
1257
+function usage($error = null)
1258 1258
 {
1259
-	global $prog,$config;
1259
+	global $prog, $config;
1260 1260
 
1261 1261
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n";
1262 1262
 	echo "options and their defaults:\n";
1263
-	unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1264
-	foreach($config as $name => $default)
1263
+	unset($config['modules']); // they give an error, because of nested array and are quite lengthy
1264
+	foreach ($config as $name => $default)
1265 1265
 	{
1266
-		if (is_array($default)) $default = implode(' ',$default);
1267
-		echo '--'.str_pad($name,20).$default."\n";
1266
+		if (is_array($default)) $default = implode(' ', $default);
1267
+		echo '--'.str_pad($name, 20).$default."\n";
1268 1268
 	}
1269 1269
 	if ($error)
1270 1270
 	{
Please login to merge, or discard this patch.
Braces   +224 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
13
+if (php_sapi_name() !== 'cli')
14
+{
15
+	// security precaution: forbit calling setup-cli as web-page
14 16
 {
15 17
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 18
 }
19
+}
17 20
 date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
18 21
 
19 22
 $verbose = 0;
@@ -115,7 +118,10 @@  discard block
 block discarded – undo
115 118
 			case 'release':
116 119
 			case 'copychangelog':
117 120
 				$config[$name] = $value;
118
-				if ($value) array_unshift($config['run'],$name);
121
+				if ($value)
122
+				{
123
+					array_unshift($config['run'],$name);
124
+				}
119 125
 				break;
120 126
 
121 127
 			case 'editchangelog':
@@ -131,7 +137,10 @@  discard block
 block discarded – undo
131 137
 				{
132 138
 					usage("Path '$value' not found!");
133 139
 				}
134
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
140
+				if (!in_array('obs',$config['run']))
141
+				{
142
+					$config['run'][] = 'obs';
143
+				}
135 144
 				// fall through
136 145
 			default:
137 146
 				$config[$name] = $value;
@@ -183,7 +192,10 @@  discard block
 block discarded – undo
183 192
 	}
184 193
 
185 194
 	$cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD');
186
-	if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd;
195
+	if (getcwd() != $path)
196
+	{
197
+		$cmd = 'cd '.$path.'; '.$cmd;
198
+	}
187 199
 	$output = null;
188 200
 	run_cmd($cmd, $output);
189 201
 
@@ -214,7 +226,10 @@  discard block
 block discarded – undo
214 226
 {
215 227
 	global $config, $verbose;
216 228
 
217
-	if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
229
+	if ($verbose)
230
+	{
231
+		echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
232
+	}
218 233
 
219 234
 	if (!is_dir($config['checkoutdir']))
220 235
 	{
@@ -241,11 +256,17 @@  discard block
 block discarded – undo
241 256
 		elseif (isset($module) && preg_match('/^checkout\s*=\s*(git clone (-b [0-9.]+)? (git[^ ]+)|svn checkout ((svn|http)[^ ]+))/', $line, $matches))
242 257
 		{
243 258
 			$repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[4] : $matches[3];
244
-			if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
259
+			if (substr($matches[1], 0, 3) == 'svn')
260
+			{
261
+				$repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
262
+			}
245 263
 			$modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url;
246 264
 		}
247 265
 	}
248
-	if ($verbose) print_r($modules);
266
+	if ($verbose)
267
+	{
268
+		print_r($modules);
269
+	}
249 270
 	return $modules;
250 271
 }
251 272
 
@@ -312,7 +333,11 @@  discard block
 block discarded – undo
312 333
 
313 334
 	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
314 335
 
315
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
336
+	if (empty($config['tag']))
337
+	{
338
+		return;
339
+	}
340
+	// otherwise we copy everything in svn root!
316 341
 
317 342
 	echo "Creating tag $config[tag]\n";
318 343
 
@@ -328,7 +353,10 @@  discard block
 block discarded – undo
328 353
 	global $config,$verbose;
329 354
 
330 355
 	// push local changes to Github incl. tags
331
-	if ($verbose) echo "Pushing changes and tags\n";
356
+	if ($verbose)
357
+	{
358
+		echo "Pushing changes and tags\n";
359
+	}
332 360
 	chdir($config['checkoutdir']);
333 361
 	run_cmd($config['mr']. ' up');		// in case someone else pushed something
334 362
 	chdir($config['checkoutdir']);
@@ -390,7 +418,10 @@  discard block
 block discarded – undo
390 418
 	{
391 419
 		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
392 420
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
393
-		if ($verbose) echo $cmd."\n";
421
+		if ($verbose)
422
+		{
423
+			echo $cmd."\n";
424
+		}
394 425
 		passthru($cmd);
395 426
 	}
396 427
 }
@@ -423,25 +454,40 @@  discard block
 block discarded – undo
423 454
 	{
424 455
 		case 'POST':
425 456
 			curl_setopt($c, CURLOPT_POST, true);
426
-			if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT);
457
+			if (is_array($data))
458
+			{
459
+				$data = json_encode($data, JSON_FORCE_OBJECT);
460
+			}
427 461
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
428 462
 			break;
429 463
 		case 'GET':
430
-			if(count($data)) $url .= '?' . http_build_query($data);
464
+			if(count($data))
465
+			{
466
+				$url .= '?' . http_build_query($data);
467
+			}
431 468
 			break;
432 469
 		case 'FILE':
433 470
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
434 471
 			curl_setopt($c, CURLOPT_POST, true);
435 472
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
436
-			if(count($data)) $url .= '?' . http_build_query($data);
473
+			if(count($data))
474
+			{
475
+				$url .= '?' . http_build_query($data);
476
+			}
437 477
 			break;
438 478
 		default:
439 479
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
440 480
 	}
441 481
 	curl_setopt($c, CURLOPT_URL, $url);
442 482
 
443
-	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
444
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
483
+	if (is_string($data))
484
+	{
485
+		$short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
486
+	}
487
+	if ($verbose)
488
+	{
489
+		echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
490
+	}
445 491
 
446 492
 	if (($response = curl_exec($c)) === false)
447 493
 	{
@@ -452,7 +498,10 @@  discard block
 block discarded – undo
452 498
 		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
453 499
 	}
454 500
 
455
-	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
501
+	if ($verbose)
502
+	{
503
+		echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
504
+	}
456 505
 
457 506
 	curl_close($c);
458 507
 
@@ -469,13 +518,19 @@  discard block
 block discarded – undo
469 518
 {
470 519
 	global $config;
471 520
 
472
-	if (!isset($value)) $value = $config[$name];
521
+	if (!isset($value))
522
+	{
523
+		$value = $config[$name];
524
+	}
473 525
 	if (is_string($value) && strpos($value, '$') !== false)
474 526
 	{
475 527
 		$translate = array();
476 528
 		foreach($config as $n => $val)
477 529
 		{
478
-			if (is_string($val)) $translate['$'.$n] = $val;
530
+			if (is_string($val))
531
+			{
532
+				$translate['$'.$n] = $val;
533
+			}
479 534
 		}
480 535
 		$value = strtr($value, $translate);
481 536
 	}
@@ -577,7 +632,10 @@  discard block
 block discarded – undo
577 632
 	if (is_null($revision))
578 633
 	{
579 634
 		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
580
-		if (empty($branch)) $branch = $config['version'];
635
+		if (empty($branch))
636
+		{
637
+			$branch = $config['version'];
638
+		}
581 639
 		$tags_url .= '/tags';
582 640
 		$pattern='/tags\/(14\.3\.[0-9.]+)/';//str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
583 641
 		$matches = null;
@@ -603,11 +661,18 @@  discard block
 block discarded – undo
603 661
 	$message = '';
604 662
 	foreach($xml as $log)
605 663
 	{
606
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
664
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix)))
665
+		{
666
+			continue;
667
+		}
668
+		// no match --> ignore
607 669
 
608 670
 		$message .= $msg."\n";
609 671
 	}
610
-	if ($verbose) echo $message;
672
+	if ($verbose)
673
+	{
674
+		echo $message;
675
+	}
611 676
 
612 677
 	return $message;
613 678
 }
@@ -638,7 +703,10 @@  discard block
 block discarded – undo
638 703
 	{
639 704
 		return null;
640 705
 	}
641
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
706
+	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix)
707
+	{
708
+		$msg = $prefix.$msg;
709
+	}
642 710
 
643 711
 	return $msg;
644 712
 }
@@ -674,7 +742,10 @@  discard block
 block discarded – undo
674 742
 		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
675 743
 			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
676 744
 		{
677
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
745
+			if ($verbose)
746
+			{
747
+				echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
748
+			}
678 749
 			return (int)$log['revision'];
679 750
 		}
680 751
 	}
@@ -694,7 +765,10 @@  discard block
 block discarded – undo
694 765
 	{
695 766
 		usage("Path '$config[obs]' not found!");
696 767
 	}
697
-	if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
768
+	if ($verbose)
769
+	{
770
+		echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
771
+	}
698 772
 	run_cmd('osc up '.$config['obs']);
699 773
 
700 774
 	$n = 0;
@@ -714,10 +788,16 @@  discard block
 block discarded – undo
714 788
 			if (basename($path) != basename($new_name))
715 789
 			{
716 790
 				unlink($path);
717
-				if ($verbose) echo "rm $path\n";
791
+				if ($verbose)
792
+				{
793
+					echo "rm $path\n";
794
+				}
718 795
 			}
719 796
 			copy($new_name,dirname($path).'/'.basename($new_name));
720
-			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
797
+			if ($verbose)
798
+			{
799
+				echo "cp $new_name ".dirname($path)."/\n";
800
+			}
721 801
 			++$n;
722 802
 		}
723 803
 		// if we have no changelog (eg. because commands run separate), try parsing it from changelog file
@@ -755,7 +835,10 @@  discard block
 block discarded – undo
755 835
 			if ($content != $content_was)
756 836
 			{
757 837
 				file_put_contents($path,$content);
758
-				if ($verbose) echo "Updated $path\n";
838
+				if ($verbose)
839
+				{
840
+					echo "Updated $path\n";
841
+				}
759 842
 				++$n;
760 843
 			}
761 844
 		}
@@ -786,9 +869,12 @@  discard block
 block discarded – undo
786 869
 		{
787 870
 			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
788 871
 			$logentry = '';
789
-			while($lines[$n])	// entry is terminated by empty line
872
+			while($lines[$n])
873
+			{
874
+				// entry is terminated by empty line
790 875
 			{
791 876
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
877
+			}
792 878
 				++$n;
793 879
 			}
794 880
 			return substr($logentry, 0, -1);	// remove training "\n"
@@ -809,7 +895,10 @@  discard block
 block discarded – undo
809 895
 
810 896
 	list($header) = explode("\n", $content);
811 897
 	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
812
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
898
+	if (substr($config['changelog'],0,2) != '  ')
899
+	{
900
+		$config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
901
+	}
813 902
 	$content = $new_header."\n\n".$config['changelog'].
814 903
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
815 904
 
@@ -823,10 +912,13 @@  discard block
 block discarded – undo
823 912
 {
824 913
 	global $config;
825 914
 
826
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
915
+	if (substr($config['sourcedir'],0,2) == '~/')
916
+	{
917
+		// sha1_file cant deal with '~/rpm'
827 918
 	{
828 919
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
829 920
 	}
921
+	}
830 922
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
831 923
 
832 924
 	if (!file_exists($sumsfile))
@@ -837,11 +929,17 @@  discard block
 block discarded – undo
837 929
 	// signing it
838 930
 	if (empty($config['gpg']) || !file_exists($config['gpg']))
839 931
 	{
840
-		if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
932
+		if (!empty($config['gpg']))
933
+		{
934
+			echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
935
+		}
841 936
 		return;
842 937
 	}
843 938
 	echo "Signing sha1sum file:\n";
844
-	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
939
+	if (file_exists($sumsfile.'.asc'))
940
+	{
941
+		unlink($sumsfile.'.asc');
942
+	}
845 943
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
846 944
 	run_cmd($cmd);
847 945
 	unlink($sumsfile);	// delete the unsigned file
@@ -854,11 +952,17 @@  discard block
 block discarded – undo
854 952
 {
855 953
 	global $config;
856 954
 
857
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
858
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
955
+	if (!file_exists($config['sourcedir']))
956
+	{
957
+		mkdir($config['sourcedir'],0755,true);
958
+	}
959
+	if (substr($config['sourcedir'],0,2) == '~/')
960
+	{
961
+		// sha1_file cant deal with '~/rpm'
859 962
 	{
860 963
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
861 964
 	}
965
+	}
862 966
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
863 967
 	$sums = '';
864 968
 
@@ -896,12 +1000,22 @@  discard block
 block discarded – undo
896 1000
 				{
897 1001
 					foreach((array)$config['all-add'] as $add)
898 1002
 					{
899
-						if (substr($add, -4) != '.tar') continue;	// probably a module
900
-						if (!($tar = realpath($add))) throw new Exception("File '$add' not found!");
1003
+						if (substr($add, -4) != '.tar')
1004
+						{
1005
+							continue;
1006
+						}
1007
+						// probably a module
1008
+						if (!($tar = realpath($add)))
1009
+						{
1010
+							throw new Exception("File '$add' not found!");
1011
+						}
901 1012
 						$cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar;
902 1013
 					}
903 1014
 				}
904
-				if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2';
1015
+				if (file_exists($file.'.bz2'))
1016
+				{
1017
+					$cmd .= '; rm -f '.$file.'.bz2';
1018
+				}
905 1019
 				$cmd .= '; '.$config['bzip2'].' '.$file;
906 1020
 				// run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it
907 1021
 				run_cmd($cmd);
@@ -922,7 +1036,10 @@  discard block
 block discarded – undo
922 1036
 
923 1037
 		foreach($config['extra'] as $name => $modules)
924 1038
 		{
925
-			if (is_numeric($name)) $name = $modules;
1039
+			if (is_numeric($name))
1040
+			{
1041
+				$name = $modules;
1042
+			}
926 1043
 			$dirs = ' egroupware/'.implode(' egroupware/', (array)$modules);
927 1044
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
928 1045
 			switch($type)
@@ -963,7 +1080,10 @@  discard block
 block discarded – undo
963 1080
 	{
964 1081
 		echo "Updating virus signatures\n";
965 1082
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
966
-		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
1083
+		if (!$verbose && function_exists('posix_getuid') && posix_getuid())
1084
+		{
1085
+			echo $cmd."\n";
1086
+		}
967 1087
 		$output = null;
968 1088
 		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
969 1089
 	}
@@ -991,7 +1111,10 @@  discard block
 block discarded – undo
991 1111
 	}
992 1112
 
993 1113
 	// we need to stash uncommited changes like .mrconfig, before copying
994
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash");
1114
+	if (file_exists($config['checkoutdir'].'/.git'))
1115
+	{
1116
+		run_cmd("cd $config[checkoutdir]; git stash");
1117
+	}
995 1118
 
996 1119
 	try {
997 1120
 		$cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/';
@@ -1000,8 +1123,14 @@  discard block
 block discarded – undo
1000 1123
 	catch (Exception $e) {
1001 1124
 		// catch failures to pop stash, before throwing exception
1002 1125
 	}
1003
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop");
1004
-	if (isset($e)) throw $e;
1126
+	if (file_exists($config['checkoutdir'].'/.git'))
1127
+	{
1128
+		run_cmd("git stash pop");
1129
+	}
1130
+	if (isset($e))
1131
+	{
1132
+		throw $e;
1133
+	}
1005 1134
 
1006 1135
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
1007 1136
 	{
@@ -1086,9 +1215,12 @@  discard block
 block discarded – undo
1086 1215
 				if ($ret || substr($line,0,5) == 'URL: ')
1087 1216
 				{
1088 1217
 					$url = substr($line,5);
1089
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1218
+					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)
1219
+					{
1220
+						// wrong branch (or no svn dir)
1090 1221
 					{
1091 1222
 						echo "Checkout is of wrong branch --> deleting it\n";
1223
+					}
1092 1224
 						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1093 1225
 						clearstatcache();
1094 1226
 					}
@@ -1135,19 +1267,31 @@  discard block
 block discarded – undo
1135 1267
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
1136 1268
 	$url = $svnbranch.'/'.$config['svnalias'];
1137 1269
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1138
-	if ($verbose) echo $cmd."\n";
1270
+	if ($verbose)
1271
+	{
1272
+		echo $cmd."\n";
1273
+	}
1139 1274
 	$output = $ret = null;
1140 1275
 	exec($cmd,$output,$ret);
1141 1276
 	$config['modules'] = array();
1142 1277
 	foreach($output as $line)
1143 1278
 	{
1144 1279
 		$line = trim($line);
1145
-		if (empty($line) || $line[0] == '#') continue;
1280
+		if (empty($line) || $line[0] == '#')
1281
+		{
1282
+			continue;
1283
+		}
1146 1284
 		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1147 1285
 		$matches = null;
1148
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1286
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1287
+		{
1288
+			die("Invalid SVN URL: $url\n");
1289
+		}
1149 1290
 		$repo = $matches[1];
1150
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1291
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1292
+		{
1293
+			$repo = 'svn+ssh://[email protected]/egroupware';
1294
+		}
1151 1295
 		$config['modules'][$repo][$path] = $url;
1152 1296
 	}
1153 1297
 	// process extra modules
@@ -1156,13 +1300,25 @@  discard block
 block discarded – undo
1156 1300
 		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1157 1301
 		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1158 1302
 		$url .= $module;
1159
-		if (strpos($module,'://') !== false) $module = basename($module);
1160
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1303
+		if (strpos($module,'://') !== false)
1304
+		{
1305
+			$module = basename($module);
1306
+		}
1307
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1308
+		{
1309
+			die("Invalid SVN URL: $url\n");
1310
+		}
1161 1311
 		$repo = $matches[1];
1162
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1312
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1313
+		{
1314
+			$repo = 'svn+ssh://[email protected]/egroupware';
1315
+		}
1163 1316
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
1164 1317
 	}
1165
-	if ($verbose) print_r($config['modules']);
1318
+	if ($verbose)
1319
+	{
1320
+		print_r($config['modules']);
1321
+	}
1166 1322
 	return $config['modules'];
1167 1323
 }
1168 1324
 
@@ -1173,7 +1329,11 @@  discard block
 block discarded – undo
1173 1329
 {
1174 1330
 	global $config,$svn;
1175 1331
 
1176
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1332
+	if (empty($config['svntag']))
1333
+	{
1334
+		return;
1335
+	}
1336
+	// otherwise we copy everything in svn root!
1177 1337
 
1178 1338
 	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1179 1339
 
@@ -1212,11 +1372,17 @@  discard block
 block discarded – undo
1212 1372
 	{
1213 1373
 		$output[] = $cmd;
1214 1374
 		exec($cmd,$output,$ret);
1215
-		if ($verbose) echo implode("\n",$output)."\n";
1375
+		if ($verbose)
1376
+		{
1377
+			echo implode("\n",$output)."\n";
1378
+		}
1216 1379
 	}
1217 1380
 	if ($ret && !in_array($ret,(array)$no_bailout))
1218 1381
 	{
1219
-		if (!$verbose) echo implode("\n",$output)."\n";
1382
+		if (!$verbose)
1383
+		{
1384
+			echo implode("\n",$output)."\n";
1385
+		}
1220 1386
 		throw new Exception("Error during '$cmd' --> aborting",$ret);
1221 1387
 	}
1222 1388
 	return $ret;
@@ -1263,7 +1429,10 @@  discard block
 block discarded – undo
1263 1429
 	unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1264 1430
 	foreach($config as $name => $default)
1265 1431
 	{
1266
-		if (is_array($default)) $default = implode(' ',$default);
1432
+		if (is_array($default))
1433
+		{
1434
+			$default = implode(' ',$default);
1435
+		}
1267 1436
 		echo '--'.str_pad($name,20).$default."\n";
1268 1437
 	}
1269 1438
 	if ($error)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	curl_setopt($c, CURLOPT_URL, $url);
442 442
 
443 443
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
444
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
444
+	if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
445 445
 
446 446
 	if (($response = curl_exec($c)) === false)
447 447
 	{
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
675 675
 			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
676 676
 		{
677
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
677
+			if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
678 678
 			return (int)$log['revision'];
679 679
 		}
680 680
 	}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			if ($content != $content_was)
756 756
 			{
757 757
 				file_put_contents($path,$content);
758
-				if ($verbose) echo "Updated $path\n";
758
+				if ($verbose) echo "updated $path\n";
759 759
 				++$n;
760 760
 			}
761 761
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	}
884 884
 	foreach($config['types'] as $type)
885 885
 	{
886
-		echo "Creating $type archives\n";
886
+		echo "creating $type archives\n";
887 887
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
888 888
 
889 889
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 
1006 1006
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
1007 1007
 	{
1008
-		echo "Running $cmd\n";
1008
+		echo "running $cmd\n";
1009 1009
 		run_cmd($cmd);
1010 1010
 	}
1011 1011
 	// fix permissions
Please login to merge, or discard this patch.
doc/rpm-build/post_install.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  *
486 486
  * @param string $cmd
487 487
  * @param array &$output=null $output of command
488
- * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
488
+ * @param integer $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 489
  * @return int exit code of $cmd
490 490
  */
491 491
 function run_cmd($cmd,array &$output=null,$no_bailout=null)
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  * Read one Univention secret/password eg. _ucr_secret('mysql')
713 713
  *
714 714
  * @param string $name
715
- * @return string|boolean
715
+ * @return false|string
716 716
  */
717 717
 function _ucr_secret($name)
718 718
 {
Please login to merge, or discard this patch.
Spacing   +80 added lines, -83 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	'php'         => '/usr/bin/php',
19 19
 	'source_dir'  => '/usr/share/egroupware',
20 20
 	'data_dir'    => '/var/lib/egroupware',
21
-	'header'      => '$data_dir/header.inc.php',	// symlinked to source_dir by rpm
21
+	'header'      => '$data_dir/header.inc.php', // symlinked to source_dir by rpm
22 22
 	'setup-cli'   => '$source_dir/setup/setup-cli.php',
23 23
 	'domain'      => 'default',
24 24
 	'config_user' => 'admin',
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	'db_user'     => 'egroupware',
31 31
 	'db_pass'     => randomstring(),
32 32
 	'db_grant_host' => 'localhost',
33
-	'db_root'     => 'root',	// mysql root user/pw to create database
33
+	'db_root'     => 'root', // mysql root user/pw to create database
34 34
 	'db_root_pw'  => '',
35 35
 	'backup'      => '',
36 36
 	'admin_user'  => 'sysop',
37 37
 	'admin_passwd'=> randomstring(),
38 38
 	'admin_email' => '',
39
-	'lang'        => 'en',	// languages for admin user and extra lang to install
39
+	'lang'        => 'en', // languages for admin user and extra lang to install
40 40
 	'charset'     => 'utf-8',
41 41
 	'start_db'    => '/sbin/service mysqld',
42 42
 	'autostart_db' => '/sbin/chkconfig --level 345 mysqld on',
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
 	'ldap_search_filter' => '(uid=%user)',
57 57
 	'ldap_group_context' => 'ou=groups,$base',
58 58
 	'ldap_encryption_type' => '',
59
-	'sambaadmin/sambasid'=> '',	// SID for sambaadmin
59
+	'sambaadmin/sambasid'=> '', // SID for sambaadmin
60 60
 	'mailserver'    => '',
61 61
 	'smtpserver'    => 'localhost,25',
62
-	'smtp'          => '',	// see setup-cli.php --help config
62
+	'smtp'          => '', // see setup-cli.php --help config
63 63
 	'imap'          => '',
64 64
 	'sieve'         => '',
65 65
 	'folder'        => '',
66
-	'install-update-app' => '',	// install or update a single (non-default) app
67
-	'webserver_user'=> 'apache',	// required to fix permissions
66
+	'install-update-app' => '', // install or update a single (non-default) app
67
+	'webserver_user'=> 'apache', // required to fix permissions
68 68
 	'php5enmod'     => '',
69 69
 );
70 70
 
71 71
 // read language from LANG enviroment variable
72 72
 if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null)))
73 73
 {
74
-	@list($lang,$nat) = preg_split('/[_.]/',$lang);
75
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
74
+	@list($lang, $nat) = preg_split('/[_.]/', $lang);
75
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
76 76
 	{
77 77
 		$lang .= '-'.strtolower($nat);
78 78
 	}
@@ -85,16 +85,13 @@  discard block
 block discarded – undo
85 85
  *
86 86
  * @param string $distro =null default autodetect
87 87
  */
88
-function set_distro_defaults($distro=null)
88
+function set_distro_defaults($distro = null)
89 89
 {
90 90
 	global $config;
91 91
 	if (is_null($distro))
92 92
 	{
93
-		$distro = file_exists('/etc/SuSE-release') ? 'suse' :
94
-			(file_exists('/etc/mandriva-release') ? 'mandriva' :
95
-			(file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
96
-				file_get_contents('/etc/lsb-release')) ? 'univention' :
97
-			(file_exists('/etc/debian_version') ? 'debian' : 'rh')));
93
+		$distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
94
+				file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh')));
98 95
 	}
99 96
 	switch (($config['distro'] = $distro))
100 97
 	{
@@ -162,9 +159,9 @@  discard block
 block discarded – undo
162 159
 			}
163 160
 			elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql'))
164 161
 			{
165
-				foreach(array('start_db','autostart_db') as $name)
162
+				foreach (array('start_db', 'autostart_db') as $name)
166 163
 				{
167
-					$config[$name] = str_replace('mysqld','mysql',$config[$name]);
164
+					$config[$name] = str_replace('mysqld', 'mysql', $config[$name]);
168 165
 				}
169 166
 			}
170 167
 			break;
@@ -180,48 +177,48 @@  discard block
 block discarded – undo
180 177
 if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL']))
181 178
 {
182 179
 	$conf = array();
183
-	$config_set = preg_split('/[ \t]+/',trim($config_set));
184
-	while($config_set)
180
+	$config_set = preg_split('/[ \t]+/', trim($config_set));
181
+	while ($config_set)
185 182
 	{
186 183
 		$val = array_shift($config_set);
187 184
 		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
188 185
 		{
189
-			while (substr($val,-1) != $quote)
186
+			while (substr($val, -1) != $quote)
190 187
 			{
191 188
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
192 189
 				$val .= ' '.array_shift($config_set);
193 190
 			}
194
-			$val = substr($val,1,-1);
191
+			$val = substr($val, 1, -1);
195 192
 		}
196 193
 		$conf[] = $val;
197 194
 	}
198
-	$argv = array_merge($conf,$argv);
195
+	$argv = array_merge($conf, $argv);
199 196
 }
200 197
 
201 198
 $auth_type_given = false;
202
-while(($arg = array_shift($argv)))
199
+while (($arg = array_shift($argv)))
203 200
 {
204 201
 	if ($arg == '-v' || $arg == '--verbose')
205 202
 	{
206 203
 		$verbose = true;
207 204
 	}
208
-	elseif($arg == '-h' || $arg == '--help')
205
+	elseif ($arg == '-h' || $arg == '--help')
209 206
 	{
210 207
 		usage();
211 208
 	}
212
-	elseif($arg == '--suse')
209
+	elseif ($arg == '--suse')
213 210
 	{
214 211
 		set_distro_defaults('suse');
215 212
 	}
216
-	elseif($arg == '--distro')
213
+	elseif ($arg == '--distro')
217 214
 	{
218 215
 		set_distro_defaults(array_shift($argv));
219 216
 	}
220
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
217
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
221 218
 	{
222 219
 		$config[$name] = array_shift($argv);
223 220
 
224
-		switch($name)
221
+		switch ($name)
225 222
 		{
226 223
 			case 'auth_type':
227 224
 				$auth_type_given = true;
@@ -242,18 +239,18 @@  discard block
 block discarded – undo
242 239
 }
243 240
 
244 241
 $replace = array();
245
-foreach($config as $name => $value)
242
+foreach ($config as $name => $value)
246 243
 {
247 244
 	$replace['$'.$name] = $value;
248
-	if (strpos($value,'$') !== false)
245
+	if (strpos($value, '$') !== false)
249 246
 	{
250
-		$config[$name] = strtr($value,$replace);
247
+		$config[$name] = strtr($value, $replace);
251 248
 	}
252 249
 }
253 250
 // basic config checks
254
-foreach(array('php','source_dir','data_dir','setup-cli') as $name)
251
+foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name)
255 252
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
253
+	if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!');
257 254
 }
258 255
 
259 256
 // fix important php.ini and conf.d/*.ini settings
@@ -278,7 +275,7 @@  discard block
 block discarded – undo
278 275
 	}
279 276
 	// create database
280 277
 	$setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db';
281
-	foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name)
278
+	foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name)
282 279
 	{
283 280
 		$setup_db .= ' '.escapeshellarg($name.'='.$config[$name]);
284 281
 	}
@@ -286,7 +283,7 @@  discard block
 block discarded – undo
286 283
 
287 284
 	// check if ldap is required and initialise it
288 285
 	// we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql!
289
-	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
286
+	@list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3);
290 287
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 288
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292 289
 	if (empty($rest)) unset($config['account-auth']);
@@ -297,15 +294,15 @@  discard block
 block discarded – undo
297 294
 
298 295
 		$setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='.
299 296
 			($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap');
300
-		foreach(array(
301
-			'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw',	// non-egw params: only used for create
302
-			'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context',	// egw params
297
+		foreach (array(
298
+			'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create
299
+			'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params
303 300
 			'ldap_encryption_type', 'sambaadmin/sambasid',
304 301
 		) as $name)
305 302
 		{
306
-			if (strpos($value=$config[$name],'$') !== false)
303
+			if (strpos($value = $config[$name], '$') !== false)
307 304
 			{
308
-				$config[$name] = $value = strtr($value,array(
305
+				$config[$name] = $value = strtr($value, array(
309 306
 					'$suffix' => $config['ldap_suffix'],
310 307
 					'$base' => $config['ldap_base'],
311 308
 					'$admin_pw' => $config['ldap_admin_pw'],
@@ -313,7 +310,7 @@  discard block
 block discarded – undo
313 310
 			}
314 311
 			$setup_ldap .= ' '.escapeshellarg($name.'='.$value);
315 312
 
316
-			if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw')))
313
+			if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw')))
317 314
 			{
318 315
 				$extra_config .= ' '.escapeshellarg($name.'='.$value);
319 316
 			}
@@ -346,7 +343,7 @@  discard block
 block discarded – undo
346 343
 	}
347 344
 	// create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error)
348 345
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349
-	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
346
+	foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name)
350 347
 	{
351 348
 		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
352 349
 	}
@@ -360,7 +357,7 @@  discard block
 block discarded – undo
360 357
 	// check if webserver is started and start it (permanent) if not
361 358
 	if ($config['start_webserver'])
362 359
 	{
363
-		exec(build_cmd('start_webserver', 'status'),$dummy,$ret);
360
+		exec(build_cmd('start_webserver', 'status'), $dummy, $ret);
364 361
 		if ($ret)
365 362
 		{
366 363
 			system(build_cmd('start_webserver', 'start'));
@@ -399,7 +396,7 @@  discard block
 block discarded – undo
399 396
 	// --> existing install --> update
400 397
 
401 398
 	// get user from header and replace password, as we dont know it
402
-	$old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']);
399
+	$old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']);
403 400
 	// register a shutdown function to put old password back in any case
404 401
 	register_shutdown_function(function() use (&$config, $old_password)
405 402
 	{
@@ -408,18 +405,18 @@  discard block
 block discarded – undo
408 405
 
409 406
 	// update egroupware
410 407
 	$setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].',,'.$config['install-update-app']);
411
-	$ret = run_cmd($setup_update,$output,array(4,15));
408
+	$ret = run_cmd($setup_update, $output, array(4, 15));
412 409
 
413
-	switch($ret)
410
+	switch ($ret)
414 411
 	{
415 412
 		case 4:		// header needs an update
416 413
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 414
 			run_cmd($header_update);
418
-			$ret = run_cmd($setup_update,$output,15);
415
+			$ret = run_cmd($setup_update, $output, 15);
419 416
 			if ($ret != 15) break;
420 417
 			// fall through
421 418
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
419
+			if (!$verbose) echo implode("\n", (array)$output)."\n";
423 420
 			break;
424 421
 
425 422
 		case 0:
@@ -462,18 +459,18 @@  discard block
 block discarded – undo
462 459
  * @param string $password new password
463 460
  * @return string old password
464 461
  */
465
-function patch_header($filename,&$user,$password)
462
+function patch_header($filename, &$user, $password)
466 463
 {
467 464
 	$header = file_get_contents($filename);
468 465
 
469 466
 	$umatches = $pmatches = null;
470
-	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) ||
471
-		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches))
467
+	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) ||
468
+		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches))
472 469
 	{
473
-		bail_out(99,"$filename is no regular EGroupware header.inc.php!");
470
+		bail_out(99, "$filename is no regular EGroupware header.inc.php!");
474 471
 	}
475
-	file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
476
-		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header));
472
+	file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
473
+		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header));
477 474
 
478 475
 	$user = $umatches[1];
479 476
 
@@ -488,7 +485,7 @@  discard block
 block discarded – undo
488 485
  * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 486
  * @return int exit code of $cmd
490 487
  */
491
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
488
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
492 489
 {
493 490
 	global $verbose;
494 491
 
@@ -496,16 +493,16 @@  discard block
 block discarded – undo
496 493
 	{
497 494
 		echo $cmd."\n";
498 495
 		$ret = null;
499
-		system($cmd,$ret);
496
+		system($cmd, $ret);
500 497
 	}
501 498
 	else
502 499
 	{
503 500
 		$output[] = $cmd;
504
-		exec($cmd,$output,$ret);
501
+		exec($cmd, $output, $ret);
505 502
 	}
506
-	if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout))
503
+	if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout))
507 504
 	{
508
-		bail_out($ret,$verbose?null:$output);
505
+		bail_out($ret, $verbose ? null : $output);
509 506
 	}
510 507
 	return $ret;
511 508
 }
@@ -516,9 +513,9 @@  discard block
 block discarded – undo
516 513
  * @param int $ret =1
517 514
  * @param array|string $output line(s) to output before temination notice
518 515
  */
519
-function bail_out($ret=1,$output=null)
516
+function bail_out($ret = 1, $output = null)
520 517
 {
521
-	if ($output) echo implode("\n",(array)$output);
518
+	if ($output) echo implode("\n", (array)$output);
522 519
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 520
 	exit($ret);
524 521
 }
@@ -529,21 +526,21 @@  discard block
 block discarded – undo
529 526
  * @param int $len =16
530 527
  * @return string
531 528
  */
532
-function randomstring($len=16)
529
+function randomstring($len = 16)
533 530
 {
534 531
 	static $usedchars = array(
535
-		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
536
-		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
537
-		'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
538
-		'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
539
-		'@','!','%','&','(',')','=','?',';',':','#','_','-','<',
540
-		'>','|','[',']','}',	// dont add /\,'"{ as we have problems dealing with them
532
+		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
533
+		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
534
+		'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
535
+		'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
536
+		'@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<',
537
+		'>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them
541 538
 	);
542 539
 
543 540
 	$str = '';
544
-	for($i=0; $i < $len; $i++)
541
+	for ($i = 0; $i < $len; $i++)
545 542
 	{
546
-		$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
543
+		$str .= $usedchars[mt_rand(0, count($usedchars) - 1)];
547 544
 	}
548 545
 	return $str;
549 546
 }
@@ -553,20 +550,20 @@  discard block
 block discarded – undo
553 550
  *
554 551
  * @param string $error =null optional error-message
555 552
  */
556
-function usage($error=null)
553
+function usage($error = null)
557 554
 {
558
-	global $prog,$config;
555
+	global $prog, $config;
559 556
 
560 557
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n";
561 558
 	echo "options and their defaults:\n";
562
-	foreach($config as $name => $default)
559
+	foreach ($config as $name => $default)
563 560
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
565
-		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
561
+		if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options
562
+		if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16)
566 563
 		{
567 564
 			$default = '<16 char random string>';
568 565
 		}
569
-		echo '--'.str_pad($name,20).$default."\n";
566
+		echo '--'.str_pad($name, 20).$default."\n";
570 567
 	}
571 568
 	if ($error)
572 569
 	{
@@ -616,8 +613,8 @@  discard block
 block discarded – undo
616 613
 	$config['distro'] = 'univention';
617 614
 
618 615
 	// set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment
619
-	@list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
620
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
616
+	@list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
617
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
621 618
 	{
622 619
 		$lang .= '-'.strtolower($nat);
623 620
 	}
@@ -642,7 +639,7 @@  discard block
 block discarded – undo
642 639
 		// ldap password hash (our default blowfish_crypt seems not to work)
643 640
 		$config['ldap_encryption_type'] = 'sha512_crypt';
644 641
 
645
-		$config['account_min_id'] = 1200;	// UCS use 11xx for internal users/groups
642
+		$config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups
646 643
 
647 644
 		$config['account-auth'] = 'univention,ldap';
648 645
 
@@ -652,7 +649,7 @@  discard block
 block discarded – undo
652 649
 		// mailserver, see setup-cli.php --help config
653 650
 		if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) &&
654 651
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655
-			($domains=_ucr_get('mail/hosteddomains')))
652
+			($domains = _ucr_get('mail/hosteddomains')))
656 653
 		{
657 654
 			if (!is_array($domains)) $domains = explode("\n", $domains);
658 655
 			$domain = array_shift($domains);
@@ -692,12 +689,12 @@  discard block
 block discarded – undo
692 689
  */
693 690
 function _ucr_get($name)
694 691
 {
695
-	static $values=null;
692
+	static $values = null;
696 693
 	if (!isset($values))
697 694
 	{
698 695
 		$output = $matches = null;
699 696
 		exec('/usr/sbin/ucr dump', $output);
700
-		foreach($output as $line)
697
+		foreach ($output as $line)
701 698
 		{
702 699
 			if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches))
703 700
 			{
@@ -773,7 +770,7 @@  discard block
 block discarded – undo
773 770
  */
774 771
 function _size_with_unit($size)
775 772
 {
776
-	switch(strtoupper(substr($size, -1)))
773
+	switch (strtoupper(substr($size, -1)))
777 774
 	{
778 775
 		case 'G':
779 776
 			$size *= 1024;
Please login to merge, or discard this patch.
Braces   +90 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,10 +9,13 @@  discard block
 block discarded – undo
9 9
  * @version $Id$
10 10
  */
11 11
 
12
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling post_install as web-page
12
+if (php_sapi_name() !== 'cli')
13
+{
14
+	// security precaution: forbit calling post_install as web-page
13 15
 {
14 16
 	die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>');
15 17
 }
18
+}
16 19
 $verbose = false;
17 20
 $config = array(
18 21
 	'php'         => '/usr/bin/php',
@@ -100,7 +103,10 @@  discard block
 block discarded – undo
100 103
 	{
101 104
 		case 'suse':
102 105
 			// openSUSE 12.1+ no longer uses php5
103
-			if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5';
106
+			if (file_exists('/usr/bin/php5'))
107
+			{
108
+				$config['php'] = '/usr/bin/php5';
109
+			}
104 110
 			$config['start_db'] = '/sbin/service mysql';
105 111
 			$config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on';
106 112
 			$config['start_webserver'] = '/sbin/service apache2';
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$config['php5enmod'] = '/usr/sbin/php5enmod';
132 138
 				// Ubuntu only needs "-s ALL" and Debian gives an error, because it does not support it
133
-				if (!file_exists('/etc/php5/conf.d/')) $config['php5enmod'] .= ' -s ALL';
139
+				if (!file_exists('/etc/php5/conf.d/'))
140
+				{
141
+					$config['php5enmod'] .= ' -s ALL';
142
+				}
134 143
 				$config['php5enmod'] .= ' mcrypt';
135 144
 			}
136 145
 			$config['autostart_db'] = '/usr/sbin/update-rc.d mysql defaults';
@@ -153,9 +162,12 @@  discard block
 block discarded – undo
153 162
 			// fall through
154 163
 		case 'rh':
155 164
 			// some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld"
156
-			if (file_exists('/usr/bin/systemctl'))	// RHEL 7
165
+			if (file_exists('/usr/bin/systemctl'))
166
+			{
167
+				// RHEL 7
157 168
 			{
158 169
 				$config['start_db'] = '/usr/bin/systemctl %s mariadb';
170
+			}
159 171
 				$config['autostart_db'] = build_cmd('start_db', 'enable');
160 172
 				$config['start_webserver'] = '/usr/bin/systemctl %s httpd';
161 173
 				$config['autostart_webserver'] = build_cmd('start_webserver', 'enable');
@@ -184,11 +196,14 @@  discard block
 block discarded – undo
184 196
 	while($config_set)
185 197
 	{
186 198
 		$val = array_shift($config_set);
187
-		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
199
+		if (($quote = $val[0]) == "'" || $quote == '"')
200
+		{
201
+			// arguments might be quoted with ' or "
188 202
 		{
189 203
 			while (substr($val,-1) != $quote)
190 204
 			{
191 205
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
206
+		}
192 207
 				$val .= ' '.array_shift($config_set);
193 208
 			}
194 209
 			$val = substr($val,1,-1);
@@ -253,18 +268,24 @@  discard block
 block discarded – undo
253 268
 // basic config checks
254 269
 foreach(array('php','source_dir','data_dir','setup-cli') as $name)
255 270
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
257
-}
271
+	if (!file_exists($config[$name]))
272
+	{
273
+		bail_out(1,$config[$name].' not found!');
274
+	}
275
+	}
258 276
 
259 277
 // fix important php.ini and conf.d/*.ini settings
260 278
 check_fix_php_apc_ini();
261 279
 
262 280
 $setup_cli = $config['php'].' -d memory_limit=256M '.$config['setup-cli'];
263 281
 
264
-if (!file_exists($config['header']) || filesize($config['header']) < 200)	// default header redirecting to setup is 147 bytes
282
+if (!file_exists($config['header']) || filesize($config['header']) < 200)
283
+{
284
+	// default header redirecting to setup is 147 bytes
265 285
 {
266 286
 	// --> new install
267 287
 	$extra_config = '';
288
+}
268 289
 
269 290
 	// check for localhost if database server is started and start it (permanent) if not
270 291
 	if ($config['db_host'] == 'localhost' && $config['start_db'])
@@ -273,7 +294,10 @@  discard block
 block discarded – undo
273 294
 		if ($ret)
274 295
 		{
275 296
 			system(build_cmd('start_db', 'start'));
276
-			if (!empty($config['autostart_db'])) system($config['autostart_db']);
297
+			if (!empty($config['autostart_db']))
298
+			{
299
+				system($config['autostart_db']);
300
+			}
277 301
 		}
278 302
 	}
279 303
 	// create database
@@ -289,7 +313,10 @@  discard block
 block discarded – undo
289 313
 	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
290 314
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 315
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292
-	if (empty($rest)) unset($config['account-auth']);
316
+	if (empty($rest))
317
+	{
318
+		unset($config['account-auth']);
319
+	}
293 320
 	if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap')
294 321
 	{
295 322
 		// set account_min_id to 1100 if not specified to NOT clash with system accounts
@@ -348,7 +375,10 @@  discard block
 block discarded – undo
348 375
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349 376
 	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
350 377
 	{
351
-		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
378
+		if (!empty($config[$name]))
379
+		{
380
+			$setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
381
+		}
352 382
 	}
353 383
 	run_cmd($setup_mailserver);
354 384
 
@@ -364,7 +394,10 @@  discard block
 block discarded – undo
364 394
 		if ($ret)
365 395
 		{
366 396
 			system(build_cmd('start_webserver', 'start'));
367
-			if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']);
397
+			if (!empty($config['autostart_webserver']))
398
+			{
399
+				system($config['autostart_webserver']);
400
+			}
368 401
 		}
369 402
 		else
370 403
 		{
@@ -416,10 +449,16 @@  discard block
 block discarded – undo
416 449
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 450
 			run_cmd($header_update);
418 451
 			$ret = run_cmd($setup_update,$output,15);
419
-			if ($ret != 15) break;
452
+			if ($ret != 15)
453
+			{
454
+				break;
455
+			}
420 456
 			// fall through
421 457
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
458
+			if (!$verbose)
459
+			{
460
+				echo implode("\n",(array)$output)."\n";
461
+			}
423 462
 			break;
424 463
 
425 464
 		case 0:
@@ -447,9 +486,15 @@  discard block
 block discarded – undo
447 486
 {
448 487
 	global $config;
449 488
 
450
-	if (isset($config[$cmd])) $cmd = $config[$cmd];
489
+	if (isset($config[$cmd]))
490
+	{
491
+		$cmd = $config[$cmd];
492
+	}
451 493
 
452
-	if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd);
494
+	if (strpos($cmd, '%s'))
495
+	{
496
+		return str_replace('%s', $arg, $cmd);
497
+	}
453 498
 
454 499
 	return $cmd.' '.$arg;
455 500
 }
@@ -518,7 +563,10 @@  discard block
 block discarded – undo
518 563
  */
519 564
 function bail_out($ret=1,$output=null)
520 565
 {
521
-	if ($output) echo implode("\n",(array)$output);
566
+	if ($output)
567
+	{
568
+		echo implode("\n",(array)$output);
569
+	}
522 570
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 571
 	exit($ret);
524 572
 }
@@ -561,7 +609,11 @@  discard block
 block discarded – undo
561 609
 	echo "options and their defaults:\n";
562 610
 	foreach($config as $name => $default)
563 611
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
612
+		if (in_array($name, array('postfix','cyrus')))
613
+		{
614
+			continue;
615
+		}
616
+		// do NOT report deprecated options
565 617
 		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
566 618
 		{
567 619
 			$default = '<16 char random string>';
@@ -654,7 +706,10 @@  discard block
 block discarded – undo
654 706
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655 707
 			($domains=_ucr_get('mail/hosteddomains')))
656 708
 		{
657
-			if (!is_array($domains)) $domains = explode("\n", $domains);
709
+			if (!is_array($domains))
710
+			{
711
+				$domains = explode("\n", $domains);
712
+			}
658 713
 			$domain = array_shift($domains);
659 714
 			// set "use auth with session credentials",tls,"not user editable","further identities"
660 715
 			$config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes";
@@ -664,13 +719,19 @@  discard block
 block discarded – undo
664 719
 			{
665 720
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Dovecot';
666 721
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
667
-				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190;
722
+				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port')))
723
+				{
724
+					$sieve_port = 4190;
725
+				}
668 726
 			}
669 727
 			else
670 728
 			{
671 729
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus';
672 730
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
673
-				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
731
+				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port')))
732
+				{
733
+					$sieve_port = 4190;
734
+				}
674 735
 			}
675 736
 			// set folders so mail creates them on first login, UCS does not automatic
676 737
 			$config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,INBOX/Spam';
@@ -735,7 +796,10 @@  discard block
 block discarded – undo
735 796
 		$shm_size = ini_get('apc.shm_size');
736 797
 		$shm_segments = ini_get('apc.shm_segments');
737 798
 		// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
738
-		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M';
799
+		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576))
800
+		{
801
+			$shm_size .= 'M';
802
+		}
739 803
 
740 804
 		$size = _size_with_unit($shm_size) * $shm_segments;
741 805
 		//echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n";
@@ -751,7 +815,10 @@  discard block
 block discarded – undo
751 815
 				file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path)))
752 816
 			{
753 817
 				$new_shm_size = 128 / $shm_segments;
754
-				if (!$numeric_size) $new_shm_size .= 'M';
818
+				if (!$numeric_size)
819
+				{
820
+					$new_shm_size .= 'M';
821
+				}
755 822
 				if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini))
756 823
 				{
757 824
 					file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini));
Please login to merge, or discard this patch.