Completed
Push — 14.2 ( c53e78...a8db63 )
by Ralf
29:08
created
calendar/inc/class.calendar_uiforms.inc.php 5 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
 	 * Freetime search
2203 2203
 	 *
2204 2204
 	 * As the function is called in a popup via javascript, parametes get initialy transfered via the url
2205
-	 * @param array $content=null array with parameters or false (default) to use the get-params
2205
+	 * @param array $content array with parameters or false (default) to use the get-params
2206 2206
 	 * @param string start[str] start-date
2207 2207
 	 * @param string start[hour] start-hour
2208 2208
 	 * @param string start[min] start-minutes
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
 	/**
2447 2447
 	 * Export events as vCalendar version 2.0 files (iCal)
2448 2448
 	 *
2449
-	 * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2449
+	 * @param integer $content numeric cal_id or submitted content from etempalte::exec
2450 2450
 	 * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2451 2451
 	 * @return string error-msg if $return_error
2452 2452
 	 */
@@ -2683,12 +2683,12 @@  discard block
 block discarded – undo
2683 2683
 	/**
2684 2684
 	 * moves an event to another date/time
2685 2685
 	 *
2686
-	 * @param string $eventId id of the event which has to be moved
2686
+	 * @param string $_eventId id of the event which has to be moved
2687 2687
 	 * @param string $calendarOwner the owner of the calendar the event is in
2688 2688
 	 * @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD
2689 2689
 	 * @param string $targetOwner the owner of the target calendar
2690 2690
 	 * @param string $durationT the duration to support resizable calendar event
2691
-	 * @return string XML response if no error occurs
2691
+	 * @return false|null XML response if no error occurs
2692 2692
 	 */
2693 2693
 	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null)
2694 2694
 	{
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 	 */
2453 2453
 	function export($content=0,$return_error=false)
2454 2454
 	{
2455
-        $boical = new calendar_ical();
2455
+		$boical = new calendar_ical();
2456 2456
 		#error_log(__METHOD__.print_r($content,true));
2457 2457
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2458 2458
 		{
@@ -2616,8 +2616,8 @@  discard block
 block discarded – undo
2616 2616
 	}
2617 2617
 
2618 2618
 	/**
2619
-	* Set up the required fields to get the history tab
2620
-	*/
2619
+	 * Set up the required fields to get the history tab
2620
+	 */
2621 2621
 	public function setup_history(&$content, &$sel_options)
2622 2622
 	{
2623 2623
 		$status = 'history_status';
Please login to merge, or discard this patch.
Switch Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -538,268 +538,268 @@  discard block
 block discarded – undo
538 538
 
539 539
 		switch((string)$button)
540 540
 		{
541
-		case 'exception':	// create an exception in a recuring event
542
-			$msg = $this->_create_exception($event,$preserv);
543
-			break;
541
+			case 'exception':	// create an exception in a recuring event
542
+				$msg = $this->_create_exception($event,$preserv);
543
+				break;
544 544
 
545
-		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
546
-			unset($event['id']);
547
-			unset($event['uid']);
548
-			unset($event['reference']);
549
-			unset($preserv['reference']);
550
-			unset($event['recurrence']);
551
-			unset($preserv['recurrence']);
552
-			unset($event['recur_exception']);
553
-			unset($event['edit_single']);	// in case it has been set
554
-			unset($event['modified']);
555
-			unset($event['modifier']);
556
-			unset($event['caldav_name']);
557
-			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner;
545
+			case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
546
+				unset($event['id']);
547
+				unset($event['uid']);
548
+				unset($event['reference']);
549
+				unset($preserv['reference']);
550
+				unset($event['recurrence']);
551
+				unset($preserv['recurrence']);
552
+				unset($event['recur_exception']);
553
+				unset($event['edit_single']);	// in case it has been set
554
+				unset($event['modified']);
555
+				unset($event['modifier']);
556
+				unset($event['caldav_name']);
557
+				$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner;
558
+
559
+				// Clear participant stati
560
+				foreach($event['participant_types'] as $type => &$participants)
561
+				{
562
+					foreach($participants as $id => &$response)
563
+					{
564
+						if($type == 'u' && $id == $event['owner']) continue;
565
+						calendar_so::split_status($response, $quantity, $role);
566
+						// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
567
+						$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
568
+						$response = calendar_so::combine_status($status,$quantity,$role);
569
+					}
570
+				}
558 571
 
559
-			// Clear participant stati
560
-			foreach($event['participant_types'] as $type => &$participants)
561
-			{
562
-				foreach($participants as $id => &$response)
572
+				// Copy alarms
573
+				if (is_array($event['alarm']))
563 574
 				{
564
-					if($type == 'u' && $id == $event['owner']) continue;
565
-					calendar_so::split_status($response, $quantity, $role);
566
-					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
567
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
568
-					$response = calendar_so::combine_status($status,$quantity,$role);
575
+					foreach($event['alarm'] as $n => &$alarm)
576
+					{
577
+						unset($alarm['id']);
578
+						unset($alarm['cal_id']);
579
+					}
569 580
 				}
570
-			}
571 581
 
572
-			// Copy alarms
573
-			if (is_array($event['alarm']))
574
-			{
575
-				foreach($event['alarm'] as $n => &$alarm)
582
+				// Get links to be copied
583
+				// With no ID, $content['link_to']['to_id'] is used
584
+				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
585
+				foreach(egw_link::get_links('calendar', $content['id']) as $link)
576 586
 				{
577
-					unset($alarm['id']);
578
-					unset($alarm['cal_id']);
587
+					if ($link['app'] != egw_link::VFS_APPNAME)
588
+					{
589
+						egw_link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
590
+					}
591
+					elseif ($link['app'] == egw_link::VFS_APPNAME)
592
+					{
593
+						egw_link::link('calendar', $content['link_to']['to_id'], egw_link::VFS_APPNAME, array(
594
+							'tmp_name' => egw_link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
595
+							'name' => $link['id'],
596
+						), $link['remark']);
597
+					}
579 598
 				}
580
-			}
599
+				unset($link);
600
+				$preserv['view'] = $preserv['edit_single'] = false;
601
+				$msg = lang('Event copied - the copy can now be edited');
602
+				$event['title'] = lang('Copy of:').' '.$event['title'];
603
+				break;
581 604
 
582
-			// Get links to be copied
583
-			// With no ID, $content['link_to']['to_id'] is used
584
-			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
585
-			foreach(egw_link::get_links('calendar', $content['id']) as $link)
586
-			{
587
-				if ($link['app'] != egw_link::VFS_APPNAME)
605
+			case 'mail':
606
+			case 'sendrequest':
607
+			case 'save':
608
+			case 'print':
609
+			case 'apply':
610
+			case 'infolog':
611
+				if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
588 612
 				{
589
-					egw_link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
613
+					$msg = lang('Permission denied');
614
+					$button = '';
615
+					break;
590 616
 				}
591
-				elseif ($link['app'] == egw_link::VFS_APPNAME)
617
+				if ($event['start'] > $event['end'])
592 618
 				{
593
-					egw_link::link('calendar', $content['link_to']['to_id'], egw_link::VFS_APPNAME, array(
594
-						'tmp_name' => egw_link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
595
-						'name' => $link['id'],
596
-					), $link['remark']);
619
+					$msg = lang('Error: Starttime has to be before the endtime !!!');
620
+					$button = '';
621
+					break;
597 622
 				}
598
-			}
599
-			unset($link);
600
-			$preserv['view'] = $preserv['edit_single'] = false;
601
-			$msg = lang('Event copied - the copy can now be edited');
602
-			$event['title'] = lang('Copy of:').' '.$event['title'];
603
-			break;
604
-
605
-		case 'mail':
606
-		case 'sendrequest':
607
-		case 'save':
608
-		case 'print':
609
-		case 'apply':
610
-		case 'infolog':
611
-			if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
612
-			{
613
-				$msg = lang('Permission denied');
614
-				$button = '';
615
-				break;
616
-			}
617
-			if ($event['start'] > $event['end'])
618
-			{
619
-				$msg = lang('Error: Starttime has to be before the endtime !!!');
620
-				$button = '';
621
-				break;
622
-			}
623
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
624
-			{
625
-				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
626
-				$button = '';
627
-				break;
628
-			}
629
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
630
-			{
631
-				$msg = lang('Error: Duration of event longer then recurrence interval!');
632
-				$button = '';
633
-				break;
634
-			}
635
-			if (!$event['participants'])
636
-			{
637
-				$msg = lang('Error: no participants selected !!!');
638
-				$button = '';
639
-				break;
640
-			}
641
-			// if private event with ressource reservation is forbidden
642
-			if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
643
-			{
644
-				foreach (array_keys($event['participants']) as $uid)
623
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
624
+				{
625
+					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
626
+					$button = '';
627
+					break;
628
+				}
629
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
630
+				{
631
+					$msg = lang('Error: Duration of event longer then recurrence interval!');
632
+					$button = '';
633
+					break;
634
+				}
635
+				if (!$event['participants'])
636
+				{
637
+					$msg = lang('Error: no participants selected !!!');
638
+					$button = '';
639
+					break;
640
+				}
641
+				// if private event with ressource reservation is forbidden
642
+				if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
645 643
 				{
646
-					if ($uid[0] == 'r') //ressource detection
644
+					foreach (array_keys($event['participants']) as $uid)
647 645
 					{
648
-						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
649
-						$button = '';
650
-						break 2; //break foreach and case
646
+						if ($uid[0] == 'r') //ressource detection
647
+						{
648
+							$msg = lang('Error: ressources reservation in private events is not allowed!!!');
649
+							$button = '';
650
+							break 2; //break foreach and case
651
+						}
651 652
 					}
652 653
 				}
653
-			}
654
-			if ($content['edit_single'])	// we edited a single event from a series
655
-			{
656
-				$event['reference'] = $event['id'];
657
-				$event['recurrence'] = $content['edit_single'];
658
-				unset($event['id']);
659
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
660
-				if (!is_array($conflicts) && $conflicts)
654
+				if ($content['edit_single'])	// we edited a single event from a series
661 655
 				{
662
-					// now we need to add the original start as recur-execption to the series
663
-					$recur_event = $this->bo->read($event['reference']);
664
-					$recur_event['recur_exception'][] = $content['edit_single'];
665
-					// check if we need to move the alarms, because they are next on that exception
666
-					foreach($recur_event['alarm'] as $id => $alarm)
656
+					$event['reference'] = $event['id'];
657
+					$event['recurrence'] = $content['edit_single'];
658
+					unset($event['id']);
659
+					$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
660
+					if (!is_array($conflicts) && $conflicts)
667 661
 					{
668
-						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
662
+						// now we need to add the original start as recur-execption to the series
663
+						$recur_event = $this->bo->read($event['reference']);
664
+						$recur_event['recur_exception'][] = $content['edit_single'];
665
+						// check if we need to move the alarms, because they are next on that exception
666
+						foreach($recur_event['alarm'] as $id => $alarm)
669 667
 						{
670
-							$rrule = calendar_rrule::event2rrule($recur_event, true);
671
-							foreach ($rrule as $time)
668
+							if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
672 669
 							{
673
-								if ($content['edit_single'] < $time->format('ts'))
670
+								$rrule = calendar_rrule::event2rrule($recur_event, true);
671
+								foreach ($rrule as $time)
674 672
 								{
675
-									$alarm['time'] = $time->format('ts') - $alarm['offset'];
676
-									$this->bo->save_alarm($event['reference'], $alarm);
677
-									break;
673
+									if ($content['edit_single'] < $time->format('ts'))
674
+									{
675
+										$alarm['time'] = $time->format('ts') - $alarm['offset'];
676
+										$this->bo->save_alarm($event['reference'], $alarm);
677
+										break;
678
+									}
678 679
 								}
679 680
 							}
680 681
 						}
682
+						unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
683
+						unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
684
+						$this->bo->update($recur_event,true);	// no conflict check here
685
+						unset($recur_event);
686
+						unset($event['edit_single']);			// if we further edit it, it's just a single event
687
+						unset($preserv['edit_single']);
688
+					}
689
+					else	// conflict or error, we need to reset everything to the state befor we tried to save it
690
+					{
691
+						$event['id'] = $event['reference'];
692
+						$event['reference'] = $event['recurrence'] = 0;
693
+						$event['uid'] = $content['uid'];
681 694
 					}
682
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
683
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
684
-					$this->bo->update($recur_event,true);	// no conflict check here
685
-					unset($recur_event);
686
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
687
-					unset($preserv['edit_single']);
688 695
 				}
689
-				else	// conflict or error, we need to reset everything to the state befor we tried to save it
696
+				else	// we edited a non-reccuring event or the whole series
690 697
 				{
691
-					$event['id'] = $event['reference'];
692
-					$event['reference'] = $event['recurrence'] = 0;
693
-					$event['uid'] = $content['uid'];
694
-				}
695
-			}
696
-			else	// we edited a non-reccuring event or the whole series
697
-			{
698
-				if (($old_event = $this->bo->read($event['id'])))
699
-				{
700
-					if ($event['recur_type'] != MCAL_RECUR_NONE)
698
+					if (($old_event = $this->bo->read($event['id'])))
701 699
 					{
702
-						// we edit a existing series event
703
-						if ($event['start'] != $old_event['start'] ||
704
-							$event['whole_day'] != $old_event['whole_day'])
700
+						if ($event['recur_type'] != MCAL_RECUR_NONE)
705 701
 						{
706
-							if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
702
+							// we edit a existing series event
703
+							if ($event['start'] != $old_event['start'] ||
704
+								$event['whole_day'] != $old_event['whole_day'])
707 705
 							{
708
-								$msg = lang("Error: You can't shift a series from the past!");
709
-								$noerror = false;
710
-								break;
711
-							}
712
-							// splitting of series confirmed or first event clicked (no confirmation necessary)
713
-							$orig_event = $event;
706
+								if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
707
+								{
708
+									$msg = lang("Error: You can't shift a series from the past!");
709
+									$noerror = false;
710
+									break;
711
+								}
712
+								// splitting of series confirmed or first event clicked (no confirmation necessary)
713
+								$orig_event = $event;
714 714
 
715
-							// calculate offset against old series start or clicked recurrance,
716
-							// depending on which is smaller
717
-							$offset = $event['start'] - $old_event['start'];
718
-							if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
719
-							{
720
-								$offset = $off2;
721
-							}
722
-							// base start-date of new series on actual / clicked date
723
-							$actual_date = $event['actual_date'];
724
-							$event['start'] = $actual_date + $offset;
725
-							if ($content['duration'])
726
-							{
727
-								$event['end'] = $event['start'] + $content['duration'];
728
-							}
729
-							elseif($event['end'] < $event['start'])
730
-							{
731
-								$event['end'] = $event['start'] + $event['end'] - $actual_date;
732
-							}
733
-							//echo "<p>".__LINE__.": event[start]=$event[start]=".egw_time::to($event['start']).", duration=$content[duration], event[end]=$event[end]=".egw_time::to($event['end']).", offset=$offset</p>\n";
734
-							$event['participants'] = $old_event['participants'];
735
-							foreach ($old_event['recur_exception'] as $key => $exdate)
736
-							{
737
-								if ($exdate > $actual_date)
715
+								// calculate offset against old series start or clicked recurrance,
716
+								// depending on which is smaller
717
+								$offset = $event['start'] - $old_event['start'];
718
+								if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
738 719
 								{
739
-									unset($old_event['recur_exception'][$key]);
740
-									$event['recur_exception'][$key] += $offset;
720
+									$offset = $off2;
741 721
 								}
742
-								else
722
+								// base start-date of new series on actual / clicked date
723
+								$actual_date = $event['actual_date'];
724
+								$event['start'] = $actual_date + $offset;
725
+								if ($content['duration'])
743 726
 								{
744
-									unset($event['recur_exception'][$key]);
727
+									$event['end'] = $event['start'] + $content['duration'];
745 728
 								}
746
-							}
747
-							$old_alarms = $old_event['alarm'];
748
-							if ($old_event['start'] < $actual_date)
749
-							{
750
-								unset($orig_event);
751
-								// copy event by unsetting the id(s)
752
-								unset($event['id']);
753
-								unset($event['uid']);
754
-								unset($event['caldav_name']);
755
-
756
-								// set enddate of existing event
757
-								$rriter = calendar_rrule::event2rrule($old_event, true);
758
-								$rriter->rewind();
759
-								$last = $rriter->current();
760
-								do
729
+								elseif($event['end'] < $event['start'])
761 730
 								{
762
-									$rriter->next_no_exception();
763
-									$occurrence = $rriter->current();
731
+									$event['end'] = $event['start'] + $event['end'] - $actual_date;
764 732
 								}
765
-								while ($rriter->valid() &&
766
-										egw_time::to($occurrence, 'ts') < $actual_date &&
767
-										($last = $occurrence));
768
-								$last->setTime(0, 0, 0);
769
-								$old_event['recur_enddate'] = egw_time::to($last, 'ts');
770
-								if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$content['no_notifications']))
733
+								//echo "<p>".__LINE__.": event[start]=$event[start]=".egw_time::to($event['start']).", duration=$content[duration], event[end]=$event[end]=".egw_time::to($event['end']).", offset=$offset</p>\n";
734
+								$event['participants'] = $old_event['participants'];
735
+								foreach ($old_event['recur_exception'] as $key => $exdate)
771 736
 								{
772
-									$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
773
-										lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
774
-											htmlspecialchars(egw::link('/index.php',array(
775
-												'menuaction' => 'calendar.calendar_uiforms.edit',
776
-												'cal_id'    => $content['id'],
777
-											))).'">','</a>');
778
-									$noerror = false;
779
-									$event = $orig_event;
780
-									break;
737
+									if ($exdate > $actual_date)
738
+									{
739
+										unset($old_event['recur_exception'][$key]);
740
+										$event['recur_exception'][$key] += $offset;
741
+									}
742
+									else
743
+									{
744
+										unset($event['recur_exception'][$key]);
745
+									}
746
+								}
747
+								$old_alarms = $old_event['alarm'];
748
+								if ($old_event['start'] < $actual_date)
749
+								{
750
+									unset($orig_event);
751
+									// copy event by unsetting the id(s)
752
+									unset($event['id']);
753
+									unset($event['uid']);
754
+									unset($event['caldav_name']);
755
+
756
+									// set enddate of existing event
757
+									$rriter = calendar_rrule::event2rrule($old_event, true);
758
+									$rriter->rewind();
759
+									$last = $rriter->current();
760
+									do
761
+									{
762
+										$rriter->next_no_exception();
763
+										$occurrence = $rriter->current();
764
+									}
765
+									while ($rriter->valid() &&
766
+											egw_time::to($occurrence, 'ts') < $actual_date &&
767
+											($last = $occurrence));
768
+									$last->setTime(0, 0, 0);
769
+									$old_event['recur_enddate'] = egw_time::to($last, 'ts');
770
+									if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$content['no_notifications']))
771
+									{
772
+										$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
773
+											lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
774
+												htmlspecialchars(egw::link('/index.php',array(
775
+													'menuaction' => 'calendar.calendar_uiforms.edit',
776
+													'cal_id'    => $content['id'],
777
+												))).'">','</a>');
778
+										$noerror = false;
779
+										$event = $orig_event;
780
+										break;
781
+									}
782
+									$event['alarm'] = array();
781 783
 								}
782
-								$event['alarm'] = array();
783 784
 							}
784 785
 						}
785
-					}
786
-					else
787
-					{
788
-						if ($old_event['start'] != $event['start'] ||
789
-							$old_event['end'] != $event['end'] ||
790
-							$event['whole_day'] != $old_event['whole_day'])
786
+						else
791 787
 						{
792
-							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
793
-							foreach((array)$event['participants'] as $uid => $status)
788
+							if ($old_event['start'] != $event['start'] ||
789
+								$old_event['end'] != $event['end'] ||
790
+								$event['whole_day'] != $old_event['whole_day'])
794 791
 							{
795
-								$q = $r = null;
796
-								calendar_so::split_status($status,$q,$r);
797
-								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
792
+								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
793
+								foreach((array)$event['participants'] as $uid => $status)
798 794
 								{
799
-									$preferences = CreateObject('phpgwapi.preferences',$uid);
800
-									$part_prefs = $preferences->read_repository();
801
-									switch ($part_prefs['calendar']['reset_stati'])
795
+									$q = $r = null;
796
+									calendar_so::split_status($status,$q,$r);
797
+									if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
802 798
 									{
799
+										$preferences = CreateObject('phpgwapi.preferences',$uid);
800
+										$part_prefs = $preferences->read_repository();
801
+										switch ($part_prefs['calendar']['reset_stati'])
802
+										{
803 803
 										case 'no':
804 804
 											break;
805 805
 										case 'startday':
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 											$status_reset_to_unknown = true;
809 809
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
810 810
 											// todo: report reset status to user
811
-									}
811
+										}
812 812
 								}
813 813
 							}
814 814
 							// check if we need to move the alarms, because they are relative
@@ -925,83 +925,83 @@  discard block
 block discarded – undo
925 925
 			}
926 926
 			break;
927 927
 
928
-		case 'cancel':
929
-			if($content['cancel_needs_refresh'])
930
-			{
931
-				egw_framework::refresh_opener($msg, 'calendar');
932
-			}
933
-			break;
934
-
935
-		case 'delete':					// delete of event (regular or series)
936
-			$exceptions_kept = null;
937
-			if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
938
-				$content['delete_exceptions'] == 'true', $exceptions_kept))
939
-			{
940
-				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
928
+			case 'cancel':
929
+				if($content['cancel_needs_refresh'])
941 930
 				{
942
-					$msg = lang('Series deleted');
943
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
931
+					egw_framework::refresh_opener($msg, 'calendar');
944 932
 				}
945
-				else
933
+				break;
934
+
935
+			case 'delete':					// delete of event (regular or series)
936
+				$exceptions_kept = null;
937
+				if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
938
+					$content['delete_exceptions'] == 'true', $exceptions_kept))
946 939
 				{
947
-					$msg = lang('Event deleted');
948
-				}
940
+					if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
941
+					{
942
+						$msg = lang('Series deleted');
943
+						if ($exceptions_kept) $msg .= lang(', exceptions preserved');
944
+					}
945
+					else
946
+					{
947
+						$msg = lang('Event deleted');
948
+					}
949 949
 
950
-			}
951
-			break;
950
+				}
951
+				break;
952 952
 
953
-		case 'freetime':
954
-			// the "click" has to be in onload, to make sure the button is already created
955
-			$event['button_was'] = $button;
956
-			break;
953
+			case 'freetime':
954
+				// the "click" has to be in onload, to make sure the button is already created
955
+				$event['button_was'] = $button;
956
+				break;
957 957
 
958
-		case 'add_alarm':
959
-			$time = $content['start'];
960
-			$offset = $time - $content['new_alarm']['date'];
961
-			if ($event['recur_type'] != MCAL_RECUR_NONE &&
962
-				($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
963
-				$time < $next_occurrence['start'])
964
-			{
965
-				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
966
-			}
967
-			if ($this->bo->check_perms(EGW_ACL_EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
968
-			{
969
-				$alarm = array(
970
-					'offset' => $offset,
971
-					'time'   => $content['new_alarm']['date'],
972
-					'all'    => !$content['new_alarm']['owner'],
973
-					'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
974
-				);
975
-				if ($alarm['time'] < $this->bo->now_su)
958
+			case 'add_alarm':
959
+				$time = $content['start'];
960
+				$offset = $time - $content['new_alarm']['date'];
961
+				if ($event['recur_type'] != MCAL_RECUR_NONE &&
962
+					($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
963
+					$time < $next_occurrence['start'])
976 964
 				{
977
-					$msg = lang("Can't add alarms in the past !!!");
965
+					$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
978 966
 				}
979
-				elseif ($event['id'])	// save the alarm immediatly
967
+				if ($this->bo->check_perms(EGW_ACL_EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
980 968
 				{
981
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
969
+					$alarm = array(
970
+						'offset' => $offset,
971
+						'time'   => $content['new_alarm']['date'],
972
+						'all'    => !$content['new_alarm']['owner'],
973
+						'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
974
+					);
975
+					if ($alarm['time'] < $this->bo->now_su)
976
+					{
977
+						$msg = lang("Can't add alarms in the past !!!");
978
+					}
979
+					elseif ($event['id'])	// save the alarm immediatly
982 980
 					{
983
-						$alarm['id'] = $alarm_id;
984
-						$event['alarm'][$alarm_id] = $alarm;
981
+						if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
982
+						{
983
+							$alarm['id'] = $alarm_id;
984
+							$event['alarm'][$alarm_id] = $alarm;
985 985
 
986
-						$msg = lang('Alarm added');
987
-						egw_framework::refresh_opener($msg,'calendar', $event['id'], 'update');
986
+							$msg = lang('Alarm added');
987
+							egw_framework::refresh_opener($msg,'calendar', $event['id'], 'update');
988
+						}
989
+						else
990
+						{
991
+							$msg = lang('Error adding the alarm');
992
+						}
988 993
 					}
989 994
 					else
990 995
 					{
991
-						$msg = lang('Error adding the alarm');
996
+						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
997
+						$event['alarm'][$alarm['id']] = $alarm;
992 998
 					}
993 999
 				}
994 1000
 				else
995 1001
 				{
996
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
997
-					$event['alarm'][$alarm['id']] = $alarm;
1002
+					$msg = lang('Permission denied');
998 1003
 				}
999
-			}
1000
-			else
1001
-			{
1002
-				$msg = lang('Permission denied');
1003
-			}
1004
-			break;
1004
+				break;
1005 1005
 		}
1006 1006
 		// add notification-errors, if we have some
1007 1007
 		if (($notification_errors = notifications::errors(true)))
Please login to merge, or discard this patch.
Spacing   +404 added lines, -404 removed lines patch added patch discarded remove patch
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @var locktime in seconds
49 49
 	 */
50
-	var $locktime_default=1;
50
+	var $locktime_default = 1;
51 51
 
52 52
 	/**
53 53
 	 * Constructor
54 54
 	 */
55 55
 	function __construct()
56 56
 	{
57
-		parent::__construct(true);	// call the parent's constructor
57
+		parent::__construct(true); // call the parent's constructor
58 58
 
59
-		for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
59
+		for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
60 60
 		{
61
-			$this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60);
61
+			$this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60);
62 62
 		}
63 63
 	}
64 64
 
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function &default_add_event()
71 71
 	{
72
-		$extra_participants = $_GET['participants'] ? explode(',',$_GET['participants']) : array();
72
+		$extra_participants = $_GET['participants'] ? explode(',', $_GET['participants']) : array();
73 73
 
74 74
 		// if participant is a contact, add its link title as title
75
-		foreach($extra_participants as $uid)
75
+		foreach ($extra_participants as $uid)
76 76
 		{
77 77
 			if ($uid[0] == 'c')
78 78
 			{
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 		}
93 93
 
94 94
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
95
-			!$this->bo->check_perms(EGW_ACL_ADD,0,$owner))
95
+			!$this->bo->check_perms(EGW_ACL_ADD, 0, $owner))
96 96
 		{
97 97
 			if ($owner)	// make an owner who is no user or we have no add-rights a participant
98 98
 			{
99 99
 				// if we come from ressources we don't need any users selected in calendar
100 100
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
101 101
 				{
102
-					foreach(explode(',',$owner) as $uid)
102
+					foreach (explode(',', $owner) as $uid)
103 103
 					{
104 104
 						// only add users or a single ressource, not all ressources displayed by a category
105 105
 						if (is_numeric($uid) || $owner == $uid)
@@ -117,48 +117,48 @@  discard block
 block discarded – undo
117 117
 		$extra_participants[] = $owner;
118 118
 
119 119
 		$start = $this->bo->date2ts(array(
120
-			'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date,
121
-			'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
122
-			'minute' => (int) $_GET['minute'],
120
+			'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date,
121
+			'hour' => (int)(isset($_GET['hour']) && (int)$_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
122
+			'minute' => (int)$_GET['minute'],
123 123
 		));
124 124
 		//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";
125 125
 
126 126
 		$participant_types['u'] = $participant_types = $participants = array();
127
-		foreach($extra_participants as $uid)
127
+		foreach ($extra_participants as $uid)
128 128
 		{
129
-			if (isset($participants[$uid])) continue;	// already included
129
+			if (isset($participants[$uid])) continue; // already included
130 130
 
131
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
131
+			if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored
132 132
 
133 133
 			if (is_numeric($uid))
134 134
 			{
135 135
 				$participants[$uid] = $participant_types['u'][$uid] =
136
-					calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
137
-					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
136
+					calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
137
+					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
138 138
 			}
139 139
 			elseif (is_array($this->bo->resources[$uid[0]]))
140 140
 			{
141 141
 				// if contact is a user, use the user instead (as the GUI)
142
-				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
142
+				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id')))
143 143
 				{
144 144
 					$uid = $account_id;
145 145
 					$participants[$uid] = $participant_types['u'][$uid] =
146
-						calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
147
-						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
146
+						calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
147
+						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(EGW_ACL_ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
148 148
 					continue;
149 149
 				}
150 150
 				$res_data = $this->bo->resources[$uid[0]];
151
-				list($id,$quantity) = explode(':',substr($uid,1));
152
-				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U'))
151
+				list($id, $quantity) = explode(':', substr($uid, 1));
152
+				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U'))
153 153
 				{
154 154
 					$participants[$uid] = $participant_types[$uid[0]][$id] =
155
-						calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT');
155
+						calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT');
156 156
 				}
157 157
 			}
158 158
 		}
159 159
 		if (!$participants)	// if all participants got removed, include current user
160 160
 		{
161
-			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
161
+			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR');
162 162
 		}
163 163
 		$alarms = array();
164 164
 		// if default alarm set in prefs --> add it
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 		if ((string)$this->cal_prefs['default-alarm'] !== '')
167 167
 		{
168 168
 			$offset = 60 * $this->cal_prefs['default-alarm'];
169
-			$alarms[1] =  array(
169
+			$alarms[1] = array(
170 170
 				'default' => 1,
171
-				'offset' => $offset ,
171
+				'offset' => $offset,
172 172
 				'time'   => $start - $offset,
173 173
 				'all'    => false,
174 174
 				'owner'  => $owner,
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 			'participants' => $participants,
181 181
 			'owner' => $owner,
182 182
 			'start' => $start,
183
-			'end'   => $start + (int) $this->bo->cal_prefs['defaultlength']*60,
183
+			'end'   => $start + (int)$this->bo->cal_prefs['defaultlength'] * 60,
184 184
 			'tzid'  => $this->bo->common_prefs['tz'],
185
-			'priority' => 2,	// normal
185
+			'priority' => 2, // normal
186 186
 			'public'=> $this->cal_prefs['default_private'] ? 0 : 1,
187 187
 			'alarm' => $alarms,
188 188
 			'recur_exception' => array(),
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
 	{
201 201
 		if (!is_array($content))	// redirect from etemplate, if POST empty
202 202
 		{
203
-			return $this->edit(null,null,strip_tags($_GET['msg']));
203
+			return $this->edit(null, null, strip_tags($_GET['msg']));
204 204
 		}
205 205
 		// clear notification errors
206 206
 		notifications::errors(true);
207 207
 		$messages = null;
208 208
 		$msg_permission_denied_added = false;
209 209
 		list($button) = @each($content['button']);
210
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
210
+		if (!$button && $content['action']) $button = $content['action']; // action selectbox
211 211
 		unset($content['button']); unset($content['action']);
212 212
 
213 213
 		$view = $content['view'];
214 214
 		if ($button == 'ical')
215 215
 		{
216
-			$msg = $this->export($content['id'],true);
216
+			$msg = $this->export($content['id'], true);
217 217
 		}
218 218
 		// delete a recur-exception
219 219
 		if ($content['recur_exception']['delete_exception'])
220 220
 		{
221 221
 			list($date) = each($content['recur_exception']['delete_exception']);
222 222
 			// eT2 converts time to
223
-			if (!is_numeric($date)) $date = egw_time::to (str_replace('Z','', $date), 'ts');
223
+			if (!is_numeric($date)) $date = egw_time::to(str_replace('Z', '', $date), 'ts');
224 224
 			unset($content['recur_exception']['delete_exception']);
225
-			if (($key = array_search($date,$content['recur_exception'])) !== false)
225
+			if (($key = array_search($date, $content['recur_exception'])) !== false)
226 226
 			{
227 227
 				// propagate the exception to a single event
228 228
 				$recur_exceptions = $this->bo->so->get_related($content['uid']);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
233 233
 					$exception['uid'] = common::generate_uid('calendar', $id);
234 234
 					$exception['reference'] = $exception['recurrence'] = 0;
235
-					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
235
+					$this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']);
236 236
 					break;
237 237
 				}
238 238
 				unset($content['recur_exception'][$key]);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			$def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')];
273 273
 			if ((string)$def_alarm === '')
274 274
 			{
275
-				unset($content['alarm'][1]);	// '' = no alarm on whole day --> delete it
275
+				unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it
276 276
 			}
277 277
 			else
278 278
 			{
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		unset($event['alarm']['delete_alarm']);
287 287
 		unset($event['duration']);
288 288
 
289
-		if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series')))
289
+		if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series')))
290 290
 		{
291 291
 			// no conversation necessary, event is already in the right format
292 292
 		}
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
307 307
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
308 308
 			{
309
-				$event['recur_data'] = 1 << (int)date('w',$event['start']);
309
+				$event['recur_data'] = 1 << (int)date('w', $event['start']);
310 310
 			}
311 311
 			if (isset($content['participants']))
312 312
 			{
313 313
 
314 314
 				$event['participants'] = $event['participant_types'] = array();
315 315
 
316
-				foreach($content['participants'] as $key => $data)
316
+				foreach ($content['participants'] as $key => $data)
317 317
 				{
318
-					switch($key)
318
+					switch ($key)
319 319
 					{
320 320
 						case 'delete':		// handled in default
321 321
 						case 'quantity':	// handled in new_resource
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
 							// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") in the search field
329 329
 							$matches = array();
330 330
 							if (($email = $content['participants']['resource']['search']) &&
331
-									(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$email,$matches)))
331
+									(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $email, $matches)))
332 332
 							{
333
-								$status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']);
333
+								$status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']);
334 334
 								// check if email belongs to account or contact --> prefer them over just emails (if we are allowed to invite him)
335
-								if (($data = $GLOBALS['egw']->accounts->name2id($matches[2],'account_email')) && $this->bo->check_acl_invite($data))
335
+								if (($data = $GLOBALS['egw']->accounts->name2id($matches[2], 'account_email')) && $this->bo->check_acl_invite($data))
336 336
 								{
337 337
 									$event['participants'][$data] = $event['participant_types']['u'][$data] = $status;
338 338
 								}
339
-								elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array(
339
+								elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array(
340 340
 									'email' => $matches[2],
341 341
 									'email_home' => $matches[2],
342
-								),true,'','','',false,'OR')))
342
+								), true, '', '', '', false, 'OR')))
343 343
 								{
344 344
 									$event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status;
345 345
 								}
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 						case 'resource':
358 358
 							if (is_array($data))	// if $data['current'] is NOT set --> $app==''
359 359
 							{
360
-								list($app,$id) = explode(':',$data['current']);
361
-								if(!$app && !$id)
360
+								list($app, $id) = explode(':', $data['current']);
361
+								if (!$app && !$id)
362 362
 								{
363 363
 									$app = $data['app'];
364 364
 									$id = $data['id'];
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 							}
367 367
 							else
368 368
 							{
369
-								list($app,$id) = explode(':',$data);
369
+								list($app, $id) = explode(':', $data);
370 370
 							}
371
-							foreach($this->bo->resources as $type => $data)
371
+							foreach ($this->bo->resources as $type => $data)
372 372
 							{
373 373
 								if ($data['app'] == $app) break;
374 374
 							}
@@ -378,19 +378,19 @@  discard block
 block discarded – undo
378 378
 								$data = $id;
379 379
 							}
380 380
 							// check if new entry is no account (or contact entry of an account)
381
-							elseif ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id,'person_id')) || !$this->bo->check_acl_invite($data))
381
+							elseif ($app != 'addressbook' || !($data = $GLOBALS['egw']->accounts->name2id($id, 'person_id')) || !$this->bo->check_acl_invite($data))
382 382
 							{
383 383
 								if ($uid && $id)
384 384
 								{
385
-									$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
385
+									$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
386 386
 									if ($status)
387 387
 									{
388 388
 										$res_info = $this->bo->resource_info($uid);
389 389
 										// todo check real availability = maximum - already booked quantity
390 390
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
391 391
 										{
392
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
393
-											foreach(array('quantity','resource','role') as $n)
392
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
393
+											foreach (array('quantity', 'resource', 'role') as $n)
394 394
 											{
395 395
 												$event['participants'][$n] = $content['participants'][$n];
396 396
 											}
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
 										else
399 399
 										{
400 400
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
401
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
401
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
402 402
 										}
403 403
 									}
404
-									elseif(!$msg_permission_denied_added)
404
+									elseif (!$msg_permission_denied_added)
405 405
 									{
406 406
 										$msg .= lang('Permission denied!');
407 407
 										$msg_permission_denied_added = true;
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 							}
417 417
 							// fall-through for accounts entered as contact
418 418
 						case 'account':
419
-							foreach(is_array($data) ? $data : explode(',',$data) as $uid)
419
+							foreach (is_array($data) ? $data : explode(',', $data) as $uid)
420 420
 							{
421 421
 								if ($uid && $this->bo->check_acl_invite($uid))
422 422
 								{
423 423
 									$event['participants'][$uid] = $event['participant_types']['u'][$uid] =
424
-										calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U',1,$content['participants']['role']);
424
+										calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U', 1, $content['participants']['role']);
425 425
 								}
426
-								elseif($uid && !$msg_permission_denied_added)
426
+								elseif ($uid && !$msg_permission_denied_added)
427 427
 								{
428 428
 									$msg .= lang('Permission denied!');
429 429
 									$msg_permission_denied_added = true;
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
 							break;
433 433
 
434 434
 						default:		// existing participant row
435
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
436
-							foreach(array('uid','status','quantity','role') as $name)
435
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
436
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
437 437
 							{
438 438
 								$$name = $data[$name];
439 439
 							}
440 440
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
441 441
 							{
442
-								$uid = false;	// entry has been deleted
442
+								$uid = false; // entry has been deleted
443 443
 							}
444 444
 							elseif ($uid)
445 445
 							{
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 								}
451 451
 								else
452 452
 								{
453
-									$id = substr($uid,1);
453
+									$id = substr($uid, 1);
454 454
 									$type = $uid[0];
455 455
 								}
456 456
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
459 459
 									$quantity = $role = null;
460 460
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
461
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
461
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
462 462
 									{
463 463
 										// refreshing the calendar-view with the changed participant-status
464
-										if($event['recur_type'] != MCAL_RECUR_NONE)
464
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
465 465
 										{
466 466
 											$msg = lang('Status for all future scheduled days changed');
467 467
 										}
468 468
 										else
469 469
 										{
470
-											if(isset($content['edit_single']))
470
+											if (isset($content['edit_single']))
471 471
 											{
472 472
 												$msg = lang('Status for this particular day changed');
473 473
 												// prevent accidentally creating a real exception afterwards
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 										if ($status == 'R' && $event['alarm'])
489 489
 										{
490 490
 											// remove from bo->set_status deleted alarms of rejected users from UI too
491
-											foreach($event['alarm'] as $alarm_id => $alarm)
491
+											foreach ($event['alarm'] as $alarm_id => $alarm)
492 492
 											{
493 493
 												if ((string)$alarm['owner'] === (string)$uid)
494 494
 												{
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 								if ($uid && $status != 'G')
502 502
 								{
503 503
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
504
-										calendar_so::combine_status($status,$quantity,$role);
504
+										calendar_so::combine_status($status, $quantity, $role);
505 505
 								}
506 506
 							}
507 507
 							break;
@@ -520,26 +520,26 @@  discard block
 block discarded – undo
520 520
 			'tabs'			=> $content['tabs'],
521 521
 			'template'      => $content['template'],
522 522
 		);
523
-		$noerror=true;
523
+		$noerror = true;
524 524
 
525 525
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
526 526
 
527 527
 		$ignore_conflicts = $status_reset_to_unknown = false;
528 528
 
529
-		switch((string)$button)
529
+		switch ((string)$button)
530 530
 		{
531 531
 			case 'ignore':
532 532
 				$ignore_conflicts = true;
533
-				$button = $event['button_was'];	// save or apply
533
+				$button = $event['button_was']; // save or apply
534 534
 				unset($event['button_was']);
535 535
 				break;
536 536
 
537 537
 		}
538 538
 
539
-		switch((string)$button)
539
+		switch ((string)$button)
540 540
 		{
541 541
 		case 'exception':	// create an exception in a recuring event
542
-			$msg = $this->_create_exception($event,$preserv);
542
+			$msg = $this->_create_exception($event, $preserv);
543 543
 			break;
544 544
 
545 545
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -550,29 +550,29 @@  discard block
 block discarded – undo
550 550
 			unset($event['recurrence']);
551 551
 			unset($preserv['recurrence']);
552 552
 			unset($event['recur_exception']);
553
-			unset($event['edit_single']);	// in case it has been set
553
+			unset($event['edit_single']); // in case it has been set
554 554
 			unset($event['modified']);
555 555
 			unset($event['modifier']);
556 556
 			unset($event['caldav_name']);
557
-			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD,0,$this->owner) ? $this->user : $this->owner;
557
+			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(EGW_ACL_ADD, 0, $this->owner) ? $this->user : $this->owner;
558 558
 
559 559
 			// Clear participant stati
560
-			foreach($event['participant_types'] as $type => &$participants)
560
+			foreach ($event['participant_types'] as $type => &$participants)
561 561
 			{
562
-				foreach($participants as $id => &$response)
562
+				foreach ($participants as $id => &$response)
563 563
 				{
564
-					if($type == 'u' && $id == $event['owner']) continue;
564
+					if ($type == 'u' && $id == $event['owner']) continue;
565 565
 					calendar_so::split_status($response, $quantity, $role);
566 566
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
567
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
568
-					$response = calendar_so::combine_status($status,$quantity,$role);
567
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
568
+					$response = calendar_so::combine_status($status, $quantity, $role);
569 569
 				}
570 570
 			}
571 571
 
572 572
 			// Copy alarms
573 573
 			if (is_array($event['alarm']))
574 574
 			{
575
-				foreach($event['alarm'] as $n => &$alarm)
575
+				foreach ($event['alarm'] as $n => &$alarm)
576 576
 				{
577 577
 					unset($alarm['id']);
578 578
 					unset($alarm['cal_id']);
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			// Get links to be copied
583 583
 			// With no ID, $content['link_to']['to_id'] is used
584 584
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
585
-			foreach(egw_link::get_links('calendar', $content['id']) as $link)
585
+			foreach (egw_link::get_links('calendar', $content['id']) as $link)
586 586
 			{
587 587
 				if ($link['app'] != egw_link::VFS_APPNAME)
588 588
 				{
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		case 'print':
609 609
 		case 'apply':
610 610
 		case 'infolog':
611
-			if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
611
+			if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT, $event))
612 612
 			{
613 613
 				$msg = lang('Permission denied');
614 614
 				$button = '';
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 				$button = '';
627 627
 				break;
628 628
 			}
629
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
629
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
630 630
 			{
631 631
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
632 632
 				$button = '';
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 				$event['reference'] = $event['id'];
657 657
 				$event['recurrence'] = $content['edit_single'];
658 658
 				unset($event['id']);
659
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
659
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
660 660
 				if (!is_array($conflicts) && $conflicts)
661 661
 				{
662 662
 					// now we need to add the original start as recur-execption to the series
663 663
 					$recur_event = $this->bo->read($event['reference']);
664 664
 					$recur_event['recur_exception'][] = $content['edit_single'];
665 665
 					// check if we need to move the alarms, because they are next on that exception
666
-					foreach($recur_event['alarm'] as $id => $alarm)
666
+					foreach ($recur_event['alarm'] as $id => $alarm)
667 667
 					{
668 668
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
669 669
 						{
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 							}
680 680
 						}
681 681
 					}
682
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
683
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
684
-					$this->bo->update($recur_event,true);	// no conflict check here
682
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
683
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
684
+					$this->bo->update($recur_event, true); // no conflict check here
685 685
 					unset($recur_event);
686
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
686
+					unset($event['edit_single']); // if we further edit it, it's just a single event
687 687
 					unset($preserv['edit_single']);
688 688
 				}
689 689
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 						if ($event['start'] != $old_event['start'] ||
704 704
 							$event['whole_day'] != $old_event['whole_day'])
705 705
 						{
706
-							if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
706
+							if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
707 707
 							{
708 708
 								$msg = lang("Error: You can't shift a series from the past!");
709 709
 								$noerror = false;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 							{
727 727
 								$event['end'] = $event['start'] + $content['duration'];
728 728
 							}
729
-							elseif($event['end'] < $event['start'])
729
+							elseif ($event['end'] < $event['start'])
730 730
 							{
731 731
 								$event['end'] = $event['start'] + $event['end'] - $actual_date;
732 732
 							}
@@ -767,14 +767,14 @@  discard block
 block discarded – undo
767 767
 										($last = $occurrence));
768 768
 								$last->setTime(0, 0, 0);
769 769
 								$old_event['recur_enddate'] = egw_time::to($last, 'ts');
770
-								if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$content['no_notifications']))
770
+								if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $content['no_notifications']))
771 771
 								{
772
-									$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
773
-										lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
774
-											htmlspecialchars(egw::link('/index.php',array(
772
+									$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
773
+										lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
774
+											htmlspecialchars(egw::link('/index.php', array(
775 775
 												'menuaction' => 'calendar.calendar_uiforms.edit',
776 776
 												'cal_id'    => $content['id'],
777
-											))).'">','</a>');
777
+											))).'">', '</a>');
778 778
 									$noerror = false;
779 779
 									$event = $orig_event;
780 780
 									break;
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 							$event['whole_day'] != $old_event['whole_day'])
791 791
 						{
792 792
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
793
-							foreach((array)$event['participants'] as $uid => $status)
793
+							foreach ((array)$event['participants'] as $uid => $status)
794 794
 							{
795 795
 								$q = $r = null;
796
-								calendar_so::split_status($status,$q,$r);
796
+								calendar_so::split_status($status, $q, $r);
797 797
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
798 798
 								{
799
-									$preferences = CreateObject('phpgwapi.preferences',$uid);
799
+									$preferences = CreateObject('phpgwapi.preferences', $uid);
800 800
 									$part_prefs = $preferences->read_repository();
801 801
 									switch ($part_prefs['calendar']['reset_stati'])
802 802
 									{
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 											if ($sameday) break;
807 807
 										default:
808 808
 											$status_reset_to_unknown = true;
809
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
809
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
810 810
 											// todo: report reset status to user
811 811
 									}
812 812
 								}
@@ -816,27 +816,27 @@  discard block
 block discarded – undo
816 816
 						}
817 817
 					}
818 818
 				}
819
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
819
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
820 820
 				unset($event['ignore']);
821 821
 			}
822 822
 			if (is_array($conflicts))
823 823
 			{
824
-				$event['button_was'] = $button;	// remember for ignore
825
-				return $this->conflicts($event,$conflicts,$preserv);
824
+				$event['button_was'] = $button; // remember for ignore
825
+				return $this->conflicts($event, $conflicts, $preserv);
826 826
 			}
827 827
 			// check if there are messages from update, eg. removed participants or categories because of missing rights
828 828
 			if ($messages)
829 829
 			{
830
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
830
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
831 831
 			}
832 832
 			if ($conflicts === 0)
833 833
 			{
834
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
835
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
836
-								htmlspecialchars(egw::link('/index.php',array(
834
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
835
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
836
+								htmlspecialchars(egw::link('/index.php', array(
837 837
 								'menuaction' => 'calendar.calendar_uiforms.edit',
838 838
 								'cal_id'    => $content['id'],
839
-							))).'">','</a>');
839
+							))).'">', '</a>');
840 840
 				$noerror = false;
841 841
 			}
842 842
 			elseif ($conflicts > 0)
@@ -857,19 +857,19 @@  discard block
 block discarded – undo
857 857
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
858 858
 						if ($alarm['time'] < $this->bo->now_su)
859 859
 						{
860
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
860
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
861 861
 							{
862
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
862
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
863 863
 							}
864 864
 							else
865 865
 							{
866
-								$alarm = false;	// no (further) recurence found --> ignore alarm
866
+								$alarm = false; // no (further) recurence found --> ignore alarm
867 867
 							}
868 868
 						}
869 869
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
870 870
 						elseif ($event_time < $event['start'])
871 871
 						{
872
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
872
+							$alarm['time'] = $event['start'] - $alarm['offset'];
873 873
 						}
874 874
 						if ($alarm)
875 875
 						{
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
 						}
879 879
 					}
880 880
 					// attach all future exceptions to the new series
881
-					$events =& $this->bo->search(array(
881
+					$events = & $this->bo->search(array(
882 882
 						'query' => array('cal_uid' => $old_event['uid']),
883
-						'filter' => 'owner',  // return all possible entries
883
+						'filter' => 'owner', // return all possible entries
884 884
 						'daywise' => false,
885 885
 						'date_format' => 'ts',
886 886
 					));
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 							$exception['recurrence'] += $offset;
892 892
 							$exception['reference'] = $event['id'];
893 893
 							$exception['uid'] = $event['uid'];
894
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
894
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
895 895
 						}
896 896
 					}
897 897
 				}
@@ -899,24 +899,24 @@  discard block
 block discarded – undo
899 899
 				$message = lang('Event saved');
900 900
 				if ($status_reset_to_unknown)
901 901
 				{
902
-					foreach((array)$event['participants'] as $uid => $status)
902
+					foreach ((array)$event['participants'] as $uid => $status)
903 903
 					{
904 904
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
905 905
 						{
906
-							calendar_so::split_status($status,$q,$r);
907
-							$status = calendar_so::combine_status('U',$q,$r);
906
+							calendar_so::split_status($status, $q, $r);
907
+							$status = calendar_so::combine_status('U', $q, $r);
908 908
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
909 909
 						}
910 910
 					}
911 911
 					$message .= lang(', stati of participants reset');
912 912
 				}
913 913
 
914
-				$msg = $message . ($msg ? ', ' . $msg : '');
914
+				$msg = $message.($msg ? ', '.$msg : '');
915 915
 				egw_framework::refresh_opener($msg, 'calendar', $event['id']);
916 916
 				// writing links for new entry, existing ones are handled by the widget itself
917 917
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
918 918
 				{
919
-					egw_link::link('calendar',$event['id'],$content['link_to']['to_id']);
919
+					egw_link::link('calendar', $event['id'], $content['link_to']['to_id']);
920 920
 				}
921 921
 			}
922 922
 			else
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 			break;
927 927
 
928 928
 		case 'cancel':
929
-			if($content['cancel_needs_refresh'])
929
+			if ($content['cancel_needs_refresh'])
930 930
 			{
931 931
 				egw_framework::refresh_opener($msg, 'calendar');
932 932
 			}
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			{
965 965
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
966 966
 			}
967
-			if ($this->bo->check_perms(EGW_ACL_EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
967
+			if ($this->bo->check_perms(EGW_ACL_EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
968 968
 			{
969 969
 				$alarm = array(
970 970
 					'offset' => $offset,
@@ -978,13 +978,13 @@  discard block
 block discarded – undo
978 978
 				}
979 979
 				elseif ($event['id'])	// save the alarm immediatly
980 980
 				{
981
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
981
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
982 982
 					{
983 983
 						$alarm['id'] = $alarm_id;
984 984
 						$event['alarm'][$alarm_id] = $alarm;
985 985
 
986 986
 						$msg = lang('Alarm added');
987
-						egw_framework::refresh_opener($msg,'calendar', $event['id'], 'update');
987
+						egw_framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
988 988
 					}
989 989
 					else
990 990
 					{
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 				}
994 994
 				else
995 995
 				{
996
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
996
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
997 997
 					$event['alarm'][$alarm['id']] = $alarm;
998 998
 				}
999 999
 			}
@@ -1008,22 +1008,22 @@  discard block
 block discarded – undo
1008 1008
 		{
1009 1009
 			$msg .= ($msg ? "\n" : '').implode("\n", $notification_errors);
1010 1010
 		}
1011
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1011
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1012 1012
 		{
1013 1013
 			if ($content['lock_token'])	// remove an existing lock
1014 1014
 			{
1015
-				egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1015
+				egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1016 1016
 			}
1017 1017
 			if ($content['no_popup'])
1018 1018
 			{
1019
-				egw::redirect_link('/index.php',array(
1019
+				egw::redirect_link('/index.php', array(
1020 1020
 					'menuaction' => 'calendar.calendar_uiviews.index',
1021 1021
 					'msg'        => $msg,
1022 1022
 				));
1023 1023
 			}
1024
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1024
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1025 1025
 			{
1026
-				egw_framework::refresh_opener($msg,'calendar');
1026
+				egw_framework::refresh_opener($msg, 'calendar');
1027 1027
 			}
1028 1028
 			else
1029 1029
 			{
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 			common::egw_exit();
1034 1034
 		}
1035 1035
 		unset($event['no_notifications']);
1036
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1036
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1037 1037
 	}
1038 1038
 
1039 1039
 	/**
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	 * @param array &$preserv
1046 1046
 	 * @return string message that exception was created
1047 1047
 	 */
1048
-	function _create_exception(&$event,&$preserv)
1048
+	function _create_exception(&$event, &$preserv)
1049 1049
 	{
1050 1050
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1051 1051
 		$preserv['actual_date'] = $preserv['acutal_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1056 1056
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1057 1057
 		$event['recur_type'] = MCAL_RECUR_NONE;
1058
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1058
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1059 1059
 		{
1060 1060
 			unset($event[$name]);
1061 1061
 		}
1062 1062
 		// add all alarms as new alarms to execption
1063 1063
 		$event['alarm'] = array_values((array)$event['alarm']);
1064
-		foreach($event['alarm'] as &$alarm)
1064
+		foreach ($event['alarm'] as &$alarm)
1065 1065
 		{
1066 1066
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1067 1067
 		}
1068
-		if($this->bo->check_perms(EGW_ACL_EDIT,$event))
1068
+		if ($this->bo->check_perms(EGW_ACL_EDIT, $event))
1069 1069
 		{
1070 1070
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1071 1071
 		}
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
 	{
1093 1093
 		$msg = false;
1094 1094
 
1095
-		if(!$as_of_date )
1095
+		if (!$as_of_date)
1096 1096
 		{
1097 1097
 			$as_of_date = time();
1098 1098
 		}
1099 1099
 
1100 1100
 		//error_log(__METHOD__ . egw_time::to($old_event['start']) . ' -> '. egw_time::to($event['start']) . ' as of ' . egw_time::to($as_of_date));
1101 1101
 
1102
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1102
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1103 1103
 		{
1104 1104
 			$msg = lang("Error: You can't shift a series from the past!");
1105 1105
 			$noerror = false;
@@ -1113,11 +1113,11 @@  discard block
 block discarded – undo
1113 1113
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1114 1114
 
1115 1115
 		// base start-date of new series on actual / clicked date
1116
-		$event['start'] = $as_of_date ;
1116
+		$event['start'] = $as_of_date;
1117 1117
 
1118
-		if (egw_time::to($old_event['start'],'Ymd') < egw_time::to($as_of_date,'Ymd') ||
1118
+		if (egw_time::to($old_event['start'], 'Ymd') < egw_time::to($as_of_date, 'Ymd') ||
1119 1119
 			// Adjust for requested date in the past
1120
-			egw_time::to($as_of_date,'ts') < time()
1120
+			egw_time::to($as_of_date, 'ts') < time()
1121 1121
 		)
1122 1122
 		{
1123 1123
 
@@ -1137,17 +1137,17 @@  discard block
 block discarded – undo
1137 1137
 				$rriter->next_no_exception();
1138 1138
 				$occurrence = $rriter->current();
1139 1139
 			}
1140
-			while ($rriter->valid()  && (
1140
+			while ($rriter->valid() && (
1141 1141
 				egw_time::to($occurrence, 'ts') <= time() ||
1142
-				egw_time::to($occurrence, 'Ymd') < egw_time::to($as_of_date,'Ymd')
1142
+				egw_time::to($occurrence, 'Ymd') < egw_time::to($as_of_date, 'Ymd')
1143 1143
 			) && ($last = $occurrence));
1144 1144
 
1145 1145
 
1146 1146
 			// Make sure as_of_date is still valid, may have to move forward
1147
-			if(egw_time::to($as_of_date,'ts') < egw_time::to($last,'ts') ||
1147
+			if (egw_time::to($as_of_date, 'ts') < egw_time::to($last, 'ts') ||
1148 1148
 				egw_time::to($as_of_date, 'Ymd') == egw_time::to($last, 'Ymd'))
1149 1149
 			{
1150
-				$event['start'] = egw_time::to($rriter->current(),'ts') + $offset;
1150
+				$event['start'] = egw_time::to($rriter->current(), 'ts') + $offset;
1151 1151
 			}
1152 1152
 
1153 1153
 			//error_log(__METHOD__ ." Series should end at " . egw_time::to($last) . " New series starts at " . egw_time::to($event['start']));
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			{
1156 1156
 				$event['end'] = $event['start'] + $duration;
1157 1157
 			}
1158
-			elseif($event['end'] < $event['start'])
1158
+			elseif ($event['end'] < $event['start'])
1159 1159
 			{
1160 1160
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1161 1161
 			}
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 			$event['participants'] = $old_event['participants'];
1165 1165
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1166 1166
 			{
1167
-				if ($exdate > egw_time::to($last,'ts'))
1167
+				if ($exdate > egw_time::to($last, 'ts'))
1168 1168
 				{
1169 1169
 					//error_log("Moved exception on " . egw_time::to($exdate));
1170 1170
 					unset($old_event['recur_exception'][$key]);
@@ -1178,18 +1178,18 @@  discard block
 block discarded – undo
1178 1178
 			}
1179 1179
 			$last->setTime(0, 0, 0);
1180 1180
 			$old_event['recur_enddate'] = egw_time::to($last, 'ts');
1181
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1181
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1182 1182
 			{
1183
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1184
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1185
-						htmlspecialchars(egw::link('/index.php',array(
1183
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1184
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1185
+						htmlspecialchars(egw::link('/index.php', array(
1186 1186
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1187 1187
 							'cal_id'    => $content['id'],
1188
-						))).'">','</a>');
1188
+						))).'">', '</a>');
1189 1189
 				$event = $orig_event;
1190 1190
 			}
1191 1191
 		}
1192
-		$event['start'] = egw_time::to($event['start'],'ts');
1192
+		$event['start'] = egw_time::to($event['start'], 'ts');
1193 1193
 		return $msg;
1194 1194
 	}
1195 1195
 
@@ -1200,11 +1200,11 @@  discard block
 block discarded – undo
1200 1200
 	 * @param boolean $added
1201 1201
 	 * @return string javascript window.open command
1202 1202
 	 */
1203
-	function ajax_custom_mail($event,$added,$asrequest=false)
1203
+	function ajax_custom_mail($event, $added, $asrequest = false)
1204 1204
 	{
1205 1205
 		$to = array();
1206 1206
 
1207
-		foreach($event['participants'] as $uid => $status)
1207
+		foreach ($event['participants'] as $uid => $status)
1208 1208
 		{
1209 1209
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1210 1210
 			if (empty($status)) continue;
@@ -1213,35 +1213,35 @@  discard block
 block discarded – undo
1213 1213
 
1214 1214
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1215 1215
 			{
1216
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1216
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1217 1217
 
1218 1218
 				$lid = $firstname = $lastname = null;
1219
-				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1219
+				$GLOBALS['egw']->accounts->get_account_name($status['uid'], $lid, $firstname, $lastname);
1220 1220
 
1221 1221
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1222
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1222
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1223 1223
 				//error_log(__METHOD__.__LINE__.array2string($to));
1224 1224
 			}
1225 1225
 			elseif ($uid < 0)
1226 1226
 			{
1227
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1227
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1228 1228
 				{
1229
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1229
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1230 1230
 
1231
-					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1231
+					$GLOBALS['egw']->accounts->get_account_name($uid, $lid, $firstname, $lastname);
1232 1232
 
1233 1233
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1234 1234
 					// dont add groupmembers if they already rejected the event, or are the current user
1235
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1235
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1236 1236
 					//error_log(__METHOD__.__LINE__.array2string($to));
1237 1237
 				}
1238 1238
 			}
1239
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1239
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1240 1240
 			{
1241 1241
 				$to[] = $info['email'];
1242 1242
 				//error_log(__METHOD__.__LINE__.array2string($to));
1243 1243
 			}
1244
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1244
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1245 1245
 			{
1246 1246
 				$to[] = $info['email'];
1247 1247
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 		// prefer event description over standard notification text
1251 1251
 		if (empty($event['description']))
1252 1252
 		{
1253
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1253
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1254 1254
 		}
1255 1255
 		else
1256 1256
 		{
@@ -1265,12 +1265,12 @@  discard block
 block discarded – undo
1265 1265
 		$boical = new calendar_ical();
1266 1266
 		// we need to pass $event[id] so iCal class reads event again,
1267 1267
 		// as event is in user TZ, but iCal class expects server TZ!
1268
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1268
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1269 1269
 
1270
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1271
-		if(($f = fopen($ics_file,'w')))
1270
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1271
+		if (($f = fopen($ics_file, 'w')))
1272 1272
 		{
1273
-			fwrite($f,$ics);
1273
+			fwrite($f, $ics);
1274 1274
 			fclose($f);
1275 1275
 		}
1276 1276
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
 			'preset[body]'    => $body,
1283 1283
 			'preset[name]'    => 'event.ics',
1284 1284
 			'preset[file]'    => $ics_file,
1285
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1285
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1286 1286
 			'preset[size]'    => filesize($ics_file),
1287 1287
 		);
1288 1288
 		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.');
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 	 * @param mixed $link_to_id ='' from or for the link-widget
1339 1339
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1340 1340
 	 */
1341
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1341
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1342 1342
 	{
1343 1343
 		$sel_options = array(
1344 1344
 			'recur_type' => &$this->bo->recur_types,
@@ -1362,8 +1362,8 @@  discard block
 block discarded – undo
1362 1362
 				'no_popup' => isset($_GET['no_popup']),
1363 1363
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1364 1364
 			);
1365
-			$cal_id = (int) $_GET['cal_id'];
1366
-			if($_GET['action'])
1365
+			$cal_id = (int)$_GET['cal_id'];
1366
+			if ($_GET['action'])
1367 1367
 			{
1368 1368
 				$event = $this->bo->read($cal_id);
1369 1369
 				$event['action'] = $_GET['action'];
@@ -1381,14 +1381,14 @@  discard block
 block discarded – undo
1381 1381
 			{
1382 1382
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1383 1383
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1384
-				$event =& $this->default_add_event();
1384
+				$event = & $this->default_add_event();
1385 1385
 			}
1386 1386
 			if (!empty($_GET['ical_data']) &&
1387 1387
 				!($_GET['ical'] = egw_link::get_data($_GET['ical_data'])))
1388 1388
 			{
1389 1389
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1390 1390
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1391
-				$event =& $this->default_add_event();
1391
+				$event = & $this->default_add_event();
1392 1392
 			}
1393 1393
 			if (!empty($_GET['ical']))
1394 1394
 			{
@@ -1397,14 +1397,14 @@  discard block
 block discarded – undo
1397 1397
 				{
1398 1398
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1399 1399
 					$msg = lang('Error: importing the iCal');
1400
-					$event =& $this->default_add_event();
1400
+					$event = & $this->default_add_event();
1401 1401
 				}
1402 1402
 				else
1403 1403
 				{
1404 1404
 					if (count($events) > 1)
1405 1405
 					{
1406 1406
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1407
-						$msg_type = 'notice';	// no not hide automatic
1407
+						$msg_type = 'notice'; // no not hide automatic
1408 1408
 					}
1409 1409
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1410 1410
 					$this->bo->db2data($events, 'ts');
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 					else
1418 1418
 					{
1419 1419
 						$event['participant_types'] = array();
1420
-						foreach($event['participants'] as $uid => $status)
1420
+						foreach ($event['participants'] as $uid => $status)
1421 1421
 						{
1422 1422
 							$user_type = $user_id = null;
1423 1423
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1438,15 +1438,15 @@  discard block
 block discarded – undo
1438 1438
 					}
1439 1439
 					else
1440 1440
 					{
1441
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1441
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1442 1442
 						common::egw_exit();
1443 1443
 					}
1444 1444
 				}
1445
-				$event =& $this->default_add_event();
1445
+				$event = & $this->default_add_event();
1446 1446
 			}
1447 1447
 			else
1448 1448
 			{
1449
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1449
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1450 1450
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1451 1451
 				{
1452 1452
 					if (empty($event['whole_day']))
@@ -1459,10 +1459,10 @@  discard block
 block discarded – undo
1459 1459
 						$date->setUser();
1460 1460
 					}
1461 1461
 					$event = $this->bo->read($cal_id, $date, true);
1462
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1462
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1463 1463
 					if ($_GET['exception'])
1464 1464
 					{
1465
-						$msg = $this->_create_exception($event,$preserv);
1465
+						$msg = $this->_create_exception($event, $preserv);
1466 1466
 					}
1467 1467
 					else
1468 1468
 					{
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 				}
1472 1472
 			}
1473 1473
 			// set new start and end if given by $_GET
1474
-			if(isset($_GET['start'])) { $event['start'] = $_GET['start']; }
1475
-			if(isset($_GET['end'])) { $event['end'] = $_GET['end']; }
1474
+			if (isset($_GET['start'])) { $event['start'] = $_GET['start']; }
1475
+			if (isset($_GET['end'])) { $event['end'] = $_GET['end']; }
1476 1476
 			// check if the event is the whole day
1477 1477
 			$start = $this->bo->date2array($event['start']);
1478 1478
 			$end = $this->bo->date2array($event['end']);
@@ -1482,30 +1482,30 @@  discard block
 block discarded – undo
1482 1482
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1483 1483
 			{
1484 1484
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1485
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1485
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1486 1486
 				{
1487 1487
 					$link_id = $link_ids[$n];
1488
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1488
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1489 1489
 					{
1490 1490
 						continue;
1491 1491
 					}
1492
-					if(!$n)
1492
+					if (!$n)
1493 1493
 					{
1494
-						$event['title'] = egw_link::title($link_app,$link_id);
1494
+						$event['title'] = egw_link::title($link_app, $link_id);
1495 1495
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1496
-						if (($set = $GLOBALS['egw']->hooks->single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1496
+						if (($set = $GLOBALS['egw']->hooks->single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1497 1497
 						{
1498
-							foreach((array)$set['link_app'] as $i => $l_app)
1498
+							foreach ((array)$set['link_app'] as $i => $l_app)
1499 1499
 							{
1500
-								if (($l_id=$set['link_id'][$i])) egw_link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1500
+								if (($l_id = $set['link_id'][$i])) egw_link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1501 1501
 							}
1502 1502
 							unset($set['link_app']);
1503 1503
 							unset($set['link_id']);
1504 1504
 
1505
-							$event = array_merge($event,$set);
1505
+							$event = array_merge($event, $set);
1506 1506
 						}
1507 1507
 					}
1508
-					egw_link::link('calendar',$link_to_id,$link_app,$link_id);
1508
+					egw_link::link('calendar', $link_to_id, $link_app, $link_id);
1509 1509
 				}
1510 1510
 			}
1511 1511
 		}
@@ -1515,44 +1515,44 @@  discard block
 block discarded – undo
1515 1515
 		{
1516 1516
 			$etpl->read($preserv['template'] = 'calendar.edit');
1517 1517
 		}
1518
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event);
1518
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT, $event);
1519 1519
 		//echo "view=$view, event="; _debug_array($event);
1520 1520
 		// shared locking of entries to edit
1521 1521
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1522 1522
 		{
1523
-			$lock_path = egw_vfs::app_entry_lock_path('calendar',$event['id']);
1523
+			$lock_path = egw_vfs::app_entry_lock_path('calendar', $event['id']);
1524 1524
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1525 1525
 
1526 1526
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1527 1527
 			{
1528
-				egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1528
+				egw_vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1529 1529
 			}
1530 1530
 			if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1531 1531
 			{
1532 1532
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1533
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1533
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1534 1534
 					common::grab_owner_name($lock_uid) : $lock['owner']));
1535 1535
 			}
1536
-			elseif($lock)
1536
+			elseif ($lock)
1537 1537
 			{
1538 1538
 				$preserv['lock_token'] = $lock['token'];
1539 1539
 			}
1540
-			elseif(egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1540
+			elseif (egw_vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1541 1541
 			{
1542 1542
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1543 1543
 			}
1544 1544
 			else
1545 1545
 			{
1546
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1546
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1547 1547
 				$view = true;
1548 1548
 			}
1549 1549
 		}
1550
-		$content = array_merge($event,array(
1550
+		$content = array_merge($event, array(
1551 1551
 			'link_to' => array(
1552 1552
 				'to_id'  => $link_to_id,
1553 1553
 				'to_app' => 'calendar',
1554 1554
 			),
1555
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1555
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1556 1556
 			'tabs'   => $preserv['tabs'],
1557 1557
 			'view' => $view,
1558 1558
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1564,11 +1564,11 @@  discard block
 block discarded – undo
1564 1564
 		$row = 3;
1565 1565
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1566 1566
 		// preserve some ui elements, if set eg. under error-conditions
1567
-		foreach(array('quantity','resource','role') as $n)
1567
+		foreach (array('quantity', 'resource', 'role') as $n)
1568 1568
 		{
1569 1569
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1570 1570
 		}
1571
-		foreach($event['participant_types'] as $type => $participants)
1571
+		foreach ($event['participant_types'] as $type => $participants)
1572 1572
 		{
1573 1573
 			$name = 'accounts';
1574 1574
 			if (isset($this->bo->resources[$type]))
@@ -1577,17 +1577,17 @@  discard block
 block discarded – undo
1577 1577
 			}
1578 1578
 			// sort participants (in there group/app) by title
1579 1579
 			uksort($participants, array($this, 'uid_title_cmp'));
1580
-			foreach($participants as $id => $status)
1580
+			foreach ($participants as $id => $status)
1581 1581
 			{
1582 1582
 				$uid = $type == 'u' ? $id : $type.$id;
1583 1583
 				$quantity = $role = null;
1584
-				calendar_so::split_status($status,$quantity,$role);
1584
+				calendar_so::split_status($status, $quantity, $role);
1585 1585
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1586 1586
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1587 1587
 					'uid'      => $uid,
1588 1588
 					'status'   => $status,
1589 1589
 					'old_status' => $status,
1590
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1590
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1591 1591
 					'role'     => $role,
1592 1592
 				);
1593 1593
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1596,33 +1596,33 @@  discard block
 block discarded – undo
1596 1596
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1597 1597
 				}
1598 1598
 				// allow third party apps to use categories for roles
1599
-				elseif(substr($role,0,6) == 'X-CAT-')
1599
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1600 1600
 				{
1601
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1601
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1602 1602
 				}
1603 1603
 				else
1604 1604
 				{
1605
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1605
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1606 1606
 				}
1607
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1607
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1608 1608
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1609 1609
 
1610
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1610
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1611 1611
 					$readonlys['participants'][$row]['status'] = $no_status;
1612
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event))
1612
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT, $event))
1613 1613
 					$readonlys['participants']['delete'][$uid] = true;
1614 1614
 				// todo: make the participants available as links with email as title
1615 1615
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1616 1616
 				// enumerate group-invitations, so people can accept/reject them
1617 1617
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1618
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1618
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1619 1619
 				{
1620 1620
 					$sel_options['status']['G'] = lang('Select one');
1621 1621
 					// sort members by title
1622 1622
 					usort($members, array($this, 'uid_title_cmp'));
1623
-					foreach($members as $member)
1623
+					foreach ($members as $member)
1624 1624
 					{
1625
-						if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ,0,$member))
1625
+						if (!isset($participants[$member]) && $this->bo->check_perms(EGW_ACL_READ, 0, $member))
1626 1626
 						{
1627 1627
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1628 1628
 								'app'      => 'Group invitation',
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 							);
1632 1632
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1633 1633
 							// read access is enough to invite participants, but you need edit rights to change status
1634
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(EGW_ACL_EDIT,0,$member);
1634
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(EGW_ACL_EDIT, 0, $member);
1635 1635
 							$content['participants'][$row++]['title'] = common::grab_owner_name($member);
1636 1636
 						}
1637 1637
 					}
@@ -1639,16 +1639,16 @@  discard block
 block discarded – undo
1639 1639
 			}
1640 1640
 			// resouces / apps we shedule, atm. resources and addressbook
1641 1641
 			$content['participants']['cal_resources'] = '';
1642
-			foreach($this->bo->resources as $data)
1642
+			foreach ($this->bo->resources as $data)
1643 1643
 			{
1644
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1644
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1645 1645
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1646 1646
 			}
1647 1647
 			// adding extra content for the resource link-entry widget to
1648 1648
 			// * select resources or addressbook as a default selection on the app selectbox based on prefs
1649 1649
 			$content['participants']['resource']['app'] = $this->cal_prefs['defaultresource_sel'];
1650 1650
 			// * get informations from the event on the ajax callback
1651
-			if (in_array($content['participants']['resource']['app'],array('resources_conflict','resources_without_conflict')))
1651
+			if (in_array($content['participants']['resource']['app'], array('resources_conflict', 'resources_without_conflict')))
1652 1652
 			{
1653 1653
 				// fix real app string
1654 1654
 				$content['participants']['resource']['app'] = 'resources';
@@ -1660,36 +1660,36 @@  discard block
 block discarded – undo
1660 1660
 			}
1661 1661
 		}
1662 1662
 		$content['participants']['status_date'] = $preserv['actual_date'];
1663
-		$preserved = array_merge($preserv,$content);
1663
+		$preserved = array_merge($preserv, $content);
1664 1664
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1665 1665
 		if ($event['alarm'])
1666 1666
 		{
1667 1667
 			// makes keys of the alarm-array starting with 1
1668 1668
 			$content['alarm'] = array(false);
1669
-			foreach(array_values($event['alarm']) as $id => $alarm)
1669
+			foreach (array_values($event['alarm']) as $id => $alarm)
1670 1670
 			{
1671
-				if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ,0,$alarm['owner']))
1671
+				if (!$alarm['all'] && !$this->bo->check_perms(EGW_ACL_READ, 0, $alarm['owner']))
1672 1672
 				{
1673
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1673
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1674 1674
 				}
1675
-				$alarm['all'] = (int) $alarm['all'];
1675
+				$alarm['all'] = (int)$alarm['all'];
1676 1676
 				$after = false;
1677
-				if($alarm['offset'] < 0)
1677
+				if ($alarm['offset'] < 0)
1678 1678
 				{
1679 1679
 					$after = true;
1680 1680
 					$alarm['offset'] = -1 * $alarm['offset'];
1681 1681
 				}
1682
-				$days = (int) ($alarm['offset'] / DAY_s);
1683
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1684
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1682
+				$days = (int)($alarm['offset'] / DAY_s);
1683
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1684
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1685 1685
 				$label = array();
1686 1686
 				if ($days) $label[] = $days.' '.lang('days');
1687 1687
 				if ($hours) $label[] = $hours.' '.lang('hours');
1688 1688
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1689
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1689
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1690 1690
 				$content['alarm'][] = $alarm;
1691 1691
 
1692
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1692
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1693 1693
 			}
1694 1694
 			if (count($content['alarm']) == 1)
1695 1695
 			{
@@ -1704,20 +1704,20 @@  discard block
 block discarded – undo
1704 1704
 
1705 1705
 		if ($view)
1706 1706
 		{
1707
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1707
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1708 1708
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1709 1709
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1710 1710
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1711 1711
 
1712 1712
 			$content['participants']['no_add'] = true;
1713 1713
 
1714
-			if(!$event['whole_day'])
1714
+			if (!$event['whole_day'])
1715 1715
 			{
1716 1716
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1717 1717
 			}
1718 1718
 
1719 1719
 			// respect category permissions
1720
-			if(!empty($event['category']))
1720
+			if (!empty($event['category']))
1721 1721
 			{
1722 1722
 				$content['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
1723 1723
 			}
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 
1729 1729
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1730 1730
 			{
1731
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1731
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1732 1732
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1733 1733
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1734 1734
 			}
@@ -1753,13 +1753,13 @@  discard block
 block discarded – undo
1753 1753
 		{
1754 1754
 			$readonlys['action'] = true;
1755 1755
 		}
1756
-		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1756
+		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate'])))
1757 1757
 		{
1758 1758
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1759 1759
 		}
1760
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE,$event);
1760
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE, $event);
1761 1761
 
1762
-		if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1762
+		if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT, $event))	// new event or edit rights to the event ==> allow to add alarm for all users
1763 1763
 		{
1764 1764
 			$sel_options['owner'][0] = lang('All participants');
1765 1765
 		}
@@ -1767,25 +1767,25 @@  discard block
 block discarded – undo
1767 1767
 		{
1768 1768
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1769 1769
 		}
1770
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1770
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1771 1771
 		{
1772
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(EGW_ACL_EDIT,0,$uid))
1772
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(EGW_ACL_EDIT, 0, $uid))
1773 1773
 			{
1774 1774
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1775 1775
 			}
1776 1776
 		}
1777
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1777
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1778 1778
 		if (!$event['id'])
1779 1779
 		{
1780
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1780
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1781 1781
 		}
1782 1782
 		if ($preserved['no_popup'])
1783 1783
 		{
1784
-			$etpl->set_cell_attribute('button[cancel]','onclick','');
1784
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', '');
1785 1785
 		}
1786 1786
 
1787 1787
 		// Allow admins to restore deleted events
1788
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1788
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1789 1789
 		{
1790 1790
 			$content['deleted'] = $preserved['deleted'] = null;
1791 1791
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
 		//echo "preserv="; _debug_array($preserved);
1802 1802
  		//echo "readonlys="; _debug_array($readonlys);
1803 1803
  		//echo "sel_options="; _debug_array($sel_options);
1804
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1804
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1805 1805
 			. (!$event['id'] ? lang('Add')
1806 1806
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1807 1807
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
 		}
1818 1818
 
1819 1819
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1820
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1820
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1821 1821
 		{
1822
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1822
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1823 1823
 			$content['button']['save'] = true;
1824
-			$this->process_edit(array_merge($content,$preserved));
1824
+			$this->process_edit(array_merge($content, $preserved));
1825 1825
 		}
1826 1826
 		else
1827 1827
 		{
1828
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1828
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1829 1829
 		}
1830 1830
 	}
1831 1831
 
@@ -1835,14 +1835,14 @@  discard block
 block discarded – undo
1835 1835
 	 * @param int $id
1836 1836
 	 * @param string $token
1837 1837
 	 */
1838
-	function ajax_unlock($id,$token)
1838
+	function ajax_unlock($id, $token)
1839 1839
 	{
1840
-		$lock_path = egw_vfs::app_entry_lock_path('calendar',$id);
1840
+		$lock_path = egw_vfs::app_entry_lock_path('calendar', $id);
1841 1841
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1842 1842
 
1843 1843
 		if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1844 1844
 		{
1845
-			egw_vfs::unlock($lock_path,$token,false);
1845
+			egw_vfs::unlock($lock_path, $token, false);
1846 1846
 		}
1847 1847
 	}
1848 1848
 
@@ -1854,17 +1854,17 @@  discard block
 block discarded – undo
1854 1854
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1855 1855
 	 * @param string $msg = null
1856 1856
 	 */
1857
-	function meeting(array $event=null, $msg=null)
1857
+	function meeting(array $event = null, $msg = null)
1858 1858
 	{
1859 1859
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1860 1860
 		$readonlys['button[apply]'] = true;
1861
-		$_usesession=!is_array($event);
1861
+		$_usesession = !is_array($event);
1862 1862
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1863 1863
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1864
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1864
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1865 1865
 		{
1866
-			$event=null; // set to null
1867
-			$_usesession=true; // trigger session read
1866
+			$event = null; // set to null
1867
+			$_usesession = true; // trigger session read
1868 1868
 		}
1869 1869
 		if (!is_array($event))
1870 1870
 		{
@@ -1893,7 +1893,7 @@  discard block
 block discarded – undo
1893 1893
 
1894 1894
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1895 1895
 			{
1896
-				switch(strtolower($ical_method))
1896
+				switch (strtolower($ical_method))
1897 1897
 				{
1898 1898
 					case 'reply':
1899 1899
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -1947,19 +1947,19 @@  discard block
 block discarded – undo
1947 1947
 			}
1948 1948
 			else	// event not in calendar
1949 1949
 			{
1950
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
1950
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
1951 1951
 			}
1952 1952
 			$event['participant_types'] = array();
1953
-			foreach($event['participants'] as $uid => $status)
1953
+			foreach ($event['participants'] as $uid => $status)
1954 1954
 			{
1955 1955
 				$user_type = $user_id = null;
1956 1956
 				calendar_so::split_user($uid, $user_type, $user_id);
1957 1957
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
1958
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
1958
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
1959 1959
 			}
1960 1960
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
1961 1961
 			$event['recure'] = $this->bo->recure2string($event);
1962
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
1962
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
1963 1963
 
1964 1964
 			// ignore events in the past (for recurring events check enddate!)
1965 1965
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -1979,23 +1979,23 @@  discard block
 block discarded – undo
1979 1979
 			// clear notification errors
1980 1980
 			notifications::errors(true);
1981 1981
 
1982
-			switch($button)
1982
+			switch ($button)
1983 1983
 			{
1984 1984
 				case 'reject':
1985 1985
 					if (!$event['id'])
1986 1986
 					{
1987 1987
 						// send reply to organizer
1988
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
1989
-						break;	// no need to store rejected event
1988
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
1989
+						break; // no need to store rejected event
1990 1990
 					}
1991 1991
 					// fall-through
1992 1992
 				case 'accept':
1993 1993
 				case 'tentativ':
1994
-					$status = strtoupper($button[0]);	// A, R or T
1994
+					$status = strtoupper($button[0]); // A, R or T
1995 1995
 					if (!$event['id'])
1996 1996
 					{
1997 1997
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
1998
-						if (isset($event['owner']) && !$this->bo->check_perms(EGW_ACL_ADD,0,$event['owner']))
1998
+						if (isset($event['owner']) && !$this->bo->check_perms(EGW_ACL_ADD, 0, $event['owner']))
1999 1999
 						{
2000 2000
 							// --> make organize a participant with role chair and current user the owner
2001 2001
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
 							$event['owner'] = $this->user;
2004 2004
 						}
2005 2005
 						// store event without notifications!
2006
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
2006
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
2007 2007
 						{
2008 2008
 							$msg[] = lang('Event saved');
2009 2009
 						}
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 		egw_framework::message(implode("\n", (array)$msg));
2042 2042
 		$readonlys['button[edit]'] = !$event['id'];
2043 2043
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2044
-		switch(strtolower($ical_method))
2044
+		switch (strtolower($ical_method))
2045 2045
 		{
2046 2046
 			case 'reply':
2047 2047
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2065,37 +2065,37 @@  discard block
 block discarded – undo
2065 2065
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2066 2066
 	 * @param array $preserv data to preserv
2067 2067
 	 */
2068
-	function conflicts($event,$conflicts,$preserv)
2068
+	function conflicts($event, $conflicts, $preserv)
2069 2069
 	{
2070
-		$etpl = CreateObject('etemplate.etemplate_new','calendar.conflicts');
2070
+		$etpl = CreateObject('etemplate.etemplate_new', 'calendar.conflicts');
2071 2071
 		$allConflicts = array();
2072 2072
 
2073
-		foreach($conflicts as $k => $conflict)
2073
+		foreach ($conflicts as $k => $conflict)
2074 2074
 		{
2075
-			$is_readable = $this->bo->check_perms(EGW_ACL_READ,$conflict);
2075
+			$is_readable = $this->bo->check_perms(EGW_ACL_READ, $conflict);
2076 2076
 
2077 2077
 			$conflicts[$k] += array(
2078 2078
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2079
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2080
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2081
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2082
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2083
-				),true,true)),	// show group invitations too
2079
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2080
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2081
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2082
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2083
+				), true, true)), // show group invitations too
2084 2084
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2085 2085
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2086 2086
 			);
2087
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2087
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2088 2088
 			}
2089 2089
 		$content = $event + array(
2090
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2090
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2091 2091
 		);
2092
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2092
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2093 2093
 		$resources_config = config::read('resources');
2094 2094
 		$readonlys = array();
2095 2095
 
2096 2096
 		foreach (array_keys($allConflicts) as $pId)
2097 2097
 		{
2098
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2098
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2099 2099
 			{
2100 2100
 
2101 2101
 				switch ($resources_config['ignoreconflicts'])
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 				}
2116 2116
 			}
2117 2117
 		}
2118
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2118
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2119 2119
 	}
2120 2120
 
2121 2121
 	/**
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2134 2134
 
2135 2135
 		// convert start/end date-time values to timestamps
2136
-		foreach(array('start', 'end') as $name)
2136
+		foreach (array('start', 'end') as $name)
2137 2137
 		{
2138 2138
 			if (!empty($edit_content[$name]))
2139 2139
 			{
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 			'recur_type'   => $edit_content['recur_type'],
2164 2164
 			'participants' => array(),
2165 2165
 		);
2166
-		foreach($edit_content['participants'] as $key => $data)
2166
+		foreach ($edit_content['participants'] as $key => $data)
2167 2167
 		{
2168 2168
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2169 2169
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2178,21 +2178,21 @@  discard block
 block discarded – undo
2178 2178
 		// default search parameters
2179 2179
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2180 2180
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2181
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2181
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2182 2182
 		{
2183
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2183
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2184 2184
 		}
2185 2185
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2186 2186
 
2187 2187
 		$content['search_window'] = 7 * DAY_s;
2188 2188
 
2189 2189
 		// store content in session
2190
-		egw_cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2190
+		egw_cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2191 2191
 
2192 2192
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2193
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2193
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2194 2194
 
2195
-		$response->call('app.calendar.freetime_search_popup',$link);
2195
+		$response->call('app.calendar.freetime_search_popup', $link);
2196 2196
 
2197 2197
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2198 2198
 
@@ -2215,26 +2215,26 @@  discard block
 block discarded – undo
2215 2215
 	{
2216 2216
 		$etpl = new etemplate_new('calendar.freetimesearch');
2217 2217
 		$sel_options['search_window'] = array(
2218
-			7*DAY_s		=> lang('one week'),
2219
-			14*DAY_s	=> lang('two weeks'),
2220
-			31*DAY_s	=> lang('one month'),
2221
-			92*DAY_s	=> lang('three month'),
2222
-			365*DAY_s	=> lang('one year'),
2218
+			7 * DAY_s		=> lang('one week'),
2219
+			14 * DAY_s	=> lang('two weeks'),
2220
+			31 * DAY_s	=> lang('one month'),
2221
+			92 * DAY_s	=> lang('three month'),
2222
+			365 * DAY_s	=> lang('one year'),
2223 2223
 		);
2224 2224
 		if (!is_array($content))
2225 2225
 		{
2226 2226
 			// get content from session (and delete it immediatly)
2227
-			$content = egw_cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2228
-			egw_cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2227
+			$content = egw_cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2228
+			egw_cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2229 2229
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2230 2230
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2231 2231
 			$sTime = $content['start_time'];
2232 2232
 			$eTime = $content['end_time'];
2233
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2234
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2233
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2234
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2235 2235
 
2236 2236
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2237
-			foreach(array_keys($sel_options['search_window']) as $window)
2237
+			foreach (array_keys($sel_options['search_window']) as $window)
2238 2238
 			{
2239 2239
 				if ($window > $content['duration'])
2240 2240
 				{
@@ -2261,19 +2261,19 @@  discard block
 block discarded – undo
2261 2261
 		{
2262 2262
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2263 2263
 		}
2264
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2265
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2264
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2265
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2266 2266
 
2267
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2267
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2268 2268
 
2269 2269
 		$sel_options['duration'] = $this->durations;
2270 2270
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2271 2271
 
2272
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2272
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2273 2273
 				'participants'	=> $content['participants'],
2274 2274
 				'cal_id'		=> $content['cal_id'],
2275 2275
 				'recur_type'	=> $content['recur_type'],
2276
-			),2);
2276
+			), 2);
2277 2277
 	}
2278 2278
 
2279 2279
 	/**
@@ -2286,15 +2286,15 @@  discard block
 block discarded – undo
2286 2286
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2287 2287
 	 * @return array of free time-slots: array with start and end values
2288 2288
 	 */
2289
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2289
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2290 2290
 	{
2291
-		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);
2291
+		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);
2292 2292
 
2293 2293
 		$busy = $this->bo->search(array(
2294 2294
 			'start' => $start,
2295 2295
 			'end'	=> $end,
2296 2296
 			'users'	=> $participants,
2297
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2297
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2298 2298
 		));
2299 2299
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2300 2300
 			'start'	=> $end,
@@ -2303,15 +2303,15 @@  discard block
 block discarded – undo
2303 2303
 		$ft_start = $start;
2304 2304
 		$freetime = array();
2305 2305
 		$n = 0;
2306
-		foreach($busy as $event)
2306
+		foreach ($busy as $event)
2307 2307
 		{
2308
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2308
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2309 2309
 
2310 2310
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2311 2311
 
2312 2312
 			// check if from all wanted participants at least one has a not rejected status in found event
2313 2313
 			$non_rejected_found = false;
2314
-			foreach($participants as $uid)
2314
+			foreach ($participants as $uid)
2315 2315
 			{
2316 2316
 				if ($event['participants'][$uid] == 'R') continue;
2317 2317
 
@@ -2327,10 +2327,10 @@  discard block
 block discarded – undo
2327 2327
 
2328 2328
 			if ($this->debug)
2329 2329
 			{
2330
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2330
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2331 2331
 				echo "event[title]=$event[title]<br>\n";
2332
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2333
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2332
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2333
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2334 2334
 			}
2335 2335
 			// $events ends before our actual position ==> ignore it
2336 2336
 			if ($event['end'] < $ft_start)
@@ -2354,11 +2354,11 @@  discard block
 block discarded – undo
2354 2354
 					'start'	=> $ft_start,
2355 2355
 					'end'	=> $ft_end,
2356 2356
 				);
2357
-				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";
2357
+				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";
2358 2358
 			}
2359 2359
 			$ft_start = $event['end'];
2360 2360
 		}
2361
-		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);
2361
+		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);
2362 2362
 
2363 2363
 		return $freetime;
2364 2364
 	}
@@ -2378,46 +2378,46 @@  discard block
 block discarded – undo
2378 2378
 	 */
2379 2379
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2380 2380
 	{
2381
-		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);
2381
+		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);
2382 2382
 
2383 2383
 		$freetime_daywise = array();
2384 2384
 		if (!is_array($sel_options)) $sel_options = array();
2385 2385
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2386 2386
 
2387
-		$start_time = (int) $_start_time;	// ignore leading zeros
2388
-		$end_time   = (int) $_end_time;
2387
+		$start_time = (int)$_start_time; // ignore leading zeros
2388
+		$end_time   = (int)$_end_time;
2389 2389
 
2390 2390
 		// ignore the end_time, if duration would never fit
2391
-		if (($end_time - $start_time)*HOUR_s < $duration)
2391
+		if (($end_time - $start_time) * HOUR_s < $duration)
2392 2392
 		{
2393 2393
 			$end_time = 0;
2394
-			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);
2394
+			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);
2395 2395
 		}
2396 2396
 		$n = 0;
2397
-		foreach($freetime as $ft)
2397
+		foreach ($freetime as $ft)
2398 2398
 		{
2399 2399
 			$adaybegin = $this->bo->date2array($ft['start']);
2400 2400
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2401 2401
 			unset($adaybegin['raw']);
2402 2402
 			$daybegin = $this->bo->date2ts($adaybegin);
2403 2403
 
2404
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2404
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2405 2405
 			{
2406
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2407
-				$mcal_dow = pow(2,$dow);
2408
-				if (!($weekdays & $mcal_dow))
2406
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2407
+				$mcal_dow = pow(2, $dow);
2408
+				if (!($weekdays&$mcal_dow))
2409 2409
 				{
2410 2410
 					//echo "wrong day of week $dow<br>\n";
2411
-					continue;	// wrong day of week
2411
+					continue; // wrong day of week
2412 2412
 				}
2413 2413
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2414 2414
 
2415
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2415
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2416 2416
 				{
2417
-					$start = $daybegin + $start_time*HOUR_s;
2417
+					$start = $daybegin + $start_time * HOUR_s;
2418 2418
 				}
2419 2419
 				// if end_time given use it, else the original slot's end
2420
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2420
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2421 2421
 				if ($end > $ft['end']) $end = $ft['end'];
2422 2422
 
2423 2423
 				// slot to small for duration
@@ -2431,11 +2431,11 @@  discard block
 block discarded – undo
2431 2431
 					'end'	=> $end,
2432 2432
 				);
2433 2433
 				$times = array();
2434
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2434
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2435 2435
 				{
2436 2436
 					$e = $s + $duration;
2437
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2438
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2437
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2438
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2439 2439
 				}
2440 2440
 				$sel_options[$n.'start'] = $times;
2441 2441
 			}
@@ -2450,13 +2450,13 @@  discard block
 block discarded – undo
2450 2450
 	 * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2451 2451
 	 * @return string error-msg if $return_error
2452 2452
 	 */
2453
-	function export($content=0,$return_error=false)
2453
+	function export($content = 0, $return_error = false)
2454 2454
 	{
2455 2455
         $boical = new calendar_ical();
2456 2456
 		#error_log(__METHOD__.print_r($content,true));
2457 2457
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2458 2458
 		{
2459
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2459
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2460 2460
 			{
2461 2461
 				$msg = lang('Permission denied');
2462 2462
 
@@ -2464,20 +2464,20 @@  discard block
 block discarded – undo
2464 2464
 			}
2465 2465
 			else
2466 2466
 			{
2467
-				html::content_header('event.ics','text/calendar',bytes($ical));
2467
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2468 2468
 				echo $ical;
2469 2469
 				common::egw_exit();
2470 2470
 			}
2471 2471
 		}
2472 2472
 		if (is_array($content))
2473 2473
 		{
2474
-			$events =& $this->bo->search(array(
2474
+			$events = & $this->bo->search(array(
2475 2475
 				'start' => $content['start'],
2476 2476
 				'end'   => $content['end'],
2477 2477
 				'enum_recuring' => false,
2478 2478
 				'daywise'       => false,
2479 2479
 				'owner'         => $this->owner,
2480
-				'date_format'   => 'server',	// timestamp in server time for boical class
2480
+				'date_format'   => 'server', // timestamp in server time for boical class
2481 2481
 			));
2482 2482
 			if (!$events)
2483 2483
 			{
@@ -2485,8 +2485,8 @@  discard block
 block discarded – undo
2485 2485
 			}
2486 2486
 			else
2487 2487
 			{
2488
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2489
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2488
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2489
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2490 2490
 				echo $ical;
2491 2491
 				common::egw_exit();
2492 2492
 			}
@@ -2502,9 +2502,9 @@  discard block
 block discarded – undo
2502 2502
 		}
2503 2503
 		$content['msg'] = $msg;
2504 2504
 
2505
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2505
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2506 2506
 		$etpl = new etemplate_new('calendar.export');
2507
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2507
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2508 2508
 	}
2509 2509
 
2510 2510
 	/**
@@ -2512,25 +2512,25 @@  discard block
 block discarded – undo
2512 2512
 	 *
2513 2513
 	 * @param array $content submitted content from etempalte::exec
2514 2514
 	 */
2515
-	function import($content=null)
2515
+	function import($content = null)
2516 2516
 	{
2517 2517
 		if (is_array($content))
2518 2518
 		{
2519 2519
 			if (is_array($content['ical_file']) && is_uploaded_file($content['ical_file']['tmp_name']))
2520 2520
 			{
2521
-				@set_time_limit(0);	// try switching execution time limit off
2521
+				@set_time_limit(0); // try switching execution time limit off
2522 2522
 				$start = microtime(true);
2523 2523
 
2524 2524
 				$calendar_ical = new calendar_ical;
2525 2525
 				$calendar_ical->setSupportedFields('file', '');
2526
-				if (!$calendar_ical->importVCal($f=fopen($content['ical_file']['tmp_name'],'r')))
2526
+				if (!$calendar_ical->importVCal($f = fopen($content['ical_file']['tmp_name'], 'r')))
2527 2527
 				{
2528 2528
 					$msg = lang('Error: importing the iCal');
2529 2529
 				}
2530 2530
 				else
2531 2531
 				{
2532 2532
 					$msg = lang('iCal successful imported').' '.lang('(%1 events in %2 seconds)',
2533
-						$calendar_ical->events_imported,number_format(microtime(true)-$start,1));
2533
+						$calendar_ical->events_imported, number_format(microtime(true) - $start, 1));
2534 2534
 				}
2535 2535
 				if ($f) fclose($f);
2536 2536
 			}
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
 				$msg = lang('You need to select an iCal file first');
2540 2540
 			}
2541 2541
 		}
2542
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Import');
2542
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Import');
2543 2543
 		$etpl = new etemplate_new('calendar.import');
2544 2544
 
2545 2545
 		$etpl->exec('calendar.calendar_uiforms.import', array(
@@ -2552,7 +2552,7 @@  discard block
 block discarded – undo
2552 2552
 	 *
2553 2553
 	 * @param array $_content
2554 2554
 	 */
2555
-	function cat_acl(array $_content=null)
2555
+	function cat_acl(array $_content = null)
2556 2556
 	{
2557 2557
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2558 2558
 		{
@@ -2564,15 +2564,15 @@  discard block
 block discarded – undo
2564 2564
 			unset($_content['button']);
2565 2565
 			if ($button != 'cancel')	// store changed acl
2566 2566
 			{
2567
-				foreach($_content as $data)
2567
+				foreach ($_content as $data)
2568 2568
 				{
2569 2569
 					if (!($cat_id = $data['cat_id'])) continue;
2570
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2570
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2571 2571
 					{
2572 2572
 						$rights = 0;
2573
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2574
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2575
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2573
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2574
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2575
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2576 2576
 					}
2577 2577
 				}
2578 2578
 			}
@@ -2584,20 +2584,20 @@  discard block
 block discarded – undo
2584 2584
 				), 'admin');
2585 2585
 			}
2586 2586
 		}
2587
-		$content= $preserv = array();
2587
+		$content = $preserv = array();
2588 2588
 		$n = 1;
2589
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2589
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2590 2590
 		{
2591
-			$cat_id = substr($Lcat_id,1);
2591
+			$cat_id = substr($Lcat_id, 1);
2592 2592
 			$row = array(
2593 2593
 				'cat_id' => $cat_id,
2594 2594
 				'add' => array(),
2595 2595
 				'status' => array(),
2596 2596
 			);
2597
-			foreach($data as $account_id => $rights)
2597
+			foreach ($data as $account_id => $rights)
2598 2598
 			{
2599
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2600
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2599
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2600
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2601 2601
 			}
2602 2602
 			$content[$n] = $row;
2603 2603
 			$preserv[$n] = array(
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
 
2613 2613
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2614 2614
 		$tmp = new etemplate_new('calendar.cat_acl');
2615
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2615
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2616 2616
 	}
2617 2617
 
2618 2618
 	/**
@@ -2662,18 +2662,18 @@  discard block
 block discarded – undo
2662 2662
 
2663 2663
 
2664 2664
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2665
-		if($content['recur_type'] || $content['recurrence'])
2665
+		if ($content['recur_type'] || $content['recurrence'])
2666 2666
 		{
2667 2667
 			$content['history']['filter'] = array(
2668 2668
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2669
-					history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2670
-					history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2669
+					history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2670
+					history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2671 2671
 			);
2672 2672
 		}
2673 2673
 
2674 2674
 		// Translate labels
2675 2675
 		$tracking = new calendar_tracking();
2676
-		foreach($tracking->field2label as $field => $label)
2676
+		foreach ($tracking->field2label as $field => $label)
2677 2677
 		{
2678 2678
 			$sel_options[$status][$field] = lang($label);
2679 2679
 		}
@@ -2690,20 +2690,20 @@  discard block
 block discarded – undo
2690 2690
 	 * @param string $durationT the duration to support resizable calendar event
2691 2691
 	 * @return string XML response if no error occurs
2692 2692
 	 */
2693
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null)
2693
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null)
2694 2694
 	{
2695 2695
 		// we do not allow dragging into another users calendar ATM
2696
-		if(!$calendarOwner == $targetOwner)
2696
+		if (!$calendarOwner == $targetOwner)
2697 2697
 		{
2698 2698
 			return false;
2699 2699
 		}
2700 2700
 
2701
-		list($eventId, $date) = explode(':', $_eventId,2);
2701
+		list($eventId, $date) = explode(':', $_eventId, 2);
2702 2702
 
2703
-		$old_event=$event=$this->bo->read($eventId);
2703
+		$old_event = $event = $this->bo->read($eventId);
2704 2704
 		if (!$durationT)
2705 2705
 		{
2706
-			$duration=$event['end']-$event['start'];
2706
+			$duration = $event['end'] - $event['start'];
2707 2707
 		}
2708 2708
 		else
2709 2709
 		{
@@ -2712,13 +2712,13 @@  discard block
 block discarded – undo
2712 2712
 
2713 2713
 		$event['start'] = $this->bo->date2ts($targetDateTime);
2714 2714
 
2715
-		$event['end'] = $event['start']+$duration;
2715
+		$event['end'] = $event['start'] + $duration;
2716 2716
 
2717 2717
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $date)
2718 2718
 		{
2719 2719
 			// calculate offset against clicked recurrance,
2720 2720
 			// depending on which is smaller
2721
-			$offset = egw_time::to($targetDateTime,'ts') - egw_time::to($date,'ts');
2721
+			$offset = egw_time::to($targetDateTime, 'ts') - egw_time::to($date, 'ts');
2722 2722
 			$event['start'] = $old_event['start'] + $offset;
2723 2723
 			$event['duration'] = $duration;
2724 2724
 
@@ -2728,13 +2728,13 @@  discard block
 block discarded – undo
2728 2728
 		}
2729 2729
 		$status_reset_to_unknown = false;
2730 2730
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2731
-		foreach((array)$event['participants'] as $uid => $status)
2731
+		foreach ((array)$event['participants'] as $uid => $status)
2732 2732
 		{
2733 2733
 			$q = $r = null;
2734
-			calendar_so::split_status($status,$q,$r);
2734
+			calendar_so::split_status($status, $q, $r);
2735 2735
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2736 2736
 			{
2737
-				$preferences = CreateObject('phpgwapi.preferences',$uid);
2737
+				$preferences = CreateObject('phpgwapi.preferences', $uid);
2738 2738
 				$part_prefs = $preferences->read_repository();
2739 2739
 				switch ($part_prefs['calendar']['reset_stati'])
2740 2740
 				{
@@ -2744,18 +2744,18 @@  discard block
 block discarded – undo
2744 2744
 						if ($sameday) break;
2745 2745
 					default:
2746 2746
 						$status_reset_to_unknown = true;
2747
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2747
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2748 2748
 						// todo: report reset status to user
2749 2749
 				}
2750 2750
 			}
2751 2751
 		}
2752 2752
 
2753
-		$conflicts=$this->bo->update($event);
2753
+		$conflicts = $this->bo->update($event);
2754 2754
 
2755 2755
 		$response = egw_json_response::get();
2756
-		if(!is_array($conflicts))
2756
+		if (!is_array($conflicts))
2757 2757
 		{
2758
-			$response->redirect(egw::link('/index.php',array(
2758
+			$response->redirect(egw::link('/index.php', array(
2759 2759
 				'menuaction' => $this->view_menuaction,
2760 2760
 			)));
2761 2761
 		}
@@ -2769,16 +2769,16 @@  discard block
 block discarded – undo
2769 2769
 					.'&end='.$event['end']
2770 2770
 					.'&non_interactive=true'
2771 2771
 					.'&cancel_needs_refresh=true',
2772
-				'',750,410);
2772
+				'', 750, 410);
2773 2773
 		}
2774 2774
 		if ($status_reset_to_unknown)
2775 2775
 		{
2776
-			foreach((array)$event['participants'] as $uid => $status)
2776
+			foreach ((array)$event['participants'] as $uid => $status)
2777 2777
 			{
2778 2778
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2779 2779
 				{
2780
-					calendar_so::split_status($status,$q,$r);
2781
-					$status = calendar_so::combine_status('U',$q,$r);
2780
+					calendar_so::split_status($status, $q, $r);
2781
+					$status = calendar_so::combine_status('U', $q, $r);
2782 2782
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2783 2783
 				}
2784 2784
 			}
@@ -2796,35 +2796,35 @@  discard block
 block discarded – undo
2796 2796
 		// Arbitrarily limited to 50 / resource
2797 2797
 		$options = array('start' => 0, 'num_rows' => 50);
2798 2798
 		$results = array();
2799
-		if($query)
2799
+		if ($query)
2800 2800
 		{
2801
-			$resources = array_merge(array('' => $this->bo->resources['']),$this->bo->resources);
2802
-			foreach($resources as $type => $data)
2801
+			$resources = array_merge(array('' => $this->bo->resources['']), $this->bo->resources);
2802
+			foreach ($resources as $type => $data)
2803 2803
 			{
2804 2804
 				$mapped = array();
2805 2805
 				$_results = array();
2806 2806
 
2807 2807
 				// Handle accounts seperately
2808
-				if($type == '')
2808
+				if ($type == '')
2809 2809
 				{
2810 2810
 					$list = array('accounts', 'owngroups');
2811
-					foreach($list as $a_type)
2811
+					foreach ($list as $a_type)
2812 2812
 					{
2813 2813
 						$account_options = $options + array('account_type' => $a_type);
2814
-						$_results += accounts::link_query('',$account_options);
2814
+						$_results += accounts::link_query('', $account_options);
2815 2815
 					}
2816 2816
 					$_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar'));
2817 2817
 				}
2818 2818
 				else if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
2819 2819
 				{
2820
-					$_results = egw_link::query($data['app'], $query,$options);
2820
+					$_results = egw_link::query($data['app'], $query, $options);
2821 2821
 				}
2822
-				if(!$_results) continue;
2822
+				if (!$_results) continue;
2823 2823
 				$_results = array_unique($_results);
2824 2824
 
2825
-				foreach($_results as $id => $title)
2825
+				foreach ($_results as $id => $title)
2826 2826
 				{
2827
-					if($id && $title)
2827
+					if ($id && $title)
2828 2828
 					{
2829 2829
 						// Magicsuggest uses id, not value.
2830 2830
 						$value = array(
@@ -2833,14 +2833,14 @@  discard block
 block discarded – undo
2833 2833
 							'label' => $title,
2834 2834
 							'app'	=> lang($data['app'])
2835 2835
 						);
2836
-						if(is_array($value['label']))
2836
+						if (is_array($value['label']))
2837 2837
 						{
2838 2838
 							$value = array_merge($value, $value['label']);
2839 2839
 						}
2840 2840
 						$mapped[] = $value;
2841 2841
 					}
2842 2842
 				}
2843
-				if(count($mapped))
2843
+				if (count($mapped))
2844 2844
 				{
2845 2845
 					$results = array_merge($results, $mapped);
2846 2846
 				}
@@ -2860,13 +2860,13 @@  discard block
 block discarded – undo
2860 2860
 	 * @param array $mailContent = null mail content
2861 2861
 	 * @return  array
2862 2862
 	 */
2863
-	function mail_import(array $mailContent=null)
2863
+	function mail_import(array $mailContent = null)
2864 2864
 	{
2865 2865
 		// It would get called from compose as a popup with egw_data
2866 2866
 		if (!is_array($mailContent) && ($_GET['egw_data']))
2867 2867
 		{
2868 2868
 			// get raw mail data
2869
-			egw_link::get_data ($_GET['egw_data']);
2869
+			egw_link::get_data($_GET['egw_data']);
2870 2870
 			return false;
2871 2871
 		}
2872 2872
 
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 			$AB = new addressbook_bo();
2877 2877
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
2878 2878
 
2879
-			$participants[0] = array (
2879
+			$participants[0] = array(
2880 2880
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
2881 2881
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
2882 2882
 				'status' => 'A',
@@ -2884,23 +2884,23 @@  discard block
 block discarded – undo
2884 2884
 				'app' => 'User',
2885 2885
 				'role' => 'REQ-PARTICIPANT'
2886 2886
 			);
2887
-			foreach($mailContent['addresses'] as $address)
2887
+			foreach ($mailContent['addresses'] as $address)
2888 2888
 			{
2889 2889
 				// Get available contacts from the email
2890 2890
 				$contacts = $AB->search(array(
2891 2891
 						'email' => $address['email'],
2892 2892
 						'email_home' => $address['email']
2893
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
2893
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
2894 2894
 				if (is_array($contacts))
2895 2895
 				{
2896
-					foreach($contacts as $account)
2896
+					foreach ($contacts as $account)
2897 2897
 					{
2898 2898
 						$accounts[] = $account['account_id'];
2899 2899
 					}
2900 2900
 				}
2901 2901
 				else
2902 2902
 				{
2903
-					$participants []= array (
2903
+					$participants [] = array(
2904 2904
 						'app' => 'email',
2905 2905
 						'uid' => 'e'.$address['email'],
2906 2906
 						'status' => 'U',
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 					);
2909 2909
 				}
2910 2910
 			}
2911
-			$participants = array_merge($participants , array(
2911
+			$participants = array_merge($participants, array(
2912 2912
 				"account" => $accounts,
2913 2913
 				"role" => "REQ-PARTICIPANT",
2914 2914
 				"add" => "pressed"
@@ -2932,14 +2932,14 @@  discard block
 block discarded – undo
2932 2932
 			{
2933 2933
 				foreach ($mailContent['attachments'] as $attachment)
2934 2934
 				{
2935
-					if($attachment['egw_data'])
2935
+					if ($attachment['egw_data'])
2936 2936
 					{
2937
-						egw_link::link('calendar',$event['link_to']['to_id'],egw_link::DATA_APPNAME,  $attachment);
2937
+						egw_link::link('calendar', $event['link_to']['to_id'], egw_link::DATA_APPNAME, $attachment);
2938 2938
 					}
2939
-					else if(is_readable($attachment['tmp_name']) ||
2939
+					else if (is_readable($attachment['tmp_name']) ||
2940 2940
 						(egw_vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
2941 2941
 					{
2942
-						egw_link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
2942
+						egw_link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
2943 2943
 					}
2944 2944
 				}
2945 2945
 			}
Please login to merge, or discard this patch.
Braces   +287 added lines, -73 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@  discard block
 block discarded – undo
94 94
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
95 95
 			!$this->bo->check_perms(EGW_ACL_ADD,0,$owner))
96 96
 		{
97
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
97
+			if ($owner)
98
+			{
99
+				// make an owner who is no user or we have no add-rights a participant
98 100
 			{
99 101
 				// if we come from ressources we don't need any users selected in calendar
100 102
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -105,6 +107,7 @@  discard block
 block discarded – undo
105 107
 						if (is_numeric($uid) || $owner == $uid)
106 108
 						{
107 109
 							$extra_participants[] = $uid;
110
+			}
108 111
 						}
109 112
 					}
110 113
 				}
@@ -126,9 +129,17 @@  discard block
 block discarded – undo
126 129
 		$participant_types['u'] = $participant_types = $participants = array();
127 130
 		foreach($extra_participants as $uid)
128 131
 		{
129
-			if (isset($participants[$uid])) continue;	// already included
132
+			if (isset($participants[$uid]))
133
+			{
134
+				continue;
135
+			}
136
+			// already included
130 137
 
131
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
138
+			if (!$this->bo->check_acl_invite($uid))
139
+			{
140
+				continue;
141
+			}
142
+			// no right to invite --> ignored
132 143
 
133 144
 			if (is_numeric($uid))
134 145
 			{
@@ -156,10 +167,13 @@  discard block
 block discarded – undo
156 167
 				}
157 168
 			}
158 169
 		}
159
-		if (!$participants)	// if all participants got removed, include current user
170
+		if (!$participants)
171
+		{
172
+			// if all participants got removed, include current user
160 173
 		{
161 174
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
162 175
 		}
176
+		}
163 177
 		$alarms = array();
164 178
 		// if default alarm set in prefs --> add it
165 179
 		// we assume here that user does NOT have a whole-day but no regular default-alarm, no whole-day!
@@ -198,16 +212,23 @@  discard block
 block discarded – undo
198 212
 	 */
199 213
 	function process_edit($content)
200 214
 	{
201
-		if (!is_array($content))	// redirect from etemplate, if POST empty
215
+		if (!is_array($content))
216
+		{
217
+			// redirect from etemplate, if POST empty
202 218
 		{
203 219
 			return $this->edit(null,null,strip_tags($_GET['msg']));
204 220
 		}
221
+		}
205 222
 		// clear notification errors
206 223
 		notifications::errors(true);
207 224
 		$messages = null;
208 225
 		$msg_permission_denied_added = false;
209 226
 		list($button) = @each($content['button']);
210
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
227
+		if (!$button && $content['action'])
228
+		{
229
+			$button = $content['action'];
230
+		}
231
+		// action selectbox
211 232
 		unset($content['button']); unset($content['action']);
212 233
 
213 234
 		$view = $content['view'];
@@ -220,7 +241,10 @@  discard block
 block discarded – undo
220 241
 		{
221 242
 			list($date) = each($content['recur_exception']['delete_exception']);
222 243
 			// eT2 converts time to
223
-			if (!is_numeric($date)) $date = egw_time::to (str_replace('Z','', $date), 'ts');
244
+			if (!is_numeric($date))
245
+			{
246
+				$date = egw_time::to (str_replace('Z','', $date), 'ts');
247
+			}
224 248
 			unset($content['recur_exception']['delete_exception']);
225 249
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
226 250
 			{
@@ -229,7 +253,10 @@  discard block
 block discarded – undo
229 253
 				foreach ($recur_exceptions as $id)
230 254
 				{
231 255
 					if (!($exception = $this->bo->read($id)) ||
232
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
256
+							$exception['recurrence'] != $content['recur_exception'][$key])
257
+					{
258
+						continue;
259
+					}
233 260
 					$exception['uid'] = common::generate_uid('calendar', $id);
234 261
 					$exception['reference'] = $exception['recurrence'] = 0;
235 262
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -303,7 +330,10 @@  discard block
 block discarded – undo
303 330
 				$event['end'] = $this->bo->date2ts($event['end']);
304 331
 			}
305 332
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
306
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
333
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
334
+			{
335
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
336
+			}
307 337
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
308 338
 			{
309 339
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -355,9 +385,12 @@  discard block
 block discarded – undo
355 385
 							break;
356 386
 
357 387
 						case 'resource':
358
-							if (is_array($data))	// if $data['current'] is NOT set --> $app==''
388
+							if (is_array($data))
389
+							{
390
+								// if $data['current'] is NOT set --> $app==''
359 391
 							{
360 392
 								list($app,$id) = explode(':',$data['current']);
393
+							}
361 394
 								if(!$app && !$id)
362 395
 								{
363 396
 									$app = $data['app'];
@@ -370,7 +403,10 @@  discard block
 block discarded – undo
370 403
 							}
371 404
 							foreach($this->bo->resources as $type => $data)
372 405
 							{
373
-								if ($data['app'] == $app) break;
406
+								if ($data['app'] == $app)
407
+								{
408
+									break;
409
+								}
374 410
 							}
375 411
 							$uid = $this->bo->resources[$type]['app'] == $app ? $type.$id : false;
376 412
 							if ($app == 'home-accounts')
@@ -432,7 +468,11 @@  discard block
 block discarded – undo
432 468
 							break;
433 469
 
434 470
 						default:		// existing participant row
435
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
471
+							if (!is_array($data))
472
+							{
473
+								continue;
474
+							}
475
+							// widgets in participant tab, above participant list
436 476
 							foreach(array('uid','status','quantity','role') as $name)
437 477
 							{
438 478
 								$$name = $data[$name];
@@ -561,7 +601,10 @@  discard block
 block discarded – undo
561 601
 			{
562 602
 				foreach($participants as $id => &$response)
563 603
 				{
564
-					if($type == 'u' && $id == $event['owner']) continue;
604
+					if($type == 'u' && $id == $event['owner'])
605
+					{
606
+						continue;
607
+					}
565 608
 					calendar_so::split_status($response, $quantity, $role);
566 609
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
567 610
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -643,17 +686,23 @@  discard block
 block discarded – undo
643 686
 			{
644 687
 				foreach (array_keys($event['participants']) as $uid)
645 688
 				{
646
-					if ($uid[0] == 'r') //ressource detection
689
+					if ($uid[0] == 'r')
690
+					{
691
+						//ressource detection
647 692
 					{
648 693
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
694
+					}
649 695
 						$button = '';
650 696
 						break 2; //break foreach and case
651 697
 					}
652 698
 				}
653 699
 			}
654
-			if ($content['edit_single'])	// we edited a single event from a series
700
+			if ($content['edit_single'])
701
+			{
702
+				// we edited a single event from a series
655 703
 			{
656 704
 				$event['reference'] = $event['id'];
705
+			}
657 706
 				$event['recurrence'] = $content['edit_single'];
658 707
 				unset($event['id']);
659 708
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -803,7 +852,10 @@  discard block
 block discarded – undo
803 852
 										case 'no':
804 853
 											break;
805 854
 										case 'startday':
806
-											if ($sameday) break;
855
+											if ($sameday)
856
+											{
857
+												break;
858
+											}
807 859
 										default:
808 860
 											$status_reset_to_unknown = true;
809 861
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -940,7 +992,10 @@  discard block
 block discarded – undo
940 992
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
941 993
 				{
942 994
 					$msg = lang('Series deleted');
943
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
995
+					if ($exceptions_kept)
996
+					{
997
+						$msg .= lang(', exceptions preserved');
998
+					}
944 999
 				}
945 1000
 				else
946 1001
 				{
@@ -976,11 +1031,14 @@  discard block
 block discarded – undo
976 1031
 				{
977 1032
 					$msg = lang("Can't add alarms in the past !!!");
978 1033
 				}
979
-				elseif ($event['id'])	// save the alarm immediatly
1034
+				elseif ($event['id'])
1035
+				{
1036
+					// save the alarm immediatly
980 1037
 				{
981 1038
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
982 1039
 					{
983 1040
 						$alarm['id'] = $alarm_id;
1041
+				}
984 1042
 						$event['alarm'][$alarm_id] = $alarm;
985 1043
 
986 1044
 						$msg = lang('Alarm added');
@@ -993,7 +1051,9 @@  discard block
 block discarded – undo
993 1051
 				}
994 1052
 				else
995 1053
 				{
996
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1054
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1055
+					{
1056
+}	// get a temporary non-conflicting, numeric id
997 1057
 					$event['alarm'][$alarm['id']] = $alarm;
998 1058
 				}
999 1059
 			}
@@ -1010,10 +1070,13 @@  discard block
 block discarded – undo
1010 1070
 		}
1011 1071
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1012 1072
 		{
1013
-			if ($content['lock_token'])	// remove an existing lock
1073
+			if ($content['lock_token'])
1074
+			{
1075
+				// remove an existing lock
1014 1076
 			{
1015 1077
 				egw_vfs::unlock(egw_vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1016 1078
 			}
1079
+			}
1017 1080
 			if ($content['no_popup'])
1018 1081
 			{
1019 1082
 				egw::redirect_link('/index.php',array(
@@ -1118,8 +1181,7 @@  discard block
 block discarded – undo
1118 1181
 		if (egw_time::to($old_event['start'],'Ymd') < egw_time::to($as_of_date,'Ymd') ||
1119 1182
 			// Adjust for requested date in the past
1120 1183
 			egw_time::to($as_of_date,'ts') < time()
1121
-		)
1122
-		{
1184
+		) {
1123 1185
 
1124 1186
 			unset($orig_event);
1125 1187
 			// copy event by unsetting the id(s)
@@ -1207,32 +1269,50 @@  discard block
 block discarded – undo
1207 1269
 		foreach($event['participants'] as $uid => $status)
1208 1270
 		{
1209 1271
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1210
-			if (empty($status)) continue;
1272
+			if (empty($status))
1273
+			{
1274
+				continue;
1275
+			}
1211 1276
 			$toadd = '';
1212
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1277
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1278
+			{
1279
+				continue;
1280
+			}
1213 1281
 
1214 1282
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1215 1283
 			{
1216
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1284
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1285
+				{
1286
+					continue;
1287
+				}
1217 1288
 
1218 1289
 				$lid = $firstname = $lastname = null;
1219 1290
 				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1220 1291
 
1221 1292
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1222
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1293
+				if (!in_array($toadd,$to))
1294
+				{
1295
+					$to[] = $toadd;
1296
+				}
1223 1297
 				//error_log(__METHOD__.__LINE__.array2string($to));
1224 1298
 			}
1225 1299
 			elseif ($uid < 0)
1226 1300
 			{
1227 1301
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1228 1302
 				{
1229
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1303
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1304
+					{
1305
+						continue;
1306
+					}
1230 1307
 
1231 1308
 					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1232 1309
 
1233 1310
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1234 1311
 					// dont add groupmembers if they already rejected the event, or are the current user
1235
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1312
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1313
+					{
1314
+						$to[] = $toadd;
1315
+					}
1236 1316
 					//error_log(__METHOD__.__LINE__.array2string($to));
1237 1317
 				}
1238 1318
 			}
@@ -1285,7 +1365,10 @@  discard block
 block discarded – undo
1285 1365
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1286 1366
 			'preset[size]'    => filesize($ics_file),
1287 1367
 		);
1288
-		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.');
1368
+		if ($asrequest)
1369
+		{
1370
+			$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.');
1371
+		}
1289 1372
 		$response = egw_json_response::get();
1290 1373
 		$response->call('app.calendar.custom_mail', $vars);
1291 1374
 	}
@@ -1471,8 +1554,12 @@  discard block
 block discarded – undo
1471 1554
 				}
1472 1555
 			}
1473 1556
 			// set new start and end if given by $_GET
1474
-			if(isset($_GET['start'])) { $event['start'] = $_GET['start']; }
1475
-			if(isset($_GET['end'])) { $event['end'] = $_GET['end']; }
1557
+			if(isset($_GET['start']))
1558
+			{
1559
+$event['start'] = $_GET['start']; }
1560
+			if(isset($_GET['end']))
1561
+			{
1562
+$event['end'] = $_GET['end']; }
1476 1563
 			// check if the event is the whole day
1477 1564
 			$start = $this->bo->date2array($event['start']);
1478 1565
 			$end = $this->bo->date2array($event['end']);
@@ -1485,10 +1572,13 @@  discard block
 block discarded – undo
1485 1572
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1486 1573
 				{
1487 1574
 					$link_id = $link_ids[$n];
1488
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1575
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1576
+					{
1577
+						// guard against XSS
1489 1578
 					{
1490 1579
 						continue;
1491 1580
 					}
1581
+					}
1492 1582
 					if(!$n)
1493 1583
 					{
1494 1584
 						$event['title'] = egw_link::title($link_app,$link_id);
@@ -1497,7 +1587,10 @@  discard block
 block discarded – undo
1497 1587
 						{
1498 1588
 							foreach((array)$set['link_app'] as $i => $l_app)
1499 1589
 							{
1500
-								if (($l_id=$set['link_id'][$i])) egw_link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1590
+								if (($l_id=$set['link_id'][$i]))
1591
+								{
1592
+									egw_link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1593
+								}
1501 1594
 							}
1502 1595
 							unset($set['link_app']);
1503 1596
 							unset($set['link_id']);
@@ -1523,10 +1616,13 @@  discard block
 block discarded – undo
1523 1616
 			$lock_path = egw_vfs::app_entry_lock_path('calendar',$event['id']);
1524 1617
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1525 1618
 
1526
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1619
+			if (($preserv['lock_token'] = $event['lock_token']))
1620
+			{
1621
+				// already locked --> refresh the lock
1527 1622
 			{
1528 1623
 				egw_vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1529 1624
 			}
1625
+			}
1530 1626
 			if (($lock = egw_vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1531 1627
 			{
1532 1628
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1559,14 +1655,20 @@  discard block
 block discarded – undo
1559 1655
 		));
1560 1656
 		egw_framework::message($msg, $msg_type);
1561 1657
 		$content['duration'] = $content['end'] - $content['start'];
1562
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1658
+		if (isset($this->durations[$content['duration']]))
1659
+		{
1660
+			$content['end'] = '';
1661
+		}
1563 1662
 
1564 1663
 		$row = 3;
1565 1664
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1566 1665
 		// preserve some ui elements, if set eg. under error-conditions
1567 1666
 		foreach(array('quantity','resource','role') as $n)
1568 1667
 		{
1569
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1668
+			if (isset($event['participants'][$n]))
1669
+			{
1670
+				$content['participants'][$n] = $event['participants'][$n];
1671
+			}
1570 1672
 		}
1571 1673
 		foreach($event['participant_types'] as $type => $participants)
1572 1674
 		{
@@ -1608,9 +1710,13 @@  discard block
 block discarded – undo
1608 1710
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1609 1711
 
1610 1712
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1611
-					$readonlys['participants'][$row]['status'] = $no_status;
1713
+				{
1714
+									$readonlys['participants'][$row]['status'] = $no_status;
1715
+				}
1612 1716
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(EGW_ACL_EDIT,$event))
1613
-					$readonlys['participants']['delete'][$uid] = true;
1717
+				{
1718
+									$readonlys['participants']['delete'][$uid] = true;
1719
+				}
1614 1720
 				// todo: make the participants available as links with email as title
1615 1721
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1616 1722
 				// enumerate group-invitations, so people can accept/reject them
@@ -1641,7 +1747,11 @@  discard block
 block discarded – undo
1641 1747
 			$content['participants']['cal_resources'] = '';
1642 1748
 			foreach($this->bo->resources as $data)
1643 1749
 			{
1644
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1750
+				if ($data['app'] == 'email')
1751
+				{
1752
+					continue;
1753
+				}
1754
+				// make no sense, as we cant search for email
1645 1755
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1646 1756
 			}
1647 1757
 			// adding extra content for the resource link-entry widget to
@@ -1683,9 +1793,18 @@  discard block
 block discarded – undo
1683 1793
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1684 1794
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1685 1795
 				$label = array();
1686
-				if ($days) $label[] = $days.' '.lang('days');
1687
-				if ($hours) $label[] = $hours.' '.lang('hours');
1688
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1796
+				if ($days)
1797
+				{
1798
+					$label[] = $days.' '.lang('days');
1799
+				}
1800
+				if ($hours)
1801
+				{
1802
+					$label[] = $hours.' '.lang('hours');
1803
+				}
1804
+				if ($minutes)
1805
+				{
1806
+					$label[] = $minutes.' '.lang('Minutes');
1807
+				}
1689 1808
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1690 1809
 				$content['alarm'][] = $alarm;
1691 1810
 
@@ -1744,25 +1863,34 @@  discard block
 block discarded – undo
1744 1863
 			'participants' => $this->accountsel->account_selection == 'none',
1745 1864
 			'history' => !$event['id'],
1746 1865
 		);
1747
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1866
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1867
+		{
1868
+			// no mail without mail-app
1748 1869
 		{
1749 1870
 			unset($sel_options['action']['mail']);
1871
+		}
1750 1872
 			unset($sel_options['action']['sendmeetingrequest']);
1751 1873
 		}
1752
-		if (!$event['id'])	// no ical export for new (not saved) events
1874
+		if (!$event['id'])
1875
+		{
1876
+			// no ical export for new (not saved) events
1753 1877
 		{
1754 1878
 			$readonlys['action'] = true;
1755 1879
 		}
1880
+		}
1756 1881
 		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(EGW_ACL_EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1757 1882
 		{
1758 1883
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1759 1884
 		}
1760 1885
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(EGW_ACL_DELETE,$event);
1761 1886
 
1762
-		if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1887
+		if (!$event['id'] || $this->bo->check_perms(EGW_ACL_EDIT,$event))
1888
+		{
1889
+			// new event or edit rights to the event ==> allow to add alarm for all users
1763 1890
 		{
1764 1891
 			$sel_options['owner'][0] = lang('All participants');
1765 1892
 		}
1893
+		}
1766 1894
 		if (isset($event['participant_types']['u'][$this->user]))
1767 1895
 		{
1768 1896
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1808,7 +1936,10 @@  discard block
 block discarded – undo
1808 1936
 
1809 1937
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1810 1938
 
1811
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1939
+		if (!empty($preserved['lock_token']))
1940
+		{
1941
+			$content['lock_token'] = $preserved['lock_token'];
1942
+		}
1812 1943
 
1813 1944
 		// disabling Apply button for IE 10/11 and Edge, because all but current tab fail to load
1814 1945
 		if (html::$user_agent == 'msie' || html::$user_agent == 'edge')
@@ -2016,7 +2147,10 @@  discard block
 block discarded – undo
2016 2147
 					// set status and send notification / meeting response
2017 2148
 					if ($this->bo->set_status($event['id'], $user, $status))
2018 2149
 					{
2019
-						if (!$msg) $msg = lang('Status changed');
2150
+						if (!$msg)
2151
+						{
2152
+							$msg = lang('Status changed');
2153
+						}
2020 2154
 					}
2021 2155
 					break;
2022 2156
 
@@ -2095,13 +2229,16 @@  discard block
 block discarded – undo
2095 2229
 
2096 2230
 		foreach (array_keys($allConflicts) as $pId)
2097 2231
 		{
2098
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2232
+			if(substr($pId,0,1) == 'r' && $resources_config )
2233
+			{
2234
+				// resources Allow ignore conflicts
2099 2235
 			{
2100 2236
 
2101 2237
 				switch ($resources_config['ignoreconflicts'])
2102 2238
 				{
2103 2239
 					case 'no':
2104 2240
 						$readonlys['button[ignore]'] = true;
2241
+			}
2105 2242
 						break;
2106 2243
 					case 'allusers':
2107 2244
 						$readonlys['button[ignore]'] = false;
@@ -2245,7 +2382,10 @@  discard block
 block discarded – undo
2245 2382
 		}
2246 2383
 		else
2247 2384
 		{
2248
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2385
+			if (!$content['duration'])
2386
+			{
2387
+				$content['duration'] = $content['end'] - $content['start'];
2388
+			}
2249 2389
 			$weekds = 0;
2250 2390
 			foreach ($content['weekdays'] as &$wdays)
2251 2391
 			{
@@ -2267,7 +2407,10 @@  discard block
 block discarded – undo
2267 2407
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2268 2408
 
2269 2409
 		$sel_options['duration'] = $this->durations;
2270
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2410
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2411
+		{
2412
+			$content['end'] = '';
2413
+		}
2271 2414
 
2272 2415
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2273 2416
 				'participants'	=> $content['participants'],
@@ -2288,7 +2431,10 @@  discard block
 block discarded – undo
2288 2431
 	 */
2289 2432
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2290 2433
 	{
2291
-		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);
2434
+		if ($this->debug > 2)
2435
+		{
2436
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2437
+		}
2292 2438
 
2293 2439
 		$busy = $this->bo->search(array(
2294 2440
 			'start' => $start,
@@ -2305,15 +2451,26 @@  discard block
 block discarded – undo
2305 2451
 		$n = 0;
2306 2452
 		foreach($busy as $event)
2307 2453
 		{
2308
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2454
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2455
+			{
2456
+				continue;
2457
+			}
2458
+			// ignore our own event
2309 2459
 
2310
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2460
+ 			if ($event['non_blocking'])
2461
+ 			{
2462
+ 				continue;
2463
+ 			}
2464
+ 			// ignore non_blocking events
2311 2465
 
2312 2466
 			// check if from all wanted participants at least one has a not rejected status in found event
2313 2467
 			$non_rejected_found = false;
2314 2468
 			foreach($participants as $uid)
2315 2469
 			{
2316
-				if ($event['participants'][$uid] == 'R') continue;
2470
+				if ($event['participants'][$uid] == 'R')
2471
+				{
2472
+					continue;
2473
+				}
2317 2474
 
2318 2475
 				if (isset($event['participants'][$uid]) ||
2319 2476
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2323,7 +2480,10 @@  discard block
 block discarded – undo
2323 2480
 					break;
2324 2481
 				}
2325 2482
 			}
2326
-			if (!$non_rejected_found) continue;
2483
+			if (!$non_rejected_found)
2484
+			{
2485
+				continue;
2486
+			}
2327 2487
 
2328 2488
 			if ($this->debug)
2329 2489
 			{
@@ -2354,11 +2514,17 @@  discard block
 block discarded – undo
2354 2514
 					'start'	=> $ft_start,
2355 2515
 					'end'	=> $ft_end,
2356 2516
 				);
2357
-				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";
2517
+				if ($this->debug > 1)
2518
+				{
2519
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2520
+				}
2358 2521
 			}
2359 2522
 			$ft_start = $event['end'];
2360 2523
 		}
2361
-		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);
2524
+		if ($this->debug > 0)
2525
+		{
2526
+			$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);
2527
+		}
2362 2528
 
2363 2529
 		return $freetime;
2364 2530
 	}
@@ -2378,10 +2544,16 @@  discard block
 block discarded – undo
2378 2544
 	 */
2379 2545
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2380 2546
 	{
2381
-		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);
2547
+		if ($this->debug > 1)
2548
+		{
2549
+			$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);
2550
+		}
2382 2551
 
2383 2552
 		$freetime_daywise = array();
2384
-		if (!is_array($sel_options)) $sel_options = array();
2553
+		if (!is_array($sel_options))
2554
+		{
2555
+			$sel_options = array();
2556
+		}
2385 2557
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2386 2558
 
2387 2559
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2391,7 +2563,10 @@  discard block
 block discarded – undo
2391 2563
 		if (($end_time - $start_time)*HOUR_s < $duration)
2392 2564
 		{
2393 2565
 			$end_time = 0;
2394
-			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);
2566
+			if ($this->debug > 1)
2567
+			{
2568
+				$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);
2569
+			}
2395 2570
 		}
2396 2571
 		$n = 0;
2397 2572
 		foreach($freetime as $ft)
@@ -2412,13 +2587,19 @@  discard block
 block discarded – undo
2412 2587
 				}
2413 2588
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2414 2589
 
2415
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2590
+				if ($start-$daybegin < $start_time*HOUR_s)
2591
+				{
2592
+					// start earlier then start_time
2416 2593
 				{
2417 2594
 					$start = $daybegin + $start_time*HOUR_s;
2418 2595
 				}
2596
+				}
2419 2597
 				// if end_time given use it, else the original slot's end
2420 2598
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2421
-				if ($end > $ft['end']) $end = $ft['end'];
2599
+				if ($end > $ft['end'])
2600
+				{
2601
+					$end = $ft['end'];
2602
+				}
2422 2603
 
2423 2604
 				// slot to small for duration
2424 2605
 				if ($end - $start < $duration)
@@ -2460,7 +2641,10 @@  discard block
 block discarded – undo
2460 2641
 			{
2461 2642
 				$msg = lang('Permission denied');
2462 2643
 
2463
-				if ($return_error) return $msg;
2644
+				if ($return_error)
2645
+				{
2646
+					return $msg;
2647
+				}
2464 2648
 			}
2465 2649
 			else
2466 2650
 			{
@@ -2532,7 +2716,10 @@  discard block
 block discarded – undo
2532 2716
 					$msg = lang('iCal successful imported').' '.lang('(%1 events in %2 seconds)',
2533 2717
 						$calendar_ical->events_imported,number_format(microtime(true)-$start,1));
2534 2718
 				}
2535
-				if ($f) fclose($f);
2719
+				if ($f)
2720
+				{
2721
+					fclose($f);
2722
+				}
2536 2723
 			}
2537 2724
 			else
2538 2725
 			{
@@ -2562,27 +2749,42 @@  discard block
 block discarded – undo
2562 2749
 		{
2563 2750
 			list($button) = each($_content['button']);
2564 2751
 			unset($_content['button']);
2565
-			if ($button != 'cancel')	// store changed acl
2752
+			if ($button != 'cancel')
2753
+			{
2754
+				// store changed acl
2566 2755
 			{
2567 2756
 				foreach($_content as $data)
2568 2757
 				{
2569 2758
 					if (!($cat_id = $data['cat_id'])) continue;
2759
+			}
2570 2760
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2571 2761
 					{
2572 2762
 						$rights = 0;
2573
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2574
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2575
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2763
+						if (in_array($account_id,(array)$data['add']))
2764
+						{
2765
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2766
+						}
2767
+						if (in_array($account_id,(array)$data['status']))
2768
+						{
2769
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2770
+						}
2771
+						if ($account_id)
2772
+						{
2773
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2774
+						}
2576 2775
 					}
2577 2776
 				}
2578 2777
 			}
2579
-			if ($button != 'apply')	// end dialog
2778
+			if ($button != 'apply')
2779
+			{
2780
+				// end dialog
2580 2781
 			{
2581 2782
 				egw::redirect_link('/index.php', array(
2582 2783
 					'menuaction' => 'admin.admin_ui.index',
2583 2784
 					'ajax' => 'true'
2584 2785
 				), 'admin');
2585 2786
 			}
2787
+			}
2586 2788
 		}
2587 2789
 		$content= $preserv = array();
2588 2790
 		$n = 1;
@@ -2596,8 +2798,14 @@  discard block
 block discarded – undo
2596 2798
 			);
2597 2799
 			foreach($data as $account_id => $rights)
2598 2800
 			{
2599
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2600
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2801
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2802
+				{
2803
+					$row['add'][] = $account_id;
2804
+				}
2805
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2806
+				{
2807
+					$row['status'][] = $account_id;
2808
+				}
2601 2809
 			}
2602 2810
 			$content[$n] = $row;
2603 2811
 			$preserv[$n] = array(
@@ -2741,7 +2949,10 @@  discard block
 block discarded – undo
2741 2949
 					case 'no':
2742 2950
 						break;
2743 2951
 					case 'startday':
2744
-						if ($sameday) break;
2952
+						if ($sameday)
2953
+						{
2954
+							break;
2955
+						}
2745 2956
 					default:
2746 2957
 						$status_reset_to_unknown = true;
2747 2958
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2819,7 +3030,10 @@  discard block
 block discarded – undo
2819 3030
 				{
2820 3031
 					$_results = egw_link::query($data['app'], $query,$options);
2821 3032
 				}
2822
-				if(!$_results) continue;
3033
+				if(!$_results)
3034
+				{
3035
+					continue;
3036
+				}
2823 3037
 				$_results = array_unique($_results);
2824 3038
 
2825 3039
 				foreach($_results as $id => $title)
Please login to merge, or discard this patch.
calendar/inc/class.calendar_uilist.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Constructor
50 50
 	 *
51
-	 * @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST
51
+	 * @param array $set_states to manualy set / change one of the states, default NULL = use $_REQUEST
52 52
 	 */
53 53
 	function __construct($set_states=null)
54 54
 	{
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 * @param int &$success number of succeded actions
543 543
 	 * @param int &$failed number of failed actions (not enought permissions)
544 544
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 events 'deleted'
545
-	 * @param string/array $session_name 'calendar_list'
545
+	 * @param string $session_name 'calendar_list'
546 546
 	 * @return boolean true if all actions succeded, false otherwise
547 547
 	 */
548 548
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @var mixed
34 34
 	 */
35
-	var $debug=false;
35
+	var $debug = false;
36 36
 	/**
37 37
 	 * Filternames
38 38
 	 *
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST
52 52
 	 */
53
-	function __construct($set_states=null)
53
+	function __construct($set_states = null)
54 54
 	{
55
-		parent::__construct(true,$set_states);	// call the parent's constructor
55
+		parent::__construct(true, $set_states); // call the parent's constructor
56 56
 
57 57
 		$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Listview').
58 58
 			// for a single owner we add it's name to the app-header
59
-			(count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : '');
59
+			(count(explode(',', $this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : '');
60 60
 
61
-		foreach($this->date_filters as $name => $label)
61
+		foreach ($this->date_filters as $name => $label)
62 62
 		{
63 63
 			$this->date_filters[$name] = lang($label);
64 64
 		}
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 			'multiple'   => 0,
83 83
 			'view'	   => $this->bo->cal_prefs['mainscreen_showevents'],
84 84
 		));
85
-		egw_session::appsession('calendar_list','calendar','');	// in case there's already something set
85
+		egw_session::appsession('calendar_list', 'calendar', ''); // in case there's already something set
86 86
 
87
-		return $this->listview(null,'',true);
87
+		return $this->listview(null, '', true);
88 88
 	}
89 89
 
90 90
 	/**
91 91
 	 * Show the listview
92 92
 	 */
93
-	function listview($content=null,$msg='',$home=false)
93
+	function listview($content = null, $msg = '', $home = false)
94 94
 	{
95 95
 		if ($_GET['msg']) $msg .= $_GET['msg'];
96 96
 		if ($this->group_warning) $msg .= $this->group_warning;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		$etpl = new etemplate_new('calendar.list');
99 99
 
100 100
 		// Handle merge from sidebox
101
-		if($_GET['merge'])
101
+		if ($_GET['merge'])
102 102
 		{
103 103
 			$content['nm']['action'] = 'document_'.$_GET['merge'];
104 104
 			$content['nm']['select_all'] = true;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		if (is_array($content))
108 108
 		{
109 109
 			// handle a single button like actions
110
-			foreach(array('delete','timesheet','document') as $button)
110
+			foreach (array('delete', 'timesheet', 'document') as $button)
111 111
 			{
112 112
 				if ($content['nm']['rows'][$button])
113 113
 				{
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			if ($content['nm']['action'])
121 121
 			{
122 122
 				// Allow merge using the date range filter
123
-				if(strpos($content['nm']['action'],'document') !== false &&
123
+				if (strpos($content['nm']['action'], 'document') !== false &&
124 124
 					!count($content['nm']['selected']) && !$content['nm']['select_all']) {
125 125
 					$content['nm']['selected'][] = $this->get_merge_range($content['nm']);
126 126
 				}
@@ -130,42 +130,42 @@  discard block
 block discarded – undo
130 130
 				}
131 131
 				else
132 132
 				{
133
-					if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
134
-						$success,$failed,$action_msg,'calendar_list',$msg, $content['nm']['checkboxes']['no_notifications']))
133
+					if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
134
+						$success, $failed, $action_msg, 'calendar_list', $msg, $content['nm']['checkboxes']['no_notifications']))
135 135
 					{
136
-						$msg .= lang('%1 event(s) %2',$success,$action_msg);
136
+						$msg .= lang('%1 event(s) %2', $success, $action_msg);
137 137
 					}
138
-					elseif(is_null($msg))
138
+					elseif (is_null($msg))
139 139
 					{
140
-						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
140
+						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
141 141
 					}
142 142
 				}
143 143
 			}
144 144
 		}
145 145
 		$content = array(
146
-			'nm'  => egw_session::appsession('calendar_list','calendar'),
146
+			'nm'  => egw_session::appsession('calendar_list', 'calendar'),
147 147
 		);
148 148
 		if (!is_array($content['nm']))
149 149
 		{
150 150
 			$content['nm'] = array(
151 151
 				'get_rows'        =>	'calendar.calendar_uilist.get_rows',
152
-	 			'filter_no_lang'  => True,	// I  set no_lang for filter (=dont translate the options)
153
-				'no_filter2'      => True,	// I  disable the 2. filter (params are the same as for filter)
154
-				'no_cat'          => True,	// I  disable the cat-selectbox
152
+	 			'filter_no_lang'  => True, // I  set no_lang for filter (=dont translate the options)
153
+				'no_filter2'      => True, // I  disable the 2. filter (params are the same as for filter)
154
+				'no_cat'          => True, // I  disable the cat-selectbox
155 155
 				'filter'          => 'after',
156
-				'order'           => 'cal_start',// IO name of the column to sort after (optional for the sortheaders)
157
-				'sort'            => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
156
+				'order'           => 'cal_start', // IO name of the column to sort after (optional for the sortheaders)
157
+				'sort'            => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
158 158
 				'default_cols'    => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id',
159 159
 				'filter_onchange' => "app.calendar.filter_change",
160 160
 				'header_left'     => 'calendar.list.dates',
161
-				'row_id'          => 'row_id',	// set in get rows "$event[id]:$event[recur_date]"
161
+				'row_id'          => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
162 162
 				'row_modified'    => 'modified',
163 163
 				'favorites'       => true
164 164
 			);
165 165
 		}
166 166
 		$content['nm']['actions'] = $this->get_actions();
167 167
 
168
-		if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters)))
168
+		if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters)))
169 169
 		{
170 170
 			$content['nm']['filter'] = $_GET['filter'];
171 171
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) &&
178 178
 			!empty($json_data['request']['parameters'][0]))
179 179
 		{
180
-			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
180
+			parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
181 181
 			if (isset($params['keywords']))	// new search => set filters so every match is shown
182 182
 			{
183 183
 				$this->adjust_for_search($params['keywords'], $content['nm']);
@@ -185,22 +185,22 @@  discard block
 block discarded – undo
185 185
 		}
186 186
 		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
187 187
 		{
188
-			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
188
+			$this->adjust_for_search($_REQUEST['keywords'], $content['nm']);
189 189
 		}
190 190
 		$sel_options['filter'] = &$this->date_filters;
191 191
 
192 192
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
193
-		$sel_options['category'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,calendar',$no_lang,false,$value['cat_id']);
193
+		$sel_options['category'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,calendar', $no_lang, false, $value['cat_id']);
194 194
 		// Prevent double encoding - widget does this on its own, but we're just grabbing the options
195
-		foreach($sel_options['category'] as &$label)
195
+		foreach ($sel_options['category'] as &$label)
196 196
 		{
197
-			if(!is_array($label))
197
+			if (!is_array($label))
198 198
 			{
199
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
199
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
200 200
 			}
201
-			elseif($label['label'])
201
+			elseif ($label['label'])
202 202
 			{
203
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
203
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
204 204
 			}
205 205
 		}
206 206
 
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 		if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '')
209 209
 		{
210 210
 			$content['css'] .= '<style type="text/css">@media screen { .listDescription {  max-height: '.
211
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	   // dono why em is not real lines
211
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
212 212
 				'em; overflow: auto; }}</style>';
213 213
 		}
214 214
 
215
-		if($msg)
215
+		if ($msg)
216 216
 		{
217 217
 			egw_framework::message($msg);
218 218
 		}
219
-		$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,$readonlys,array(),$home ? -1 : 0);
219
+		$html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, $readonlys, array(), $home ? -1 : 0);
220 220
 
221 221
 		// Not sure why this has to be echoed instead of appended, but that's what works.
222 222
 		//echo calendar_uiviews::edit_series();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	/**
228 228
 	 * set filter for search, so that everything is shown
229 229
 	 */
230
-	function adjust_for_search($keywords,&$params)
230
+	function adjust_for_search($keywords, &$params)
231 231
 	{
232 232
 		$params['search'] = $keywords;
233 233
 		$params['start']  = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @param array &$rows returned rows/events
254 254
 	 * @param array &$readonlys eg. to disable buttons based on acl
255 255
 	 */
256
-	function get_rows(&$params,&$rows,&$readonlys)
256
+	function get_rows(&$params, &$rows, &$readonlys)
257 257
 	{
258 258
 		//echo "uilist::get_rows() params="; _debug_array($params);
259 259
 		if (isset($_GET['listview_days']) && is_numeric($_GET['listview_days']))
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				$this->manage_states(array('date' => $this->bo->date2string($params['startdate'])));
278 278
 			}
279 279
 		}
280
-		$old_params = egw_session::appsession('calendar_list','calendar');
280
+		$old_params = egw_session::appsession('calendar_list', 'calendar');
281 281
 		if (is_array($old_params))
282 282
 		{
283 283
 			if ($old_params['filter'] && $old_params['filter'] != $params['filter'])	// filter changed => order accordingly
@@ -287,58 +287,58 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 			if ($old_params['search'] != $params['search'])
289 289
 			{
290
-				$this->adjust_for_search($params['search'],$params);
290
+				$this->adjust_for_search($params['search'], $params);
291 291
 			}
292 292
 		}
293
-		if (!$params['csv_export']) egw_session::appsession('calendar_list','calendar',$params);
293
+		if (!$params['csv_export']) egw_session::appsession('calendar_list', 'calendar', $params);
294 294
 
295 295
 		// do we need to query custom fields and which
296 296
 		// Check stored preference if selectcols isn't available (ie: first call)
297 297
 		$select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows'];
298
-		if(!is_array($params['selectcols']))
298
+		if (!is_array($params['selectcols']))
299 299
 		{
300
-			$select_cols = explode(',',$select_cols);
300
+			$select_cols = explode(',', $select_cols);
301 301
 		}
302
-		if (in_array('cfs',$select_cols))
302
+		if (in_array('cfs', $select_cols))
303 303
 		{
304 304
 			$cfs = array();
305
-			foreach($select_cols as $col)
305
+			foreach ($select_cols as $col)
306 306
 			{
307
-				if ($col[0] == '#') $cfs[] = substr($col,1);
307
+				if ($col[0] == '#') $cfs[] = substr($col, 1);
308 308
 			}
309 309
 		}
310 310
 		$search_params = array(
311
-			'cat_id'  => $this->cat_id ? explode(',',$this->cat_id) : 0,
311
+			'cat_id'  => $this->cat_id ? explode(',', $this->cat_id) : 0,
312 312
 			'filter'  => $this->filter,
313 313
 			'query'   => $params['search'],
314
-			'offset'  => (int) $params['start'],
314
+			'offset'  => (int)$params['start'],
315 315
 			'num_rows'=> $params['num_rows'],
316 316
 			'order'   => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start',
317 317
 			'cfs'	 => $params['csv_export'] ? array() : $cfs,
318 318
 		);
319
-		switch($params['filter'])
319
+		switch ($params['filter'])
320 320
 		{
321 321
 			case 'all':
322 322
 				break;
323 323
 			case 'before':
324 324
 				$search_params['end'] = $this->date;
325
-				$label = lang('Before %1',$this->bo->long_date($this->date));
325
+				$label = lang('Before %1', $this->bo->long_date($this->date));
326 326
 				break;
327 327
 			case 'custom':
328 328
 				$this->first = $search_params['start'] = $params['startdate'];
329
-				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
330
-				$label = $this->bo->long_date($this->first,$this->last);
329
+				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1;
330
+				$label = $this->bo->long_date($this->first, $this->last);
331 331
 				break;
332 332
 			case 'fixed':
333 333
 				if ($this->listview_days == 5 || $this->listview_days == 7)	// weekview
334 334
 				{
335
-					$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
335
+					$this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day);
336 336
 					$this->last = $this->bo->date2array($this->first);
337
-					$this->last['day'] += (int) $this->listview_days - 1;
337
+					$this->last['day'] += (int)$this->listview_days - 1;
338 338
 					$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
339 339
 					unset($this->last['raw']);
340 340
 					$this->last = $this->bo->date2ts($this->last);
341
-					$this->date_filters['fixed'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
341
+					$this->date_filters['fixed'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last);
342 342
 					$params['startdate'] = $search_params['start'] = $this->first;
343 343
 					$params['enddate'] = $search_params['end'] = $this->last;
344 344
 					break;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 					$this->first = $this->bo->date2ts($this->first);
354 354
 					$this->last = $this->bo->date2ts($this->last);
355 355
 					$this->last--;
356
-					$this->date_filters['fixed'] = $label = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
356
+					$this->date_filters['fixed'] = $label = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year;
357 357
 					$params['startdate'] = $search_params['start'] = $this->first;
358 358
 					$params['enddate'] = $search_params['end'] = $this->last;
359 359
 					break;
@@ -361,24 +361,24 @@  discard block
 block discarded – undo
361 361
 				// fall through to after given date
362 362
 			case 'after':
363 363
 			default:
364
-				$label = lang('After %1',$this->bo->long_date($this->date));
364
+				$label = lang('After %1', $this->bo->long_date($this->date));
365 365
 				$search_params['start'] = $this->date;
366 366
 				break;
367 367
 		}
368
-		if ((int) $params['col_filter']['participant'])
368
+		if ((int)$params['col_filter']['participant'])
369 369
 		{
370
-			$search_params['users'] = (int) $params['col_filter']['participant'];
370
+			$search_params['users'] = (int)$params['col_filter']['participant'];
371 371
 		}
372
-		elseif(empty($params['search']))	// active search displays entries from all users
372
+		elseif (empty($params['search']))	// active search displays entries from all users
373 373
 		{
374
-			$search_params['users'] = explode(',',$this->owner);
374
+			$search_params['users'] = explode(',', $this->owner);
375 375
 		}
376 376
 		if ($params['col_filter'])
377 377
 		{
378 378
 			$col_filter = array();
379
-			foreach($params['col_filter'] as $name => $val)
379
+			foreach ($params['col_filter'] as $name => $val)
380 380
 			{
381
-				if (!in_array($name, array('participant','row_id')) && (string)$val !== '')
381
+				if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '')
382 382
 				{
383 383
 					$col_filter[$name] = $val;
384 384
 				}
@@ -392,15 +392,15 @@  discard block
 block discarded – undo
392 392
 			$rows['sel_options']['filter'] = $this->date_filters;
393 393
 			$rows['sel_options']['filter'][$params['filter']] = $label;
394 394
 		}
395
-		foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
395
+		foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
396 396
 		{
397
-			if (!$this->bo->check_perms(EGW_ACL_EDIT,$event))
397
+			if (!$this->bo->check_perms(EGW_ACL_EDIT, $event))
398 398
 			{
399 399
 				$event['class'] .= 'rowNoEdit ';
400 400
 			}
401 401
 
402 402
 			// Delete disabled for other applications
403
-			if (!$this->bo->check_perms(EGW_ACL_DELETE,$event) || !is_numeric($event['id']))
403
+			if (!$this->bo->check_perms(EGW_ACL_DELETE, $event) || !is_numeric($event['id']))
404 404
 			{
405 405
 				$event['class'] .= 'rowNoDelete ';
406 406
 			}
@@ -414,39 +414,39 @@  discard block
 block discarded – undo
414 414
 			$event['recure'] = $this->bo->recure2string($event);
415 415
 			if ($params['csv_export'])
416 416
 			{
417
-				$event['participants'] = implode(",\n",$this->bo->participants($event,true));
417
+				$event['participants'] = implode(",\n", $this->bo->participants($event, true));
418 418
 			}
419 419
 			else
420 420
 			{
421
-				$event['parts'] = implode(",\n",$this->bo->participants($event,true));
421
+				$event['parts'] = implode(",\n", $this->bo->participants($event, true));
422 422
 				$event['date'] = $this->bo->date2string($event['start']);
423 423
 			}
424
-			if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
425
-			if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
424
+			if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment
425
+			if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment
426 426
 
427 427
 			// respect category permissions
428
-			if(!empty($event['category']))
428
+			if (!empty($event['category']))
429 429
 			{
430 430
 				$event['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']);
431 431
 			}
432 432
 
433
-			if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
433
+			if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
434 434
 			{
435 435
 				$app = $matches[1];
436 436
 				$app_id = $matches[2];
437 437
 				$icons = array();
438
-				if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
438
+				if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
439 439
 				{
440
-					$icons[] = html::image('calendar','private');
440
+					$icons[] = html::image('calendar', 'private');
441 441
 				}
442 442
 				else
443 443
 				{
444
-					$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
444
+					$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
445 445
 				}
446 446
 			}
447 447
 			else
448 448
 			{
449
-				$is_private = !$this->bo->check_perms(EGW_ACL_READ,$event);
449
+				$is_private = !$this->bo->check_perms(EGW_ACL_READ, $event);
450 450
 			}
451 451
 			if ($is_private)
452 452
 			{
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 			$event['app_id'] = $event['id'];
458 458
 
459 459
 			// Edit link
460
-			if($app && $app_id)
460
+			if ($app && $app_id)
461 461
 			{
462
-				$popup = calendar_uiviews::integration_get_popup($app,$app_id);
462
+				$popup = calendar_uiviews::integration_get_popup($app, $app_id);
463 463
 
464 464
 				// Need to strip off 'onclick'
465 465
 				$event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup);
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 				// populate js_integration_data, if not already set
471 471
 				if (!isset($js_integration_data[$app]))
472 472
 				{
473
-					$js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link');
473
+					$js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link');
474 474
 					if (!is_array($js_integration_data[$app]) || !isset($js_integration_data[$app]['edit']))
475 475
 					{
476 476
 						$js_integration_data[$app]['edit'] = egw_link::get_registry($app, 'edit');
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 			}
487 487
 			else
488 488
 			{
489
-				$view_link = egw::link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
489
+				$view_link = egw::link('/index.php', array('menuaction'=>'calendar.calendar_uiforms.edit', 'cal_id'=>$event['id'], 'date'=>$this->bo->date2string($event['start'])));
490 490
 				$event['edit_link'] = $this->popup($view_link).'; return false;';
491 491
 			}
492 492
 
@@ -494,9 +494,9 @@  discard block
 block discarded – undo
494 494
 			$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.$event['recur_date'] : '');
495 495
 
496 496
 			// Format start and end with timezone
497
-			foreach(array('start','end') as $time)
497
+			foreach (array('start', 'end') as $time)
498 498
 			{
499
-				$event[$time] = egw_time::to($event[$time],'Y-m-d\TH:i:s\Z');
499
+				$event[$time] = egw_time::to($event[$time], 'Y-m-d\TH:i:s\Z');
500 500
 			}
501 501
 
502 502
 			$rows[] = $event;
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 		// set js_calendar_integration object, to use it in app.js cal_open() function
507 507
 		$params['js_integration_data'] = json_encode($js_integration_data);
508 508
 
509
-		$wv=0;
510
-		$dv=0;
509
+		$wv = 0;
510
+		$dv = 0;
511 511
 		$params['options-selectcols']['week'] = lang('Week');
512 512
 		$params['options-selectcols']['weekday'] = lang('Weekday');
513
-		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,')
513
+		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,')
514 514
 		{
515
-			$rows['format'] = '32';	// prefix date with week-number
516
-			$wv=1;
515
+			$rows['format'] = '32'; // prefix date with week-number
516
+			$wv = 1;
517 517
 		}
518
-		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE))
518
+		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE))
519 519
 		{
520 520
 			$rows['format'] = '16';
521
-			$dv=1;
521
+			$dv = 1;
522 522
 		}
523 523
 		if ($wv && $dv)
524 524
 		{
@@ -545,35 +545,35 @@  discard block
 block discarded – undo
545 545
 	 * @param string/array $session_name 'calendar_list'
546 546
 	 * @return boolean true if all actions succeded, false otherwise
547 547
 	 */
548
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
548
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false)
549 549
 	{
550 550
 		//error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
551 551
 		$success = $failed = 0;
552 552
 		$msg = null;
553 553
 
554 554
 		// Split out combined values
555
-		if(strpos($action, 'status') !== false)
555
+		if (strpos($action, 'status') !== false)
556 556
 		{
557 557
 			list($action, $status) = explode('-', $action);
558 558
 		}
559 559
 		elseif (strpos($action, '_') !== false)
560 560
 		{
561
-			list($action, $settings) = explode('_', $action,2);
561
+			list($action, $settings) = explode('_', $action, 2);
562 562
 		}
563 563
 
564 564
 		if ($use_all)
565 565
 		{
566 566
 			// get the whole selection
567
-			$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar');
568
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
569
-			$query['num_rows'] = -1;		// all
570
-			$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document')));	   // true = only return the id's
567
+			$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name, 'calendar');
568
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
569
+			$query['num_rows'] = -1; // all
570
+			$this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's
571 571
 			// Get rid of any extras (rows that aren't events)
572
-			if(in_array($action,array('ical','document')))
572
+			if (in_array($action, array('ical', 'document')))
573 573
 			{
574
-				foreach($checked as $key => $event)
574
+				foreach ($checked as $key => $event)
575 575
 				{
576
-					if(!is_numeric($key))
576
+					if (!is_numeric($key))
577 577
 					{
578 578
 						unset($checked[$key]);
579 579
 					}
@@ -581,26 +581,26 @@  discard block
 block discarded – undo
581 581
 			}
582 582
 		}
583 583
 		// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
584
-		elseif($action == 'document')
584
+		elseif ($action == 'document')
585 585
 		{
586
-			$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar');
587
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
588
-			$this->get_rows($query,$events,$readonlys);
589
-			foreach($events as $key => $event)
586
+			$query = is_array($session_name) ? $session_name : egw_session::appsession($session_name, 'calendar');
587
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
588
+			$this->get_rows($query, $events, $readonlys);
589
+			foreach ($events as $key => $event)
590 590
 			{
591
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
591
+				if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
592 592
 			}
593 593
 			$checked = array_values($events); // Clear keys
594 594
 		}
595 595
 
596 596
 		// Actions where one action is done to the group
597
-		switch($action)
597
+		switch ($action)
598 598
 		{
599 599
 			case 'ical':
600 600
 				// compile list of unique cal_id's, as iCal should contain whole series, not recurrences
601 601
 				// calendar_ical->exportVCal needs to read events again, to get them in server-time
602 602
 				$ids = array();
603
-				foreach($checked as $id)
603
+				foreach ($checked as $id)
604 604
 				{
605 605
 					if (is_array($id)) $id = $id['id'];
606 606
 					// get rid of recurrences, doublicate series and calendar-integration events
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 					}
611 611
 				}
612 612
 				$boical = new calendar_ical();
613
-				$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
613
+				$ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH');
614 614
 				html::content_header('event.ics', 'text/calendar', bytes($ical));
615 615
 				echo $ical;
616 616
 				common::egw_exit();
@@ -624,18 +624,18 @@  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
-			if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
638
+			if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches))
639 639
 			{
640 640
 				$app = $matches[1];
641 641
 				$app_id = $matches[2];
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
 			}
644 644
 			else
645 645
 			{
646
-				list($id,$recur_date) = explode(':',$id);
646
+				list($id, $recur_date) = explode(':', $id);
647 647
 			}
648
-			switch($action)
648
+			switch ($action)
649 649
 			{
650 650
 				case 'delete':
651 651
 					$action_msg = lang('deleted');
652
-					if($settings == 'series')
652
+					if ($settings == 'series')
653 653
 					{
654 654
 						// Delete the whole thing
655 655
 						$recur_date = 0;
656 656
 					}
657
-					if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
657
+					if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification))
658 658
 					{
659 659
 						$success++;
660
-						if(!$recur_date && $settings == 'series')
660
+						if (!$recur_date && $settings == 'series')
661 661
 						{
662 662
 							// If there are multiple events in a series selected, the next one could purge
663
-							foreach($checked as $key => $c_id)
663
+							foreach ($checked as $key => $c_id)
664 664
 							{
665
-								list($c_id,$recur_date) = explode(':',$c_id);
666
-								if($c_id == $id)
665
+								list($c_id, $recur_date) = explode(':', $c_id);
666
+								if ($c_id == $id)
667 667
 								{
668 668
 									unset($checked[$key]);
669 669
 								}
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
 					break;
678 678
 				case 'undelete':
679 679
 					$action_msg = lang('recovered');
680
-					if($settings == 'series')
680
+					if ($settings == 'series')
681 681
 					{
682 682
 						// unDelete the whole thing
683 683
 						$recur_date = 0;
684 684
 					}
685
-					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) &&
685
+					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT, $id) &&
686 686
 						is_array($event) && $event['deleted'])
687 687
 					{
688 688
 						$event['deleted'] = null;
689
-						if($this->bo->save($event))
689
+						if ($this->bo->save($event))
690 690
 						{
691 691
 							$success++;
692 692
 							break;
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 					break;
697 697
 				case 'status':
698 698
 					$action_msg = lang('Status changed');
699
-					if($id && ($event = $this->bo->read($id, $recur_date)))
699
+					if ($id && ($event = $this->bo->read($id, $recur_date)))
700 700
 					{
701 701
 						$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
702 702
 						calendar_so::split_status($old_status, $quantity, $role);
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 						{
705 705
 							//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
706 706
 							$new_status = calendar_so::combine_status($status, $quantity, $role);
707
-							if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
708
-								false,true,$skip_notification))
707
+							if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date,
708
+								false, true, $skip_notification))
709 709
 							{
710 710
 								$success++;
711 711
 								//$msg = lang('Status changed');
@@ -722,19 +722,19 @@  discard block
 block discarded – undo
722 722
 					}
723 723
 					break;
724 724
 				case 'timesheet-add':
725
-					if($id && !$app)
725
+					if ($id && !$app)
726 726
 					{
727 727
 						$event = $this->bo->read($id, $recur_date);
728 728
 					}
729 729
 					elseif ($app)
730 730
 					{
731
-						$query = egw_session::appsession('calendar_list','calendar');
731
+						$query = egw_session::appsession('calendar_list', 'calendar');
732 732
 						$query['query'] = $app_id;
733 733
 						$query['search'] = $app_id;
734 734
 						$result = $this->bo->search($query);
735 735
 						$event = $result[$app.$app_id];
736 736
 					}
737
-					if(!$event)
737
+					if (!$event)
738 738
 					{
739 739
 						$failed++;
740 740
 						continue;
@@ -751,16 +751,16 @@  discard block
 block discarded – undo
751 751
 					);
752 752
 
753 753
 					// Add global categories
754
-					$categories = explode(',',$event['category']);
754
+					$categories = explode(',', $event['category']);
755 755
 					$global_categories = array();
756
-					foreach($categories as $cat_id)
756
+					foreach ($categories as $cat_id)
757 757
 					{
758
-						if($GLOBALS['egw']->categories->is_global($cat_id))
758
+						if ($GLOBALS['egw']->categories->is_global($cat_id))
759 759
 						{
760 760
 							$global_categories[] = $cat_id;
761 761
 						}
762 762
 					}
763
-					if(count($global_categories))
763
+					if (count($global_categories))
764 764
 					{
765 765
 						$timesheet['cat_id'] = implode(',', $global_categories);
766 766
 					}
@@ -780,12 +780,12 @@  discard block
 block discarded – undo
780 780
 						}
781 781
 					}
782 782
 
783
-					if(!$err)
783
+					if (!$err)
784 784
 					{
785 785
 						$success++;
786 786
 
787 787
 						// Can't link to just one of a recurring series of events
788
-						if(!$recur_date || $app) {
788
+						if (!$recur_date || $app) {
789 789
 							// Create link
790 790
 							$link_id = $app ? $app_id : $id;
791 791
 							egw_link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	protected function get_merge_range($nm)
814 814
 	{
815 815
 		$checked = array();
816
-		if($nm['filter'] == 'fixed')
816
+		if ($nm['filter'] == 'fixed')
817 817
 		{
818 818
 			$checked['start'] = $nm['startdate'];
819 819
 			$last = $this->bo->date2array($nm['enddate']);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		}
823 823
 		else
824 824
 		{
825
-			switch($nm['filter'])
825
+			switch ($nm['filter'])
826 826
 			{
827 827
 				case 'after':
828 828
 					$checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today');
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 					$checked['end'] = $nm['enddate'];
836 836
 					break;
837 837
 				default:
838
-					$date = date_create_from_format('Ymd',$this->date);
839
-					$checked['start']= $date->format('U');
838
+					$date = date_create_from_format('Ymd', $this->date);
839
+					$checked['start'] = $date->format('U');
840 840
 			}
841 841
 		}
842 842
 		return $checked;
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 				'allowOnMultiple' => false,
861 861
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
862 862
 				'popup' => egw_link::get_registry('calendar', 'view_popup'),
863
-				'group' => $group=1,
863
+				'group' => $group = 1,
864 864
 				'onExecute' => 'javaScript:app.calendar.cal_open',
865 865
 				'disableClass' => 'rowNoView',
866 866
 			),
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 				'group' => $group,
886 886
 			),
887 887
 		);
888
-		$status = array_map('lang',$this->bo->verbose_status);
888
+		$status = array_map('lang', $this->bo->verbose_status);
889 889
 		unset($status['G']);
890 890
 		$actions['status'] = array(
891 891
 			'caption' => 'Change your status',
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 			'children' => $status,
895 895
 			'group' => ++$group,
896 896
 		);
897
-		++$group;	// integration with other apps: infolog, calendar, filemanager
897
+		++$group; // integration with other apps: infolog, calendar, filemanager
898 898
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
899 899
 		{
900 900
 			$actions['filemanager'] = array(
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id',
927 927
 				'group' => $group,
928 928
 				'allowOnMultiple' => false,
929
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
929
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
930 930
 				'onExecute' => 'javaScript:app.calendar.cal_fix_app_id',
931 931
 				'popup' => egw_link::get_registry('timesheet', 'add_popup'),
932 932
 			);
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 				'caption' => 'Timesheet',
936 936
 				'group' => $group,
937 937
 				'allowOnMultiple' => 'only',
938
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
938
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
939 939
 			);
940 940
 		}
941 941
 		$actions['ical'] = array(
@@ -944,11 +944,11 @@  discard block
 block discarded – undo
944 944
 			'group' => ++$group,
945 945
 			'hint' => 'Download this event as iCal',
946 946
 			'disableClass' => 'rowNoView',
947
-			'postSubmit' => true,	// download needs post submit (not Ajax) to work
947
+			'postSubmit' => true, // download needs post submit (not Ajax) to work
948 948
 		);
949 949
 		$actions['documents'] = calendar_merge::document_action(
950 950
 			$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
951
-			$this->bo->cal_prefs['default_document'],bo_merge::getExportLimit('calendar')
951
+			$this->bo->cal_prefs['default_document'], bo_merge::getExportLimit('calendar')
952 952
 		);
953 953
 		++$group;
954 954
 		$actions['delete'] = array(
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			'disableClass' => 'rowNoDelete',
959 959
 		);
960 960
 		// Add in deleted for admins
961
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
961
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
962 962
 		{
963 963
 			$actions['undelete'] = array(
964 964
 				'caption' => 'Un-delete',
Please login to merge, or discard this patch.
Braces   +70 added lines, -18 removed lines patch added patch discarded remove patch
@@ -92,8 +92,14 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	function listview($content=null,$msg='',$home=false)
94 94
 	{
95
-		if ($_GET['msg']) $msg .= $_GET['msg'];
96
-		if ($this->group_warning) $msg .= $this->group_warning;
95
+		if ($_GET['msg'])
96
+		{
97
+			$msg .= $_GET['msg'];
98
+		}
99
+		if ($this->group_warning)
100
+		{
101
+			$msg .= $this->group_warning;
102
+		}
97 103
 
98 104
 		$etpl = new etemplate_new('calendar.list');
99 105
 
@@ -121,7 +127,8 @@  discard block
 block discarded – undo
121 127
 			{
122 128
 				// Allow merge using the date range filter
123 129
 				if(strpos($content['nm']['action'],'document') !== false &&
124
-					!count($content['nm']['selected']) && !$content['nm']['select_all']) {
130
+					!count($content['nm']['selected']) && !$content['nm']['select_all'])
131
+				{
125 132
 					$content['nm']['selected'][] = $this->get_merge_range($content['nm']);
126 133
 				}
127 134
 				if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
@@ -178,15 +185,21 @@  discard block
 block discarded – undo
178 185
 			!empty($json_data['request']['parameters'][0]))
179 186
 		{
180 187
 			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
181
-			if (isset($params['keywords']))	// new search => set filters so every match is shown
188
+			if (isset($params['keywords']))
189
+			{
190
+				// new search => set filters so every match is shown
182 191
 			{
183 192
 				$this->adjust_for_search($params['keywords'], $content['nm']);
184 193
 			}
194
+			}
185 195
 		}
186
-		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
196
+		if (isset($_REQUEST['keywords']))
197
+		{
198
+			// new search => set filters so every match is shown
187 199
 		{
188 200
 			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
189 201
 		}
202
+		}
190 203
 		$sel_options['filter'] = &$this->date_filters;
191 204
 
192 205
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
@@ -280,9 +293,12 @@  discard block
 block discarded – undo
280 293
 		$old_params = egw_session::appsession('calendar_list','calendar');
281 294
 		if (is_array($old_params))
282 295
 		{
283
-			if ($old_params['filter'] && $old_params['filter'] != $params['filter'])	// filter changed => order accordingly
296
+			if ($old_params['filter'] && $old_params['filter'] != $params['filter'])
297
+			{
298
+				// filter changed => order accordingly
284 299
 			{
285 300
 				$params['order'] = 'cal_start';
301
+			}
286 302
 				$params['sort'] = $params['filter'] == 'after' ? 'ASC' : 'DESC';
287 303
 			}
288 304
 			if ($old_params['search'] != $params['search'])
@@ -290,7 +306,10 @@  discard block
 block discarded – undo
290 306
 				$this->adjust_for_search($params['search'],$params);
291 307
 			}
292 308
 		}
293
-		if (!$params['csv_export']) egw_session::appsession('calendar_list','calendar',$params);
309
+		if (!$params['csv_export'])
310
+		{
311
+			egw_session::appsession('calendar_list','calendar',$params);
312
+		}
294 313
 
295 314
 		// do we need to query custom fields and which
296 315
 		// Check stored preference if selectcols isn't available (ie: first call)
@@ -304,7 +323,10 @@  discard block
 block discarded – undo
304 323
 			$cfs = array();
305 324
 			foreach($select_cols as $col)
306 325
 			{
307
-				if ($col[0] == '#') $cfs[] = substr($col,1);
326
+				if ($col[0] == '#')
327
+				{
328
+					$cfs[] = substr($col,1);
329
+				}
308 330
 			}
309 331
 		}
310 332
 		$search_params = array(
@@ -330,9 +352,12 @@  discard block
 block discarded – undo
330 352
 				$label = $this->bo->long_date($this->first,$this->last);
331 353
 				break;
332 354
 			case 'fixed':
333
-				if ($this->listview_days == 5 || $this->listview_days == 7)	// weekview
355
+				if ($this->listview_days == 5 || $this->listview_days == 7)
356
+				{
357
+					// weekview
334 358
 				{
335 359
 					$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
360
+				}
336 361
 					$this->last = $this->bo->date2array($this->first);
337 362
 					$this->last['day'] += (int) $this->listview_days - 1;
338 363
 					$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
@@ -343,9 +368,12 @@  discard block
 block discarded – undo
343 368
 					$params['enddate'] = $search_params['end'] = $this->last;
344 369
 					break;
345 370
 				}
346
-				elseif ((string)$this->listview_days === '0')	// monthview
371
+				elseif ((string)$this->listview_days === '0')
372
+				{
373
+					// monthview
347 374
 				{
348 375
 					$this->first = $this->bo->date2array($this->date);
376
+				}
349 377
 					$this->first['day'] = 1;
350 378
 					unset($this->first['raw']);
351 379
 					$this->last = $this->first;
@@ -369,10 +397,13 @@  discard block
 block discarded – undo
369 397
 		{
370 398
 			$search_params['users'] = (int) $params['col_filter']['participant'];
371 399
 		}
372
-		elseif(empty($params['search']))	// active search displays entries from all users
400
+		elseif(empty($params['search']))
401
+		{
402
+			// active search displays entries from all users
373 403
 		{
374 404
 			$search_params['users'] = explode(',',$this->owner);
375 405
 		}
406
+		}
376 407
 		if ($params['col_filter'])
377 408
 		{
378 409
 			$col_filter = array();
@@ -421,8 +452,16 @@  discard block
 block discarded – undo
421 452
 				$event['parts'] = implode(",\n",$this->bo->participants($event,true));
422 453
 				$event['date'] = $this->bo->date2string($event['start']);
423 454
 			}
424
-			if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
425
-			if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
455
+			if (empty($event['description']))
456
+			{
457
+				$event['description'] = ' ';
458
+			}
459
+			// no description screws the titles horz. alignment
460
+			if (empty($event['location']))
461
+			{
462
+				$event['location'] = ' ';
463
+			}
464
+			// no location screws the owner horz. alignment
426 465
 
427 466
 			// respect category permissions
428 467
 			if(!empty($event['category']))
@@ -524,7 +563,10 @@  discard block
 block discarded – undo
524 563
 		{
525 564
 			$rows['format'] = '64';
526 565
 		}
527
-		if ($this->cat_id) $rows['no_cat_id'] = true;
566
+		if ($this->cat_id)
567
+		{
568
+			$rows['no_cat_id'] = true;
569
+		}
528 570
 		if (!$GLOBALS['egw_info']['user']['apps']['projectmanager'])
529 571
 		{
530 572
 			$params['options-selectcols']['pm_id'] = false;
@@ -588,7 +630,10 @@  discard block
 block discarded – undo
588 630
 			$this->get_rows($query,$events,$readonlys);
589 631
 			foreach($events as $key => $event)
590 632
 			{
591
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
633
+				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked))
634
+				{
635
+					unset($events[$key]);
636
+				}
592 637
 			}
593 638
 			$checked = array_values($events); // Clear keys
594 639
 		}
@@ -602,7 +647,10 @@  discard block
 block discarded – undo
602 647
 				$ids = array();
603 648
 				foreach($checked as $id)
604 649
 				{
605
-					if (is_array($id)) $id = $id['id'];
650
+					if (is_array($id))
651
+					{
652
+						$id = $id['id'];
653
+					}
606 654
 					// get rid of recurrences, doublicate series and calendar-integration events
607 655
 					if (($id = (int)$id))
608 656
 					{
@@ -616,7 +664,10 @@  discard block
 block discarded – undo
616 664
 				common::egw_exit();
617 665
 
618 666
 			case 'document':
619
-				if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];
667
+				if (!$settings)
668
+				{
669
+					$settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];
670
+				}
620 671
 				$document_merge = new calendar_merge();
621 672
 				$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
622 673
 				$failed = count($checked);
@@ -785,7 +836,8 @@  discard block
 block discarded – undo
785 836
 						$success++;
786 837
 
787 838
 						// Can't link to just one of a recurring series of events
788
-						if(!$recur_date || $app) {
839
+						if(!$recur_date || $app)
840
+						{
789 841
 							// Create link
790 842
 							$link_id = $app ? $app_id : $id;
791 843
 							egw_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 4 patches
Doc Comments   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -713,6 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @param int &$first timestamp 0h of first day of week containing the first of the current month
714 714
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
715 715
 	 * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
716
+	 * @param integer $first
717
+	 * @param integer $last
716 718
 	 */
717 719
 	function _week_align_month(&$first,&$last,$day=1)
718 720
 	{
@@ -741,6 +743,8 @@  discard block
 block discarded – undo
741 743
 	 *
742 744
 	 * @param int &$first timestamp 0h of first day of week containing the first of the current year
743 745
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current year
746
+	 * @param integer $first
747
+	 * @param integer $last
744 748
 	 */
745 749
 	function _month_align_year(&$first,&$last)
746 750
 	{
@@ -1029,7 +1033,7 @@  discard block
 block discarded – undo
1029 1033
 	 *
1030 1034
 	 * @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all
1031 1035
 	 *	On return $todo_label contains the label for the todo-box
1032
-	 * @return string/boolean html with a table of open todo's or false if no hook availible
1036
+	 * @return string html with a table of open todo's or false if no hook availible
1033 1037
 	 */
1034 1038
 	function get_todos(&$todo_label)
1035 1039
 	{
@@ -1580,6 +1584,7 @@  discard block
 block discarded – undo
1580 1584
 	 * @param int $width width of the widget
1581 1585
 	 * @param string $indent string for correct indention
1582 1586
 	 * @param int $owner owner of the eventCol
1587
+	 * @param double $z_index
1583 1588
 	 */
1584 1589
 	function eventColWidget($events,$left,$width,$indent,$owner,$z_index=null)
1585 1590
 	{
@@ -1607,7 +1612,7 @@  discard block
 block discarded – undo
1607 1612
 	 * The display of the event and it's tooltip is done via the event_widget.tpl template
1608 1613
 	 *
1609 1614
 	 * @param $event array with the data of event to show
1610
-	 * @param $width int width of the widget
1615
+	 * @param integer $width int width of the widget
1611 1616
 	 * @param string $indent string for correct indention
1612 1617
 	 * @param int $owner owner of the calendar the event is in
1613 1618
 	 * @param boolean $return_array = false should an array with keys(tooltip,popup,html) be returned or the complete widget as string
@@ -1921,7 +1926,7 @@  discard block
 block discarded – undo
1921 1926
 	 * - 'edit_popup' => '400x300' (optional)
1922 1927
 	 *
1923 1928
 	 * @param string $app
1924
-	 * @param int|string $id
1929
+	 * @param string $id
1925 1930
 	 * @return string
1926 1931
 	 */
1927 1932
 	function integration_get_popup($app,$id)
@@ -1963,7 +1968,7 @@  discard block
 block discarded – undo
1963 1968
 	 * Icons specified in $events['icons'] are always displayed!
1964 1969
 	 *
1965 1970
 	 * @param string $app
1966
-	 * @param int|string $id
1971
+	 * @param string $id
1967 1972
 	 * @param array $event
1968 1973
 	 * @return array
1969 1974
 	 */
@@ -2072,7 +2077,7 @@  discard block
 block discarded – undo
2072 2077
 	 * @param array $events events to show
2073 2078
 	 * @param mixed $start start-time of the grid
2074 2079
 	 * @param mixed $end end-time of the grid
2075
-	 * @param string|int $by_cat rows by sub-categories of $by_cat (cat_id or 0 for upmost level) or by 'user' or 'month'
2080
+	 * @param integer $by_cat rows by sub-categories of $by_cat (cat_id or 0 for upmost level) or by 'user' or 'month'
2076 2081
 	 * @param string $indent = '' string for correct indention
2077 2082
 	 * @return string with widget
2078 2083
 	 */
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2016,12 +2016,12 @@
 block discarded – undo
2016 2016
 	}
2017 2017
 
2018 2018
 	/**
2019
-	* Calculates a brighter color for a given color
2020
-	*
2021
-	* @param $rgb string color as #rrggbb value
2022
-	* @param $decr int value to add to each component, default 64
2023
-	* @return string the brighter color
2024
-	*/
2019
+	 * Calculates a brighter color for a given color
2020
+	 *
2021
+	 * @param $rgb string color as #rrggbb value
2022
+	 * @param $decr int value to add to each component, default 64
2023
+	 * @return string the brighter color
2024
+	 */
2025 2025
 	static function brighter($rgb,$decr=64)
2026 2026
 	{
2027 2027
 		if (!preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$rgb,$components))
Please login to merge, or discard this patch.
Spacing   +508 added lines, -512 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @var mixed
44 44
 	 */
45
-	var $debug=false;
45
+	var $debug = false;
46 46
 
47 47
 	/**
48 48
 	 * minimum width for an event
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @var boolean
102 102
 	 */
103
-	var $use_time_grid=true;
103
+	var $use_time_grid = true;
104 104
 
105 105
 	/**
106 106
 	 * Can we display the whole day in a timeGrid of the size of the workday and just scroll to workday start
107 107
 	 *
108 108
 	 * @var boolean
109 109
 	 */
110
-	var $scroll_to_wdstart=false;
110
+	var $scroll_to_wdstart = false;
111 111
 
112 112
 	/**
113 113
 	 * counter for the current whole day event of a single day
114 114
 	 *
115 115
 	 * @var int
116 116
 	 */
117
-	var $wholeDayPosCounter=1;
117
+	var $wholeDayPosCounter = 1;
118 118
 
119 119
 	/**
120 120
 	 * Switch to disable private data and possibility to view and edit events
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST
139 139
 	 */
140
-	function __construct($set_states=null)
140
+	function __construct($set_states = null)
141 141
 	{
142
-		parent::__construct(false,$set_states);	// call the parent's constructor
142
+		parent::__construct(false, $set_states); // call the parent's constructor
143 143
 		$this->extraRowsOriginal = $this->extraRows; //save original extraRows value
144 144
 
145 145
 		$GLOBALS['egw_info']['flags']['nonavbar'] = False;
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 		$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['calendar']['title'].
155 155
 			(isset($app_header[$this->view]) ? ' - '.$app_header[$this->view] : '').
156 156
 			// for a single owner we add it's name to the app-header
157
-			(count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : '');
157
+			(count(explode(',', $this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : '');
158 158
 
159 159
 		// standard params for calling bocal::search for all views
160
-		$this->owner = str_replace('%2C',',',$this->owner);
160
+		$this->owner = str_replace('%2C', ',', $this->owner);
161 161
 		$this->search_params = array(
162 162
 			'start'   => $this->date,
163
-			'cat_id'  => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0,
164
-			'users'   => explode(',',$this->owner),
163
+			'cat_id'  => $this->cat_id ? (is_array($this->cat_id) ? $this->cat_id : explode(',', $this->cat_id)) : 0,
164
+			'users'   => explode(',', $this->owner),
165 165
 			'filter'  => $this->filter,
166 166
 			'daywise' => True,
167 167
 			'use_so_events' => $this->test === 'true',
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function week_number($time)
185 185
 	{
186
-		if (!is_a($time,'DateTime')) $time = new egw_time($time);
186
+		if (!is_a($time, 'DateTime')) $time = new egw_time($time);
187 187
 
188 188
 		// if week does not start Monday and $time is Sunday --> add one day
189 189
 		if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		// handle views in other files
209 209
 		if (!isset($this->public_functions[$this->view]))
210 210
 		{
211
-			$GLOBALS['egw']->redirect_link('/index.php',array('menuaction'=>$this->view_menuaction,'ajax'=>'true'),'calendar');
211
+			$GLOBALS['egw']->redirect_link('/index.php', array('menuaction'=>$this->view_menuaction, 'ajax'=>'true'), 'calendar');
212 212
 		}
213 213
 		// get manual to load the right page
214 214
 		$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view));
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			'date'       => $this->bo->date2string($this->bo->now_su),
229 229
 			'cat_id'     => 0,
230 230
 			'filter'     => 'default',
231
-			'owner'      => substr($this->cal_prefs['mainscreen_showevents'],0,7) == 'planner' && $this->cal_prefs['planner_start_with_group'] ?
231
+			'owner'      => substr($this->cal_prefs['mainscreen_showevents'], 0, 7) == 'planner' && $this->cal_prefs['planner_start_with_group'] ?
232 232
 				$this->cal_prefs['planner_start_with_group'] : $this->user,
233 233
 			'multiple'   => 0,
234 234
 			'view'       => $this->bo->cal_prefs['mainscreen_showevents'],
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		{
243 243
 			$group_warning = '<p class="message" align="center">'.$this->group_warning."</p>\n";
244 244
 		}
245
-		switch($this->cal_prefs['mainscreen_showevents'])
245
+		switch ($this->cal_prefs['mainscreen_showevents'])
246 246
 		{
247 247
 			case 'planner_user':
248 248
 			case 'planner_cat':
@@ -253,20 +253,20 @@  discard block
 block discarded – undo
253 253
 				return $group_warning.$this->year(true);
254 254
 
255 255
 			case 'month':
256
-				return $group_warning.$this->month(0,true);
256
+				return $group_warning.$this->month(0, true);
257 257
 
258 258
 			case 'weekN':
259 259
 				return $group_warning.$this->weekN(true);
260 260
 
261 261
 			default:
262 262
 			case 'week':
263
-				return $group_warning.$this->week(0,true);
263
+				return $group_warning.$this->week(0, true);
264 264
 
265 265
 			case 'day':
266 266
 				return $group_warning.$this->day(true);
267 267
 
268 268
 			case 'day4':
269
-				return $group_warning.$this->week(4,true);
269
+				return $group_warning.$this->week(4, true);
270 270
 		}
271 271
 	}
272 272
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param boolean $home = false if true return content suitable for home-page
277 277
 	 */
278
-	function &planner($home=false)
278
+	function &planner($home = false)
279 279
 	{
280 280
 		if ($this->sortby == 'month')	// yearly planner with month rows
281 281
 		{
@@ -284,50 +284,50 @@  discard block
 block discarded – undo
284 284
 			unset($this->first['raw']);
285 285
 			$this->last = $this->first;
286 286
 			$this->last['year']++;
287
-			$this->last = $this->bo->date2ts($this->last)-1;
287
+			$this->last = $this->bo->date2ts($this->last) - 1;
288 288
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('yearly planner').' '.
289
-				lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
290
-				lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
289
+				lang(egw_time::to($this->first, 'F')).' '.egw_time::to($this->first, 'Y').' - '.
290
+				lang(egw_time::to($this->last, 'F')).' '.egw_time::to($this->last, 'Y');
291 291
 		}
292 292
 		elseif (!$this->planner_days)	// planner monthview
293 293
 		{
294 294
 			if ($this->day < 15)	// show one complete month
295 295
 			{
296
-				$this->_week_align_month($this->first,$this->last);
297
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
296
+				$this->_week_align_month($this->first, $this->last);
297
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year;
298 298
 			}
299 299
 			else	// show 2 half month
300 300
 			{
301
-				$this->_week_align_month($this->first,$this->last,15);
302
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->first)).' / '.lang(adodb_date('F',$this->last)).' '.$this->year;
301
+				$this->_week_align_month($this->first, $this->last, 15);
302
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F', $this->first)).' / '.lang(adodb_date('F', $this->last)).' '.$this->year;
303 303
 			}
304 304
 		}
305 305
 		elseif ($this->planner_days >= 5)	// weeekview
306 306
 		{
307
-			$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
307
+			$this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day);
308 308
 			$this->last = $this->bo->date2array($this->first);
309
-			$this->last['day'] += (int) $this->planner_days - 1;
309
+			$this->last['day'] += (int)$this->planner_days - 1;
310 310
 			$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
311 311
 			unset($this->last['raw']);
312 312
 			$this->last = $this->bo->date2ts($this->last);
313
-			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first,$this->last);
313
+			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first, $this->last);
314 314
 		}
315 315
 		else // dayview
316 316
 		{
317 317
 			$this->first = $this->bo->date2ts($this->date);
318 318
 			$this->last = $this->bo->date2array($this->first);
319
-			$this->last['day'] += (int) $this->planner_days - 1;
319
+			$this->last['day'] += (int)$this->planner_days - 1;
320 320
 			$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
321 321
 			unset($this->last['raw']);
322 322
 			$this->last = $this->bo->date2ts($this->last);
323
-			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.($this->planner_days == 1 ? lang(date('l',$this->first)).', ' : '').
324
-				$this->bo->long_date($this->first,$this->planner_days > 1 ? $this->last : 0);
323
+			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.($this->planner_days == 1 ? lang(date('l', $this->first)).', ' : '').
324
+				$this->bo->long_date($this->first, $this->planner_days > 1 ? $this->last : 0);
325 325
 		}
326 326
 
327 327
 		$merge = $this->merge();
328
-		if($merge)
328
+		if ($merge)
329 329
 		{
330
-			egw::redirect_link('/index.php',array(
330
+			egw::redirect_link('/index.php', array(
331 331
 				'menuaction' => 'calendar.calendar_uiviews.index',
332 332
 				'msg'        => $merge,
333 333
 			));
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 		$search_params['start'] = $this->first;
339 339
 		$search_params['end'] = $this->last;
340 340
 		$search_params['enum_groups'] = $this->sortby == 'user';
341
-		$events =& $this->bo->search($search_params);
341
+		$events = & $this->bo->search($search_params);
342 342
 
343
-		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));
343
+		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));
344 344
 
345
-		$content =& $this->plannerWidget($events,$this->first,$this->last,$this->sortby != 'category' ? $this->sortby : (int) $this->cat_id);
345
+		$content = & $this->plannerWidget($events, $this->first, $this->last, $this->sortby != 'category' ? $this->sortby : (int)$this->cat_id);
346 346
 
347 347
 
348 348
 		if (!$home)
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @param boolean $home = false if true return content suitable for home-page
361 361
 	 */
362
-	function &weekN($home=false)
362
+	function &weekN($home = false)
363 363
 	{
364
-		if (($num = (int)$this->cal_prefs['multiple_weeks']) < 2) $num = 3;	// default 3 weeks
364
+		if (($num = (int)$this->cal_prefs['multiple_weeks']) < 2) $num = 3; // default 3 weeks
365 365
 
366
-		return $this->month($num,$home);
366
+		return $this->month($num, $home);
367 367
 	}
368 368
 
369 369
 	/** Month column width (usually 3 or 4) in year view */
@@ -374,25 +374,25 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @param boolean $home = false if true return content suitable for home-page
376 376
 	 */
377
-	function &year($home=false)
377
+	function &year($home = false)
378 378
 	{
379
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::year date=%2',True,$this->date);
379
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::year date=%2', True, $this->date);
380 380
 
381 381
 
382
-		$this->_month_align_year($this->first,$this->last);
382
+		$this->_month_align_year($this->first, $this->last);
383 383
 
384 384
 		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$this->year;
385 385
 
386 386
 		$merge = $this->merge();
387
-		if($merge)
387
+		if ($merge)
388 388
 		{
389
-			egw::redirect_link('/index.php',array(
389
+			egw::redirect_link('/index.php', array(
390 390
 				'menuaction' => 'calendar.calendar_uiviews.index',
391 391
 				'msg'        => $merge,
392 392
 			));
393 393
 		}
394 394
 
395
-		$days =& $this->bo->search(array(
395
+		$days = & $this->bo->search(array(
396 396
 			'start'   => $this->first,
397 397
 			'end'     => $this->last,
398 398
 		) + $this->search_params);
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 				$content .= "\t".'<div class="calDayColsNoGrip">'."\n";
408 408
 			}
409 409
 
410
-			$month_start = $this->datetime->get_weekday_start($this->year,$month,1);
410
+			$month_start = $this->datetime->get_weekday_start($this->year, $month, 1);
411 411
 			// Beginning of the last week in the month
412 412
 			$month_end = $this->datetime->get_weekday_start(
413 413
 							$this->year,
414 414
 							$month,
415
-							$this->datetime->days_in_month($month,$this->year));
415
+							$this->datetime->days_in_month($month, $this->year));
416 416
 			// End of the last week in month
417
-			$month_end = strtotime("+6 days",$month_end);
417
+			$month_end = strtotime("+6 days", $month_end);
418 418
 
419 419
 			$content .= "\t\t".'<div class="calendar_calDayCol" style="left: '.
420 420
 				((($month - 1) % self::YEARVIEW_COLS) * (100 / self::YEARVIEW_COLS)).'%; width: '.
@@ -422,26 +422,26 @@  discard block
 block discarded – undo
422 422
 
423 423
 			// Year Header
424 424
 			$content .= "\t\t\t".'<div class="calendar_calDayColHeader '.($month % 2 == 0 ? "th" : "row_on").'"'.
425
-				' style="height: 20px; line-height: 20px; z-index: 0;" title="'.lang(adodb_date('F',strtotime("+1 week",$month_start))).' '.adodb_date('Y',strtotime("+1 week",$month_start)).'">'."\n";
425
+				' style="height: 20px; line-height: 20px; z-index: 0;" title="'.lang(adodb_date('F', strtotime("+1 week", $month_start))).' '.adodb_date('Y', strtotime("+1 week", $month_start)).'">'."\n";
426 426
 			if (($month) == 1)
427 427
 			{
428 428
 				$content .= '<span style="position: absolute; left: 0px;">';
429
-				$content .= html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
429
+				$content .= html::a_href(html::image('phpgwapi', 'first', lang('previous'), $options = ' alt="<<"'), array(
430 430
 					'menuaction' => $this->view_menuaction,
431
-					'date'       => date('Ymd',strtotime('-1 year',strtotime($this->date))),
431
+					'date'       => date('Ymd', strtotime('-1 year', strtotime($this->date))),
432 432
 				));
433 433
 				$content .= '</span>'."\n";
434 434
 			}
435 435
 			$content .= "\t\t\t\t".'<a href="'.$GLOBALS['egw']->link('/index.php',
436 436
 				array('menuaction'=>'calendar.calendar_uiviews.month',
437 437
 				'date'=>$this->year.($month < 10 ? '0' : '').$month.'01')).
438
-				'" title="'.lang('Monthview').'">'.lang(adodb_date('F',strtotime("+1 week",$month_start))).'</a>'."\n";
438
+				'" title="'.lang('Monthview').'">'.lang(adodb_date('F', strtotime("+1 week", $month_start))).'</a>'."\n";
439 439
 			if ($month == self::YEARVIEW_COLS)
440 440
 			{
441 441
 				$content .= '<span style="position: absolute; right: 0px;">';
442
-				$content .= html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
442
+				$content .= html::a_href(html::image('phpgwapi', 'last', lang('next'), $options = ' alt=">>"'), array(
443 443
 					'menuaction' => $this->view_menuaction,
444
-					'date'       => date('Ymd',strtotime('+1 year',strtotime($this->date))),
444
+					'date'       => date('Ymd', strtotime('+1 year', strtotime($this->date))),
445 445
 				));
446 446
 				$content .= '</span>'."\n";
447 447
 			}
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 			// Day Columns, Legend
456 456
 			for ($i = 0; $i <= 6; $i++)
457 457
 			{
458
-				$day_date = ($i ? strtotime("+$i days",$month_start) : $month_start);
459
-				if (adodb_date('w',$day_date) % 6 == 0)
458
+				$day_date = ($i ? strtotime("+$i days", $month_start) : $month_start);
459
+				if (adodb_date('w', $day_date) % 6 == 0)
460 460
 				{
461 461
 					$style = 'calendar_cal_year_legend_weekend';
462 462
 				}
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
 
468 468
 				$content .= "\t\t\t\t".'<div class="'.$style.'"'.
469 469
 					' style="text-align: center; position: absolute; width: 11.5%; height: 16px; left: '.((($i + 1) * 12.5) + 0.5).'%;">'.
470
-					lang(adodb_date('D',$day_date)).'</div>'."\n";
470
+					lang(adodb_date('D', $day_date)).'</div>'."\n";
471 471
 			}
472 472
 			$content .= "\t\t\t".'</div>'."\n";
473 473
 
474 474
 			// Week rows in month
475 475
 			$week_start = $month_start;
476
-			for ($week_in_month = 1; $week_in_month <= 6; $week_in_month ++)
476
+			for ($week_in_month = 1; $week_in_month <= 6; $week_in_month++)
477 477
 			{
478 478
 				$content .= "\t\t\t".'<div'.
479 479
 						' style="position: absolute; width: 100%; height: 16px;'.
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
 				$content .= "\t\t\t\t".'<div class="calendar_cal_year_legend"'.
483 483
 					' style="text-align: center;position: absolute; width: 11.5%; height: 16px; left: 0.5%;" '.
484
-					'title="'.lang('Wk').' '.$this->week_number($week_start).'/'.adodb_date('Y',$week_start).'">'."\n";
484
+					'title="'.lang('Wk').' '.$this->week_number($week_start).'/'.adodb_date('Y', $week_start).'">'."\n";
485 485
 				$content .= "\t\t\t\t\t".
486 486
 					'<a href="'.$GLOBALS['egw']->link('/index.php',
487 487
 								array('menuaction'=>'calendar.calendar_uiviews.week',
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 				// Day columns in week row
492 492
 				for ($i = 0; $i <= 6; $i++)
493 493
 				{
494
-					$day_date = $i ? strtotime("+$i days",$week_start) : $week_start;
494
+					$day_date = $i ? strtotime("+$i days", $week_start) : $week_start;
495 495
 					$day_ymd = $this->bo->date2string($day_date);
496 496
 					$eventcount = count($days[$day_ymd]);
497 497
 					$in_month = true;
498 498
 					$css_class = "";
499
-					$this->_day_class_holiday($day_ymd,$class,$holidays,false,false);
500
-					if (adodb_date('n',$day_date) != $month)
499
+					$this->_day_class_holiday($day_ymd, $class, $holidays, false, false);
500
+					if (adodb_date('n', $day_date) != $month)
501 501
 					{
502 502
 						$css_class .= 'calendar_cal_year_legend';
503 503
 						$in_month = false;
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 					else
506 506
 					{
507 507
 						$css_class .= 'calendar_calEvent calendar_calEventAllAccepted';
508
-						if (adodb_date('w',$day_date) % 6 == 0)
508
+						if (adodb_date('w', $day_date) % 6 == 0)
509 509
 						{
510 510
 							$css_class .= ' calendar_cal_year_weekend';
511 511
 						}
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
 					{
536 536
 						$content .= ' title="'.$holidays.'"';
537 537
 					}
538
-					$content .= '>'.adodb_date('d',$day_date).'</div>'."\n";
538
+					$content .= '>'.adodb_date('d', $day_date).'</div>'."\n";
539 539
 
540 540
 
541 541
 					if (($in_month) && (count($days[$day_ymd])))
542 542
 					{
543
-						$eventCols = $this->getEventCols($day_ymd,$days[$day_ymd]);
543
+						$eventCols = $this->getEventCols($day_ymd, $days[$day_ymd]);
544 544
 						// displaying all event columns of the day
545 545
 						$row_height = 100 / count($eventCols);
546 546
 						$space_left = 4; //%
@@ -549,19 +549,19 @@  discard block
 block discarded – undo
549 549
 						// settings for time2pos
550 550
 						$this->scroll_to_wdstart = false;
551 551
 						$this->wd_start = 0;
552
-						$this->wd_end = 24*60;
552
+						$this->wd_end = 24 * 60;
553 553
 						$this->granularity_m = 24 * 60;
554 554
 						$this->extraRows = -1;
555 555
 						$this->remBotExtraRows = 0;
556 556
 						$this->rowHeight = $row_width;
557
-						foreach($eventCols as $n => $eventCol)
557
+						foreach ($eventCols as $n => $eventCol)
558 558
 						{
559 559
 							foreach ($eventCol as $event)
560 560
 							{
561 561
 								$indent = "\t\t\t\t";
562 562
 								// some fields set by the dayColWidget for the other views
563 563
 								unset($event['whole_day_on_top']);
564
-								$data = $this->eventWidget($event,25,$indent,$this->owner,true,'planner_event');
564
+								$data = $this->eventWidget($event, 25, $indent, $this->owner, true, 'planner_event');
565 565
 
566 566
 								$left = ((($i + 1) * 12.5) + 0.5 + $space_left + $this->time2pos($event['start_m']));
567 567
 								$width = $this->time2pos($event['end_m'] - $event['start_m']);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 
570 570
 								$tooltip = html::htmlspecialchars($data['tooltip']);
571 571
 								$content .= $indent.'<div class="calendar_plannerEvent'.($data['private'] ? 'Private' : '').
572
-									'" data-tooltip ="'.$tooltip .
572
+									'" data-tooltip ="'.$tooltip.
573 573
 									'" style="position: absolute; left: '.$left.'%; width: '.$width.'%; height: '.
574 574
 									$row_height.'%; top: '.($n * $row_height).'%;'.
575 575
 									'background-color: '.$color.';" '.'" data-date ="'.$this->bo->date2string($event['start']).'|'.$data['popup'].'" '.
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 						}
579 579
 					}
580 580
 				}
581
-				$week_start = strtotime("+1 week",$week_start);
581
+				$week_start = strtotime("+1 week", $week_start);
582 582
 				$content .= "\t\t\t".'</div>'."\n";
583 583
 			}
584 584
 			$content .= "\t\t".'</div>'."\n";
@@ -606,35 +606,35 @@  discard block
 block discarded – undo
606 606
 	 * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown
607 607
 	 * @param boolean $home = false if true return content suitable for home-page
608 608
 	 */
609
-	function &month($weeks=0,$home=false)
609
+	function &month($weeks = 0, $home = false)
610 610
 	{
611
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
611
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2', True, $weeks, $this->date);
612 612
 
613
-		$this->use_time_grid = !$this->cal_prefs['use_time_grid'] || $this->cal_prefs['use_time_grid'] == 'all'; 	// all views
613
+		$this->use_time_grid = !$this->cal_prefs['use_time_grid'] || $this->cal_prefs['use_time_grid'] == 'all'; // all views
614 614
 
615 615
 		// Merge print
616
-		if($weeks)
616
+		if ($weeks)
617 617
 		{
618 618
 			// Split up span into multiple weeks
619 619
 			$timespan = array();
620
-			$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
621
-			for($i = 0; $i < $weeks; $i++)
620
+			$this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day);
621
+			for ($i = 0; $i < $weeks; $i++)
622 622
 			{
623 623
 				$timespan[] = array(
624 624
 					'start' => strtotime("+$i weeks", $this->first),
625
-					'end' => strtotime('+' . ($i+1).' weeks', $this->first) -1
625
+					'end' => strtotime('+'.($i + 1).' weeks', $this->first) - 1
626 626
 				);
627 627
 			}
628 628
 		} else {
629 629
 			$timespan[] = array(
630
-				'start' => mktime(0,0,0,$this->month,1,$this->year),
631
-				'end' => mktime(0,0,0,$this->month+1,1,$this->year)-1
630
+				'start' => mktime(0, 0, 0, $this->month, 1, $this->year),
631
+				'end' => mktime(0, 0, 0, $this->month + 1, 1, $this->year) - 1
632 632
 			);
633 633
 		}
634 634
 		$merge = $this->merge($timespan);
635
-		if($merge)
635
+		if ($merge)
636 636
 		{
637
-			egw::redirect_link('/index.php',array(
637
+			egw::redirect_link('/index.php', array(
638 638
 				'menuaction' => 'calendar.calendar_uiviews.index',
639 639
 				'msg'        => $merge,
640 640
 			));
@@ -642,34 +642,34 @@  discard block
 block discarded – undo
642 642
 
643 643
 		if ($weeks)
644 644
 		{
645
-			$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
646
-			$this->last = strtotime("+$weeks weeks",$this->first) - 1;
645
+			$this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day);
646
+			$this->last = strtotime("+$weeks weeks", $this->first) - 1;
647 647
 			$weekNavH = "$weeks weeks";
648 648
 			$navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '.
649
-				$this->bo->long_date($this->first,$this->last);
649
+				$this->bo->long_date($this->first, $this->last);
650 650
 		}
651 651
 		else
652 652
 		{
653
-			$this->_week_align_month($this->first,$this->last);
653
+			$this->_week_align_month($this->first, $this->last);
654 654
 			$weekNavH = "1 month";
655
-			$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
655
+			$navHeader = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year;
656 656
 		}
657
-		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));
657
+		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));
658 658
 
659 659
 		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$navHeader;
660 660
 
661
-		$days =& $this->bo->search(array(
661
+		$days = & $this->bo->search(array(
662 662
 			'start'   => $this->first,
663 663
 			'end'     => $this->last,
664
-		)+$this->search_params);
664
+		) + $this->search_params);
665 665
 
666 666
 		// we add DAY_s/2 to $this->first (using 12h), to deal with daylight saving changes
667
-		for ($week_start = $this->first; $week_start < $this->last; $week_start = strtotime("+1 week",$week_start))
667
+		for ($week_start = $this->first; $week_start < $this->last; $week_start = strtotime("+1 week", $week_start))
668 668
 		{
669 669
 			$week = array();
670 670
 			for ($i = 0; $i < 7; ++$i)
671 671
 			{
672
-				$day_ymd = $this->bo->date2string($i ? strtotime("+$i days",$week_start) : $week_start);
672
+				$day_ymd = $this->bo->date2string($i ? strtotime("+$i days", $week_start) : $week_start);
673 673
 				$week[$day_ymd] = array_shift($days);
674 674
 			}
675 675
 			$week_view = array(
@@ -679,21 +679,21 @@  discard block
 block discarded – undo
679 679
 			$title = lang('Wk').' '.$this->week_number($week_start);
680 680
 			if ($this->allowEdit)
681 681
 			{
682
-				$title = html::a_href($title,$week_view,'',' title="'.lang('Weekview').'"');
682
+				$title = html::a_href($title, $week_view, '', ' title="'.lang('Weekview').'"');
683 683
 			}
684 684
 
685
-			$content .= $this->timeGridWidget($this->tagWholeDayOnTop($week),$weeks == 2 ? 30 : 60,200,'',$title,0,$week_start+WEEK_s >= $this->last);
685
+			$content .= $this->timeGridWidget($this->tagWholeDayOnTop($week), $weeks == 2 ? 30 : 60, 200, '', $title, 0, $week_start + WEEK_s >= $this->last);
686 686
 		}
687 687
 
688 688
 		$navHeader = '<div class="calendar_calMonthNavHeader calendar_calMonth">'
689
-				.html::a_href(html::image('phpgwapi','left',lang('previous'),$options=' alt="<<"'),array(
689
+				.html::a_href(html::image('phpgwapi', 'left', lang('previous'), $options = ' alt="<<"'), array(
690 690
 				'menuaction' => $this->view_menuaction,
691
-				'date'       => date('Ymd',strtotime("-".$weekNavH,  $weeks? $this->first: $this->bo->date2ts($this->date))),
692
-				)). ' <span>'.$navHeader;
691
+				'date'       => date('Ymd', strtotime("-".$weekNavH, $weeks ? $this->first : $this->bo->date2ts($this->date))),
692
+				)).' <span>'.$navHeader;
693 693
 
694
-		$navHeader = $navHeader.'</span> '.html::a_href(html::image('phpgwapi','right',lang('next'),$options=' alt=">>"'),array(
694
+		$navHeader = $navHeader.'</span> '.html::a_href(html::image('phpgwapi', 'right', lang('next'), $options = ' alt=">>"'), array(
695 695
 				'menuaction' => $this->view_menuaction,
696
-				'date'       => date('Ymd',strtotime("+".$weekNavH, $weeks? $this->first: $this->bo->date2ts($this->date))),
696
+				'date'       => date('Ymd', strtotime("+".$weekNavH, $weeks ? $this->first : $this->bo->date2ts($this->date))),
697 697
 				)).'</div>';
698 698
 		$content = $navHeader.$content;
699 699
 		if (!$home)
@@ -714,17 +714,17 @@  discard block
 block discarded – undo
714 714
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month
715 715
 	 * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15.
716 716
 	 */
717
-	function _week_align_month(&$first,&$last,$day=1)
717
+	function _week_align_month(&$first, &$last, $day = 1)
718 718
 	{
719
-		$first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day=$day);
719
+		$first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day = $day);
720 720
 		if ($day == 1)
721 721
 		{
722
-			$last = $this->datetime->get_weekday_start($this->year,$this->month,
723
-				$this->datetime->days_in_month($this->month,$this->year));
722
+			$last = $this->datetime->get_weekday_start($this->year, $this->month,
723
+				$this->datetime->days_in_month($this->month, $this->year));
724 724
 		}
725 725
 		else
726 726
 		{
727
-			$last = $this->datetime->get_weekday_start($this->year,$this->month+1,$day);
727
+			$last = $this->datetime->get_weekday_start($this->year, $this->month + 1, $day);
728 728
 		}
729 729
 		// now we need to calculate the end of the last day of that week
730 730
 		// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		$last['day'] += 6;
733 733
 		$last['hour'] = 23;
734 734
 		$last['min'] = $last['sec'] = 59;
735
-		unset($last['raw']);	// otherwise date2ts does not calc raw new, but uses it
735
+		unset($last['raw']); // otherwise date2ts does not calc raw new, but uses it
736 736
 		$last = $this->bo->date2ts($last);
737 737
 	}
738 738
 
@@ -742,18 +742,18 @@  discard block
 block discarded – undo
742 742
 	 * @param int &$first timestamp 0h of first day of week containing the first of the current year
743 743
 	 * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current year
744 744
 	 */
745
-	function _month_align_year(&$first,&$last)
745
+	function _month_align_year(&$first, &$last)
746 746
 	{
747
-		$first = $this->datetime->get_weekday_start($this->year,$this->month=1,$this->day=1);
748
-		$last = $this->datetime->get_weekday_start($this->year,$this->month+12,
749
-				$this->datetime->days_in_month($this->month+12,$this->year));
747
+		$first = $this->datetime->get_weekday_start($this->year, $this->month = 1, $this->day = 1);
748
+		$last = $this->datetime->get_weekday_start($this->year, $this->month + 12,
749
+				$this->datetime->days_in_month($this->month + 12, $this->year));
750 750
 		// now we need to calculate the end of the last day of that week
751 751
 		// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
752 752
 		$last = $this->bo->date2array($last);
753 753
 		$last['day'] += 6;
754 754
 		$last['hour'] = 23;
755 755
 		$last['min'] = $last['sec'] = 59;
756
-		unset($last['raw']);	// otherwise date2ts does not calc raw new, but uses it
756
+		unset($last['raw']); // otherwise date2ts does not calc raw new, but uses it
757 757
 		$last = $this->bo->date2ts($last);
758 758
 	}
759 759
 
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
 	 * @param boolean $home = false if true return content suitable for home-page
764 764
 	 * @return string
765 765
 	 */
766
-	function day4($home=false)
766
+	function day4($home = false)
767 767
 	{
768
-		return $this->week(4,$home);
768
+		return $this->week(4, $home);
769 769
 	}
770 770
 
771 771
 	/**
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 */
778 778
 	private function close_button($uid)
779 779
 	{
780
-		return html::a_href(html::image('phpgwapi', 'close.button', 'Close','style="width: 12px; padding-top: 1px;"'), array(
780
+		return html::a_href(html::image('phpgwapi', 'close.button', 'Close', 'style="width: 12px; padding-top: 1px;"'), array(
781 781
 			'menuaction' => 'calendar.calendar_uiviews.index',
782 782
 			'close' => $uid,
783 783
 		));
@@ -789,9 +789,9 @@  discard block
 block discarded – undo
789 789
 	 * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used
790 790
 	 * @param boolean $home = false if true return content suitable for home-page
791 791
 	 */
792
-	function week($days=0,$home=false)
792
+	function week($days = 0, $home = false)
793 793
 	{
794
-		$this->use_time_grid = $days != 4 && !in_array($this->cal_prefs['use_time_grid'],array('day','day4')) ||
794
+		$this->use_time_grid = $days != 4 && !in_array($this->cal_prefs['use_time_grid'], array('day', 'day4')) ||
795 795
 			$days == 4 && $this->cal_prefs['use_time_grid'] != 'day';
796 796
 
797 797
 		if (!$days)
@@ -800,55 +800,55 @@  discard block
 block discarded – undo
800 800
 			if ($days != 5) $days = 7;
801 801
 			if ($days != $this->cal_prefs['days_in_weekview'])	// save the preference
802 802
 			{
803
-				$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
803
+				$GLOBALS['egw']->preferences->add('calendar', 'days_in_weekview', $days);
804 804
 				$GLOBALS['egw']->preferences->save_repository();
805 805
 				$this->cal_prefs['days_in_weekview'] = $days;
806 806
 			}
807 807
 		}
808
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
808
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2', True, $days, $this->date);
809 809
 
810 810
 		if ($days == 4)		// next 4 days view
811 811
 		{
812 812
 			$wd_start = $this->first = $this->bo->date2ts($this->date);
813
-			$this->last = strtotime("+$days days",$this->first) - 1;
814
-			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Four days view').' '.$this->bo->long_date($this->first,$this->last);
815
-			$navHeader =lang('Four days view').' '.$this->bo->long_date($this->first,$this->last);
813
+			$this->last = strtotime("+$days days", $this->first) - 1;
814
+			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Four days view').' '.$this->bo->long_date($this->first, $this->last);
815
+			$navHeader = lang('Four days view').' '.$this->bo->long_date($this->first, $this->last);
816 816
 		}
817 817
 		else
818 818
 		{
819
-			$wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
819
+			$wd_start = $this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day);
820 820
 			if ($days == 5)		// no weekend-days
821 821
 			{
822
-				switch($this->cal_prefs['weekdaystarts'])
822
+				switch ($this->cal_prefs['weekdaystarts'])
823 823
 				{
824 824
 					case 'Saturday':
825
-						$this->first = strtotime("+2 days",$this->first);
825
+						$this->first = strtotime("+2 days", $this->first);
826 826
 						break;
827 827
 					case 'Sunday':
828
-						$this->first = strtotime("+1 day",$this->first);
828
+						$this->first = strtotime("+1 day", $this->first);
829 829
 						break;
830 830
 				}
831 831
 			}
832
-			$this->last = strtotime("+$days days",$this->first) - 1;
833
-			$GLOBALS['egw_info']['flags']['app_header'] .=': ' .lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first,$this->last);
834
-			$navHeader = lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first,$this->last);
832
+			$this->last = strtotime("+$days days", $this->first) - 1;
833
+			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first, $this->last);
834
+			$navHeader = lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first, $this->last);
835 835
 		}
836 836
 
837 837
 		$navHeader = '<div class="calendar_calWeek calendar_calWeekNavHeader">'
838
-				.html::a_href(html::image('phpgwapi','left',lang('previous'),$options=' alt="<<"'),array(
838
+				.html::a_href(html::image('phpgwapi', 'left', lang('previous'), $options = ' alt="<<"'), array(
839 839
 				'menuaction' => $this->view_menuaction,
840
-				'date'       => date('Ymd', strtotime("-$days days",$this->first)),
841
-				)). '<span>'.$navHeader;
840
+				'date'       => date('Ymd', strtotime("-$days days", $this->first)),
841
+				)).'<span>'.$navHeader;
842 842
 
843
-		$navHeader = $navHeader.'</span>'.html::a_href(html::image('phpgwapi','right',lang('next'),$options=' alt=">>"'),array(
843
+		$navHeader = $navHeader.'</span>'.html::a_href(html::image('phpgwapi', 'right', lang('next'), $options = ' alt=">>"'), array(
844 844
 				'menuaction' => $this->view_menuaction,
845
-				'date'       => date('Ymd', strtotime("+$days days",$this->last)),
845
+				'date'       => date('Ymd', strtotime("+$days days", $this->last)),
846 846
 				)).'</div>';
847 847
 
848 848
 		$merge = $this->merge();
849
-		if($merge)
849
+		if ($merge)
850 850
 		{
851
-			egw::redirect_link('/index.php',array(
851
+			egw::redirect_link('/index.php', array(
852 852
 				'menuaction' => 'calendar.calendar_uiviews.index',
853 853
 				'msg'        => $merge,
854 854
 			));
@@ -864,13 +864,13 @@  discard block
 block discarded – undo
864 864
 
865 865
 		if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate)	// for more then X users, show all in one row
866 866
 		{
867
-			$content = $this->timeGridWidget($this->tagWholeDayOnTop($this->bo->search($search_params)),$this->cal_prefs['interval']);
867
+			$content = $this->timeGridWidget($this->tagWholeDayOnTop($this->bo->search($search_params)), $this->cal_prefs['interval']);
868 868
 		}
869 869
 		else
870 870
 		{
871 871
 			$content = '';
872 872
 			$headerCounter = 0;
873
-			foreach(explode(',',$this->owner) as $uid)
873
+			foreach (explode(',', $this->owner) as $uid)
874 874
 			{
875 875
 				$label = $this->bo->participant_name($uid);
876 876
 				$content .= '<div data-sortable-id="'.$uid.'">';
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 				$content .= '<b>'.$label."</b>\n";
879 879
 				$content .= $this->close_button($uid);
880 880
 				$content .= $this->timeGridWidget($this->tagWholeDayOnTop($this->bo->search($search_params)),
881
-					count($users) * $this->cal_prefs['interval'],400 / count($users),'','',$uid);
881
+					count($users) * $this->cal_prefs['interval'], 400 / count($users), '', '', $uid);
882 882
 				++$headerCounter;
883 883
 				if (count($users) > $headerCounter)
884 884
 				{
@@ -907,21 +907,21 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @param boolean $home = false if true return content suitable for home-page
909 909
 	 */
910
-	function &day($home=false)
910
+	function &day($home = false)
911 911
 	{
912
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::day() date=%1',True,$this->date);
912
+		if ($this->debug > 0) $this->bo->debug_message('uiviews::day() date=%1', True, $this->date);
913 913
 
914 914
 		$this->last = $this->first = $this->bo->date2ts((string)$this->date);
915
-		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$this->bo->long_date($this->first,0,false,true);
915
+		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$this->bo->long_date($this->first, 0, false, true);
916 916
 
917
-		$this->use_time_grid = true;    // day-view always uses a time-grid, independent what's set in the prefs!
917
+		$this->use_time_grid = true; // day-view always uses a time-grid, independent what's set in the prefs!
918 918
 
919
-		$this->search_params['end'] = $this->last = $this->first+DAY_s-1;
919
+		$this->search_params['end'] = $this->last = $this->first + DAY_s - 1;
920 920
 
921 921
 		$merge = $this->merge();
922
-		if($merge)
922
+		if ($merge)
923 923
 		{
924
-			egw::redirect_link('/index.php',array(
924
+			egw::redirect_link('/index.php', array(
925 925
 				'menuaction' => 'calendar.calendar_uiviews.index',
926 926
 				'msg'        => $merge,
927 927
 			));
@@ -937,14 +937,14 @@  discard block
 block discarded – undo
937 937
 			// for more then X users, show all in one row
938 938
 			if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate)
939 939
 			{
940
-				$dayEvents =& $this->bo->search($this->search_params);
940
+				$dayEvents = & $this->bo->search($this->search_params);
941 941
 				$owner = 0;
942 942
 			}
943 943
 			else
944 944
 			{
945 945
 				$dayEvents = $owner = array();
946 946
 				$search_params = $this->search_params;
947
-				foreach($this->_get_planner_users(false) as $uid => $label)
947
+				foreach ($this->_get_planner_users(false) as $uid => $label)
948 948
 				{
949 949
 					$search_params['users'] = $uid;
950 950
 					list(,$dayEvents['<b>'.$label.'</b>'.$this->close_button($uid)]) = each($this->bo->search($search_params));
@@ -957,32 +957,32 @@  discard block
 block discarded – undo
957 957
 			//types mask accordingly.
958 958
 			$display_holidays_event = $GLOBALS['egw_info']['user']['preferences']['calendar']['display_holidays_event'];
959 959
 			$this->display_holiday_event_types = array(
960
-				'bdays' => ((int)$display_holidays_event & 1) != 0,
961
-				'hdays' => ((int)$display_holidays_event & 2) != 0
960
+				'bdays' => ((int)$display_holidays_event&1) != 0,
961
+				'hdays' => ((int)$display_holidays_event&2) != 0
962 962
 			);
963 963
 
964 964
 			//Add the holiday events
965 965
 			$holidays = $this->_get_holiday_events($this->date, $this->display_holiday_event_types);
966
-			foreach($dayEvents as &$events)
966
+			foreach ($dayEvents as &$events)
967 967
 			{
968
-				$events = array_merge($events,$holidays);
968
+				$events = array_merge($events, $holidays);
969 969
 			}
970 970
 			unset($events);
971 971
 			unset($holidays);
972 972
 
973
-			$cols[0] =& $this->timeGridWidget($this->tagWholeDayOnTop($dayEvents),$this->cal_prefs['interval'],450,'','',$owner);
973
+			$cols[0] = & $this->timeGridWidget($this->tagWholeDayOnTop($dayEvents), $this->cal_prefs['interval'], 450, '', '', $owner);
974 974
 
975 975
 			if (count($users) > 1)
976 976
 			{
977 977
 				$navHeader = '<div class="calendar_calWeek calendar_calWeekNavHeader">'
978
-				.html::a_href(html::image('phpgwapi','left',lang('previous'),$options=' alt="<<"'),array(
978
+				.html::a_href(html::image('phpgwapi', 'left', lang('previous'), $options = ' alt="<<"'), array(
979 979
 				'menuaction' => $this->view_menuaction,
980
-				'date'       => date('Ymd',$this->first-1),
981
-				)). '<span>'.$this->bo->long_date($this->first,0,false,true);
980
+				'date'       => date('Ymd', $this->first - 1),
981
+				)).'<span>'.$this->bo->long_date($this->first, 0, false, true);
982 982
 
983
-				$navHeader = $navHeader.'</span>'.html::a_href(html::image('phpgwapi','right',lang('next'),$options=' alt=">>"'),array(
983
+				$navHeader = $navHeader.'</span>'.html::a_href(html::image('phpgwapi', 'right', lang('next'), $options = ' alt=">>"'), array(
984 984
 				'menuaction' => $this->view_menuaction,
985
-				'date'       => date('Ymd',$this->last+1),
985
+				'date'       => date('Ymd', $this->last + 1),
986 986
 				)).'</div>';
987 987
 			}
988 988
 
@@ -991,33 +991,33 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				if ($GLOBALS['egw_info']['user']['apps']['infolog'])
993 993
 				{
994
-					foreach(array('task','phone','note') as $type)
994
+					foreach (array('task', 'phone', 'note') as $type)
995 995
 					{
996
-						$todo_label .= '&nbsp;'.html::a_href( html::image('infolog',$type,lang('Add')),'infolog.infolog_ui.edit',array(
996
+						$todo_label .= '&nbsp;'.html::a_href(html::image('infolog', $type, lang('Add')), 'infolog.infolog_ui.edit', array(
997 997
 							'type' => $type,
998 998
 							'start_time' => $ts,
999
-						),' data-todo="app|750x590"');
999
+						), ' data-todo="app|750x590"');
1000 1000
 					}
1001 1001
 				}
1002 1002
 				$cols[1] = html::div(
1003
-					html::div($todo_label,'','calendar_calDayTodosHeader th')."\n".
1004
-					html::div($todos,'','calendar_calDayTodosTable'),'','calendar_calDayTodos');
1003
+					html::div($todo_label, '', 'calendar_calDayTodosHeader th')."\n".
1004
+					html::div($todos, '', 'calendar_calDayTodosTable'), '', 'calendar_calDayTodos');
1005 1005
 				$cols['.1'] = 'width=30%';
1006 1006
 				echo html::table(array(
1007 1007
 					0 => $cols,
1008 1008
 					'.0' => 'valign="top"'
1009
-				),'class="calendar_calDayView"');
1009
+				), 'class="calendar_calDayView"');
1010 1010
 			}
1011 1011
 			else
1012 1012
 			{
1013
-				$cols[0] = $navHeader . $cols[0];
1013
+				$cols[0] = $navHeader.$cols[0];
1014 1014
 				echo $cols[0];
1015 1015
 			}
1016 1016
 
1017 1017
 		}
1018 1018
 		else
1019 1019
 		{
1020
-			$content = $this->timeGridWidget($this->bo->search($this->search_params),$this->cal_prefs['interval'],300);
1020
+			$content = $this->timeGridWidget($this->bo->search($this->search_params), $this->cal_prefs['interval'], 300);
1021 1021
 
1022 1022
 
1023 1023
 			return $content;
@@ -1041,56 +1041,55 @@  discard block
 block discarded – undo
1041 1041
 			'owner'     => $this->owner == 0 ? $this->user : $this->owner	// num. id of the user, not necessary current user
1042 1042
 		));
1043 1043
 
1044
-		if(is_array($todo_label))
1044
+		if (is_array($todo_label))
1045 1045
 		{
1046
-			list($label,$showall)=$todo_label;
1046
+			list($label, $showall) = $todo_label;
1047 1047
 		}
1048 1048
 		else
1049 1049
 		{
1050
-			$label=$todo_label;
1051
-			$showall=true;
1050
+			$label = $todo_label;
1051
+			$showall = true;
1052 1052
 		}
1053 1053
 		$maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow'];
1054
-		if($maxshow <= 0)
1054
+		if ($maxshow <= 0)
1055 1055
 		{
1056
-			$maxshow=10;
1056
+			$maxshow = 10;
1057 1057
 		}
1058 1058
 		//print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow");
1059 1059
 
1060 1060
 		$content = $todo_label = '';
1061 1061
 		if (is_array($todos_from_hook) && count($todos_from_hook))
1062 1062
 		{
1063
-			foreach($todos_from_hook as $todos)
1063
+			foreach ($todos_from_hook as $todos)
1064 1064
 			{
1065 1065
 				$i = 0;
1066 1066
 				if (is_array($todos))
1067 1067
 				{
1068 1068
 					$todo_label = !empty($label) ? $label : lang("open ToDo's:");
1069 1069
 
1070
-					foreach($todos as $todo)
1070
+					foreach ($todos as $todo)
1071 1071
 					{
1072
-						if(!$showall && ($i++ > $maxshow))
1072
+						if (!$showall && ($i++ > $maxshow))
1073 1073
 						{
1074 1074
 							break;
1075 1075
 						}
1076 1076
 						$icons = '';
1077
-						foreach($todo['icons'] as $name => $app)
1077
+						foreach ($todo['icons'] as $name => $app)
1078 1078
 						{
1079
-							$icons .= ($icons?' ':'').$GLOBALS['egw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"');
1079
+							$icons .= ($icons ? ' ' : '').$GLOBALS['egw']->html->image($app, $name, lang($name), 'border="0" width="15" height="15"');
1080 1080
 						}
1081 1081
 						$class = $class == 'row_on' ? 'row_off' : 'row_on';
1082
-						if($todo['edit']) {
1082
+						if ($todo['edit']) {
1083 1083
 							list($width, $height) = explode('x', $todo['edit']['size']);
1084 1084
 							unset($todo['edit']['size']);
1085
-							$edit_icon_href = html::a_href( $icons, $todo['edit'],'',' data-todo="app|'.$width.'x'.$height.'" ');
1086
-							$edit_href = html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" ');
1085
+							$edit_icon_href = html::a_href($icons, $todo['edit'], '', ' data-todo="app|'.$width.'x'.$height.'" ');
1086
+							$edit_href = html::a_href($todo['title'], $todo['edit'], '', ' data-todo="app|750x590" ');
1087 1087
 						}
1088
-						$icon_href = html::a_href($icons,$todo['view']);
1088
+						$icon_href = html::a_href($icons, $todo['view']);
1089 1089
 						$href = html::a_href($todo['title'], $todo['view']);
1090 1090
 						$content .= " <tr class=\"$class\">\n  <td valign=\"top\" width=\"15%\" nowrap>".
1091
-							($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)).
1092
-							"</td>\n  <td>".($this->printer_friendly?$todo['title']:
1093
-							$edit_href)."</td>\n </tr>\n";
1091
+							($this->bo->printer_friendly ? $icons : ($edit_icon_href ? $edit_icon_href : $icon_href)).
1092
+							"</td>\n  <td>".($this->printer_friendly ? $todo['title'] : $edit_href)."</td>\n </tr>\n";
1094 1093
 						/**
1095 1094
 						 * ToDo: add delete and closing action
1096 1095
 						 */
@@ -1117,7 +1116,7 @@  discard block
 block discarded – undo
1117 1116
 	{
1118 1117
 		if ($this->scroll_to_wdstart)	// we display the complete day - thought only workday is visible without scrolling
1119 1118
 		{
1120
-			return $this->rowHeight * (1 + $this->extraRows + $time/$this->granularity_m);
1119
+			return $this->rowHeight * (1 + $this->extraRows + $time / $this->granularity_m);
1121 1120
 		}
1122 1121
 		// time before workday => condensed in the first $this->extraRows rows
1123 1122
 		if ($this->wd_start > 0 && $time < $this->wd_start)
@@ -1125,18 +1124,18 @@  discard block
 block discarded – undo
1125 1124
 			$pos = (($this->extraRows - $this->extraRowsOriginal + 1) + ($time / $this->wd_start * ($this->extraRowsOriginal - 1))) * $this->rowHeight;
1126 1125
 		}
1127 1126
 		// time after workday => condensed in the last row
1128
-		elseif ($this->wd_end < 24*60 && $time > $this->wd_end+1*$this->granularity_m)
1127
+		elseif ($this->wd_end < 24 * 60 && $time > $this->wd_end + 1 * $this->granularity_m)
1129 1128
 		{
1130
-			$pos = 100 - (($this->extraRows - $this->remBotExtraRows) * $this->rowHeight * (1 - ($time - $this->wd_end) / (24*60 - $this->wd_end)));
1129
+			$pos = 100 - (($this->extraRows - $this->remBotExtraRows) * $this->rowHeight * (1 - ($time - $this->wd_end) / (24 * 60 - $this->wd_end)));
1131 1130
 		}
1132 1131
 		// time during the workday => 2. row on (= + granularity)
1133 1132
 		else
1134 1133
 		{
1135
-			$pos = $this->rowHeight * (1+$this->extraRows+($time-$this->wd_start)/$this->granularity_m);
1134
+			$pos = $this->rowHeight * (1 + $this->extraRows + ($time - $this->wd_start) / $this->granularity_m);
1136 1135
 		}
1137
-		$pos = round($pos,1);
1136
+		$pos = round($pos, 1);
1138 1137
 
1139
-		if ($this->debug > 3) $this->bo->debug_message('uiviews::time2pos(%1)=%2',False,$time,$pos);
1138
+		if ($this->debug > 3) $this->bo->debug_message('uiviews::time2pos(%1)=%2', False, $time, $pos);
1140 1139
 
1141 1140
 		return $pos;
1142 1141
 	}
@@ -1151,12 +1150,12 @@  discard block
 block discarded – undo
1151 1150
 	 * @param int $minimum = 0 minimum height
1152 1151
 	 * @return float height in percent
1153 1152
 	 */
1154
-	function times2height($start,$end,$minimum=0)
1153
+	function times2height($start, $end, $minimum = 0)
1155 1154
 	{
1156 1155
 		$minimum = $this->rowHeight;
1157 1156
 		$height = $this->time2pos($end) - $this->time2pos($start);
1158 1157
 
1159
-		if ($this->debug > 3) $this->bo->debug_message('uiviews::times2height(%1,%2,min=%3)=%4',False,$start,$end,$minimum,$height);
1158
+		if ($this->debug > 3) $this->bo->debug_message('uiviews::times2height(%1,%2,min=%3)=%4', False, $start, $end, $minimum, $height);
1160 1159
 
1161 1160
 		return $height >= $minimum ? $height : $minimum;
1162 1161
 	}
@@ -1174,36 +1173,36 @@  discard block
 block discarded – undo
1174 1173
 	 * @param int/array $owner = 0 owner of the calendar (default 0 = $this->owner) or array with owner for each column
1175 1174
 	 * @param boolean $last = true last timeGrid displayed, default true
1176 1175
 	 */
1177
-	function &timeGridWidget($daysEvents,$granularity_m=30,$height=400,$indent='',$title='',$owner=0,$last=true)
1176
+	function &timeGridWidget($daysEvents, $granularity_m = 30, $height = 400, $indent = '', $title = '', $owner = 0, $last = true)
1178 1177
 	{
1179
-		if ($this->debug > 1 || $this->debug==='timeGridWidget') $this->bo->debug_message('uiviews::timeGridWidget(events=%1,granularity_m=%2,height=%3,,title=%4)',True,$daysEvents,$granularity_m,$height,$title);
1178
+		if ($this->debug > 1 || $this->debug === 'timeGridWidget') $this->bo->debug_message('uiviews::timeGridWidget(events=%1,granularity_m=%2,height=%3,,title=%4)', True, $daysEvents, $granularity_m, $height, $title);
1180 1179
 
1181 1180
 		// determine if the browser supports scrollIntoView: IE4+, firefox1.0+ and safari2.0+ does
1182 1181
 		// then show all hours in a div of the size of the workday and scroll to the workday start
1183 1182
 		// still disabled, as things need to be re-aranged first, to that the column headers are not scrolled
1184
-		$this->scroll_to_wdstart = false;/*$this->use_time_grid && (html::$user_agent == 'msie' ||
1183
+		$this->scroll_to_wdstart = false; /*$this->use_time_grid && (html::$user_agent == 'msie' ||
1185 1184
 			html::$user_agent == 'mozilla' && html::ua_version >= 5.0 ||
1186 1185
 			html::$user_agent == 'safari' && html::ua_version >= 2.0);*/
1187 1186
 
1188 1187
 		if ($this->scroll_to_wdstart)
1189 1188
 		{
1190
-			$this->extraRows = 0;	// no extra rows necessary
1189
+			$this->extraRows = 0; // no extra rows necessary
1191 1190
 			$this->remBotExtraRows = 0;
1192 1191
 			$overflow = 'overflow: scroll;';
1193 1192
 		}
1194 1193
 		$this->granularity_m = $granularity_m;
1195 1194
 		$this->display_start = $this->wd_start - ($this->extraRows * $this->granularity_m);
1196
-		$this->display_end	= $this->wd_end + (($this->extraRows - $this->remBotExtraRows) * $this->granularity_m);
1195
+		$this->display_end = $this->wd_end + (($this->extraRows - $this->remBotExtraRows) * $this->granularity_m);
1197 1196
 
1198 1197
 		if (!$this->wd_end) $this->wd_end = 1440;
1199 1198
 		$totalDisplayMinutes	= $this->wd_end - $this->wd_start;
1200
-		$this->rowsToDisplay	= ($totalDisplayMinutes/$granularity_m)+2+2*$this->extraRows - $this->remBotExtraRows;
1201
-		$this->rowHeight		= round(100/$this->rowsToDisplay,1);
1199
+		$this->rowsToDisplay	= ($totalDisplayMinutes / $granularity_m) + 2 + 2 * $this->extraRows - $this->remBotExtraRows;
1200
+		$this->rowHeight = round(100 / $this->rowsToDisplay, 1);
1202 1201
 
1203 1202
 		// ensure a minimum height of each row
1204
-		if ($height < ($this->rowsToDisplay+1) * 12)
1203
+		if ($height < ($this->rowsToDisplay + 1) * 12)
1205 1204
 		{
1206
-			$height = ($this->rowsToDisplay+1) * 12;
1205
+			$height = ($this->rowsToDisplay + 1) * 12;
1207 1206
 		}
1208 1207
 		$html = $indent.'<div class="calendar_calTimeGrid" style="height: '.$height.'px;'.$overflow.'">'."\n";
1209 1208
 
@@ -1212,13 +1211,13 @@  discard block
 block discarded – undo
1212 1211
 
1213 1212
 		if ($this->use_time_grid)
1214 1213
 		{
1215
-			$off = false;	// Off-row means a different bgcolor
1214
+			$off = false; // Off-row means a different bgcolor
1216 1215
 			$add_links = count($daysEvents) == 1;
1217 1216
 
1218 1217
 			// the hour rows
1219
-			for($t = $this->scroll_to_wdstart ? 0 : $this->wd_start,$i = 1+$this->extraRows;
1220
-				$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24*60;
1221
-				$t += $this->granularity_m,++$i)
1218
+			for ($t = $this->scroll_to_wdstart ? 0 : $this->wd_start, $i = 1 + $this->extraRows;
1219
+				$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24 * 60;
1220
+				$t += $this->granularity_m, ++$i)
1222 1221
 			{
1223 1222
 				$set_id = '';
1224 1223
 				if ($t == $this->wd_start)
@@ -1231,29 +1230,29 @@  discard block
 block discarded – undo
1231 1230
 					}
1232 1231
 				}
1233 1232
 				$html .= $indent."\t".'<div'.$set_id.' class="calendar_calTimeRow'.($off ? 'Off row_off' : ' row_on').
1234
-					'" style="height: '.$this->rowHeight.'%; top:'. $i*$this->rowHeight .'%;">'."\n";
1233
+					'" style="height: '.$this->rowHeight.'%; top:'.$i * $this->rowHeight.'%;">'."\n";
1235 1234
 				// show time for full hours, allways for 45min interval and at least on every 3 row
1236 1235
 				$time = '';
1237 1236
 				static $show = array(
1238
-					5  => array(0,15,30,45),
1239
-					10 => array(0,30),
1240
-					15 => array(0,30),
1241
-					45 => array(0,15,30,45),
1237
+					5  => array(0, 15, 30, 45),
1238
+					10 => array(0, 30),
1239
+					15 => array(0, 30),
1240
+					45 => array(0, 15, 30, 45),
1242 1241
 				);
1243
-				if (!isset($show[$this->granularity_m]) ? $t % 60 == 0 : in_array($t % 60,$show[$this->granularity_m]))
1242
+				if (!isset($show[$this->granularity_m]) ? $t % 60 == 0 : in_array($t % 60, $show[$this->granularity_m]))
1244 1243
 				{
1245
-					$time = $GLOBALS['egw']->common->formattime(sprintf('%02d',$t/60),sprintf('%02d',$t%60));
1244
+					$time = $GLOBALS['egw']->common->formattime(sprintf('%02d', $t / 60), sprintf('%02d', $t % 60));
1246 1245
 				}
1247
-				if ($add_links) $time = $this->add_link($time,$this->date,(int) ($t/60),$t%60);
1246
+				if ($add_links) $time = $this->add_link($time, $this->date, (int)($t / 60), $t % 60);
1248 1247
 				$html .= $indent."\t\t".'<div class="calendar_calTimeRowTime">'.$time."</div>\n";
1249
-				$html .= $indent."\t</div>\n";	// calendar_calTimeRow
1248
+				$html .= $indent."\t</div>\n"; // calendar_calTimeRow
1250 1249
 				$off = !$off;
1251 1250
 			}
1252 1251
 		}
1253 1252
 		if (is_array($daysEvents) && count($daysEvents))
1254 1253
 		{
1255
-			$numberOfDays	= count($daysEvents);
1256
-			$dayColWidth	= 100/$numberOfDays;
1254
+			$numberOfDays = count($daysEvents);
1255
+			$dayColWidth = 100 / $numberOfDays;
1257 1256
 
1258 1257
 			$dayCols_width = $width - $this->timeRow_width - 1;
1259 1258
 
@@ -1275,9 +1274,9 @@  discard block
 block discarded – undo
1275 1274
 			}
1276 1275
 			$dayCol_width = $dayCols_width / count($daysEvents);
1277 1276
 			$n = 0;
1278
-			foreach($daysEvents as $day => $events)
1277
+			foreach ($daysEvents as $day => $events)
1279 1278
 			{
1280
-				$this->wholeDayPosCounter=1;
1279
+				$this->wholeDayPosCounter = 1;
1281 1280
 				$short_title = count($daysEvents) > 1;
1282 1281
 				$col_owner = $owner;
1283 1282
 				if (!is_numeric($day))
@@ -1286,15 +1285,15 @@  discard block
 block discarded – undo
1286 1285
 					$day = $this->date;
1287 1286
 					$col_owner = $owner[$n];
1288 1287
 				}
1289
-				$html .= $this->dayColWidget($day,$events,$n*$dayColWidth,
1290
-					$dayColWidth,$indent."\t\t",$short_title,++$on_off & 1,$col_owner);
1288
+				$html .= $this->dayColWidget($day, $events, $n * $dayColWidth,
1289
+					$dayColWidth, $indent."\t\t", $short_title, ++$on_off&1, $col_owner);
1291 1290
 				++$n;
1292 1291
 			}
1293 1292
 			if (html::$user_agent == 'msie') $html .= "</div>\n";
1294 1293
 
1295
-			$html .= $indent."\t</div>\n";	// calendar_calDayCols
1294
+			$html .= $indent."\t</div>\n"; // calendar_calDayCols
1296 1295
 		}
1297
-		$html .= $indent."</div>\n";	// calendar_calTimeGrid
1296
+		$html .= $indent."</div>\n"; // calendar_calTimeGrid
1298 1297
 
1299 1298
 		if ($this->scroll_to_wdstart)
1300 1299
 		{
@@ -1322,13 +1321,13 @@  discard block
 block discarded – undo
1322 1321
 
1323 1322
 		// if daylight saving is switched on or off, correct $day_start
1324 1323
 		// gives correct times after 2am, times between 0am and 2am are wrong
1325
-		if(($daylight_diff = $day_start + 12*HOUR_s - ($this->bo->date2ts($day_ymd."T120000"))))
1324
+		if (($daylight_diff = $day_start + 12 * HOUR_s - ($this->bo->date2ts($day_ymd."T120000"))))
1326 1325
 		{
1327 1326
 			$day_start -= $daylight_diff;
1328 1327
 		}
1329 1328
 
1330 1329
 		$eventCols = $col_ends = array();
1331
-		foreach($events as $event)
1330
+		foreach ($events as $event)
1332 1331
 		{
1333 1332
 			$event['multiday'] = False;
1334 1333
 			$event['start_m'] = ($event['start'] - $day_start) / 60;
@@ -1338,19 +1337,19 @@  discard block
 block discarded – undo
1338 1337
 				$event['multiday'] = True;
1339 1338
 			}
1340 1339
 			$event['end_m'] = ($event['end'] - $day_start) / 60;
1341
-			if ($event['end_m'] >= 24*60)
1340
+			if ($event['end_m'] >= 24 * 60)
1342 1341
 			{
1343
-				$event['end_m'] = 24*60-1;
1342
+				$event['end_m'] = 24 * 60 - 1;
1344 1343
 				$event['multiday'] = True;
1345 1344
 			}
1346 1345
 			if ($this->use_time_grid && !$event['whole_day_on_top'])
1347 1346
 			{
1348
-				for($c = 0; $event['start_m'] < $col_ends[$c]; ++$c);
1347
+				for ($c = 0; $event['start_m'] < $col_ends[$c]; ++$c);
1349 1348
 				$col_ends[$c] = $event['end_m'];
1350 1349
 			}
1351 1350
 			else
1352 1351
 			{
1353
-				$c = 0;		// without grid we only use one column
1352
+				$c = 0; // without grid we only use one column
1354 1353
 			}
1355 1354
 			$eventCols[$c][] = $event;
1356 1355
 		}
@@ -1371,23 +1370,22 @@  discard block
 block discarded – undo
1371 1370
 	 * @param boolean $on_off = false start with row_on or row_off, default false=row_off
1372 1371
 	 * @param int $owner = 0 if != 0 owner to add to the add-event link
1373 1372
 	 */
1374
-	function dayColWidget($day_ymd,$events,$pleft,$pwidth,$indent,$short_title=True,$on_off=False,$owner=0)
1373
+	function dayColWidget($day_ymd, $events, $pleft, $pwidth, $indent, $short_title = True, $on_off = False, $owner = 0)
1375 1374
 	{
1376
-		if ($this->debug > 1 || $this->debug==='dayColWidget') $this->bo->debug_message('uiviews::dayColWidget(%1,%2,left=%3,width=%4,)',False,$day_ymd,$events,$pleft,$pwidth);
1375
+		if ($this->debug > 1 || $this->debug === 'dayColWidget') $this->bo->debug_message('uiviews::dayColWidget(%1,%2,left=%3,width=%4,)', False, $day_ymd, $events, $pleft, $pwidth);
1377 1376
 		
1378 1377
 		$html = $indent.'<div id="calColumn'.$this->calColumnCounter++.'" class="calendar_calDayCol" '.'data-sortable-id="'.$owner.'" style="left: '.$pleft.
1379 1378
 			'%;width: '.$pwidth.'%;">'."\n";
1380 1379
 
1381 1380
 		// Creation of the header-column with date, evtl. holiday-names and a matching background-color
1382 1381
 		$ts = $this->bo->date2ts((string)$day_ymd);
1383
-		$title = !is_bool($short_title) ? $short_title :
1384
-			($short_title ? lang(adodb_date('l',$ts)).' '.adodb_date('d.',$ts) : $this->bo->long_date($ts,0,false,true));
1382
+		$title = !is_bool($short_title) ? $short_title : ($short_title ? lang(adodb_date('l', $ts)).' '.adodb_date('d.', $ts) : $this->bo->long_date($ts, 0, false, true));
1385 1383
 
1386 1384
 		$day_view = array(
1387 1385
 			'menuaction' => 'calendar.calendar_uiviews.day',
1388 1386
 			'date' => $day_ymd,
1389 1387
 		);
1390
-		$this->_day_class_holiday($day_ymd,$class,$holidays);
1388
+		$this->_day_class_holiday($day_ymd, $class, $holidays);
1391 1389
 		// the weekday and date
1392 1390
 		if (!$short_title && $holidays) $title .= html::htmlspecialchars(': '.$holidays);
1393 1391
 
@@ -1395,26 +1393,26 @@  discard block
 block discarded – undo
1395 1393
 		{
1396 1394
 			if ($this->allowEdit)
1397 1395
 			{
1398
-				$title = html::a_href($title,$day_view,'',
1399
-					!isset($this->holidays[$day_ymd])?' title="'.$this->bo->long_date($ts,0,false,true).'"':'');
1396
+				$title = html::a_href($title, $day_view, '',
1397
+					!isset($this->holidays[$day_ymd]) ? ' title="'.$this->bo->long_date($ts, 0, false, true).'"' : '');
1400 1398
 			}
1401 1399
 		}
1402 1400
 		elseif ($short_title === false)
1403 1401
 		{
1404 1402
 			// add arrows to go to the previous and next day (dayview only)
1405
-			$day_view['date'] = $this->bo->date2string($ts -= 12*HOUR_s);
1403
+			$day_view['date'] = $this->bo->date2string($ts -= 12 * HOUR_s);
1406 1404
 			if ($this->allowEdit)
1407 1405
 			{
1408
-				$title = html::a_href(html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' <span> '.$title;
1406
+				$title = html::a_href(html::image('phpgwapi', 'left', $this->bo->long_date($ts)), $day_view).' <span> '.$title;
1409 1407
 			}
1410 1408
 			else
1411 1409
 			{
1412 1410
 				$title = $day_view.' <span> '.$title;
1413 1411
 			}
1414
-			$day_view['date'] = $this->bo->date2string($ts += 48*HOUR_s);
1412
+			$day_view['date'] = $this->bo->date2string($ts += 48 * HOUR_s);
1415 1413
 			if ($this->allowEdit)
1416 1414
 			{
1417
-				$title .= ' </span> '.html::a_href(html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
1415
+				$title .= ' </span> '.html::a_href(html::image('phpgwapi', 'right', $this->bo->long_date($ts)), $day_view);
1418 1416
 			}
1419 1417
 			else
1420 1418
 			{
@@ -1422,16 +1420,16 @@  discard block
 block discarded – undo
1422 1420
 			}
1423 1421
 		}
1424 1422
 		if (is_bool($short_title) || ($short_title != "")) {
1425
-			$html .= $indent."\t".'<div style="height: '. $this->rowHeight .'%;" class="calendar_calDayColHeader '.$class.'"'.
1426
-				($holidays ? ' title="'.html::htmlspecialchars($holidays).'"':'').'>'.$title."</div>\n";
1423
+			$html .= $indent."\t".'<div style="height: '.$this->rowHeight.'%;" class="calendar_calDayColHeader '.$class.'"'.
1424
+				($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
1427 1425
 		}
1428 1426
 
1429 1427
 		if ($this->use_time_grid)
1430 1428
 		{
1431 1429
 			// drag and drop: check if the current user has EDIT permissions on the grid
1432
-			if($owner)
1430
+			if ($owner)
1433 1431
 			{
1434
-				$dropPermission = $this->bo->check_perms(EGW_ACL_EDIT,0,$owner);
1432
+				$dropPermission = $this->bo->check_perms(EGW_ACL_EDIT, 0, $owner);
1435 1433
 			}
1436 1434
 			else
1437 1435
 			{
@@ -1439,28 +1437,28 @@  discard block
 block discarded – undo
1439 1437
 			}
1440 1438
 
1441 1439
 			// adding divs to click on for each row / time-span
1442
-			for($t = $this->scroll_to_wdstart ? 0 : $this->wd_start,$i = 1 + $this->extraRows;
1443
-				$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24*60;
1444
-				$t += $this->granularity_m,++$i)
1440
+			for ($t = $this->scroll_to_wdstart ? 0 : $this->wd_start, $i = 1 + $this->extraRows;
1441
+				$t <= $this->wd_end || $this->scroll_to_wdstart && $t < 24 * 60;
1442
+				$t += $this->granularity_m, ++$i)
1445 1443
 			{
1446 1444
 				$linkData = array(
1447 1445
 					'menuaction'	=>'calendar.calendar_uiforms.edit',
1448 1446
 					'date'		=> $day_ymd,
1449
-					'hour'		=> sprintf("%02d",floor($t / 60)),
1450
-					'minute'	=> sprintf("%02d",floor($t % 60)),
1447
+					'hour'		=> sprintf("%02d", floor($t / 60)),
1448
+					'minute'	=> sprintf("%02d", floor($t % 60)),
1451 1449
 				);
1452 1450
 				if ($owner) $linkData['owner'] = $owner;
1453 1451
 
1454
-				$droppableDateTime = $linkData['date'] . "T" . $linkData['hour'] . $linkData['minute'];
1455
-				$droppableID='drop_'.$droppableDateTime.'_O'.($owner<0?str_replace('-','group',$owner):$owner);
1452
+				$droppableDateTime = $linkData['date']."T".$linkData['hour'].$linkData['minute'];
1453
+				$droppableID = 'drop_'.$droppableDateTime.'_O'.($owner < 0 ? str_replace('-', 'group', $owner) : $owner);
1456 1454
 				
1457
-				$html .= $indent."\t".'<div id="' . $droppableID . '" style="height:'. $this->rowHeight .'%; top: '. $i*$this->rowHeight .
1455
+				$html .= $indent."\t".'<div id="'.$droppableID.'" style="height:'.$this->rowHeight.'%; top: '.$i * $this->rowHeight.
1458 1456
 					'%;" class="calendar_calAddEvent"';
1459 1457
 				if ($this->allowEdit)
1460 1458
 				{
1461
-					$html .= ' data-date=' .$linkData['date'].'|'.$linkData['hour'].'|'.$linkData['minute'];
1459
+					$html .= ' data-date='.$linkData['date'].'|'.$linkData['hour'].'|'.$linkData['minute'];
1462 1460
 				}
1463
-				if($dropPermission && $owner)
1461
+				if ($dropPermission && $owner)
1464 1462
 				{
1465 1463
 					$html .= ' data-owner ='.$owner;
1466 1464
 
@@ -1470,9 +1468,9 @@  discard block
 block discarded – undo
1470 1468
 			}
1471 1469
 		}
1472 1470
 
1473
-		$eventCols = $this->getEventCols($day_ymd,$events);
1471
+		$eventCols = $this->getEventCols($day_ymd, $events);
1474 1472
 		// displaying all event columns of the day
1475
-		foreach($eventCols as $n => $eventCol)
1473
+		foreach ($eventCols as $n => $eventCol)
1476 1474
 		{
1477 1475
 			// equal sized columns
1478 1476
 			//$width = 95.0 / count($eventCols);
@@ -1486,14 +1484,14 @@  discard block
 block discarded – undo
1486 1484
 			else
1487 1485
 			{
1488 1486
 				$width = !$n ? 70 : 50;
1489
-				$left += $n * (100.0-$left) / count($eventCols);
1487
+				$left += $n * (100.0 - $left) / count($eventCols);
1490 1488
 			}
1491 1489
 			if ($left + $width > 100.0) $width = 100.0 - $left;
1492 1490
 			//echo "<p>count(\$eventCols)=".count($eventCols).", n=$n, pWidth=$pwidth, pLeft=$pleft, width=$width, left=$left</p>\n";
1493
-			$html .= $this->eventColWidget($eventCol,$left,$width,$indent."\t",
1494
-				$owner ? $owner : $this->user, 20+10*$n);
1491
+			$html .= $this->eventColWidget($eventCol, $left, $width, $indent."\t",
1492
+				$owner ? $owner : $this->user, 20 + 10 * $n);
1495 1493
 		}
1496
-		$html .= $indent."</div>\n";	// calendar_calDayCol
1494
+		$html .= $indent."</div>\n"; // calendar_calDayCol
1497 1495
 
1498 1496
 		return $html;
1499 1497
 	}
@@ -1510,14 +1508,14 @@  discard block
 block discarded – undo
1510 1508
 	 *        If the preferences allow birthdays to be displayed, they are cached within the holidays structure.
1511 1509
 	 *        This setting just suppressing the available data in the view.
1512 1510
 	 */
1513
-	function _day_class_holiday($day_ymd,&$class,&$holidays,$only_weekend=false,$show_bdays=true)
1511
+	function _day_class_holiday($day_ymd, &$class, &$holidays, $only_weekend = false, $show_bdays = true)
1514 1512
 	{
1515 1513
 		$class = $holidays = '';
1516 1514
 		$bday = false;
1517 1515
 		if (isset($this->holidays[$day_ymd]))
1518 1516
 		{
1519 1517
 			$h = array();
1520
-			foreach($this->holidays[$day_ymd] as $holiday)
1518
+			foreach ($this->holidays[$day_ymd] as $holiday)
1521 1519
 			{
1522 1520
 				if (isset($holiday['birthyear']))
1523 1521
 				{
@@ -1545,7 +1543,7 @@  discard block
 block discarded – undo
1545 1543
 					}
1546 1544
 				}
1547 1545
 			}
1548
-			$holidays = implode(', ',$h);
1546
+			$holidays = implode(', ', $h);
1549 1547
 		}
1550 1548
 		if (!$class)
1551 1549
 		{
@@ -1555,7 +1553,7 @@  discard block
 block discarded – undo
1555 1553
 			}
1556 1554
 			else
1557 1555
 			{
1558
-				$day = (int) date('w',$this->bo->date2ts((string) $day_ymd));
1556
+				$day = (int)date('w', $this->bo->date2ts((string)$day_ymd));
1559 1557
 
1560 1558
 				if ($only_weekend)
1561 1559
 				{
@@ -1563,7 +1561,7 @@  discard block
 block discarded – undo
1563 1561
 				}
1564 1562
 				else
1565 1563
 				{
1566
-					$class = $day & 1 ? 'row_on' : 'th';
1564
+					$class = $day&1 ? 'row_on' : 'th';
1567 1565
 				}
1568 1566
 			}
1569 1567
 		}
@@ -1581,9 +1579,9 @@  discard block
 block discarded – undo
1581 1579
 	 * @param string $indent string for correct indention
1582 1580
 	 * @param int $owner owner of the eventCol
1583 1581
 	 */
1584
-	function eventColWidget($events,$left,$width,$indent,$owner,$z_index=null)
1582
+	function eventColWidget($events, $left, $width, $indent, $owner, $z_index = null)
1585 1583
 	{
1586
-		if ($this->debug > 1 || $this->debug==='eventColWidget') $this->bo->debug_message('uiviews::eventColWidget(%1,left=%2,width=%3,)',False,$events,$left,$width);
1584
+		if ($this->debug > 1 || $this->debug === 'eventColWidget') $this->bo->debug_message('uiviews::eventColWidget(%1,left=%2,width=%3,)', False, $events, $left, $width);
1587 1585
 
1588 1586
 		$html = $indent.'<div class="calendar_calEventCol" style="left: '.$left.'%; width:'.$width.'%;'.
1589 1587
 			// the "calendar_calEventCol" spans across a whole column (as the name suggests) - setting the
@@ -1592,9 +1590,9 @@  discard block
 block discarded – undo
1592 1590
 			// function.
1593 1591
 			//(!is_null($z_index) ? ' z-index:'.$z_index.';' : '').
1594 1592
 			(!$this->use_time_grid ? ' top: '.$this->rowHeight.'%;height: '.(100 - $this->rowHeight).'%;overflow-y:auto;' : '').'">'."\n";
1595
-		foreach($events as $event)
1593
+		foreach ($events as $event)
1596 1594
 		{
1597
-			$html .= $this->eventWidget($event,$width,$indent."\t",$owner,false,'event_widget',$z_index);
1595
+			$html .= $this->eventWidget($event, $width, $indent."\t", $owner, false, 'event_widget', $z_index);
1598 1596
 		}
1599 1597
 		$html .= $indent."</div>\n";
1600 1598
 
@@ -1615,28 +1613,28 @@  discard block
 block discarded – undo
1615 1613
 	 * @param int $z_index is the z-index of the drag-drobable outer box of the event.
1616 1614
 	 * @return string/array
1617 1615
 	 */
1618
-	function eventWidget($event,$width,$indent,$owner,$return_array=false,$block='event_widget',$z_index=null)
1616
+	function eventWidget($event, $width, $indent, $owner, $return_array = false, $block = 'event_widget', $z_index = null)
1619 1617
 	{
1620
-		if ($this->debug > 1 || $this->debug==='eventWidget') $this->bo->debug_message('uiviews::eventWidget(%1,width=%2)',False,$event,$width);
1618
+		if ($this->debug > 1 || $this->debug === 'eventWidget') $this->bo->debug_message('uiviews::eventWidget(%1,width=%2)', False, $event, $width);
1621 1619
 
1622
-		if($this->use_time_grid && $event['whole_day_on_top']) $block = 'event_widget_wholeday_on_top';
1620
+		if ($this->use_time_grid && $event['whole_day_on_top']) $block = 'event_widget_wholeday_on_top';
1623 1621
 
1624 1622
 		static $tpl = False;
1625 1623
 		if (!$tpl)
1626 1624
 		{
1627 1625
 			$tpl = new Template(common::get_tpl_dir('calendar'));
1628 1626
 
1629
-			$tpl->set_file('event_widget_t','event_widget.tpl');
1630
-			$tpl->set_block('event_widget_t','event_widget');
1631
-			$tpl->set_block('event_widget_t','event_widget_wholeday_on_top');
1632
-			$tpl->set_block('event_widget_t','event_tooltip');
1633
-			$tpl->set_block('event_widget_t','planner_event');
1627
+			$tpl->set_file('event_widget_t', 'event_widget.tpl');
1628
+			$tpl->set_block('event_widget_t', 'event_widget');
1629
+			$tpl->set_block('event_widget_t', 'event_widget_wholeday_on_top');
1630
+			$tpl->set_block('event_widget_t', 'event_tooltip');
1631
+			$tpl->set_block('event_widget_t', 'planner_event');
1634 1632
 		}
1635
-		if (($return_array || $event['start_m'] == 0) && $event['end_m'] >= 24*60-1)
1633
+		if (($return_array || $event['start_m'] == 0) && $event['end_m'] >= 24 * 60 - 1)
1636 1634
 		{
1637
-			if ($return_array && $event['end_m'] > 24*60)
1635
+			if ($return_array && $event['end_m'] > 24 * 60)
1638 1636
 			{
1639
-				$timespan = $this->bo->format_date($event['start'],false).' - '.$this->bo->format_date($event['end']);
1637
+				$timespan = $this->bo->format_date($event['start'], false).' - '.$this->bo->format_date($event['end']);
1640 1638
 			}
1641 1639
 			else
1642 1640
 			{
@@ -1645,49 +1643,49 @@  discard block
 block discarded – undo
1645 1643
 		}
1646 1644
 		else
1647 1645
 		{
1648
-			$timespan = $this->bo->timespan($event['start_m'],$event['end_m']);
1646
+			$timespan = $this->bo->timespan($event['start_m'], $event['end_m']);
1649 1647
 		}
1650 1648
 		$icons = array();
1651
-		if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
1649
+		if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
1652 1650
 		{
1653 1651
 			$app = $matches[1];
1654 1652
 			$app_id = $matches[2];
1655
-			if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
1653
+			if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
1656 1654
 			{
1657
-				$icons[] = html::image('calendar','private');
1655
+				$icons[] = html::image('calendar', 'private');
1658 1656
 			}
1659 1657
 			else
1660 1658
 			{
1661
-				$icons = self::integration_get_icons($app,$app_id,$event);
1659
+				$icons = self::integration_get_icons($app, $app_id, $event);
1662 1660
 			}
1663 1661
 		}
1664
-		elseif($event['id'])
1662
+		elseif ($event['id'])
1665 1663
 		{
1666
-			if (($is_private = !$this->bo->check_perms(EGW_ACL_READ,$event)))
1664
+			if (($is_private = !$this->bo->check_perms(EGW_ACL_READ, $event)))
1667 1665
 			{
1668
-				$icons = array(html::image('calendar','private'));
1666
+				$icons = array(html::image('calendar', 'private'));
1669 1667
 			}
1670 1668
 			else
1671 1669
 			{
1672 1670
 				$icons = $this->event_icons($event);
1673 1671
 			}
1674 1672
 		}
1675
-		$cats  = $this->bo->categories($this->categories->check_list(EGW_ACL_READ, $event['category']),$color);
1673
+		$cats = $this->bo->categories($this->categories->check_list(EGW_ACL_READ, $event['category']), $color);
1676 1674
 		// these values control varius aspects of the geometry of the eventWidget
1677
-		$small_trigger_width = 120 + 20*count($icons);
1678
-		$corner_radius=$width > $small_trigger_width ? 10 : 5;
1679
-		$header_height=$width > $small_trigger_width ? 19 : 12;	// multi_3 icon has a height of 19=16+2*1padding+1border !
1675
+		$small_trigger_width = 120 + 20 * count($icons);
1676
+		$corner_radius = $width > $small_trigger_width ? 10 : 5;
1677
+		$header_height = $width > $small_trigger_width ? 19 : 12; // multi_3 icon has a height of 19=16+2*1padding+1border !
1680 1678
 		if (!$return_array)
1681 1679
 		{
1682
-			$height = $this->times2height($event['start_m'],$event['end_m'],$header_height);
1680
+			$height = $this->times2height($event['start_m'], $event['end_m'], $header_height);
1683 1681
 		}
1684 1682
 		//$body_height = max(0,$height - $header_height - $corner_radius);
1685
-		$border=1;
1683
+		$border = 1;
1686 1684
 		$headerbgcolor = $color ? $color : '#808080';
1687 1685
 		$headercolor = self::brightness($headerbgcolor) > 128 ? 'black' : 'white';
1688 1686
 		// the body-colors (gradient) are calculated from the headercolor, which depends on the cat of an event
1689
-		$bodybgcolor1 = $this->brighter($headerbgcolor,$headerbgcolor == '#808080' ? 100 : 170);
1690
-		$bodybgcolor2 = $this->brighter($headerbgcolor,220);
1687
+		$bodybgcolor1 = $this->brighter($headerbgcolor, $headerbgcolor == '#808080' ? 100 : 170);
1688
+		$bodybgcolor2 = $this->brighter($headerbgcolor, 220);
1691 1689
 
1692 1690
 		// mark event as invitation, by NOT using category based background color, but plain white
1693 1691
 		if ($event['participants'][$this->user][0] == 'U')
@@ -1697,11 +1695,11 @@  discard block
 block discarded – undo
1697 1695
 
1698 1696
 		// get status class of event: calendar_calEventAllAccepted, calendar_calEventAllAnswered or calendar_calEventSomeUnknown
1699 1697
 		$status_class = 'calendar_calEventAllAccepted';
1700
-		foreach($event['participants'] as $id => $status)
1698
+		foreach ($event['participants'] as $id => $status)
1701 1699
 		{
1702
-			if ($id < 0) continue;	// as we cant accept/reject groups, we dont care about them here
1700
+			if ($id < 0) continue; // as we cant accept/reject groups, we dont care about them here
1703 1701
 
1704
-			calendar_so::split_status($status,$quantity,$role);
1702
+			calendar_so::split_status($status, $quantity, $role);
1705 1703
 
1706 1704
 			switch ($status)
1707 1705
 			{
@@ -1710,7 +1708,7 @@  discard block
 block discarded – undo
1710 1708
 					break;
1711 1709
 				case 'U':
1712 1710
 					$status_class = 'calendar_calEventSomeUnknown';
1713
-					break 2;	// break foreach
1711
+					break 2; // break foreach
1714 1712
 				default:
1715 1713
 					$status_class = 'calendar_calEventAllAnswered';
1716 1714
 					break;
@@ -1720,48 +1718,46 @@  discard block
 block discarded – undo
1720 1718
 		$part_array = array();
1721 1719
 		if ($this->allowEdit)
1722 1720
  		{
1723
-			foreach($this->bo->participants($event) as $part_key => $participant)
1721
+			foreach ($this->bo->participants($event) as $part_key => $participant)
1724 1722
  			{
1725
-				if(is_numeric($part_key))
1723
+				if (is_numeric($part_key))
1726 1724
 				{
1727 1725
 					$part_array[lang('Participants')][$part_key] = $participant;
1728 1726
 				}
1729
-				elseif(isset($this->bo->resources[$part_key[0]]))
1727
+				elseif (isset($this->bo->resources[$part_key[0]]))
1730 1728
 				{
1731 1729
 					 $part_array[((isset($this->bo->resources[$part_key[0]]['participants_header'])) ? $this->bo->resources[$part_key[0]]['participants_header'] : lang($this->bo->resources[$part_key[0]]['app']))][$part_key] = $participant;
1732 1730
 				}
1733 1731
  			}
1734
-			foreach($part_array as $part_group => $participant)
1732
+			foreach ($part_array as $part_group => $participant)
1735 1733
  			{
1736
-				$participants .= $this->add_nonempty($participant,$part_group,True,False,false);
1734
+				$participants .= $this->add_nonempty($participant, $part_group, True, False, false);
1737 1735
  			}
1738 1736
  		}
1739 1737
 		// as we only deal with percentual widht, we consider only the full dayview (1 colum) as NOT small
1740 1738
 		$small = $this->view != 'day' || $width < 50;
1741 1739
 		// $small = $width <= $small_trigger_width
1742 1740
 
1743
-		$small_height = $this->use_time_grid && ( $event['end_m']-$event['start_m'] < 2*$this->granularity_m ||
1741
+		$small_height = $this->use_time_grid && ($event['end_m'] - $event['start_m'] < 2 * $this->granularity_m ||
1744 1742
 			$event['end_m'] <= $this->wd_start || $event['start_m'] >= $this->wd_end);
1745 1743
 
1746 1744
 		$tpl->set_var(array(
1747 1745
 			// event-content, some of it displays only if it really has content or is needed
1748 1746
 			'owner' => $GLOBALS['egw']->common->grab_owner_name($event['owner']),
1749
-			'header_icons' => $small ? '' : implode("",$icons),
1750
-			'body_icons' => $small ? implode("\n",$icons) : '',
1751
-			'icons' => implode('',$icons),
1747
+			'header_icons' => $small ? '' : implode("", $icons),
1748
+			'body_icons' => $small ? implode("\n", $icons) : '',
1749
+			'icons' => implode('', $icons),
1752 1750
 			'timespan' => $timespan,
1753 1751
 			'title' => ($title = !$is_private ? html::htmlspecialchars($event['title']) : lang('private')),
1754 1752
 			'header' => $small_height ? $title : $timespan,
1755 1753
 			'description' => !$is_private ? nl2br(html::htmlspecialchars($event['description'])) : '',
1756
-			'location'   => !$is_private ? $this->add_nonempty($event['location'],lang('Location')) : '',
1754
+			'location'   => !$is_private ? $this->add_nonempty($event['location'], lang('Location')) : '',
1757 1755
 			'participants' => $participants,
1758
-			'times' => !$event['multiday'] ? $this->add_nonempty($this->bo->timespan($event['start_m'],$event['end_m'],true),lang('Time')) :
1759
-				$this->add_nonempty($this->bo->format_date($event['start']),lang('Start')).
1760
-				$this->add_nonempty($this->bo->format_date($event['end']),lang('End')),
1761
-			'multidaytimes' => !$event['multiday'] ? '' :
1762
-				$this->add_nonempty($this->bo->format_date($event['start']),lang('Start')).
1763
-				$this->add_nonempty($this->bo->format_date($event['end']),lang('End')),
1764
-			'category' => !$is_private ? $this->add_nonempty($cats,lang('Category')) : '',
1756
+			'times' => !$event['multiday'] ? $this->add_nonempty($this->bo->timespan($event['start_m'], $event['end_m'], true), lang('Time')) : $this->add_nonempty($this->bo->format_date($event['start']), lang('Start')).
1757
+				$this->add_nonempty($this->bo->format_date($event['end']), lang('End')),
1758
+			'multidaytimes' => !$event['multiday'] ? '' : $this->add_nonempty($this->bo->format_date($event['start']), lang('Start')).
1759
+				$this->add_nonempty($this->bo->format_date($event['end']), lang('End')),
1760
+			'category' => !$is_private ? $this->add_nonempty($cats, lang('Category')) : '',
1765 1761
 			// the tooltip is based on the content of the actual widget, this way it takes no extra bandwidth/volum
1766 1762
 //			'tooltip' => html::tooltip(False,False,array('BorderWidth'=>0,'Padding'=>0)),
1767 1763
 			// various aspects of the geometry or style
@@ -1769,7 +1765,7 @@  discard block
 block discarded – undo
1769 1765
 			'header_height' => $header_height.'px',
1770 1766
 			//'body_height' => $body_height.'px',
1771 1767
 			'height' => $height,
1772
-			'width' => ($width-20).'px',
1768
+			'width' => ($width - 20).'px',
1773 1769
 			'border' => $border,
1774 1770
 			'bordercolor' => $headerbgcolor,
1775 1771
 			'headerbgcolor' => $headerbgcolor,
@@ -1777,7 +1773,7 @@  discard block
 block discarded – undo
1777 1773
 			'bodybackground' => ($background = 'url('.$GLOBALS['egw_info']['server']['webserver_url'].
1778 1774
 				'/calendar/inc/gradient.php?color1='.urlencode($bodybgcolor1).'&color2='.urlencode($bodybgcolor2).
1779 1775
 				'&width='.$width.') repeat-y '.$bodybgcolor2),
1780
-			'Small' => $small ? 'Small' : '',	// to use in css class-names
1776
+			'Small' => $small ? 'Small' : '', // to use in css class-names
1781 1777
 			'indent' => $indent."\t",
1782 1778
 			'status_class' => $status_class,
1783 1779
 		));
@@ -1808,16 +1804,16 @@  discard block
 block discarded – undo
1808 1804
 			$tpl->set_var('bodydescription', '');
1809 1805
 		}
1810 1806
 
1811
-		$tooltip = $tpl->fp('tooltip','event_tooltip');
1812
-		$html = $tpl->fp('out',$block);
1807
+		$tooltip = $tpl->fp('tooltip', 'event_tooltip');
1808
+		$html = $tpl->fp('out', $block);
1813 1809
 
1814 1810
 		if ($is_private || !$this->allowEdit)
1815 1811
 		{
1816 1812
 			$popup = '';
1817 1813
 		}
1818
-		elseif($app && $app_id)
1814
+		elseif ($app && $app_id)
1819 1815
 		{
1820
-			$popup = $this->integration_get_popup($app,$app_id);
1816
+			$popup = $this->integration_get_popup($app, $app_id);
1821 1817
 		}
1822 1818
 		else
1823 1819
 		{
@@ -1830,7 +1826,7 @@  discard block
 block discarded – undo
1830 1826
 				$popup = $event['id']."|n";
1831 1827
 			}
1832 1828
 		}
1833
-		$tooltip = html::htmlspecialchars($tooltip, true);	// true=need double-encoding, as it is transported as attribute!
1829
+		$tooltip = html::htmlspecialchars($tooltip, true); // true=need double-encoding, as it is transported as attribute!
1834 1830
 		//_debug_array($event);
1835 1831
 
1836 1832
 		if ($return_array)
@@ -1845,17 +1841,17 @@  discard block
 block discarded – undo
1845 1841
 		}
1846 1842
 
1847 1843
 		$draggableID = $event['id'].($event['recur_type'] ? ':'.$event['start'] : '').
1848
-			'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
1844
+			'_O'.$event['owner'].'_C'.($owner < 0 ? str_replace('-', 'group', $owner) : $owner);
1849 1845
 		
1850 1846
 		if ($this->use_time_grid)
1851 1847
 		{
1852
-			if($event['whole_day_on_top'])
1848
+			if ($event['whole_day_on_top'])
1853 1849
 			{
1854
-					$style = 'top: '.($this->rowHeight*$this->wholeDayPosCounter).'%; height: '.$this->rowHeight.'%;';
1850
+					$style = 'top: '.($this->rowHeight * $this->wholeDayPosCounter).'%; height: '.$this->rowHeight.'%;';
1855 1851
 					$this->wholeDayPosCounter++;
1856 1852
 			}
1857 1853
 			else
1858
-			{		$view_link = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
1854
+			{		$view_link = $GLOBALS['egw']->link('/index.php', array('menuaction'=>'calendar.calendar_uiforms.edit', 'cal_id'=>$event['id'], 'date'=>$this->bo->date2string($event['start'])));
1859 1855
 
1860 1856
 					$style = 'top: '.$this->time2pos($event['start_m']).'%; height: '.$height.'%;';
1861 1857
 			}
@@ -1870,17 +1866,17 @@  discard block
 block discarded – undo
1870 1866
 		$z_index = is_null($z_index) ? 20 : (int)$z_index;
1871 1867
 
1872 1868
 		if ($this->use_time_grid &&
1873
-			((int)$event['id'] || substr($event['id'],0,7) == 'infolog') && $this->bo->check_perms(EGW_ACL_EDIT,$event))
1869
+			((int)$event['id'] || substr($event['id'], 0, 7) == 'infolog') && $this->bo->check_perms(EGW_ACL_EDIT, $event))
1874 1870
 		{
1875 1871
 			if (!$event['whole_day_on_top'] &&
1876 1872
 				!$event['whole_day'] &&
1877 1873
 				!$event['recur_type'])
1878 1874
 			{
1879
-				$draggableID = 'drag_'.$event['id'].($event['recur_type'] ? ':'.$event['start'] : '').'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
1875
+				$draggableID = 'drag_'.$event['id'].($event['recur_type'] ? ':'.$event['start'] : '').'_O'.$event['owner'].'_C'.($owner < 0 ? str_replace('-', 'group', $owner) : $owner);
1880 1876
 			}
1881 1877
 			else
1882 1878
 			{
1883
-				$draggableID = 'drag_'.$event['id'].($event['recur_type'] ? ':'.$event['start'] : '').'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
1879
+				$draggableID = 'drag_'.$event['id'].($event['recur_type'] ? ':'.$event['start'] : '').'_O'.$event['owner'].'_C'.($owner < 0 ? str_replace('-', 'group', $owner) : $owner);
1884 1880
 
1885 1881
 			}
1886 1882
 		}
@@ -1889,7 +1885,7 @@  discard block
 block discarded – undo
1889 1885
 		{
1890 1886
 			// S represents Series
1891 1887
 			// '' represents Single
1892
-			$eventTypeTag = $event['recur_type']?'S':'';
1888
+			$eventTypeTag = $event['recur_type'] ? 'S' : '';
1893 1889
 		}
1894 1890
 		else if (!$event['recur_type'])
1895 1891
 		{
@@ -1902,9 +1898,9 @@  discard block
 block discarded – undo
1902 1898
 			$eventTypeTag = 'WDS';
1903 1899
 		}
1904 1900
 		// Helps client-side to bind handler to events with specific types tag
1905
-		$resizableHelper = $this->bo->date2string($event['start']). '|' .$this->bo->format_date($event['start'],false) . '|' . $this->cal_prefs['interval'].'|'.$eventTypeTag;
1901
+		$resizableHelper = $this->bo->date2string($event['start']).'|'.$this->bo->format_date($event['start'], false).'|'.$this->cal_prefs['interval'].'|'.$eventTypeTag;
1906 1902
 
1907
-		$html = $indent.'<div id="'.$draggableID.'" data-tooltip ="'.$tooltip .'" data-resize="'.$resizableHelper.'" class="calendar_calEvent'.($is_private ? 'Private' : '').' '.$status_class.
1903
+		$html = $indent.'<div id="'.$draggableID.'" data-tooltip ="'.$tooltip.'" data-resize="'.$resizableHelper.'" class="calendar_calEvent'.($is_private ? 'Private' : '').' '.$status_class.
1908 1904
 			'" style="'.$style.' border-color: '.$headerbgcolor.'; background: '.$background.'; z-index: '.$z_index.';"'.
1909 1905
 			'>'.$prefix_icon."\n".$html."\n".
1910 1906
 			$indent."</div>"."\n";
@@ -1924,9 +1920,9 @@  discard block
 block discarded – undo
1924 1920
 	 * @param int|string $id
1925 1921
 	 * @return string
1926 1922
 	 */
1927
-	function integration_get_popup($app,$id)
1923
+	function integration_get_popup($app, $id)
1928 1924
 	{
1929
-		$app_data = calendar_bo::integration_get_data($app,'edit_link');
1925
+		$app_data = calendar_bo::integration_get_data($app, 'edit_link');
1930 1926
 
1931 1927
 		if (is_array($app_data) && isset($app_data['edit']))
1932 1928
 		{
@@ -1936,11 +1932,11 @@  discard block
 block discarded – undo
1936 1932
 		}
1937 1933
 		else
1938 1934
 		{
1939
-			$edit = egw_link::edit($app,$id,$popup_size);
1935
+			$edit = egw_link::edit($app, $id, $popup_size);
1940 1936
 		}
1941 1937
 		if ($edit)
1942 1938
 		{
1943
-			$view_link = egw::link('/index.php',$edit);
1939
+			$view_link = egw::link('/index.php', $edit);
1944 1940
 
1945 1941
 			if ($popup_size)
1946 1942
 			{
@@ -1967,50 +1963,50 @@  discard block
 block discarded – undo
1967 1963
 	 * @param array $event
1968 1964
 	 * @return array
1969 1965
 	 */
1970
-	static function integration_get_icons($app,$id,$event)
1966
+	static function integration_get_icons($app, $id, $event)
1971 1967
 	{
1972 1968
 		$icons = array();
1973 1969
 		if ($event['icons'])
1974 1970
 		{
1975
-			foreach(explode(',',$event['icons']) as $icon)
1971
+			foreach (explode(',', $event['icons']) as $icon)
1976 1972
 			{
1977
-				list($icon_app,$icon) = explode(':',$icon);
1978
-				if (common::find_image($icon_app,$icon))
1973
+				list($icon_app, $icon) = explode(':', $icon);
1974
+				if (common::find_image($icon_app, $icon))
1979 1975
 				{
1980
-					$icons[] = html::image($icon_app,$icon);
1976
+					$icons[] = html::image($icon_app, $icon);
1981 1977
 				}
1982 1978
 			}
1983 1979
 		}
1984
-		$app_data = calendar_bo::integration_get_data($app,'icons');
1980
+		$app_data = calendar_bo::integration_get_data($app, 'icons');
1985 1981
 		if (is_null($app_data))
1986 1982
 		{
1987
-			$icons[] = html::image($app,'navbar');	// use navbar icon
1983
+			$icons[] = html::image($app, 'navbar'); // use navbar icon
1988 1984
 		}
1989 1985
 		elseif ($app_data)
1990 1986
 		{
1991
-			$icons += (array)ExecMethod2($app_data,$id,$event);
1987
+			$icons += (array)ExecMethod2($app_data, $id, $event);
1992 1988
 		}
1993 1989
 		return $icons;
1994 1990
 	}
1995 1991
 
1996
-	function add_nonempty($content,$label,$one_per_line=False,$space = True,$htmlspecialchars=true)
1992
+	function add_nonempty($content, $label, $one_per_line = False, $space = True, $htmlspecialchars = true)
1997 1993
 	{
1998 1994
 		if (is_array($content))
1999 1995
 		{
2000
-		   if($space)
1996
+		   if ($space)
2001 1997
 		   {
2002
-			  $content = implode($one_per_line ? ",\n" : ', ',$content);
1998
+			  $content = implode($one_per_line ? ",\n" : ', ', $content);
2003 1999
 		   }
2004 2000
 		   else
2005 2001
 		   {
2006
-			  $content = implode($one_per_line ? "\n" : ', ',$content);
2002
+			  $content = implode($one_per_line ? "\n" : ', ', $content);
2007 2003
 		   }
2008 2004
 		}
2009 2005
 		if (!empty($content))
2010 2006
 		{
2011 2007
 			return '<span class="calendar_calEventLabel">'.$label.'</span>:'.
2012 2008
 				($one_per_line ? '<br>' : ' ').
2013
-				nl2br($htmlspecialchars?html::htmlspecialchars($content):$content).'<br>';
2009
+				nl2br($htmlspecialchars ? html::htmlspecialchars($content) : $content).'<br>';
2014 2010
 		}
2015 2011
 		return '';
2016 2012
 	}
@@ -2022,18 +2018,18 @@  discard block
 block discarded – undo
2022 2018
 	* @param $decr int value to add to each component, default 64
2023 2019
 	* @return string the brighter color
2024 2020
 	*/
2025
-	static function brighter($rgb,$decr=64)
2021
+	static function brighter($rgb, $decr = 64)
2026 2022
 	{
2027
-		if (!preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$rgb,$components))
2023
+		if (!preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/', $rgb, $components))
2028 2024
 		{
2029 2025
 			return '#ffffff';
2030 2026
 		}
2031 2027
 		$brighter = '#';
2032
-		for ($i = 1; $i <=3; ++$i)
2028
+		for ($i = 1; $i <= 3; ++$i)
2033 2029
 		{
2034 2030
 			$val = hexdec($components[$i]) + $decr;
2035 2031
 			if ($val > 255) $val = 255;
2036
-			$brighter .= sprintf('%02x',$val);
2032
+			$brighter .= sprintf('%02x', $val);
2037 2033
 		}
2038 2034
 		//echo "brighter($rgb=".print_r($components,True).")=$brighter</p>\n";
2039 2035
 		return $brighter;
@@ -2049,12 +2045,12 @@  discard block
 block discarded – undo
2049 2045
 	{
2050 2046
 		if ($rgb[0] != '#' || strlen($rgb) != 7)
2051 2047
 		{
2052
-			return 128;	// no rgb color, return some default
2048
+			return 128; // no rgb color, return some default
2053 2049
 		}
2054
-		$dec = hexdec(substr($rgb,1));
2055
-		for($i = 0; $i < 24; $i += 8)
2050
+		$dec = hexdec(substr($rgb, 1));
2051
+		for ($i = 0; $i < 24; $i += 8)
2056 2052
 		{
2057
-			$sum += ($dec >> $i) & 255;
2053
+			$sum += ($dec >> $i)&255;
2058 2054
 		}
2059 2055
 		return (int)round($sum / 3.0, 0);
2060 2056
 	}
@@ -2076,7 +2072,7 @@  discard block
 block discarded – undo
2076 2072
 	 * @param string $indent = '' string for correct indention
2077 2073
 	 * @return string with widget
2078 2074
 	 */
2079
-	function &plannerWidget(&$events,$start,$end,$by_cat=0,$indent='')
2075
+	function &plannerWidget(&$events, $start, $end, $by_cat = 0, $indent = '')
2080 2076
 	{
2081 2077
 		$content = $indent.'<div class="calendar_plannerWidget">'."\n";
2082 2078
 
@@ -2084,7 +2080,7 @@  discard block
 block discarded – undo
2084 2080
 		$content .= $indent."\t".'<div class="calendar_plannerHeader">'."\n";
2085 2081
 
2086 2082
 		// display the headerTitle, and get sort2labels
2087
-		switch($by_cat)
2083
+		switch ($by_cat)
2088 2084
 		{
2089 2085
 			case 'user':
2090 2086
 				$title = lang('User');
@@ -2094,7 +2090,7 @@  discard block
 block discarded – undo
2094 2090
 				$title = lang('Month');
2095 2091
 				$sort2label = array();
2096 2092
 				$time = new egw_time($start);
2097
-				for($n = 0; $n < self::YEARLY_PLANNER_NUM_MONTH; ++$n)
2093
+				for ($n = 0; $n < self::YEARLY_PLANNER_NUM_MONTH; ++$n)
2098 2094
 				{
2099 2095
 					$sort2label[$time->format('Y-m')] = lang($time->format('F')).' '.$time->format('Y');
2100 2096
 					$time->modify('+1 month');
@@ -2110,7 +2106,7 @@  discard block
 block discarded – undo
2110 2106
 		// display the headerRows with the scales
2111 2107
 		$content .= $indent."\t\t".'<div class="calendar_plannerHeaderRows">'."\n";
2112 2108
 		// set start & end to timestamp and first & last to timestamp of 12h midday, to avoid trouble with daylight saving
2113
-		foreach(array('start' => 'first','end' => 'last') as $t => $v)
2109
+		foreach (array('start' => 'first', 'end' => 'last') as $t => $v)
2114 2110
 		{
2115 2111
 			$$t = $this->bo->date2ts($$t);
2116 2112
 			$$v = $this->bo->date2array($$t);
@@ -2125,23 +2121,23 @@  discard block
 block discarded – undo
2125 2121
 		}
2126 2122
 		else
2127 2123
 		{
2128
-			$days = 1 + (int) round(($last - $first) / DAY_s);	// we have to use round to get the right number if daylight saving changes
2124
+			$days = 1 + (int)round(($last - $first) / DAY_s); // we have to use round to get the right number if daylight saving changes
2129 2125
 			if ($days >= 28)	// display the month scale
2130 2126
 			{
2131
-				$content .= $this->plannerMonthScale($first,$days,$indent."\t\t\t");
2127
+				$content .= $this->plannerMonthScale($first, $days, $indent."\t\t\t");
2132 2128
 			}
2133 2129
 			if ($days >= 5)	// display the week scale
2134 2130
 			{
2135
-				$content .= $this->plannerWeekScale($first,$days,$indent."\t\t\t");
2131
+				$content .= $this->plannerWeekScale($first, $days, $indent."\t\t\t");
2136 2132
 			}
2137
-			$content .= $this->plannerDayScale($first,$days,$indent."\t\t\t");		// day-scale, always displayed
2133
+			$content .= $this->plannerDayScale($first, $days, $indent."\t\t\t"); // day-scale, always displayed
2138 2134
 			if ($days <= 7)	// display the hour scale
2139 2135
 			{
2140
-				$content .= $this->plannerHourScale($start,$days,$indent."\t\t\t");
2136
+				$content .= $this->plannerHourScale($start, $days, $indent."\t\t\t");
2141 2137
 			}
2142 2138
 		}
2143
-		$content .= $indent."\t\t</div>\n";	// end of the plannerHeaderRows
2144
-		$content .= $indent."\t</div>\n";	// end of the plannerHeader
2139
+		$content .= $indent."\t\t</div>\n"; // end of the plannerHeaderRows
2140
+		$content .= $indent."\t</div>\n"; // end of the plannerHeader
2145 2141
 
2146 2142
 		// sort the events after user or category
2147 2143
 		$rows = array();
@@ -2150,10 +2146,10 @@  discard block
 block discarded – undo
2150 2146
 		if ($by_cat === 'user')	// planner by user
2151 2147
 		{
2152 2148
 			// convert filter to allowed status
2153
-			switch($this->filter)
2149
+			switch ($this->filter)
2154 2150
 			{
2155 2151
 				case 'unknown':
2156
-					$status_to_show = array('U','G'); break;
2152
+					$status_to_show = array('U', 'G'); break;
2157 2153
 				case 'accepted':
2158 2154
 					$status_to_show = array('A'); break;
2159 2155
 				case 'tentative':
@@ -2163,65 +2159,65 @@  discard block
 block discarded – undo
2163 2159
 				case 'delegated':
2164 2160
 					$status_to_show = array('D'); break;
2165 2161
 				case 'all':
2166
-					$status_to_show = array('U','A','T','D','G','R'); break;
2162
+					$status_to_show = array('U', 'A', 'T', 'D', 'G', 'R'); break;
2167 2163
 				default:
2168
-					$status_to_show = array('U','A','T','D','G'); break;
2164
+					$status_to_show = array('U', 'A', 'T', 'D', 'G'); break;
2169 2165
 			}
2170 2166
 		}
2171
-		foreach($events as $key => $event)
2167
+		foreach ($events as $key => $event)
2172 2168
 		{
2173 2169
 			if ($by_cat === 'user')	// planner by user
2174 2170
 			{
2175
-				foreach($event['participants'] as $sort => $status)
2171
+				foreach ($event['participants'] as $sort => $status)
2176 2172
 				{
2177
-					calendar_so::split_status($status,$nul,$nul);
2173
+					calendar_so::split_status($status, $nul, $nul);
2178 2174
 					// only show if participant with status visible with current filter
2179
-					if (isset($sort2label[$sort]) && (in_array($status,$status_to_show) ||
2175
+					if (isset($sort2label[$sort]) && (in_array($status, $status_to_show) ||
2180 2176
 						$this->filter == 'owner' && $event['owner'] == $sort))	// owner too additionally uses owner
2181 2177
 					{
2182
-						$rows[$sort][] =& $events[$key];
2178
+						$rows[$sort][] = & $events[$key];
2183 2179
 					}
2184 2180
 				}
2185 2181
 			}
2186 2182
 			elseif ($by_cat === 'month')	// planner by month / yearly planner
2187 2183
 			{
2188
-				$sort = date('Y-m',$event['start']);
2189
-				$rows[$sort][] =& $events[$key];
2184
+				$sort = date('Y-m', $event['start']);
2185
+				$rows[$sort][] = & $events[$key];
2190 2186
 				// end in a different month?
2191
-				if ($sort != ($end_sort = date('Y-m',$event['end'])))
2187
+				if ($sort != ($end_sort = date('Y-m', $event['end'])))
2192 2188
 				{
2193
-					while($sort != $end_sort)
2189
+					while ($sort != $end_sort)
2194 2190
 					{
2195
-						list($y,$m) = explode('-',$sort);
2191
+						list($y, $m) = explode('-', $sort);
2196 2192
 						if (++$m > 12)
2197 2193
 						{
2198 2194
 							++$y;
2199 2195
 							$m = 1;
2200 2196
 						}
2201
-						$sort = sprintf('%04d-%02d',$y,$m);
2202
-						$rows[$sort][] =& $events[$key];
2197
+						$sort = sprintf('%04d-%02d', $y, $m);
2198
+						$rows[$sort][] = & $events[$key];
2203 2199
 					}
2204 2200
 				}
2205 2201
 			}
2206 2202
 			else	// planner by cat
2207 2203
 			{
2208
-				foreach($this->_get_planner_cats($event['category'],$sort2label,$sort2color) as $sort)
2204
+				foreach ($this->_get_planner_cats($event['category'], $sort2label, $sort2color) as $sort)
2209 2205
 				{
2210 2206
 					if (!is_array($rows[$sort])) $rows[$sort] = array();
2211 2207
 
2212
-					$rows[$sort][] =& $events[$key];
2208
+					$rows[$sort][] = & $events[$key];
2213 2209
 				}
2214 2210
 			}
2215 2211
 		}
2216
-		$owners = explode(',',$this->owner);
2212
+		$owners = explode(',', $this->owner);
2217 2213
 		// display a plannerRowWidget for each row (user or category)
2218
-		foreach($sort2label as $sort => $label)
2214
+		foreach ($sort2label as $sort => $label)
2219 2215
 		{
2220 2216
 			if (!isset($rows[$sort]) && (!$this->cal_prefs['planner_show_empty_rows'] ||
2221 2217
 				$by_cat === 'user' && $this->cal_prefs['planner_show_empty_rows'] == 'cat' ||
2222 2218
 				is_int($by_cat) && $this->cal_prefs['planner_show_empty_rows'] == 'user'))
2223 2219
 			{
2224
-				continue;		// dont show empty categories or user rows
2220
+				continue; // dont show empty categories or user rows
2225 2221
 			}
2226 2222
 			$class = $class == 'row_on' ? 'row_off' : 'row_on';
2227 2223
 			if ($by_cat === 'month')
@@ -2236,9 +2232,9 @@  discard block
 block discarded – undo
2236 2232
 			{
2237 2233
 				$label .= $this->close_button($sort);
2238 2234
 			}
2239
-			$content .= $this->plannerRowWidget(isset($rows[$sort]) ? $rows[$sort] : array(),$start,$end,$label,$class,$indent."\t");
2235
+			$content .= $this->plannerRowWidget(isset($rows[$sort]) ? $rows[$sort] : array(), $start, $end, $label, $class, $indent."\t");
2240 2236
 		}
2241
-		$content .= $indent."</div>\n";		// end of the plannerWidget
2237
+		$content .= $indent."</div>\n"; // end of the plannerWidget
2242 2238
 
2243 2239
 		return $content;
2244 2240
 	}
@@ -2249,12 +2245,12 @@  discard block
 block discarded – undo
2249 2245
 	 * @param boolean $enum_groups = true should groups be returned as there members (eg. planner) or not (day & week)
2250 2246
 	 * @return array with uid => label pairs, first all users alphabetically sorted, then all resources
2251 2247
 	 */
2252
-	function _get_planner_users($enum_groups=true)
2248
+	function _get_planner_users($enum_groups = true)
2253 2249
 	{
2254 2250
 		$users = $resources = array();
2255
-		foreach(explode(',',$this->owner) as $user)
2251
+		foreach (explode(',', $this->owner) as $user)
2256 2252
 		{
2257
-			if($user === '0')
2253
+			if ($user === '0')
2258 2254
 			{
2259 2255
 				// 0 means current user
2260 2256
 				$user = $this->user;
@@ -2265,10 +2261,10 @@  discard block
 block discarded – undo
2265 2261
 			}
2266 2262
 			elseif ($enum_groups && $GLOBALS['egw']->accounts->get_type($user) == 'g')	// groups
2267 2263
 			{
2268
-				foreach((array) $GLOBALS['egw']->accounts->member($user) as $data)
2264
+				foreach ((array)$GLOBALS['egw']->accounts->member($user) as $data)
2269 2265
 				{
2270 2266
 					$user = $data['account_id'];
2271
-					if ($this->bo->check_perms(EGW_ACL_READ | EGW_ACL_FREEBUSY,0,$user))
2267
+					if ($this->bo->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $user))
2272 2268
 					{
2273 2269
 						$users[$user] = $this->bo->participant_name($user);
2274 2270
 					}
@@ -2286,7 +2282,7 @@  discard block
 block discarded – undo
2286 2282
 			asort($resources);
2287 2283
 		}
2288 2284
 
2289
-		return $users+$resources;
2285
+		return $users + $resources;
2290 2286
 	}
2291 2287
 
2292 2288
 	/**
@@ -2298,7 +2294,7 @@  discard block
 block discarded – undo
2298 2294
 	 * @param array &$sort2label labels for the returned cats
2299 2295
 	 * @return array with cat_id's
2300 2296
 	 */
2301
-	function _get_planner_cats($cats,&$sort2label)
2297
+	function _get_planner_cats($cats, &$sort2label)
2302 2298
 	{
2303 2299
 		static $cat2sort;
2304 2300
 
@@ -2306,7 +2302,7 @@  discard block
 block discarded – undo
2306 2302
 		{
2307 2303
 			$cat2sort = array();
2308 2304
 			$cat_filter = $this->cat_id ? (array)$this->cat_id : array();
2309
-			foreach((array)$this->categories->return_sorted_array(0,false,'','','',true) as $data)
2305
+			foreach ((array)$this->categories->return_sorted_array(0, false, '', '', '', true) as $data)
2310 2306
 			{
2311 2307
 				if (in_array($data['parent'], $cat_filter) || in_array($data['id'], $cat_filter) ||
2312 2308
 					!$data['parent'] && !$cat_filter)	// cat is a direct sub of $this->cat_id
@@ -2314,16 +2310,16 @@  discard block
 block discarded – undo
2314 2310
 					$cat2sort[$data['id']] = $data['id'];
2315 2311
 					$sort2label[$data['id']] = stripslashes($data['name']);
2316 2312
 				}
2317
-				elseif(isset($cat2sort[$data['parent']]))	// parent is already in the array => add us with same target
2313
+				elseif (isset($cat2sort[$data['parent']]))	// parent is already in the array => add us with same target
2318 2314
 				{
2319 2315
 					$cat2sort[$data['id']] = $cat2sort[$data['parent']];
2320 2316
 				}
2321 2317
 			}
2322 2318
 		}
2323 2319
 		$ret = array();
2324
-		foreach(!is_array($cats) ? explode(',',$cats) : $cats as $cat)
2320
+		foreach (!is_array($cats) ? explode(',', $cats) : $cats as $cat)
2325 2321
 		{
2326
-			if (isset($cat2sort[$cat]) && !in_array($cat2sort[$cat],$ret))
2322
+			if (isset($cat2sort[$cat]) && !in_array($cat2sort[$cat], $ret))
2327 2323
 			{
2328 2324
 				$ret[] = $cat2sort[$cat];
2329 2325
 			}
@@ -2345,24 +2341,24 @@  discard block
 block discarded – undo
2345 2341
 	 * @param string $indent = '' string for correct indention
2346 2342
 	 * @return string with scale
2347 2343
 	 */
2348
-	function plannerMonthScale($start,$days,$indent)
2344
+	function plannerMonthScale($start, $days, $indent)
2349 2345
 	{
2350
-		$day_width = round(100 / $days,2);
2346
+		$day_width = round(100 / $days, 2);
2351 2347
 
2352 2348
 		$content .= $indent.'<div class="calendar_plannerScale">'."\n";
2353
-		for($t = $start,$left = 0,$i = 0; $i < $days; $t += $days_in_month*DAY_s,$left += $days_in_month*$day_width,$i += $days_in_month)
2349
+		for ($t = $start, $left = 0, $i = 0; $i < $days; $t += $days_in_month * DAY_s, $left += $days_in_month * $day_width, $i += $days_in_month)
2354 2350
 		{
2355 2351
 			$t_arr = $this->bo->date2array($t);
2356
-			unset($t_arr['raw']);	// force recalculation
2352
+			unset($t_arr['raw']); // force recalculation
2357 2353
 			unset($t_arr['full']);
2358
-			$days_in_month = $this->datetime->days_in_month($t_arr['month'],$t_arr['year']) - ($t_arr['day']-1);
2354
+			$days_in_month = $this->datetime->days_in_month($t_arr['month'], $t_arr['year']) - ($t_arr['day'] - 1);
2359 2355
 			if ($i + $days_in_month > $days)
2360 2356
 			{
2361 2357
 				$days_in_month = $days - $i;
2362 2358
 			}
2363 2359
 			if ($days_in_month > 10)
2364 2360
 			{
2365
-				$title = lang(date('F',$t)).' '.$t_arr['year'];
2361
+				$title = lang(date('F', $t)).' '.$t_arr['year'];
2366 2362
 				// previous links
2367 2363
 				$prev = $t_arr;
2368 2364
 				$prev['day'] = 1;
@@ -2371,21 +2367,21 @@  discard block
 block discarded – undo
2371 2367
 					$prev['month'] = 12;
2372 2368
 					$prev['year']--;
2373 2369
 				}
2374
-				if ($this->bo->date2ts($prev) < $start-20*DAY_s)
2370
+				if ($this->bo->date2ts($prev) < $start - 20 * DAY_s)
2375 2371
 				{
2376 2372
 					$prev['day'] = $this->day;
2377 2373
 					$full = $this->bo->date2string($prev);
2378
-					if ($this->day >= 15) $prev = $t_arr;		// we stay in the same month
2374
+					if ($this->day >= 15) $prev = $t_arr; // we stay in the same month
2379 2375
 					$prev['day'] = $this->day < 15 ? 15 : 1;
2380 2376
 					$half = $this->bo->date2string($prev);
2381
-					$title = html::a_href(html::image('phpgwapi','first',lang('back one month'),$options=' alt="<<"'),array(
2377
+					$title = html::a_href(html::image('phpgwapi', 'first', lang('back one month'), $options = ' alt="<<"'), array(
2382 2378
 						'menuaction' => $this->view_menuaction,
2383 2379
 						'date'       => $full,
2384
-					)) . ' &nbsp; '.
2385
-					html::a_href(html::image('phpgwapi','left',lang('back half a month'),$options=' alt="<"'),array(
2380
+					)).' &nbsp; '.
2381
+					html::a_href(html::image('phpgwapi', 'left', lang('back half a month'), $options = ' alt="<"'), array(
2386 2382
 						'menuaction' => $this->view_menuaction,
2387 2383
 						'date'       => $half,
2388
-					)) . ' &nbsp; '.$title;
2384
+					)).' &nbsp; '.$title;
2389 2385
 				}
2390 2386
 				// next links
2391 2387
 				$next = $t_arr;
@@ -2395,20 +2391,20 @@  discard block
 block discarded – undo
2395 2391
 					$next['year']++;
2396 2392
 				}
2397 2393
 				// dont show next scales, if there are more then 10 days in the next month or there is no next month
2398
-				$days_in_next_month = (int) date('d',$end = $start+$days*DAY_s);
2399
-				if ($days_in_next_month <= 10 || date('m',$end) == date('m',$t))
2394
+				$days_in_next_month = (int)date('d', $end = $start + $days * DAY_s);
2395
+				if ($days_in_next_month <= 10 || date('m', $end) == date('m', $t))
2400 2396
 				{
2401
-					if ($this->day >= 15) $next = $t_arr;		// we stay in the same month
2397
+					if ($this->day >= 15) $next = $t_arr; // we stay in the same month
2402 2398
 					$next['day'] = $this->day;
2403 2399
 					$full = $this->bo->date2string($next);
2404
-					if ($this->day < 15) $next = $t_arr;		// we stay in the same month
2400
+					if ($this->day < 15) $next = $t_arr; // we stay in the same month
2405 2401
 					$next['day'] = $this->day < 15 ? 15 : 1;
2406 2402
 					$half = $this->bo->date2string($next);
2407
-					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward half a month'),$options=' alt=">>"'),array(
2403
+					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi', 'right', lang('forward half a month'), $options = ' alt=">>"'), array(
2408 2404
 						'menuaction' => $this->view_menuaction,
2409 2405
 						'date'       => $half,
2410
-					)). ' &nbsp; '.
2411
-					html::a_href(html::image('phpgwapi','last',lang('forward one month'),$options=' alt=">>"'),array(
2406
+					)).' &nbsp; '.
2407
+					html::a_href(html::image('phpgwapi', 'last', lang('forward one month'), $options = ' alt=">>"'), array(
2412 2408
 						'menuaction' => $this->view_menuaction,
2413 2409
 						'date'       => $full,
2414 2410
 					));
@@ -2419,10 +2415,10 @@  discard block
 block discarded – undo
2419 2415
 				$title = '&nbsp;';
2420 2416
 			}
2421 2417
 			$class = $class == 'row_on' ? 'th' : 'row_on';
2422
-			$content .= $indent."\t".'<div class="calendar_plannerMonthScale '.$class.'" style="left: '.$left.'%; width: '.($day_width*$days_in_month).'%;">'.
2418
+			$content .= $indent."\t".'<div class="calendar_plannerMonthScale '.$class.'" style="left: '.$left.'%; width: '.($day_width * $days_in_month).'%;">'.
2423 2419
 				$title."</div>\n";
2424 2420
 		}
2425
-		$content .= $indent."</div>\n";		// end of plannerScale
2421
+		$content .= $indent."</div>\n"; // end of plannerScale
2426 2422
 
2427 2423
 		return $content;
2428 2424
 	}
@@ -2435,39 +2431,39 @@  discard block
 block discarded – undo
2435 2431
 	 * @param string $indent = '' string for correct indention
2436 2432
 	 * @return string with scale
2437 2433
 	 */
2438
-	function plannerWeekScale($start,$days,$indent)
2434
+	function plannerWeekScale($start, $days, $indent)
2439 2435
 	{
2440
-		$week_width = round(100 / $days * ($days <= 7 ? $days : 7),2);
2436
+		$week_width = round(100 / $days * ($days <= 7 ? $days : 7), 2);
2441 2437
 
2442 2438
 		$content .= $indent.'<div class="calendar_plannerScale">'."\n";
2443
-		for($t = $start,$left = 0,$i = 0; $i < $days; $t += 7*DAY_s,$left += $week_width,$i += 7)
2439
+		for ($t = $start, $left = 0, $i = 0; $i < $days; $t += 7 * DAY_s, $left += $week_width, $i += 7)
2444 2440
 		{
2445 2441
 			$title = lang('Week').' '.$this->week_number($t);
2446 2442
 			if ($days > 7)
2447 2443
 			{
2448
-				$title = html::a_href($title,array(
2444
+				$title = html::a_href($title, array(
2449 2445
 					'menuaction' => 'calendar.calendar_uiviews.planner',
2450 2446
 					'planner_days' => 7,
2451
-					'date'       => date('Ymd',$t),
2452
-				),false,' title="'.html::htmlspecialchars(lang('Weekview')).'"');
2447
+					'date'       => date('Ymd', $t),
2448
+				), false, ' title="'.html::htmlspecialchars(lang('Weekview')).'"');
2453 2449
 			}
2454 2450
 			else
2455 2451
 			{
2456 2452
 				// prev. week
2457
-				$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
2453
+				$title = html::a_href(html::image('phpgwapi', 'first', lang('previous'), $options = ' alt="<<"'), array(
2458 2454
 					'menuaction' => $this->view_menuaction,
2459
-					'date'       => date('Ymd',$t-7*DAY_s),
2460
-				)) . ' &nbsp; <b>'.$title;
2455
+					'date'       => date('Ymd', $t - 7 * DAY_s),
2456
+				)).' &nbsp; <b>'.$title;
2461 2457
 				// next week
2462
-				$title .= '</b> &nbsp; '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
2458
+				$title .= '</b> &nbsp; '.html::a_href(html::image('phpgwapi', 'last', lang('next'), $options = ' alt=">>"'), array(
2463 2459
 					'menuaction' => $this->view_menuaction,
2464
-					'date'       => date('Ymd',$t+7*DAY_s),
2460
+					'date'       => date('Ymd', $t + 7 * DAY_s),
2465 2461
 				));
2466 2462
 			}
2467 2463
 			$class = $class == 'row_on' ? 'th' : 'row_on';
2468 2464
 			$content .= $indent."\t".'<div class="calendar_plannerWeekScale '.$class.'" style="left: '.$left.'%; width: '.$week_width.'%;">'.$title."</div>\n";
2469 2465
 		}
2470
-		$content .= $indent."</div>\n";		// end of plannerScale
2466
+		$content .= $indent."</div>\n"; // end of plannerScale
2471 2467
 
2472 2468
 		return $content;
2473 2469
 	}
@@ -2480,56 +2476,56 @@  discard block
 block discarded – undo
2480 2476
 	 * @param string $indent = '' string for correct indention
2481 2477
 	 * @return string with scale
2482 2478
 	 */
2483
-	function plannerDayScale($start,$days,$indent)
2479
+	function plannerDayScale($start, $days, $indent)
2484 2480
 	{
2485
-		$day_width = round(100 / $days,2);
2481
+		$day_width = round(100 / $days, 2);
2486 2482
 
2487 2483
 		$content .= $indent.'<div class="calendar_plannerScale'.($days > 3 ? 'Day' : '').'">'."\n";
2488
-		for($t = $start,$left = 0,$i = 0; $i < $days; $t += DAY_s,$left += $day_width,++$i)
2484
+		for ($t = $start, $left = 0, $i = 0; $i < $days; $t += DAY_s, $left += $day_width, ++$i)
2489 2485
 		{
2490
-			$this->_day_class_holiday($this->bo->date2string($t),$class,$holidays,$days > 7);
2486
+			$this->_day_class_holiday($this->bo->date2string($t), $class, $holidays, $days > 7);
2491 2487
 
2492 2488
 			if ($days <= 3)
2493 2489
 			{
2494
-				$title = '<b>'.lang(date('l',$t)).', '.date('j',$t).'. '.lang(date('F',$t)).'</b>';
2490
+				$title = '<b>'.lang(date('l', $t)).', '.date('j', $t).'. '.lang(date('F', $t)).'</b>';
2495 2491
 			}
2496 2492
 			elseif ($days <= 7)
2497 2493
 			{
2498
-				$title = lang(date('l',$t)).'<br />'.date('j',$t).'. '.lang(date('F',$t));
2494
+				$title = lang(date('l', $t)).'<br />'.date('j', $t).'. '.lang(date('F', $t));
2499 2495
 			}
2500 2496
 			else
2501 2497
 			{
2502
-				$title = substr(lang(date('D',$t)),0,2).'<br />'.date('j',$t);
2498
+				$title = substr(lang(date('D', $t)), 0, 2).'<br />'.date('j', $t);
2503 2499
 			}
2504 2500
 			if ($days > 1)
2505 2501
 			{
2506
-				$title = html::a_href($title,array(
2502
+				$title = html::a_href($title, array(
2507 2503
 					'menuaction'   => 'calendar.calendar_uiviews.planner',
2508 2504
 					'planner_days' => 1,
2509
-					'date'         => date('Ymd',$t),
2510
-				),false,strpos($class,'calendar_calHoliday') !== false || strpos($class,'calendar_calBirthday') !== false ? '' : ' title="'.html::htmlspecialchars(lang('Dayview')).'"');
2505
+					'date'         => date('Ymd', $t),
2506
+				), false, strpos($class, 'calendar_calHoliday') !== false || strpos($class, 'calendar_calBirthday') !== false ? '' : ' title="'.html::htmlspecialchars(lang('Dayview')).'"');
2511 2507
 			}
2512 2508
 			if ($days < 5)
2513 2509
 			{
2514 2510
 				if (!$i)	// prev. day only for the first day
2515 2511
 				{
2516
-					$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
2512
+					$title = html::a_href(html::image('phpgwapi', 'first', lang('previous'), $options = ' alt="<<"'), array(
2517 2513
 						'menuaction' => $this->view_menuaction,
2518
-						'date'       => date('Ymd',$start-DAY_s),
2519
-					)) . ' &nbsp; '.$title;
2514
+						'date'       => date('Ymd', $start - DAY_s),
2515
+					)).' &nbsp; '.$title;
2520 2516
 				}
2521
-				if ($i == $days-1)	// next day only for the last day
2517
+				if ($i == $days - 1)	// next day only for the last day
2522 2518
 				{
2523
-					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
2519
+					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi', 'last', lang('next'), $options = ' alt=">>"'), array(
2524 2520
 						'menuaction' => $this->view_menuaction,
2525
-						'date'       => date('Ymd',$start+DAY_s),
2521
+						'date'       => date('Ymd', $start + DAY_s),
2526 2522
 					));
2527 2523
 				}
2528 2524
 			}
2529 2525
 			$content .= $indent."\t".'<div class="calendar_plannerDayScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;"'.
2530 2526
 				($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
2531 2527
 		}
2532
-		$content .= $indent."</div>\n";		// end of plannerScale
2528
+		$content .= $indent."</div>\n"; // end of plannerScale
2533 2529
 
2534 2530
 		return $content;
2535 2531
 	}
@@ -2542,13 +2538,13 @@  discard block
 block discarded – undo
2542 2538
 	 */
2543 2539
 	function plannerDayOfMonthScale($indent)
2544 2540
 	{
2545
-		$day_width = round(100 / 31,2);
2541
+		$day_width = round(100 / 31, 2);
2546 2542
 
2547 2543
 		// month scale with navigation
2548 2544
 		$content .= $indent.'<div class="calendar_plannerScale">'."\n";
2549 2545
 
2550
-		$title = lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
2551
-			lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
2546
+		$title = lang(egw_time::to($this->first, 'F')).' '.egw_time::to($this->first, 'Y').' - '.
2547
+			lang(egw_time::to($this->last, 'F')).' '.egw_time::to($this->last, 'Y');
2552 2548
 
2553 2549
 		// calculate date for navigation links
2554 2550
 		$time = new egw_time($this->first);
@@ -2561,37 +2557,37 @@  discard block
 block discarded – undo
2561 2557
 		$time->modify('+11month');
2562 2558
 		$next_year = $time->format('Ymd');
2563 2559
 
2564
-		$title = html::a_href(html::image('phpgwapi','first',lang('back one year'),$options=' alt="<<"'),array(
2560
+		$title = html::a_href(html::image('phpgwapi', 'first', lang('back one year'), $options = ' alt="<<"'), array(
2565 2561
 				'menuaction' => $this->view_menuaction,
2566 2562
 				'date'       => $last_year,
2567
-			)) . ' &nbsp; '.
2568
-			html::a_href(html::image('phpgwapi','left',lang('back one month'),$options=' alt="<"'),array(
2563
+			)).' &nbsp; '.
2564
+			html::a_href(html::image('phpgwapi', 'left', lang('back one month'), $options = ' alt="<"'), array(
2569 2565
 				'menuaction' => $this->view_menuaction,
2570 2566
 				'date'       => $last_month,
2571
-			)) . ' &nbsp; '.$title;
2572
-			$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward one month'),$options=' alt=">>"'),array(
2567
+			)).' &nbsp; '.$title;
2568
+			$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi', 'right', lang('forward one month'), $options = ' alt=">>"'), array(
2573 2569
 					'menuaction' => $this->view_menuaction,
2574 2570
 					'date'       => $next_month,
2575
-				)). ' &nbsp; '.
2576
-				html::a_href(html::image('phpgwapi','last',lang('forward one year'),$options=' alt=">>"'),array(
2571
+				)).' &nbsp; '.
2572
+				html::a_href(html::image('phpgwapi', 'last', lang('forward one year'), $options = ' alt=">>"'), array(
2577 2573
 					'menuaction' => $this->view_menuaction,
2578 2574
 					'date'       => $next_year,
2579 2575
 				));
2580 2576
 
2581 2577
 		$content .= $indent."\t".'<div class="calendar_plannerMonthScale th" style="left: 0; width: 100%;">'.
2582 2578
 				$title."</div>\n";
2583
-		$content .= $indent."</div>\n";		// end of plannerScale
2579
+		$content .= $indent."</div>\n"; // end of plannerScale
2584 2580
 
2585 2581
 		// day of month scale
2586 2582
 		$content .= $indent.'<div class="calendar_plannerScale">'."\n";
2587
-		$today = egw_time::to('now','d');
2588
-		for($left = 0,$i = 0; $i < 31; $left += $day_width,++$i)
2583
+		$today = egw_time::to('now', 'd');
2584
+		for ($left = 0, $i = 0; $i < 31; $left += $day_width, ++$i)
2589 2585
 		{
2590
-			$class = $i & 1 ? 'row_on' : 'row_off';
2586
+			$class = $i&1 ? 'row_on' : 'row_off';
2591 2587
 			$content .= $indent."\t".'<div class="calendar_plannerDayOfMonthScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;">'.
2592
-				(1+$i)."</div>\n";
2588
+				(1 + $i)."</div>\n";
2593 2589
 		}
2594
-		$content .= $indent."</div>\n";		// end of plannerScale
2590
+		$content .= $indent."</div>\n"; // end of plannerScale
2595 2591
 
2596 2592
 		return $content;
2597 2593
 	}
@@ -2604,9 +2600,9 @@  discard block
 block discarded – undo
2604 2600
 	 * @param string $indent = '' string for correct indention
2605 2601
 	 * @return string with scale
2606 2602
 	 */
2607
-	function plannerHourScale($start,$days,$indent)
2603
+	function plannerHourScale($start, $days, $indent)
2608 2604
 	{
2609
-		foreach(array(1,2,3,4,6,8,12) as $d)	// numbers dividing 24 without rest
2605
+		foreach (array(1, 2, 3, 4, 6, 8, 12) as $d)	// numbers dividing 24 without rest
2610 2606
 		{
2611 2607
 			if ($d > $days) break;
2612 2608
 			$decr = $d;
@@ -2621,17 +2617,17 @@  discard block
 block discarded – undo
2621 2617
 			$t_arr['hour'] = 23; $t_arr['minute'] = $t_arr['second'] = 59;
2622 2618
 			$hours = ($this->bo->date2ts($t_arr) - $s) / HOUR_s;
2623 2619
 		}
2624
-		$cell_width = round(100 / $hours * $decr,2);
2620
+		$cell_width = round(100 / $hours * $decr, 2);
2625 2621
 
2626 2622
 		$content .= $indent.'<div class="calendar_plannerScale">'."\n";
2627
-		for($t = $start,$left = 0,$i = 0; $i < $hours; $t += $decr*HOUR_s,$left += $cell_width,$i += $decr)
2623
+		for ($t = $start, $left = 0, $i = 0; $i < $hours; $t += $decr * HOUR_s, $left += $cell_width, $i += $decr)
2628 2624
 		{
2629
-			$title = date($this->cal_prefs['timeformat'] == 12 ? 'ha' : 'H',$t);
2625
+			$title = date($this->cal_prefs['timeformat'] == 12 ? 'ha' : 'H', $t);
2630 2626
 
2631 2627
 			$class = $class == 'row_on' ? 'th' : 'row_on';
2632 2628
 			$content .= $indent."\t".'<div class="calendar_plannerHourScale '.$class.'" style="left: '.$left.'%; width: '.($cell_width).'%;">'.$title."</div>\n";
2633 2629
 		}
2634
-		$content .= $indent."</div>\n";		// end of plannerScale
2630
+		$content .= $indent."</div>\n"; // end of plannerScale
2635 2631
 
2636 2632
 		return $content;
2637 2633
 	}
@@ -2649,7 +2645,7 @@  discard block
 block discarded – undo
2649 2645
 	 * @param string $indent = '' string for correct indention
2650 2646
 	 * @return string with widget
2651 2647
 	 */
2652
-	function plannerRowWidget($events,$start,$end,$header,$class,$indent='')
2648
+	function plannerRowWidget($events, $start, $end, $header, $class, $indent = '')
2653 2649
 	{
2654 2650
 		$content = $indent.'<div class="calendar_plannerRowWidget '.$class.'">'."\n";
2655 2651
 
@@ -2659,19 +2655,19 @@  discard block
 block discarded – undo
2659 2655
 		// sorting the events in non-overlapping rows
2660 2656
 		$rows = array(array());
2661 2657
 		$row_end = array();
2662
-		foreach($events as $n => $event)
2658
+		foreach ($events as $n => $event)
2663 2659
 		{
2664
-			for($row = 0; (int) $row_end[$row] > $event['start']; ++$row);	// find a "free" row (no other event)
2665
-			$rows[$row][] =& $events[$n];
2660
+			for ($row = 0; (int)$row_end[$row] > $event['start']; ++$row); // find a "free" row (no other event)
2661
+			$rows[$row][] = & $events[$n];
2666 2662
 			$row_end[$row] = $event['end'];
2667 2663
 		}
2668 2664
 		//echo $header; _debug_array($rows);
2669 2665
 		// display the rows
2670 2666
 		$content .= $indent."\t".'<div class="calendar_eventRows"';
2671 2667
 
2672
-		if ($this->sortby == 'month' && ($days = date('j',$end)) < 31)
2668
+		if ($this->sortby == 'month' && ($days = date('j', $end)) < 31)
2673 2669
 		{
2674
-			$width = round(85*$days/31,2);
2670
+			$width = round(85 * $days / 31, 2);
2675 2671
 			$content .= ' style="width: '.$width.'%;"';
2676 2672
 		}
2677 2673
 		$content .= ">\n";
@@ -2679,21 +2675,21 @@  discard block
 block discarded – undo
2679 2675
 		// mark weekends and other special days in yearly planner
2680 2676
 		if ($this->sortby == 'month')
2681 2677
 		{
2682
-			$content .= $this->yearlyPlannerMarkDays($start,$days,$indent."\t\t");
2678
+			$content .= $this->yearlyPlannerMarkDays($start, $days, $indent."\t\t");
2683 2679
 		}
2684
-		foreach($rows as $row)
2680
+		foreach ($rows as $row)
2685 2681
 		{
2686
-			$content .= $this->eventRowWidget($row,$start,$end,$indent."\t\t");
2682
+			$content .= $this->eventRowWidget($row, $start, $end, $indent."\t\t");
2687 2683
 		}
2688
-		$content .= $indent."\t</div>\n";	// end of the eventRows
2684
+		$content .= $indent."\t</div>\n"; // end of the eventRows
2689 2685
 
2690 2686
 		if ($this->sortby == 'month' && $days < 31)
2691 2687
 		{
2692 2688
 			// add a filler for non existing days in that month
2693 2689
 			$content .= $indent."\t".'<div class="calendar_eventRowsFiller"'.
2694
-				' style="left:'.(15+$width).'%; width:'.(85-$width).'%;" ></div>'."\n";
2690
+				' style="left:'.(15 + $width).'%; width:'.(85 - $width).'%;" ></div>'."\n";
2695 2691
 		}
2696
-		$content .= $indent."</div>\n";		// end of the plannerRowWidget
2692
+		$content .= $indent."</div>\n"; // end of the plannerRowWidget
2697 2693
 
2698 2694
 		return $content;
2699 2695
 	}
@@ -2706,14 +2702,14 @@  discard block
 block discarded – undo
2706 2702
 	 * @param string $indent = ''
2707 2703
 	 * @return string
2708 2704
 	 */
2709
-	function yearlyPlannerMarkDays($start,$days,$indent='')
2705
+	function yearlyPlannerMarkDays($start, $days, $indent = '')
2710 2706
 	{
2711
-		$day_width = round(100/$days,2);
2712
-		for($t = $start,$left = 0,$i = 0; $i < $days; $t += DAY_s,$left += $day_width,++$i)
2707
+		$day_width = round(100 / $days, 2);
2708
+		for ($t = $start, $left = 0, $i = 0; $i < $days; $t += DAY_s, $left += $day_width, ++$i)
2713 2709
 		{
2714
-			$this->_day_class_holiday($this->bo->date2string($t),$class,$holidays,true);
2710
+			$this->_day_class_holiday($this->bo->date2string($t), $class, $holidays, true);
2715 2711
 
2716
-			$class = trim(str_replace(array('row_on','row_off'),'',$class));
2712
+			$class = trim(str_replace(array('row_on', 'row_off'), '', $class));
2717 2713
 			if ($class)	// no regular weekday
2718 2714
 			{
2719 2715
 				$content .= $indent.'<div class="calendar_eventRowsMarkedDay '.$class.
@@ -2736,13 +2732,13 @@  discard block
 block discarded – undo
2736 2732
 	 * @param string $indent = '' string for correct indention
2737 2733
 	 * @return string with widget
2738 2734
 	 */
2739
-	function eventRowWidget($events,$start,$end,$indent='')
2735
+	function eventRowWidget($events, $start, $end, $indent = '')
2740 2736
 	{
2741 2737
 		$content = $indent.'<div class="calendar_eventRowWidget">'."\n";
2742 2738
 
2743
-		foreach($events as $event)
2739
+		foreach ($events as $event)
2744 2740
 		{
2745
-			$content .= $this->plannerEventWidget($event,$start,$end,$indent."\t");
2741
+			$content .= $this->plannerEventWidget($event, $start, $end, $indent."\t");
2746 2742
 		}
2747 2743
 		$content .= $indent."</div>\n";
2748 2744
 
@@ -2760,10 +2756,10 @@  discard block
 block discarded – undo
2760 2756
 	 * @param int $end end-time of the planner
2761 2757
 	 * @return float percentage position between 0-100
2762 2758
 	 */
2763
-	function _planner_pos($time,$start,$end)
2759
+	function _planner_pos($time, $start, $end)
2764 2760
 	{
2765
-		if ($time <= $start) return 0;	// we are left of our scale
2766
-		if ($time >= $end) return 100;	// we are right of our scale
2761
+		if ($time <= $start) return 0; // we are left of our scale
2762
+		if ($time >= $end) return 100; // we are right of our scale
2767 2763
 
2768 2764
 		if ($this->planner_days || $this->sortby == 'month')
2769 2765
 		{
@@ -2785,14 +2781,14 @@  discard block
 block discarded – undo
2785 2781
 				else
2786 2782
 				{
2787 2783
 					$wd_lenght = $this->wd_end - $this->wd_start;
2788
-					if ($wd_lenght <= 0) $wd_lenght = 24*60;
2789
-					$day_percentage = ($time_of_day-$this->wd_start) / $wd_lenght;		// between 0 and 1
2784
+					if ($wd_lenght <= 0) $wd_lenght = 24 * 60;
2785
+					$day_percentage = ($time_of_day - $this->wd_start) / $wd_lenght; // between 0 and 1
2790 2786
 				}
2791 2787
 				$days = ($end - $start) / DAY_s;
2792 2788
 				$percent += $day_percentage / $days;
2793 2789
 			}
2794 2790
 		}
2795
-		$percent = round(100 * $percent,2);
2791
+		$percent = round(100 * $percent, 2);
2796 2792
 
2797 2793
 		//echo "<p>_planner_pos(".date('Y-m-d H:i',$time).', '.date('Y-m-d H:i',$start).', '.date('Y-m-d H:i',$end).") = $percent</p>\n";
2798 2794
 		return $percent;
@@ -2806,7 +2802,7 @@  discard block
 block discarded – undo
2806 2802
 	 * @param int $end end-time of the planner
2807 2803
 	 * @return string with widget
2808 2804
 	 */
2809
-	function plannerEventWidget($event,$start,$end,$indent='')
2805
+	function plannerEventWidget($event, $start, $end, $indent = '')
2810 2806
 	{
2811 2807
 		// some fields set by the dayColWidget for the other views
2812 2808
 		$day_start = $this->bo->date2ts((string)$this->bo->date2string($event['start']));
@@ -2815,15 +2811,15 @@  discard block
 block discarded – undo
2815 2811
 		$event['multiday'] = true;
2816 2812
 		unset($event['whole_day_on_top']);
2817 2813
 
2818
-		$data = $this->eventWidget($event,200,$indent,$this->owner,true,'planner_event');
2814
+		$data = $this->eventWidget($event, 200, $indent, $this->owner, true, 'planner_event');
2819 2815
 
2820
-		$left = $this->_planner_pos($event['start'],$start,$end);
2821
-		$width = $this->_planner_pos($event['end'],$start,$end) - $left;
2816
+		$left = $this->_planner_pos($event['start'], $start, $end);
2817
+		$width = $this->_planner_pos($event['end'], $start, $end) - $left;
2822 2818
 		$color = $data['color'] ? $data['color'] : 'gray';
2823 2819
 
2824
-		$tooltip = html::htmlspecialchars(str_replace(array("\n","\r","'",'"'),array('','',"\\'",'&quot;'),$data['tooltip']));
2820
+		$tooltip = html::htmlspecialchars(str_replace(array("\n", "\r", "'", '"'), array('', '', "\\'", '&quot;'), $data['tooltip']));
2825 2821
 		return $indent.'<div class="calendar_plannerEvent'.($data['private'] ? 'Private' : '').'" style="left: '.$left.
2826
-			'%; width: '.$width.'%; background-color: '.$color.';"'.'data-tooltip="'. $tooltip.'" '.
2822
+			'%; width: '.$width.'%; background-color: '.$color.';"'.'data-tooltip="'.$tooltip.'" '.
2827 2823
 			'" data-date ="'.$this->bo->date2string($event['start']).'|'.$data['popup'].'">'."\n".$data['html'].$indent."</div>\n";
2828 2824
 	}
2829 2825
 
@@ -2847,25 +2843,25 @@  discard block
 block discarded – undo
2847 2843
 				{
2848 2844
 					$start = $this->bo->date2array($event['start']);
2849 2845
 					$end = $this->bo->date2array($event['end']);
2850
-					if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
2846
+					if (!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59)
2851 2847
 					{
2852
-						if($event['non_blocking'])
2848
+						if ($event['non_blocking'])
2853 2849
 						{
2854
-							$dayEvents[$day][$num]['whole_day_on_top']=true;
2855
-							$this->whole_day_positions[$num]=($this->rowHeight*($num+2));
2850
+							$dayEvents[$day][$num]['whole_day_on_top'] = true;
2851
+							$this->whole_day_positions[$num] = ($this->rowHeight * ($num + 2));
2856 2852
 							$extraRowsToAdd++;
2857 2853
 						}
2858 2854
 						else
2859 2855
 						{
2860
-							$dayEvents[$day][$num]['whole_day']=true;
2856
+							$dayEvents[$day][$num]['whole_day'] = true;
2861 2857
 						}
2862 2858
 					}
2863 2859
 				}
2864 2860
 				// check after every day if we have to increase $this->extraRows
2865
-				if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows)
2861
+				if (($this->extraRowsOriginal + $extraRowsToAdd) > $this->extraRows)
2866 2862
 				{
2867 2863
 					$this->remBotExtraRows = $extraRowsToAdd;
2868
-					$this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd);
2864
+					$this->extraRows = ($this->extraRowsOriginal + $extraRowsToAdd);
2869 2865
 				}
2870 2866
 			}
2871 2867
 		}
@@ -2942,7 +2938,7 @@  discard block
 block discarded – undo
2942 2938
 			$day_start = $this->bo->date2ts((string)$day_ymd);
2943 2939
 
2944 2940
 			//Iterate over the holidays array and add those the the events list
2945
-			foreach($this->holidays[$day_ymd] as $holiday)
2941
+			foreach ($this->holidays[$day_ymd] as $holiday)
2946 2942
 			{
2947 2943
 				if (isset($holiday['birthyear']))
2948 2944
 				{
Please login to merge, or discard this patch.
Braces   +271 added lines, -71 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function week_number($time)
185 185
 	{
186
-		if (!is_a($time,'DateTime')) $time = new egw_time($time);
186
+		if (!is_a($time,'DateTime'))
187
+		{
188
+			$time = new egw_time($time);
189
+		}
187 190
 
188 191
 		// if week does not start Monday and $time is Sunday --> add one day
189 192
 		if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w')))
@@ -203,7 +206,10 @@  discard block
 block discarded – undo
203 206
 	 */
204 207
 	function index()
205 208
 	{
206
-		if (!$this->view) $this->view = 'week';
209
+		if (!$this->view)
210
+		{
211
+			$this->view = 'week';
212
+		}
207 213
 
208 214
 		// handle views in other files
209 215
 		if (!isset($this->public_functions[$this->view]))
@@ -277,9 +283,12 @@  discard block
 block discarded – undo
277 283
 	 */
278 284
 	function &planner($home=false)
279 285
 	{
280
-		if ($this->sortby == 'month')	// yearly planner with month rows
286
+		if ($this->sortby == 'month')
287
+		{
288
+			// yearly planner with month rows
281 289
 		{
282 290
 			$this->first = $this->bo->date2array($this->date);
291
+		}
283 292
 			$this->first['day'] = 1;
284 293
 			unset($this->first['raw']);
285 294
 			$this->last = $this->first;
@@ -289,11 +298,14 @@  discard block
 block discarded – undo
289 298
 				lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
290 299
 				lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
291 300
 		}
292
-		elseif (!$this->planner_days)	// planner monthview
301
+		elseif (!$this->planner_days)
302
+		{
303
+			// planner monthview
293 304
 		{
294 305
 			if ($this->day < 15)	// show one complete month
295 306
 			{
296 307
 				$this->_week_align_month($this->first,$this->last);
308
+		}
297 309
 				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
298 310
 			}
299 311
 			else	// show 2 half month
@@ -302,9 +314,12 @@  discard block
 block discarded – undo
302 314
 				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->first)).' / '.lang(adodb_date('F',$this->last)).' '.$this->year;
303 315
 			}
304 316
 		}
305
-		elseif ($this->planner_days >= 5)	// weeekview
317
+		elseif ($this->planner_days >= 5)
318
+		{
319
+			// weeekview
306 320
 		{
307 321
 			$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
322
+		}
308 323
 			$this->last = $this->bo->date2array($this->first);
309 324
 			$this->last['day'] += (int) $this->planner_days - 1;
310 325
 			$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
@@ -340,7 +355,10 @@  discard block
 block discarded – undo
340 355
 		$search_params['enum_groups'] = $this->sortby == 'user';
341 356
 		$events =& $this->bo->search($search_params);
342 357
 
343
-		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));
358
+		if ($this->debug > 0)
359
+		{
360
+			$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));
361
+		}
344 362
 
345 363
 		$content =& $this->plannerWidget($events,$this->first,$this->last,$this->sortby != 'category' ? $this->sortby : (int) $this->cat_id);
346 364
 
@@ -361,7 +379,11 @@  discard block
 block discarded – undo
361 379
 	 */
362 380
 	function &weekN($home=false)
363 381
 	{
364
-		if (($num = (int)$this->cal_prefs['multiple_weeks']) < 2) $num = 3;	// default 3 weeks
382
+		if (($num = (int)$this->cal_prefs['multiple_weeks']) < 2)
383
+		{
384
+			$num = 3;
385
+		}
386
+		// default 3 weeks
365 387
 
366 388
 		return $this->month($num,$home);
367 389
 	}
@@ -376,7 +398,10 @@  discard block
 block discarded – undo
376 398
 	 */
377 399
 	function &year($home=false)
378 400
 	{
379
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::year date=%2',True,$this->date);
401
+		if ($this->debug > 0)
402
+		{
403
+			$this->bo->debug_message('uiviews::year date=%2',True,$this->date);
404
+		}
380 405
 
381 406
 
382 407
 		$this->_month_align_year($this->first,$this->last);
@@ -608,7 +633,10 @@  discard block
 block discarded – undo
608 633
 	 */
609 634
 	function &month($weeks=0,$home=false)
610 635
 	{
611
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
636
+		if ($this->debug > 0)
637
+		{
638
+			$this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date);
639
+		}
612 640
 
613 641
 		$this->use_time_grid = !$this->cal_prefs['use_time_grid'] || $this->cal_prefs['use_time_grid'] == 'all'; 	// all views
614 642
 
@@ -625,7 +653,9 @@  discard block
 block discarded – undo
625 653
 					'end' => strtotime('+' . ($i+1).' weeks', $this->first) -1
626 654
 				);
627 655
 			}
628
-		} else {
656
+		}
657
+		else
658
+		{
629 659
 			$timespan[] = array(
630 660
 				'start' => mktime(0,0,0,$this->month,1,$this->year),
631 661
 				'end' => mktime(0,0,0,$this->month+1,1,$this->year)-1
@@ -654,7 +684,10 @@  discard block
 block discarded – undo
654 684
 			$weekNavH = "1 month";
655 685
 			$navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
656 686
 		}
657
-		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));
687
+		if ($this->debug > 0)
688
+		{
689
+			$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));
690
+		}
658 691
 
659 692
 		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$navHeader;
660 693
 
@@ -797,19 +830,31 @@  discard block
 block discarded – undo
797 830
 		if (!$days)
798 831
 		{
799 832
 			$days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview'];
800
-			if ($days != 5) $days = 7;
801
-			if ($days != $this->cal_prefs['days_in_weekview'])	// save the preference
833
+			if ($days != 5)
834
+			{
835
+				$days = 7;
836
+			}
837
+			if ($days != $this->cal_prefs['days_in_weekview'])
838
+			{
839
+				// save the preference
802 840
 			{
803 841
 				$GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days);
842
+			}
804 843
 				$GLOBALS['egw']->preferences->save_repository();
805 844
 				$this->cal_prefs['days_in_weekview'] = $days;
806 845
 			}
807 846
 		}
808
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
847
+		if ($this->debug > 0)
848
+		{
849
+			$this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date);
850
+		}
809 851
 
810
-		if ($days == 4)		// next 4 days view
852
+		if ($days == 4)
853
+		{
854
+			// next 4 days view
811 855
 		{
812 856
 			$wd_start = $this->first = $this->bo->date2ts($this->date);
857
+		}
813 858
 			$this->last = strtotime("+$days days",$this->first) - 1;
814 859
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Four days view').' '.$this->bo->long_date($this->first,$this->last);
815 860
 			$navHeader =lang('Four days view').' '.$this->bo->long_date($this->first,$this->last);
@@ -817,12 +862,15 @@  discard block
 block discarded – undo
817 862
 		else
818 863
 		{
819 864
 			$wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
820
-			if ($days == 5)		// no weekend-days
865
+			if ($days == 5)
866
+			{
867
+				// no weekend-days
821 868
 			{
822 869
 				switch($this->cal_prefs['weekdaystarts'])
823 870
 				{
824 871
 					case 'Saturday':
825 872
 						$this->first = strtotime("+2 days",$this->first);
873
+			}
826 874
 						break;
827 875
 					case 'Sunday':
828 876
 						$this->first = strtotime("+1 day",$this->first);
@@ -860,12 +908,18 @@  discard block
 block discarded – undo
860 908
 			) + $this->search_params;
861 909
 
862 910
 		$users = $this->search_params['users'];
863
-		if (!is_array($users)) $users = array($users);
911
+		if (!is_array($users))
912
+		{
913
+			$users = array($users);
914
+		}
864 915
 
865
-		if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate)	// for more then X users, show all in one row
916
+		if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate)
917
+		{
918
+			// for more then X users, show all in one row
866 919
 		{
867 920
 			$content = $this->timeGridWidget($this->tagWholeDayOnTop($this->bo->search($search_params)),$this->cal_prefs['interval']);
868 921
 		}
922
+		}
869 923
 		else
870 924
 		{
871 925
 			$content = '';
@@ -909,7 +963,10 @@  discard block
 block discarded – undo
909 963
 	 */
910 964
 	function &day($home=false)
911 965
 	{
912
-		if ($this->debug > 0) $this->bo->debug_message('uiviews::day() date=%1',True,$this->date);
966
+		if ($this->debug > 0)
967
+		{
968
+			$this->bo->debug_message('uiviews::day() date=%1',True,$this->date);
969
+		}
913 970
 
914 971
 		$this->last = $this->first = $this->bo->date2ts((string)$this->date);
915 972
 		$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$this->bo->long_date($this->first,0,false,true);
@@ -932,7 +989,10 @@  discard block
 block discarded – undo
932 989
 			$this->do_header();
933 990
 
934 991
 			$users = $this->search_params['users'];
935
-			if (!is_array($users)) $users = array($users);
992
+			if (!is_array($users))
993
+			{
994
+				$users = array($users);
995
+			}
936 996
 
937 997
 			// for more then X users, show all in one row
938 998
 			if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate)
@@ -1079,7 +1139,8 @@  discard block
 block discarded – undo
1079 1139
 							$icons .= ($icons?' ':'').$GLOBALS['egw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"');
1080 1140
 						}
1081 1141
 						$class = $class == 'row_on' ? 'row_off' : 'row_on';
1082
-						if($todo['edit']) {
1142
+						if($todo['edit'])
1143
+						{
1083 1144
 							list($width, $height) = explode('x', $todo['edit']['size']);
1084 1145
 							unset($todo['edit']['size']);
1085 1146
 							$edit_icon_href = html::a_href( $icons, $todo['edit'],'',' data-todo="app|'.$width.'x'.$height.'" ');
@@ -1115,10 +1176,13 @@  discard block
 block discarded – undo
1115 1176
 	 */
1116 1177
 	function time2pos($time)
1117 1178
 	{
1118
-		if ($this->scroll_to_wdstart)	// we display the complete day - thought only workday is visible without scrolling
1179
+		if ($this->scroll_to_wdstart)
1180
+		{
1181
+			// we display the complete day - thought only workday is visible without scrolling
1119 1182
 		{
1120 1183
 			return $this->rowHeight * (1 + $this->extraRows + $time/$this->granularity_m);
1121 1184
 		}
1185
+		}
1122 1186
 		// time before workday => condensed in the first $this->extraRows rows
1123 1187
 		if ($this->wd_start > 0 && $time < $this->wd_start)
1124 1188
 		{
@@ -1136,7 +1200,10 @@  discard block
 block discarded – undo
1136 1200
 		}
1137 1201
 		$pos = round($pos,1);
1138 1202
 
1139
-		if ($this->debug > 3) $this->bo->debug_message('uiviews::time2pos(%1)=%2',False,$time,$pos);
1203
+		if ($this->debug > 3)
1204
+		{
1205
+			$this->bo->debug_message('uiviews::time2pos(%1)=%2',False,$time,$pos);
1206
+		}
1140 1207
 
1141 1208
 		return $pos;
1142 1209
 	}
@@ -1156,7 +1223,10 @@  discard block
 block discarded – undo
1156 1223
 		$minimum = $this->rowHeight;
1157 1224
 		$height = $this->time2pos($end) - $this->time2pos($start);
1158 1225
 
1159
-		if ($this->debug > 3) $this->bo->debug_message('uiviews::times2height(%1,%2,min=%3)=%4',False,$start,$end,$minimum,$height);
1226
+		if ($this->debug > 3)
1227
+		{
1228
+			$this->bo->debug_message('uiviews::times2height(%1,%2,min=%3)=%4',False,$start,$end,$minimum,$height);
1229
+		}
1160 1230
 
1161 1231
 		return $height >= $minimum ? $height : $minimum;
1162 1232
 	}
@@ -1176,7 +1246,10 @@  discard block
 block discarded – undo
1176 1246
 	 */
1177 1247
 	function &timeGridWidget($daysEvents,$granularity_m=30,$height=400,$indent='',$title='',$owner=0,$last=true)
1178 1248
 	{
1179
-		if ($this->debug > 1 || $this->debug==='timeGridWidget') $this->bo->debug_message('uiviews::timeGridWidget(events=%1,granularity_m=%2,height=%3,,title=%4)',True,$daysEvents,$granularity_m,$height,$title);
1249
+		if ($this->debug > 1 || $this->debug==='timeGridWidget')
1250
+		{
1251
+			$this->bo->debug_message('uiviews::timeGridWidget(events=%1,granularity_m=%2,height=%3,,title=%4)',True,$daysEvents,$granularity_m,$height,$title);
1252
+		}
1180 1253
 
1181 1254
 		// determine if the browser supports scrollIntoView: IE4+, firefox1.0+ and safari2.0+ does
1182 1255
 		// then show all hours in a div of the size of the workday and scroll to the workday start
@@ -1195,7 +1268,10 @@  discard block
 block discarded – undo
1195 1268
 		$this->display_start = $this->wd_start - ($this->extraRows * $this->granularity_m);
1196 1269
 		$this->display_end	= $this->wd_end + (($this->extraRows - $this->remBotExtraRows) * $this->granularity_m);
1197 1270
 
1198
-		if (!$this->wd_end) $this->wd_end = 1440;
1271
+		if (!$this->wd_end)
1272
+		{
1273
+			$this->wd_end = 1440;
1274
+		}
1199 1275
 		$totalDisplayMinutes	= $this->wd_end - $this->wd_start;
1200 1276
 		$this->rowsToDisplay	= ($totalDisplayMinutes/$granularity_m)+2+2*$this->extraRows - $this->remBotExtraRows;
1201 1277
 		$this->rowHeight		= round(100/$this->rowsToDisplay,1);
@@ -1244,7 +1320,10 @@  discard block
 block discarded – undo
1244 1320
 				{
1245 1321
 					$time = $GLOBALS['egw']->common->formattime(sprintf('%02d',$t/60),sprintf('%02d',$t%60));
1246 1322
 				}
1247
-				if ($add_links) $time = $this->add_link($time,$this->date,(int) ($t/60),$t%60);
1323
+				if ($add_links)
1324
+				{
1325
+					$time = $this->add_link($time,$this->date,(int) ($t/60),$t%60);
1326
+				}
1248 1327
 				$html .= $indent."\t\t".'<div class="calendar_calTimeRowTime">'.$time."</div>\n";
1249 1328
 				$html .= $indent."\t</div>\n";	// calendar_calTimeRow
1250 1329
 				$off = !$off;
@@ -1260,7 +1339,9 @@  discard block
 block discarded – undo
1260 1339
 			$html .= $indent."\t".'<div id="calendar_calDayCols" class="calendar_calDayCols'.
1261 1340
 				($this->use_time_grid ? ($this->bo->common_prefs['timeformat'] == 12 ? '12h' : '') : 'NoTime').'">'."\n";
1262 1341
 
1263
-			if (html::$user_agent == 'msie')	// necessary IE hack - stupid thing ...
1342
+			if (html::$user_agent == 'msie')
1343
+			{
1344
+				// necessary IE hack - stupid thing ...
1264 1345
 			{
1265 1346
 				// Lars Kneschke 2005-08-28
1266 1347
 				// why do we use a div in a div which has the same height and width???
@@ -1273,6 +1354,7 @@  discard block
 block discarded – undo
1273 1354
 				// means you width: 100% does NOT work, you need no width!
1274 1355
 				$html .= '<div style="height: 100%;">'."\n";
1275 1356
 			}
1357
+			}
1276 1358
 			$dayCol_width = $dayCols_width / count($daysEvents);
1277 1359
 			$n = 0;
1278 1360
 			foreach($daysEvents as $day => $events)
@@ -1290,7 +1372,10 @@  discard block
 block discarded – undo
1290 1372
 					$dayColWidth,$indent."\t\t",$short_title,++$on_off & 1,$col_owner);
1291 1373
 				++$n;
1292 1374
 			}
1293
-			if (html::$user_agent == 'msie') $html .= "</div>\n";
1375
+			if (html::$user_agent == 'msie')
1376
+			{
1377
+				$html .= "</div>\n";
1378
+			}
1294 1379
 
1295 1380
 			$html .= $indent."\t</div>\n";	// calendar_calDayCols
1296 1381
 		}
@@ -1299,10 +1384,13 @@  discard block
 block discarded – undo
1299 1384
 		if ($this->scroll_to_wdstart)
1300 1385
 		{
1301 1386
 			$html .= "<script>\n\tdocument.getElementById('$id').scrollIntoView();\n";
1302
-			if ($last)	// last timeGrid --> scroll whole document back up
1387
+			if ($last)
1388
+			{
1389
+				// last timeGrid --> scroll whole document back up
1303 1390
 			{
1304 1391
 				$html .= "\tdocument.getElementById('divMain').scrollIntoView();\n";
1305 1392
 			}
1393
+			}
1306 1394
 			$html .= "</script>\n";
1307 1395
 		}
1308 1396
 
@@ -1373,7 +1461,10 @@  discard block
 block discarded – undo
1373 1461
 	 */
1374 1462
 	function dayColWidget($day_ymd,$events,$pleft,$pwidth,$indent,$short_title=True,$on_off=False,$owner=0)
1375 1463
 	{
1376
-		if ($this->debug > 1 || $this->debug==='dayColWidget') $this->bo->debug_message('uiviews::dayColWidget(%1,%2,left=%3,width=%4,)',False,$day_ymd,$events,$pleft,$pwidth);
1464
+		if ($this->debug > 1 || $this->debug==='dayColWidget')
1465
+		{
1466
+			$this->bo->debug_message('uiviews::dayColWidget(%1,%2,left=%3,width=%4,)',False,$day_ymd,$events,$pleft,$pwidth);
1467
+		}
1377 1468
 		
1378 1469
 		$html = $indent.'<div id="calColumn'.$this->calColumnCounter++.'" class="calendar_calDayCol" '.'data-sortable-id="'.$owner.'" style="left: '.$pleft.
1379 1470
 			'%;width: '.$pwidth.'%;">'."\n";
@@ -1389,7 +1480,10 @@  discard block
 block discarded – undo
1389 1480
 		);
1390 1481
 		$this->_day_class_holiday($day_ymd,$class,$holidays);
1391 1482
 		// the weekday and date
1392
-		if (!$short_title && $holidays) $title .= html::htmlspecialchars(': '.$holidays);
1483
+		if (!$short_title && $holidays)
1484
+		{
1485
+			$title .= html::htmlspecialchars(': '.$holidays);
1486
+		}
1393 1487
 
1394 1488
 		if ($short_title === true)
1395 1489
 		{
@@ -1421,7 +1515,8 @@  discard block
 block discarded – undo
1421 1515
 				$title .= ' </span> '.$day_view;
1422 1516
 			}
1423 1517
 		}
1424
-		if (is_bool($short_title) || ($short_title != "")) {
1518
+		if (is_bool($short_title) || ($short_title != ""))
1519
+		{
1425 1520
 			$html .= $indent."\t".'<div style="height: '. $this->rowHeight .'%;" class="calendar_calDayColHeader '.$class.'"'.
1426 1521
 				($holidays ? ' title="'.html::htmlspecialchars($holidays).'"':'').'>'.$title."</div>\n";
1427 1522
 		}
@@ -1449,7 +1544,10 @@  discard block
 block discarded – undo
1449 1544
 					'hour'		=> sprintf("%02d",floor($t / 60)),
1450 1545
 					'minute'	=> sprintf("%02d",floor($t % 60)),
1451 1546
 				);
1452
-				if ($owner) $linkData['owner'] = $owner;
1547
+				if ($owner)
1548
+				{
1549
+					$linkData['owner'] = $owner;
1550
+				}
1453 1551
 
1454 1552
 				$droppableDateTime = $linkData['date'] . "T" . $linkData['hour'] . $linkData['minute'];
1455 1553
 				$droppableID='drop_'.$droppableDateTime.'_O'.($owner<0?str_replace('-','group',$owner):$owner);
@@ -1488,7 +1586,10 @@  discard block
 block discarded – undo
1488 1586
 				$width = !$n ? 70 : 50;
1489 1587
 				$left += $n * (100.0-$left) / count($eventCols);
1490 1588
 			}
1491
-			if ($left + $width > 100.0) $width = 100.0 - $left;
1589
+			if ($left + $width > 100.0)
1590
+			{
1591
+				$width = 100.0 - $left;
1592
+			}
1492 1593
 			//echo "<p>count(\$eventCols)=".count($eventCols).", n=$n, pWidth=$pwidth, pLeft=$pleft, width=$width, left=$left</p>\n";
1493 1594
 			$html .= $this->eventColWidget($eventCol,$left,$width,$indent."\t",
1494 1595
 				$owner ? $owner : $this->user, 20+10*$n);
@@ -1567,7 +1668,10 @@  discard block
 block discarded – undo
1567 1668
 				}
1568 1669
 			}
1569 1670
 		}
1570
-		if ($bday) $class .= ' calendar_calBirthday';
1671
+		if ($bday)
1672
+		{
1673
+			$class .= ' calendar_calBirthday';
1674
+		}
1571 1675
 	}
1572 1676
 
1573 1677
 	/**
@@ -1583,7 +1687,10 @@  discard block
 block discarded – undo
1583 1687
 	 */
1584 1688
 	function eventColWidget($events,$left,$width,$indent,$owner,$z_index=null)
1585 1689
 	{
1586
-		if ($this->debug > 1 || $this->debug==='eventColWidget') $this->bo->debug_message('uiviews::eventColWidget(%1,left=%2,width=%3,)',False,$events,$left,$width);
1690
+		if ($this->debug > 1 || $this->debug==='eventColWidget')
1691
+		{
1692
+			$this->bo->debug_message('uiviews::eventColWidget(%1,left=%2,width=%3,)',False,$events,$left,$width);
1693
+		}
1587 1694
 
1588 1695
 		$html = $indent.'<div class="calendar_calEventCol" style="left: '.$left.'%; width:'.$width.'%;'.
1589 1696
 			// the "calendar_calEventCol" spans across a whole column (as the name suggests) - setting the
@@ -1617,9 +1724,15 @@  discard block
 block discarded – undo
1617 1724
 	 */
1618 1725
 	function eventWidget($event,$width,$indent,$owner,$return_array=false,$block='event_widget',$z_index=null)
1619 1726
 	{
1620
-		if ($this->debug > 1 || $this->debug==='eventWidget') $this->bo->debug_message('uiviews::eventWidget(%1,width=%2)',False,$event,$width);
1727
+		if ($this->debug > 1 || $this->debug==='eventWidget')
1728
+		{
1729
+			$this->bo->debug_message('uiviews::eventWidget(%1,width=%2)',False,$event,$width);
1730
+		}
1621 1731
 
1622
-		if($this->use_time_grid && $event['whole_day_on_top']) $block = 'event_widget_wholeday_on_top';
1732
+		if($this->use_time_grid && $event['whole_day_on_top'])
1733
+		{
1734
+			$block = 'event_widget_wholeday_on_top';
1735
+		}
1623 1736
 
1624 1737
 		static $tpl = False;
1625 1738
 		if (!$tpl)
@@ -1699,7 +1812,11 @@  discard block
 block discarded – undo
1699 1812
 		$status_class = 'calendar_calEventAllAccepted';
1700 1813
 		foreach($event['participants'] as $id => $status)
1701 1814
 		{
1702
-			if ($id < 0) continue;	// as we cant accept/reject groups, we dont care about them here
1815
+			if ($id < 0)
1816
+			{
1817
+				continue;
1818
+			}
1819
+			// as we cant accept/reject groups, we dont care about them here
1703 1820
 
1704 1821
 			calendar_so::split_status($status,$quantity,$role);
1705 1822
 
@@ -1719,9 +1836,9 @@  discard block
 block discarded – undo
1719 1836
 		// seperate each participant types
1720 1837
 		$part_array = array();
1721 1838
 		if ($this->allowEdit)
1722
- 		{
1839
+		{
1723 1840
 			foreach($this->bo->participants($event) as $part_key => $participant)
1724
- 			{
1841
+			{
1725 1842
 				if(is_numeric($part_key))
1726 1843
 				{
1727 1844
 					$part_array[lang('Participants')][$part_key] = $participant;
@@ -1732,7 +1849,7 @@  discard block
 block discarded – undo
1732 1849
 				}
1733 1850
  			}
1734 1851
 			foreach($part_array as $part_group => $participant)
1735
- 			{
1852
+			{
1736 1853
 				$participants .= $this->add_nonempty($participant,$part_group,True,False,false);
1737 1854
  			}
1738 1855
  		}
@@ -1855,7 +1972,8 @@  discard block
 block discarded – undo
1855 1972
 					$this->wholeDayPosCounter++;
1856 1973
 			}
1857 1974
 			else
1858
-			{		$view_link = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
1975
+			{
1976
+$view_link = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
1859 1977
 
1860 1978
 					$style = 'top: '.$this->time2pos($event['start_m']).'%; height: '.$height.'%;';
1861 1979
 			}
@@ -2032,7 +2150,10 @@  discard block
 block discarded – undo
2032 2150
 		for ($i = 1; $i <=3; ++$i)
2033 2151
 		{
2034 2152
 			$val = hexdec($components[$i]) + $decr;
2035
-			if ($val > 255) $val = 255;
2153
+			if ($val > 255)
2154
+			{
2155
+				$val = 255;
2156
+			}
2036 2157
 			$brighter .= sprintf('%02x',$val);
2037 2158
 		}
2038 2159
 		//echo "brighter($rgb=".print_r($components,True).")=$brighter</p>\n";
@@ -2126,34 +2247,50 @@  discard block
 block discarded – undo
2126 2247
 		else
2127 2248
 		{
2128 2249
 			$days = 1 + (int) round(($last - $first) / DAY_s);	// we have to use round to get the right number if daylight saving changes
2129
-			if ($days >= 28)	// display the month scale
2250
+			if ($days >= 28)
2251
+			{
2252
+				// display the month scale
2130 2253
 			{
2131 2254
 				$content .= $this->plannerMonthScale($first,$days,$indent."\t\t\t");
2132 2255
 			}
2133
-			if ($days >= 5)	// display the week scale
2256
+			}
2257
+			if ($days >= 5)
2258
+			{
2259
+				// display the week scale
2134 2260
 			{
2135 2261
 				$content .= $this->plannerWeekScale($first,$days,$indent."\t\t\t");
2136 2262
 			}
2263
+			}
2137 2264
 			$content .= $this->plannerDayScale($first,$days,$indent."\t\t\t");		// day-scale, always displayed
2138
-			if ($days <= 7)	// display the hour scale
2265
+			if ($days <= 7)
2266
+			{
2267
+				// display the hour scale
2139 2268
 			{
2140 2269
 				$content .= $this->plannerHourScale($start,$days,$indent."\t\t\t");
2141 2270
 			}
2271
+			}
2142 2272
 		}
2143 2273
 		$content .= $indent."\t\t</div>\n";	// end of the plannerHeaderRows
2144 2274
 		$content .= $indent."\t</div>\n";	// end of the plannerHeader
2145 2275
 
2146 2276
 		// sort the events after user or category
2147 2277
 		$rows = array();
2148
-		if (!is_array($events)) $events = array();
2278
+		if (!is_array($events))
2279
+		{
2280
+			$events = array();
2281
+		}
2149 2282
 
2150
-		if ($by_cat === 'user')	// planner by user
2283
+		if ($by_cat === 'user')
2284
+		{
2285
+			// planner by user
2151 2286
 		{
2152 2287
 			// convert filter to allowed status
2153 2288
 			switch($this->filter)
2154 2289
 			{
2155 2290
 				case 'unknown':
2156
-					$status_to_show = array('U','G'); break;
2291
+					$status_to_show = array('U','G');
2292
+		}
2293
+		break;
2157 2294
 				case 'accepted':
2158 2295
 					$status_to_show = array('A'); break;
2159 2296
 				case 'tentative':
@@ -2170,22 +2307,31 @@  discard block
 block discarded – undo
2170 2307
 		}
2171 2308
 		foreach($events as $key => $event)
2172 2309
 		{
2173
-			if ($by_cat === 'user')	// planner by user
2310
+			if ($by_cat === 'user')
2311
+			{
2312
+				// planner by user
2174 2313
 			{
2175 2314
 				foreach($event['participants'] as $sort => $status)
2176 2315
 				{
2177 2316
 					calendar_so::split_status($status,$nul,$nul);
2317
+			}
2178 2318
 					// only show if participant with status visible with current filter
2179 2319
 					if (isset($sort2label[$sort]) && (in_array($status,$status_to_show) ||
2180
-						$this->filter == 'owner' && $event['owner'] == $sort))	// owner too additionally uses owner
2320
+						$this->filter == 'owner' && $event['owner'] == $sort))
2321
+					{
2322
+						// owner too additionally uses owner
2181 2323
 					{
2182 2324
 						$rows[$sort][] =& $events[$key];
2183 2325
 					}
2326
+					}
2184 2327
 				}
2185 2328
 			}
2186
-			elseif ($by_cat === 'month')	// planner by month / yearly planner
2329
+			elseif ($by_cat === 'month')
2330
+			{
2331
+				// planner by month / yearly planner
2187 2332
 			{
2188 2333
 				$sort = date('Y-m',$event['start']);
2334
+			}
2189 2335
 				$rows[$sort][] =& $events[$key];
2190 2336
 				// end in a different month?
2191 2337
 				if ($sort != ($end_sort = date('Y-m',$event['end'])))
@@ -2207,7 +2353,10 @@  discard block
 block discarded – undo
2207 2353
 			{
2208 2354
 				foreach($this->_get_planner_cats($event['category'],$sort2label,$sort2color) as $sort)
2209 2355
 				{
2210
-					if (!is_array($rows[$sort])) $rows[$sort] = array();
2356
+					if (!is_array($rows[$sort]))
2357
+					{
2358
+						$rows[$sort] = array();
2359
+					}
2211 2360
 
2212 2361
 					$rows[$sort][] =& $events[$key];
2213 2362
 				}
@@ -2259,15 +2408,21 @@  discard block
 block discarded – undo
2259 2408
 				// 0 means current user
2260 2409
 				$user = $this->user;
2261 2410
 			}
2262
-			if (!is_numeric($user))		// resources
2411
+			if (!is_numeric($user))
2412
+			{
2413
+				// resources
2263 2414
 			{
2264 2415
 				$resources[$user] = $this->bo->participant_name($user);
2265 2416
 			}
2266
-			elseif ($enum_groups && $GLOBALS['egw']->accounts->get_type($user) == 'g')	// groups
2417
+			}
2418
+			elseif ($enum_groups && $GLOBALS['egw']->accounts->get_type($user) == 'g')
2419
+			{
2420
+				// groups
2267 2421
 			{
2268 2422
 				foreach((array) $GLOBALS['egw']->accounts->member($user) as $data)
2269 2423
 				{
2270 2424
 					$user = $data['account_id'];
2425
+			}
2271 2426
 					if ($this->bo->check_perms(EGW_ACL_READ | EGW_ACL_FREEBUSY,0,$user))
2272 2427
 					{
2273 2428
 						$users[$user] = $this->bo->participant_name($user);
@@ -2309,15 +2464,21 @@  discard block
 block discarded – undo
2309 2464
 			foreach((array)$this->categories->return_sorted_array(0,false,'','','',true) as $data)
2310 2465
 			{
2311 2466
 				if (in_array($data['parent'], $cat_filter) || in_array($data['id'], $cat_filter) ||
2312
-					!$data['parent'] && !$cat_filter)	// cat is a direct sub of $this->cat_id
2467
+					!$data['parent'] && !$cat_filter)
2468
+				{
2469
+					// cat is a direct sub of $this->cat_id
2313 2470
 				{
2314 2471
 					$cat2sort[$data['id']] = $data['id'];
2472
+				}
2315 2473
 					$sort2label[$data['id']] = stripslashes($data['name']);
2316 2474
 				}
2317
-				elseif(isset($cat2sort[$data['parent']]))	// parent is already in the array => add us with same target
2475
+				elseif(isset($cat2sort[$data['parent']]))
2476
+				{
2477
+					// parent is already in the array => add us with same target
2318 2478
 				{
2319 2479
 					$cat2sort[$data['id']] = $cat2sort[$data['parent']];
2320 2480
 				}
2481
+				}
2321 2482
 			}
2322 2483
 		}
2323 2484
 		$ret = array();
@@ -2375,7 +2536,11 @@  discard block
 block discarded – undo
2375 2536
 				{
2376 2537
 					$prev['day'] = $this->day;
2377 2538
 					$full = $this->bo->date2string($prev);
2378
-					if ($this->day >= 15) $prev = $t_arr;		// we stay in the same month
2539
+					if ($this->day >= 15)
2540
+					{
2541
+						$prev = $t_arr;
2542
+					}
2543
+					// we stay in the same month
2379 2544
 					$prev['day'] = $this->day < 15 ? 15 : 1;
2380 2545
 					$half = $this->bo->date2string($prev);
2381 2546
 					$title = html::a_href(html::image('phpgwapi','first',lang('back one month'),$options=' alt="<<"'),array(
@@ -2398,10 +2563,18 @@  discard block
 block discarded – undo
2398 2563
 				$days_in_next_month = (int) date('d',$end = $start+$days*DAY_s);
2399 2564
 				if ($days_in_next_month <= 10 || date('m',$end) == date('m',$t))
2400 2565
 				{
2401
-					if ($this->day >= 15) $next = $t_arr;		// we stay in the same month
2566
+					if ($this->day >= 15)
2567
+					{
2568
+						$next = $t_arr;
2569
+					}
2570
+					// we stay in the same month
2402 2571
 					$next['day'] = $this->day;
2403 2572
 					$full = $this->bo->date2string($next);
2404
-					if ($this->day < 15) $next = $t_arr;		// we stay in the same month
2573
+					if ($this->day < 15)
2574
+					{
2575
+						$next = $t_arr;
2576
+					}
2577
+					// we stay in the same month
2405 2578
 					$next['day'] = $this->day < 15 ? 15 : 1;
2406 2579
 					$half = $this->bo->date2string($next);
2407 2580
 					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward half a month'),$options=' alt=">>"'),array(
@@ -2511,20 +2684,26 @@  discard block
 block discarded – undo
2511 2684
 			}
2512 2685
 			if ($days < 5)
2513 2686
 			{
2514
-				if (!$i)	// prev. day only for the first day
2687
+				if (!$i)
2688
+				{
2689
+					// prev. day only for the first day
2515 2690
 				{
2516 2691
 					$title = html::a_href(html::image('phpgwapi','first',lang('previous'),$options=' alt="<<"'),array(
2517 2692
 						'menuaction' => $this->view_menuaction,
2518 2693
 						'date'       => date('Ymd',$start-DAY_s),
2519 2694
 					)) . ' &nbsp; '.$title;
2520 2695
 				}
2521
-				if ($i == $days-1)	// next day only for the last day
2696
+				}
2697
+				if ($i == $days-1)
2698
+				{
2699
+					// next day only for the last day
2522 2700
 				{
2523 2701
 					$title .= ' &nbsp; '.html::a_href(html::image('phpgwapi','last',lang('next'),$options=' alt=">>"'),array(
2524 2702
 						'menuaction' => $this->view_menuaction,
2525 2703
 						'date'       => date('Ymd',$start+DAY_s),
2526 2704
 					));
2527 2705
 				}
2706
+				}
2528 2707
 			}
2529 2708
 			$content .= $indent."\t".'<div class="calendar_plannerDayScale '.$class.'" style="left: '.$left.'%; width: '.$day_width.'%;"'.
2530 2709
 				($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').'>'.$title."</div>\n";
@@ -2606,15 +2785,21 @@  discard block
 block discarded – undo
2606 2785
 	 */
2607 2786
 	function plannerHourScale($start,$days,$indent)
2608 2787
 	{
2609
-		foreach(array(1,2,3,4,6,8,12) as $d)	// numbers dividing 24 without rest
2788
+		foreach(array(1,2,3,4,6,8,12) as $d)
2789
+		{
2790
+			// numbers dividing 24 without rest
2610 2791
 		{
2611 2792
 			if ($d > $days) break;
2793
+		}
2612 2794
 			$decr = $d;
2613 2795
 		}
2614 2796
 		$hours = $days * 24;
2615
-		if ($days == 1)			// for a single day we calculate the hours of a days, to take into account daylight saving changes (23 or 25 hours)
2797
+		if ($days == 1)
2798
+		{
2799
+			// for a single day we calculate the hours of a days, to take into account daylight saving changes (23 or 25 hours)
2616 2800
 		{
2617 2801
 			$t_arr = $this->bo->date2array($start);
2802
+		}
2618 2803
 			unset($t_arr['raw']);
2619 2804
 			$t_arr['hour'] = $t_arr['minute'] = $t_arr['second'] = 0;
2620 2805
 			$s = $this->bo->date2ts($t_arr);
@@ -2714,13 +2899,16 @@  discard block
 block discarded – undo
2714 2899
 			$this->_day_class_holiday($this->bo->date2string($t),$class,$holidays,true);
2715 2900
 
2716 2901
 			$class = trim(str_replace(array('row_on','row_off'),'',$class));
2717
-			if ($class)	// no regular weekday
2902
+			if ($class)
2903
+			{
2904
+				// no regular weekday
2718 2905
 			{
2719 2906
 				$content .= $indent.'<div class="calendar_eventRowsMarkedDay '.$class.
2720 2907
 					'" style="left: '.$left.'%; width:'.$day_width.'%;"'.
2721 2908
 					($holidays ? ' title="'.html::htmlspecialchars($holidays).'"' : '').
2722 2909
 					' ></div>'."\n";
2723 2910
 			}
2911
+			}
2724 2912
 		}
2725 2913
 		return $content;
2726 2914
 	}
@@ -2762,8 +2950,16 @@  discard block
 block discarded – undo
2762 2950
 	 */
2763 2951
 	function _planner_pos($time,$start,$end)
2764 2952
 	{
2765
-		if ($time <= $start) return 0;	// we are left of our scale
2766
-		if ($time >= $end) return 100;	// we are right of our scale
2953
+		if ($time <= $start)
2954
+		{
2955
+			return 0;
2956
+		}
2957
+		// we are left of our scale
2958
+		if ($time >= $end)
2959
+		{
2960
+			return 100;
2961
+		}
2962
+		// we are right of our scale
2767 2963
 
2768 2964
 		if ($this->planner_days || $this->sortby == 'month')
2769 2965
 		{
@@ -2785,7 +2981,10 @@  discard block
 block discarded – undo
2785 2981
 				else
2786 2982
 				{
2787 2983
 					$wd_lenght = $this->wd_end - $this->wd_start;
2788
-					if ($wd_lenght <= 0) $wd_lenght = 24*60;
2984
+					if ($wd_lenght <= 0)
2985
+					{
2986
+						$wd_lenght = 24*60;
2987
+					}
2789 2988
 					$day_percentage = ($time_of_day-$this->wd_start) / $wd_lenght;		// between 0 and 1
2790 2989
 				}
2791 2990
 				$days = ($end - $start) / DAY_s;
@@ -2882,7 +3081,8 @@  discard block
 block discarded – undo
2882 3081
 	function _get_holiday_icon($type)
2883 3082
 	{
2884 3083
 		//Set the special icon which will be prepended to the event
2885
-		switch ($type) {
3084
+		switch ($type)
3085
+		{
2886 3086
 			case "bday":
2887 3087
 				return html::image('calendar', 'cake', '', "style=\"float:left; padding: 1px 2px 0px 2px;\"");
2888 3088
 			case "hday":
Please login to merge, or discard this patch.
calendar/inc/class.soholiday.inc.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -78,6 +78,9 @@
 block discarded – undo
78 78
 		}
79 79
 	}
80 80
 
81
+	/**
82
+	 * @param ADORecordSet $rs
83
+	 */
81 84
 	function store_to_array(&$holidays,$rs)
82 85
 	{
83 86
 		foreach($rs as $row)
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		$holiday['observance_rule'] = @$holiday['observance_rule'] ? 1 : 0;
40 40
 		$holiday['locale'] = strtoupper($holiday['locale']);
41 41
 
42
-		foreach($holiday as $name => $val)
42
+		foreach ($holiday as $name => $val)
43 43
 		{
44
-			if (substr($name,0,4) != 'hol_')
44
+			if (substr($name, 0, 4) != 'hol_')
45 45
 			{
46 46
 				if (!is_numeric($name))
47 47
 				{
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 
57 57
 		if ($hol_id)
58 58
 		{
59
-			if($this->debug)
59
+			if ($this->debug)
60 60
 			{
61 61
 				echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
62 62
 			}
63
-			$this->db->update($this->table,$holiday,array('hol_id' => $hol_id),__LINE__,__FILE__,'calendar');
63
+			$this->db->update($this->table, $holiday, array('hol_id' => $hol_id), __LINE__, __FILE__, 'calendar');
64 64
 		}
65 65
 		else
66 66
 		{
67
-			if($this->debug)
67
+			if ($this->debug)
68 68
 			{
69 69
 				echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
70 70
 			}
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 				'hol_occurence' => $holiday['hol_occurence'],
75 75
 				'hol_locale' => $holiday['hol_locale'],
76 76
 			), __LINE__, __FILES__, 'calendar');
77
-			$this->db->insert($this->table,$holiday,False,__LINE__,__FILE__,'calendar');
77
+			$this->db->insert($this->table, $holiday, False, __LINE__, __FILE__, 'calendar');
78 78
 		}
79 79
 	}
80 80
 
81
-	function store_to_array(&$holidays,$rs)
81
+	function store_to_array(&$holidays, $rs)
82 82
 	{
83
-		foreach($rs as $row)
83
+		foreach ($rs as $row)
84 84
 		{
85 85
 			$holidays[] = Array(
86 86
 				'index'			=> $row['hol_id'],
@@ -92,31 +92,31 @@  discard block
 block discarded – undo
92 92
 				'dow'			=> (int)$row['hol_dow'],
93 93
 				'observance_rule'	=> $row['hol_observance_rule']
94 94
 			);
95
-			if($this->debug)
95
+			if ($this->debug)
96 96
 			{
97 97
 				echo 'Holiday ID: '.$row['hol_id'].'<br>'."\n";
98 98
 			}
99 99
 		}
100 100
 	}
101 101
 
102
-	function read_holidays($locales='',$query='',$order='',$year=0)
102
+	function read_holidays($locales = '', $query = '', $order = '', $year = 0)
103 103
 	{
104 104
 		$holidays = Array();
105 105
 
106
-		if($locales == '')
106
+		if ($locales == '')
107 107
 		{
108 108
 			return $holidays;
109 109
 		}
110 110
 
111
-		$where = $this->_build_where($locales,$query,$order,$year);
111
+		$where = $this->_build_where($locales, $query, $order, $year);
112 112
 
113
-		if($this->debug)
113
+		if ($this->debug)
114 114
 		{
115 115
 			echo 'Read Holidays : '.$where.'<br>'."\n";
116 116
 		}
117 117
 
118
-		$rs = $this->db->select($this->table,'*',$where,__LINE__,__FILE__,false,'','calendar');
119
-		$this->store_to_array($holidays,$rs);
118
+		$rs = $this->db->select($this->table, '*', $where, __LINE__, __FILE__, false, '', 'calendar');
119
+		$this->store_to_array($holidays, $rs);
120 120
 
121 121
 		return $holidays;
122 122
 	}
@@ -124,38 +124,38 @@  discard block
 block discarded – undo
124 124
 	function read_holiday($id)
125 125
 	{
126 126
 		$holidays = Array();
127
-		if($this->debug)
127
+		if ($this->debug)
128 128
 		{
129 129
 			echo 'Reading Holiday ID : '.$id.'<br>'."\n";
130 130
 		}
131
-		$rs = $this->db->select($this->table,'*',array('hol_id'=>$id),__LINE__,__FILE__,false,'','calendar');
132
-		$this->store_to_array($holidays,$rs);
131
+		$rs = $this->db->select($this->table, '*', array('hol_id'=>$id), __LINE__, __FILE__, false, '', 'calendar');
132
+		$this->store_to_array($holidays, $rs);
133 133
 		return $holidays[0];
134 134
 	}
135 135
 
136 136
 	function delete_holiday($id)
137 137
 	{
138
-		$this->db->delete($this->table,array('hol_id' => $id),__LINE__,__FILE__,'calendar');
138
+		$this->db->delete($this->table, array('hol_id' => $id), __LINE__, __FILE__, 'calendar');
139 139
 	}
140 140
 
141 141
 	function delete_locale($locale)
142 142
 	{
143
-		$this->db->delete($this->table,array('hol_locale' => $locale),__LINE__,__FILE__,'calendar');
143
+		$this->db->delete($this->table, array('hol_locale' => $locale), __LINE__, __FILE__, 'calendar');
144 144
 	}
145 145
 
146 146
 	/* Private functions */
147
-	function _build_where($locales,$query='',$order='',$year=0,$add_order_by=True)
147
+	function _build_where($locales, $query = '', $order = '', $year = 0, $add_order_by = True)
148 148
 	{
149 149
 		$querymethod = 'hol_locale';
150 150
 		if (is_array($locales))
151 151
 		{
152
-			$querymethod .= ' IN ('.$this->db->column_data_implode(',',$locales,False).')';
152
+			$querymethod .= ' IN ('.$this->db->column_data_implode(',', $locales, False).')';
153 153
 		}
154 154
 		else
155 155
 		{
156 156
 			$querymethod .= '='.$this->db->quote($locales);
157 157
 		}
158
-		if($query)
158
+		if ($query)
159 159
 		{
160 160
 			$querymethod .= " AND hol_name LIKE ".$this->db->quote('%'.$query.'%');
161 161
 		}
@@ -165,44 +165,44 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 		if ($add_order_by)
167 167
 		{
168
-			$querymethod .= ' ORDER BY '.(preg_match('/^[a-zA-Z0-9_,]+$/',$order) ? $order : 'hol_month_num,hol_mday');
168
+			$querymethod .= ' ORDER BY '.(preg_match('/^[a-zA-Z0-9_,]+$/', $order) ? $order : 'hol_month_num,hol_mday');
169 169
 		}
170 170
 		return $querymethod;
171 171
 	}
172 172
 
173
-	function get_locale_list($sort='', $order='', $query='')
173
+	function get_locale_list($sort = '', $order = '', $query = '')
174 174
 	{
175 175
 		$querymethod = '';
176
-		if($query)
176
+		if ($query)
177 177
 		{
178 178
 			$querymethod = 'hol_locale LIKE '.$this->db->quote('%'.$query.'%');
179 179
 		}
180 180
 
181
-		if(!preg_match('/^[a-zA-Z0-9_,]+$/',$order))
181
+		if (!preg_match('/^[a-zA-Z0-9_,]+$/', $order))
182 182
 		{
183 183
 			$order = 'hol_locale';
184 184
 		}
185 185
 		if (strtoupper($sort) != 'DESC') $sort = 'ASC';
186 186
 		if (strpos($order, ',') === false) $order .= ' '.$sort;
187
-		foreach($this->db->select($this->table,'DISTINCT hol_locale',$querymethod,__LINE__,__FILE__,false,'ORDER BY '.$order,'calendar') as $row)
187
+		foreach ($this->db->select($this->table, 'DISTINCT hol_locale', $querymethod, __LINE__, __FILE__, false, 'ORDER BY '.$order, 'calendar') as $row)
188 188
 		{
189 189
 			$locale[] = $row['hol_locale'];
190 190
 		}
191 191
 		return $locale;
192 192
 	}
193 193
 
194
-	function holiday_total($locale,$query='',$year=0)
194
+	function holiday_total($locale, $query = '', $year = 0)
195 195
 	{
196
-		$where = $this->_build_where($locale,$query,'',$year,False);
196
+		$where = $this->_build_where($locale, $query, '', $year, False);
197 197
 
198
-		if($this->debug)
198
+		if ($this->debug)
199 199
 		{
200 200
 			echo 'HOLIDAY_TOTAL : '.$where.'<br>'."\n";
201 201
 		}
202 202
 
203
-		$retval = $this->db->select($this->table,'count(*)',$where,__LINE__,__FILE__,false,'','calendar')->fetchColumn();
203
+		$retval = $this->db->select($this->table, 'count(*)', $where, __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
204 204
 
205
-		if($this->debug)
205
+		if ($this->debug)
206 206
 		{
207 207
 			echo 'Total Holidays for : '.$locale.' : '.$retval."<br>\n";
208 208
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -182,8 +182,14 @@
 block discarded – undo
182 182
 		{
183 183
 			$order = 'hol_locale';
184 184
 		}
185
-		if (strtoupper($sort) != 'DESC') $sort = 'ASC';
186
-		if (strpos($order, ',') === false) $order .= ' '.$sort;
185
+		if (strtoupper($sort) != 'DESC')
186
+		{
187
+			$sort = 'ASC';
188
+		}
189
+		if (strpos($order, ',') === false)
190
+		{
191
+			$order .= ' '.$sort;
192
+		}
187 193
 		foreach($this->db->select($this->table,'DISTINCT hol_locale',$querymethod,__LINE__,__FILE__,false,'ORDER BY '.$order,'calendar') as $row)
188 194
 		{
189 195
 			$locale[] = $row['hol_locale'];
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	{
83 83
 		foreach($rs as $row)
84 84
 		{
85
-			$holidays[] = Array(
85
+			$holidays[] = array(
86 86
 				'index'			=> $row['hol_id'],
87 87
 				'locale'		=> $row['hol_locale'],
88 88
 				'name'			=> $GLOBALS['egw']->strip_html($row['hol_name']),
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	function read_holidays($locales='',$query='',$order='',$year=0)
103 103
 	{
104
-		$holidays = Array();
104
+		$holidays = array();
105 105
 
106 106
 		if($locales == '')
107 107
 		{
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 	function read_holiday($id)
125 125
 	{
126
-		$holidays = Array();
126
+		$holidays = array();
127 127
 		if($this->debug)
128 128
 		{
129 129
 			echo 'Reading Holiday ID : '.$id.'<br>'."\n";
Please login to merge, or discard this patch.
emailadmin/inc/class.defaultimap.inc.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * opens a connection to a imap server
117 117
 	 *
118 118
 	 * @param bool $_adminConnection create admin connection if true
119
-	 * @param int $_timeout=null timeout in secs, if none given fmail pref or default of 20 is used
119
+	 * @param integer $_timeout timeout in secs, if none given fmail pref or default of 20 is used
120 120
 	 * @throws Exception on error
121 121
 	 */
122 122
 	function openConnection($_adminConnection=false, $_timeout=null);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param int|string $_euser nummeric account_id or imap username
145 145
 	 * @param array $_vacation
146
-	 * @param string $_scriptName=null
146
+	 * @param string $_scriptName
147 147
 	 * @return boolean
148 148
 	 */
149 149
 	public function setVacationUser($_euser, array $_vacation, $_scriptName=null);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * Get vacation message for given user
153 153
 	 *
154 154
 	 * @param int|string $_euser nummeric account_id or imap username
155
-	 * @param string $_scriptName=null
155
+	 * @param string $_scriptName
156 156
 	 * @throws Exception on connection error or authentication failure
157 157
 	 * @return array
158 158
 	 */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 namespace EGroupware\Api\Mail\Imap;
15 15
 
16 16
 define('IMAP_NAMESPACE_PERSONAL', 'personal');
17
-define('IMAP_NAMESPACE_OTHERS'	, 'others');
18
-define('IMAP_NAMESPACE_SHARED'	, 'shared');
19
-define('IMAP_NAMESPACE_ALL'	, 'all');
17
+define('IMAP_NAMESPACE_OTHERS', 'others');
18
+define('IMAP_NAMESPACE_SHARED', 'shared');
19
+define('IMAP_NAMESPACE_ALL', 'all');
20 20
 
21 21
 /**
22 22
  * This class holds all information about the imap connection.
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string $_folderName=''
88 88
 	 * @return string utf-7 encoded (done in getMailboxName)
89 89
 	 */
90
-	function getUserMailboxString($_username, $_folderName='');
90
+	function getUserMailboxString($_username, $_folderName = '');
91 91
 
92 92
 	/**
93 93
 	 * get list of namespaces
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @param string $_what - what to retrieve either QMAX, USED or ALL is supported
104 104
 	 * @return mixed the quota for specified user (by what) or array with all available Quota Information, or false
105 105
 	 */
106
-	function getQuotaByUser($_username, $_what='QMAX');
106
+	function getQuotaByUser($_username, $_what = 'QMAX');
107 107
 
108 108
 	/**
109 109
 	 * returns information about a user
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used
123 123
 	 * @throws Exception on error
124 124
 	 */
125
-	function openConnection($_adminConnection=false, $_timeout=null);
125
+	function openConnection($_adminConnection = false, $_timeout = null);
126 126
 
127 127
 	/**
128 128
 	 * set userdata
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param string $_scriptName =null
150 150
 	 * @return boolean
151 151
 	 */
152
-	public function setVacationUser($_euser, array $_vacation, $_scriptName=null);
152
+	public function setVacationUser($_euser, array $_vacation, $_scriptName = null);
153 153
 
154 154
 	/**
155 155
 	 * Get vacation message for given user
@@ -159,5 +159,5 @@  discard block
 block discarded – undo
159 159
 	 * @throws Exception on connection error or authentication failure
160 160
 	 * @return array
161 161
 	 */
162
-	public function getVacationUser($_euser, $_scriptName=null);
162
+	public function getVacationUser($_euser, $_scriptName = null);
163 163
 }
Please login to merge, or discard this patch.
emailadmin/inc/class.emailadmin_account.inc.php 3 patches
Doc Comments   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -517,11 +517,9 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * Standard identity is always first (as it has account_id=0 and we order account_id ASC).
519 519
 	 *
520
-	 * @param int|array|emailadmin_account $account=null default this account, empty array() to get all identities of current user
521
-	 * @param boolean $replace_placeholders=false should placeholders like {{n_fn}} be replaced
522
-	 * @param string $field='name' what to return as value: "ident_(realname|org|email|signature)" or default "name"=result from identity_name
523
-	 * @param int $user=null account_id to use if not current user
524
-	 * @return Iterator ident_id => identity_name of identity
520
+	 * @param int|array|emailadmin_account $account default this account, empty array() to get all identities of current user
521
+	 * @param boolean $replace_placeholders should placeholders like {{n_fn}} be replaced
522
+	 * @return Traversable ident_id => identity_name of identity
525 523
 	 */
526 524
 	public /*static*/ function identities($account=null, $replace_placeholders=true, $field='name', $user=null)
527 525
 	{
@@ -645,7 +643,7 @@  discard block
 block discarded – undo
645 643
 	/**
646 644
 	 * Return list of identities/signatures for given account ordered by give email on top and then by identity name
647 645
 	 *
648
-	 * @param int|array|emailadmin_account $account=null default this account, empty array() to get all identities of current user
646
+	 * @param int|array|emailadmin_account $account default this account, empty array() to get all identities of current user
649 647
 	 * @param string $order_email_top email address to order top
650 648
 	 * @return array ident_id => ident_name pairs
651 649
 	 */
@@ -674,8 +672,8 @@  discard block
 block discarded – undo
674 672
 	 *
675 673
 	 * For full list of placeholders see addressbook_merge.
676 674
 	 *
677
-	 * @param array|emailadmin_account $identity=null
678
-	 * @param int $account_id=null account_id of user, or current user
675
+	 * @param array|emailadmin_account $identity
676
+	 * @param int $account_id account_id of user, or current user
679 677
 	 * @return array with modified fields
680 678
 	 */
681 679
 	public /*static*/ function replace_placeholders($identity=null, $account_id=null)
@@ -772,7 +770,7 @@  discard block
 block discarded – undo
772 770
 	 *
773 771
 	 * Can be called static, if identity is given as parameter
774 772
 	 *
775
-	 * @param array|emailadmin_account $identity=null default standard identity of current account
773
+	 * @param array|emailadmin_account $identity default standard identity of current account
776 774
 	 * @return int ident_id of new/updated identity
777 775
 	 */
778 776
 	public /*static*/ function save_identity($identity=null)
@@ -833,7 +831,7 @@  discard block
 block discarded – undo
833 831
 	 *
834 832
 	 * To get $this->params you need to call getUserData before! It is never automatically loaded.
835 833
 	 *
836
-	 * @param type $name
834
+	 * @param string $name
837 835
 	 * @return mixed
838 836
 	 */
839 837
 	public function __get($name)
@@ -857,8 +855,8 @@  discard block
 block discarded – undo
857 855
 	/**
858 856
 	 * Give read access to protected parameters in $this->params
859 857
 	 *
860
-	 * @param type $name
861
-	 * @return mixed
858
+	 * @param string $name
859
+	 * @return boolean
862 860
 	 */
863 861
 	public function __isset($name)
864 862
 	{
@@ -931,7 +929,7 @@  discard block
 block discarded – undo
931 929
 	 * Check which rights current user has on mail-account
932 930
 	 *
933 931
 	 * @param int $rights EGW_ACL_(READ|EDIT|DELETE)
934
-	 * @param array|emailadmin_account $account=null default use this
932
+	 * @param array|emailadmin_account $account default use this
935 933
 	 * @return boolean
936 934
 	 */
937 935
 	public /*static*/ function check_access($rights, $account=null)
@@ -1289,10 +1287,10 @@  discard block
 block discarded – undo
1289 1287
 	 * @param boolean|string $just_name =true true: return self::identity_name, false: return emailadmin_account objects,
1290 1288
 	 *	string with attribute-name: return that attribute, eg. acc_imap_host or 'params' to return all attributes as array
1291 1289
 	 * @param string $order_by ='acc_name ASC'
1292
-	 * @param int|boolean $offset =false offset or false to return all
1290
+	 * @param boolean $offset =false offset or false to return all
1293 1291
 	 * @param int $num_rows =0 number of rows to return, 0=default from prefs (if $offset !== false)
1294 1292
 	 * @param boolean $replace_placeholders =true should placeholders like {{n_fn}} be replaced
1295
-	 * @return Iterator with acc_id => acc_name or emailadmin_account objects
1293
+	 * @return Traversable with acc_id => acc_name or emailadmin_account objects
1296 1294
 	 */
1297 1295
 	public static function search($only_current_user=true, $just_name=true, $order_by=null, $offset=false, $num_rows=0, $replace_placeholders=true)
1298 1296
 	{
Please login to merge, or discard this patch.
Spacing   +67 added lines, -70 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	/**
187 187
 	 * Path to log smtp comunication to or null to not log
188 188
 	 */
189
-	const SMTP_DEBUG_LOG = null;//'/tmp/smtp.log';
189
+	const SMTP_DEBUG_LOG = null; //'/tmp/smtp.log';
190 190
 
191 191
 	/**
192 192
 	 * Instanciated account object by acc_id, read acts as singelton
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @param int $called_for=null if set access to given user (without smtp credentials!),
235 235
 	 *	default current user AND read username/password from current users session
236 236
 	 */
237
-	/*protected*/ function __construct(array $params, $called_for=null)
237
+	/*protected*/ function __construct(array $params, $called_for = null)
238 238
 	{
239 239
 		// read credentials from database
240 240
 		$params += emailadmin_credentials::read($params['acc_id'], null, $called_for ? array(0, $called_for) : $called_for);
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 				$this->params = array_merge($this->params, $data);
284 284
 			}
285 285
 		}
286
-		catch(Horde_Imap_Client_Exception $e) {
286
+		catch (Horde_Imap_Client_Exception $e) {
287 287
 			unset($e);
288 288
 			// ignore eg. connection errors
289 289
 		}
290
-		catch(InvalidArgumentException $e) {
290
+		catch (InvalidArgumentException $e) {
291 291
 			unset($e);
292 292
 			// ignore eg. missing admin user
293 293
 		}
294
-		$this->params += array_fill_keys(self::$user_data, null);	// make sure all keys exist now
294
+		$this->params += array_fill_keys(self::$user_data, null); // make sure all keys exist now
295 295
 
296 296
 		return (array)$data + (array)$smtp_data;
297 297
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used
326 326
 	 * @return emailadmin_imap
327 327
 	 */
328
-	public function imapServer($_adminConnection=false, $_timeout=null)
328
+	public function imapServer($_adminConnection = false, $_timeout = null)
329 329
 	{
330 330
 		if (!isset($this->imapServer) || $this->imapServer->isAdminConnection !== $_adminConnection)
331 331
 		{
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 	 *	(matters only for imap servers managed by EGroupware!)
350 350
 	 * @return boolean
351 351
 	 */
352
-	public function is_imap($try_connect=true)
352
+	public function is_imap($try_connect = true)
353 353
 	{
354 354
 		if (empty($this->acc_imap_host) || empty($this->acc_imap_username) || empty($this->acc_imap_password))
355 355
 		{
356
-			return false;	// no imap host or credentials
356
+			return false; // no imap host or credentials
357 357
 		}
358 358
 		// if we are not managing the mail-server, we do NOT need to check deliveryMode and accountStatus
359 359
 		if ($this->acc_smtp_type == 'emailadmin_smtp')
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param boolean $old_ic_server =false true: return emailadmin_oldimap as icServer, false: use new emailadmin_imap
384 384
 	 * @return string
385 385
 	 */
386
-	public static function getIcClass($imap_type, $old_ic_server=false)
386
+	public static function getIcClass($imap_type, $old_ic_server = false)
387 387
 	{
388 388
 		static $old2new_icClass = array(
389 389
 			'defaultimap' => 'emailadmin_imap',
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		// fetch the IMAP / incomming server data
409 409
 		if (!class_exists($icClass))
410 410
 		{
411
-			if (file_exists($file=EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$icClass.'.inc.php'))
411
+			if (file_exists($file = EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$icClass.'.inc.php'))
412 412
 			{
413 413
 				include_once($file);
414 414
 			}
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
 	protected static function _smtp(array $params)
445 445
 	{
446 446
 		$class = $params['acc_smtp_type'];
447
-		if ($class=='defaultsmtp') $class='emailadmin_smtp';
447
+		if ($class == 'defaultsmtp') $class = 'emailadmin_smtp';
448 448
 		// not all smtp plugins are autoloadable eg. postifxldap (qmailUser)
449
-		if (!class_exists($class) && file_exists($file=EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$class.'.inc.php'))
449
+		if (!class_exists($class) && file_exists($file = EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$class.'.inc.php'))
450 450
 		{
451 451
 			require_once($file);
452 452
 		}
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		$smtp->editForwardingAddress = false;
455 455
 		$smtp->host = $params['acc_smtp_host'];
456 456
 		$smtp->port = $params['acc_smtp_port'];
457
-		switch($params['acc_smtp_ssl'])
457
+		switch ($params['acc_smtp_ssl'])
458 458
 		{
459 459
 			case self::SSL_TLS:			// requires modified PHPMailer, or comment next two lines to use just ssl!
460 460
 				$smtp->host = 'tlsv1://'.$smtp->host;
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
 		if (!isset($this->smtpTransport))
485 485
 		{
486 486
 			$secure = false;
487
-			switch($this->acc_smtp_ssl & ~self::SSL_VERIFY)
487
+			switch ($this->acc_smtp_ssl&~self::SSL_VERIFY)
488 488
 			{
489 489
 				case self::SSL_STARTTLS:
490
-					$secure = 'tls';	// Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3
490
+					$secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3
491 491
 					break;
492 492
 				case self::SSL_SSL:
493 493
 					$secure = 'ssl';
494 494
 					break;
495 495
 				case self::SSL_TLS:
496
-					$secure = 'tlsv1';	// since Horde_Smtp-1.3.0 requiring Horde_Socket_Client-1.1.0
496
+					$secure = 'tlsv1'; // since Horde_Smtp-1.3.0 requiring Horde_Socket_Client-1.1.0
497 497
 					break;
498 498
 			}
499 499
 			// Horde use locale for translation of error messages
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	 * @param int $user=null account_id to use if not current user
524 524
 	 * @return Iterator ident_id => identity_name of identity
525 525
 	 */
526
-	public /*static*/ function identities($account=null, $replace_placeholders=true, $field='name', $user=null)
526
+	public /*static*/ function identities($account = null, $replace_placeholders = true, $field = 'name', $user = null)
527 527
 	{
528 528
 		if (is_null($account)) $account = $this;
529 529
 		if (!isset($user)) $user = $GLOBALS['egw_info']['user']['account_id'];
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				}
575 575
 				return emailadmin_account::identity_name($row, $replace_placeholders);
576 576
 			}, array(),
577
-			function($row) { return $row['ident_id'];});
577
+			function($row) { return $row['ident_id']; });
578 578
 	}
579 579
 
580 580
 	/**
@@ -617,17 +617,17 @@  discard block
 block discarded – undo
617 617
 	 * @return array acc_id:ident_id:email => rfc822 address pairs, eg. '1:1:[email protected]' => 'Ralf Becker Stylite AG <[email protected]>'
618 618
 	 * @todo add aliases for manged mail servers
619 619
 	 */
620
-	public static function rfc822_addresses($formatter=null)
620
+	public static function rfc822_addresses($formatter = null)
621 621
 	{
622 622
 		if (!$formatter || !is_callable($formatter))
623 623
 		{
624 624
 			$formatter = __CLASS__.'::rfc822';
625 625
 		}
626 626
 		$addresses = array();
627
-		foreach(self::search(true, false) as $acc_id => $account)
627
+		foreach (self::search(true, false) as $acc_id => $account)
628 628
 		{
629
-			$added = false;	// make sure each account get's at least added once, even if it uses an identical email address
630
-			foreach($account->identities(null, true, 'params') as $identity)
629
+			$added = false; // make sure each account get's at least added once, even if it uses an identical email address
630
+			foreach ($account->identities(null, true, 'params') as $identity)
631 631
 			{
632 632
 				if (($address = call_user_func($formatter, $identity)) && (!$added || !in_array($address, $addresses)))
633 633
 				{
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			}
662 662
 			return $cmp;
663 663
 		});
664
-		foreach($identities as &$identity)
664
+		foreach ($identities as &$identity)
665 665
 		{
666 666
 			$identity = self::identity_name($identity);
667 667
 		}
@@ -678,9 +678,9 @@  discard block
 block discarded – undo
678 678
 	 * @param int $account_id=null account_id of user, or current user
679 679
 	 * @return array with modified fields
680 680
 	 */
681
-	public /*static*/ function replace_placeholders($identity=null, $account_id=null)
681
+	public /*static*/ function replace_placeholders($identity = null, $account_id = null)
682 682
 	{
683
-		static $fields = array('ident_name','ident_realname','ident_org','ident_email','ident_signature');
683
+		static $fields = array('ident_name', 'ident_realname', 'ident_org', 'ident_email', 'ident_signature');
684 684
 
685 685
 		if (!$identity && isset($this)) $identity = $this;
686 686
 		if (!is_array($identity) && !is_a($identity, 'emailadmin_account'))
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 			throw new egw_exception_wrong_parameter(__METHOD__."() requires an identity or account as first parameter!");
689 689
 		}
690 690
 		$to_replace = array();
691
-		foreach($fields as $name)
691
+		foreach ($fields as $name)
692 692
 		{
693 693
 			if (strpos($identity[$name], '{{') !== false || strpos($identity[$name], '$$') !== false)
694 694
 			{
@@ -697,10 +697,10 @@  discard block
 block discarded – undo
697 697
 		}
698 698
 		if ($to_replace)
699 699
 		{
700
-			static $merge=null;
700
+			static $merge = null;
701 701
 			if (!isset($merge)) $merge = new addressbook_merge();
702 702
 			if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
703
-			foreach($to_replace as $name => &$value)
703
+			foreach ($to_replace as $name => &$value)
704 704
 			{
705 705
 				$err = null;
706 706
 				$value = $merge->merge_string($value,
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * @return array
723 723
 	 * @throws egw_exception_not_found
724 724
 	 */
725
-	public static function read_identity($ident_id, $replace_placeholders=false, $user=null, $account=null)
725
+	public static function read_identity($ident_id, $replace_placeholders = false, $user = null, $account = null)
726 726
 	{
727 727
 		if (($account && $account['ident_id'] == $ident_id))
728 728
 		{
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	 * @param array|emailadmin_account $identity=null default standard identity of current account
776 776
 	 * @return int ident_id of new/updated identity
777 777
 	 */
778
-	public /*static*/ function save_identity($identity=null)
778
+	public /*static*/ function save_identity($identity = null)
779 779
 	{
780 780
 		if (!$identity && isset($this)) $identity = $this;
781 781
 		if (!is_array($identity) && !is_a($identity, 'emailadmin_account'))
@@ -793,8 +793,7 @@  discard block
 block discarded – undo
793 793
 			'ident_org' => $identity['ident_org'],
794 794
 			'ident_email' => $identity['ident_email'],
795 795
 			'ident_signature' => $identity['ident_signature'],
796
-			'account_id' => self::is_multiple($identity) ? 0 :
797
-				(is_array($identity['account_id']) ? $identity['account_id'][0] : $identity['account_id']),
796
+			'account_id' => self::is_multiple($identity) ? 0 : (is_array($identity['account_id']) ? $identity['account_id'][0] : $identity['account_id']),
798 797
 		);
799 798
 		if ($identity['ident_id'] > 0)
800 799
 		{
@@ -838,7 +837,7 @@  discard block
 block discarded – undo
838 837
 	 */
839 838
 	public function __get($name)
840 839
 	{
841
-		switch($name)
840
+		switch ($name)
842 841
 		{
843 842
 			case 'acc_imap_administration':	// no longer stored in database
844 843
 				return !empty($this->params['acc_imap_admin_username']);
@@ -862,7 +861,7 @@  discard block
 block discarded – undo
862 861
 	 */
863 862
 	public function __isset($name)
864 863
 	{
865
-		switch($name)
864
+		switch ($name)
866 865
 		{
867 866
 			case 'acc_imap_administration':	// no longer stored in database
868 867
 				return true;
@@ -934,7 +933,7 @@  discard block
 block discarded – undo
934 933
 	 * @param array|emailadmin_account $account=null default use this
935 934
 	 * @return boolean
936 935
 	 */
937
-	public /*static*/ function check_access($rights, $account=null)
936
+	public /*static*/ function check_access($rights, $account = null)
938 937
 	{
939 938
 		if (!isset($account)) $account = $this;
940 939
 
@@ -954,11 +953,11 @@  discard block
 block discarded – undo
954 953
 		{
955 954
 			// check if account is for current user, if not deny access
956 955
 			$memberships = self::memberships();
957
-			$memberships[] = '';	// edit uses '' for everyone
956
+			$memberships[] = ''; // edit uses '' for everyone
958 957
 
959 958
 			if (array_intersect((array)$account['account_id'], $memberships))
960 959
 			{
961
-				switch($rights)
960
+				switch ($rights)
962 961
 				{
963 962
 					case EGW_ACL_READ:
964 963
 						$access = true;
@@ -1003,7 +1002,7 @@  discard block
 block discarded – undo
1003 1002
 	 * @return email_account
1004 1003
 	 * @throws egw_exception_not_found if account was not found (or not valid for current user)
1005 1004
 	 */
1006
-	public static function read($acc_id, $called_for=null)
1005
+	public static function read($acc_id, $called_for = null)
1007 1006
 	{
1008 1007
 		//error_log(__METHOD__."($acc_id, ".array2string($called_for).")");
1009 1008
 		// some caching, but only for regular usage/users
@@ -1021,7 +1020,7 @@  discard block
 block discarded – undo
1021 1020
 				//error_log(__METHOD__."($acc_id) created instance from cached data");
1022 1021
 				return self::$instances[$acc_id] = new emailadmin_account(self::$cache[$acc_id]);
1023 1022
 			}
1024
-			$data =& self::$cache[$acc_id];
1023
+			$data = & self::$cache[$acc_id];
1025 1024
 		}
1026 1025
 		$where = array(self::TABLE.'.acc_id='.(int)$acc_id);
1027 1026
 		if (!isset($called_for) || $called_for !== '0')
@@ -1045,7 +1044,7 @@  discard block
 block discarded – undo
1045 1044
 		if (!$valid_account_id_sql)
1046 1045
 		{
1047 1046
 			$data['account_id'] = array();
1048
-			foreach(self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $acc_id),
1047
+			foreach (self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $acc_id),
1049 1048
 				__LINE__, __FILE__, false, '', self::APP) as $row)
1050 1049
 			{
1051 1050
 				$data['account_id'][] = $row['account_id'];
@@ -1057,7 +1056,7 @@  discard block
 block discarded – undo
1057 1056
 		if (!isset($called_for))
1058 1057
 		{
1059 1058
 			//error_log(__METHOD__."($acc_id) creating instance and caching data read from db");
1060
-			$ret =& self::$instances[$acc_id];
1059
+			$ret = & self::$instances[$acc_id];
1061 1060
 		}
1062 1061
 		return $ret = new emailadmin_account($data, $called_for);
1063 1062
 	}
@@ -1070,7 +1069,7 @@  discard block
 block discarded – undo
1070 1069
 	 */
1071 1070
 	protected static function db2data(array $data)
1072 1071
 	{
1073
-		foreach(array('acc_sieve_enabled','acc_further_identities','acc_user_editable','acc_smtp_auth_session','acc_user_forward') as $name)
1072
+		foreach (array('acc_sieve_enabled', 'acc_further_identities', 'acc_user_editable', 'acc_smtp_auth_session', 'acc_user_forward') as $name)
1074 1073
 		{
1075 1074
 			if (isset($data[$name]))
1076 1075
 			{
@@ -1093,7 +1092,7 @@  discard block
 block discarded – undo
1093 1092
 	 * @throws egw_exception_wrong_parameter if called static without data-array
1094 1093
 	 * @throws egw_exception_db
1095 1094
 	 */
1096
-	public static function write(array $data, $user=null)
1095
+	public static function write(array $data, $user = null)
1097 1096
 	{
1098 1097
 		//error_log(__METHOD__."(".array2string($data).")");
1099 1098
 		$data['acc_modifier'] = $GLOBALS['egw_info']['user']['account_id'];
@@ -1104,7 +1103,7 @@  discard block
 block discarded – undo
1104 1103
 		{
1105 1104
 			// set not set values which, are NOT NULL and therefore would give an SQL error
1106 1105
 			$td = self::$db->get_table_definitions('emailadmin', self::TABLE);
1107
-			foreach($td['fd'] as $col => $def)
1106
+			foreach ($td['fd'] as $col => $def)
1108 1107
 			{
1109 1108
 				if (!isset($data[$col]) && $def['nullable'] === false && !isset($def['default']))
1110 1109
 				{
@@ -1138,19 +1137,19 @@  discard block
 block discarded – undo
1138 1137
 		$old_account_ids = array();
1139 1138
 		if ($where)
1140 1139
 		{
1141
-			foreach(self::$db->select(self::VALID_TABLE, 'account_id', $where,
1140
+			foreach (self::$db->select(self::VALID_TABLE, 'account_id', $where,
1142 1141
 				__LINE__, __FILE__, false, '', self::APP) as $row)
1143 1142
 			{
1144 1143
 				$old_account_ids[] = $row['account_id'];
1145 1144
 			}
1146 1145
 			if (($ids_to_remove = array_diff($old_account_ids, (array)$data['account_id'])))
1147 1146
 			{
1148
-				self::$db->delete(self::VALID_TABLE, $where+array(
1147
+				self::$db->delete(self::VALID_TABLE, $where + array(
1149 1148
 					'account_id' => $ids_to_remove,
1150 1149
 				), __LINE__, __FILE__, self::APP);
1151 1150
 			}
1152 1151
 		}
1153
-		foreach((array)$data['account_id'] as $account_id)
1152
+		foreach ((array)$data['account_id'] as $account_id)
1154 1153
 		{
1155 1154
 			if (!in_array($account_id, $old_account_ids))
1156 1155
 			{
@@ -1187,8 +1186,7 @@  discard block
 block discarded – undo
1187 1186
 		}
1188 1187
 
1189 1188
 		// store notification folders
1190
-		emailadmin_notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 :
1191
-			($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']),
1189
+		emailadmin_notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 : ($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']),
1192 1190
 			(array)$data['notify_folders']);
1193 1191
 
1194 1192
 		// store domain of an account for all user like before as "mail_suffix" config
@@ -1214,7 +1212,7 @@  discard block
 block discarded – undo
1214 1212
 	 * @param int $account_id =null
1215 1213
 	 * @return boolean
1216 1214
 	 */
1217
-	protected static function credentials_valid_for($account, $account_id=null)
1215
+	protected static function credentials_valid_for($account, $account_id = null)
1218 1216
 	{
1219 1217
 		if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
1220 1218
 
@@ -1240,7 +1238,7 @@  discard block
 block discarded – undo
1240 1238
 	 * @param int $account_id =null user or group
1241 1239
 	 * @return int number of deleted mail accounts or null if only user-data was deleted and no full mail accounts
1242 1240
 	 */
1243
-	public static function delete($acc_id, $account_id=null)
1241
+	public static function delete($acc_id, $account_id = null)
1244 1242
 	{
1245 1243
 		if (is_array($acc_id) || $acc_id > 0)
1246 1244
 		{
@@ -1251,7 +1249,7 @@  discard block
 block discarded – undo
1251 1249
 			self::$db->delete(self::TABLE, array('acc_id' => $acc_id), __LINE__, __FILE__, self::APP);
1252 1250
 
1253 1251
 			// invalidate caches
1254
-			foreach((array)$acc_id as $acc_id)
1252
+			foreach ((array)$acc_id as $acc_id)
1255 1253
 			{
1256 1254
 				self::cache_invalidate($acc_id);
1257 1255
 			}
@@ -1270,7 +1268,7 @@  discard block
 block discarded – undo
1270 1268
 		self::$db->delete(self::IDENTITIES_TABLE, array('account_id' => $account_id), __LINE__, __FILE__, self::APP);
1271 1269
 		// find profiles not belonging to anyone else and delete them
1272 1270
 		$acc_ids = array();
1273
-		foreach(self::$db->select(self::TABLE, self::TABLE.'.acc_id', 'account_id IS NULL', __LINE__, __FILE__,
1271
+		foreach (self::$db->select(self::TABLE, self::TABLE.'.acc_id', 'account_id IS NULL', __LINE__, __FILE__,
1274 1272
 			false, 'GROUP BY '.self::TABLE.'.acc_id', self::APP, 0, 'LEFT '.self::VALID_JOIN) as $row)
1275 1273
 		{
1276 1274
 			$acc_ids[] = $row['acc_id'];
@@ -1294,7 +1292,7 @@  discard block
 block discarded – undo
1294 1292
 	 * @param boolean $replace_placeholders =true should placeholders like {{n_fn}} be replaced
1295 1293
 	 * @return Iterator with acc_id => acc_name or emailadmin_account objects
1296 1294
 	 */
1297
-	public static function search($only_current_user=true, $just_name=true, $order_by=null, $offset=false, $num_rows=0, $replace_placeholders=true)
1295
+	public static function search($only_current_user = true, $just_name = true, $order_by = null, $offset = false, $num_rows = 0, $replace_placeholders = true)
1298 1296
 	{
1299 1297
 		//error_log(__METHOD__."($only_current_user, $just_name, '$order_by', $offset, $num_rows)");
1300 1298
 		$where = array();
@@ -1340,19 +1338,19 @@  discard block
 block discarded – undo
1340 1338
 				$cols[] = self::ADMIN_COL;
1341 1339
 				$join .= ' '.self::ADMIN_JOIN;
1342 1340
 			}
1343
-			$rs = self::$db->select(self::TABLE, $cols,	$where, __LINE__, __FILE__,
1341
+			$rs = self::$db->select(self::TABLE, $cols, $where, __LINE__, __FILE__,
1344 1342
 				$offset, so_sql::fix_group_by_columns($group_by, $cols, self::TABLE, 'acc_id').' ORDER BY '.$order_by,
1345 1343
 				self::APP, $num_rows, $join);
1346 1344
 
1347 1345
 			$ids = array();
1348
-			foreach($rs as $row)
1346
+			foreach ($rs as $row)
1349 1347
 			{
1350 1348
 				$row = self::db2data($row);
1351 1349
 
1352 1350
 				if ($only_current_user === true)
1353 1351
 				{
1354 1352
 					//error_log(__METHOD__."(TRUE, $just_name) caching data for acc_id=$row[acc_id]");
1355
-					self::$search_cache[$cache_key][$row['acc_id']] =& self::$cache[$row['acc_id']];
1353
+					self::$search_cache[$cache_key][$row['acc_id']] = & self::$cache[$row['acc_id']];
1356 1354
 					self::$cache[$row['acc_id']] = $row;
1357 1355
 				}
1358 1356
 				else
@@ -1364,14 +1362,14 @@  discard block
 block discarded – undo
1364 1362
 			// fetch valid_id, if not yet fetched
1365 1363
 			if (!$valid_account_id_sql && $ids)
1366 1364
 			{
1367
-				foreach(self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $ids),
1365
+				foreach (self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $ids),
1368 1366
 					__LINE__, __FILE__, false, '', self::APP) as $row)
1369 1367
 				{
1370 1368
 					self::$cache[$row['acc_id']]['account_id'][] = $row['account_id'];
1371 1369
 				}
1372 1370
 			}
1373 1371
 		}
1374
-		if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key]=array();
1372
+		if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key] = array();
1375 1373
 		return new egw_db_callback_iterator(new ArrayIterator(self::$search_cache[$cache_key]),
1376 1374
 			// process each row
1377 1375
 			function($row) use ($just_name, $replace_placeholders, $account_id)
@@ -1405,11 +1403,11 @@  discard block
 block discarded – undo
1405 1403
 	 * @param boolean $log_no_default =true true: error_log if no default found, false be silent
1406 1404
 	 * @return emailadmin_account|null
1407 1405
 	 */
1408
-	static function get_default($smtp=false, $return_id=false, $log_no_default=true)
1406
+	static function get_default($smtp = false, $return_id = false, $log_no_default = true)
1409 1407
 	{
1410 1408
 		try
1411 1409
 		{
1412
-			foreach(emailadmin_account::search(true, 'params') as $acc_id => $params)
1410
+			foreach (emailadmin_account::search(true, 'params') as $acc_id => $params)
1413 1411
 			{
1414 1412
 				if ($smtp)
1415 1413
 				{
@@ -1456,7 +1454,7 @@  discard block
 block discarded – undo
1456 1454
 	 * @param boolean $smtp =false false: usable for IMAP, true: usable for SMTP
1457 1455
 	 * @return int
1458 1456
 	 */
1459
-	static function get_default_acc_id($smtp=false)
1457
+	static function get_default_acc_id($smtp = false)
1460 1458
 	{
1461 1459
 		return self::get_default($smtp, true);
1462 1460
 	}
@@ -1469,7 +1467,7 @@  discard block
 block discarded – undo
1469 1467
 	 * @param int $account_id =null account_id of user we are called for
1470 1468
 	 * @return string with htmlencoded angle brackets
1471 1469
 	 */
1472
-	public static function identity_name($account, $replace_placeholders=true, $account_id=null)
1470
+	public static function identity_name($account, $replace_placeholders = true, $account_id = null)
1473 1471
 	{
1474 1472
 		if ($replace_placeholders)
1475 1473
 		{
@@ -1496,7 +1494,7 @@  discard block
 block discarded – undo
1496 1494
 				{
1497 1495
 					if (!isset($account['acc_imap_username']))
1498 1496
 					{
1499
-						$account += emailadmin_credentials::read($account['acc_id'], null, ($account_id?array($account_id, 0):null));
1497
+						$account += emailadmin_credentials::read($account['acc_id'], null, ($account_id ? array($account_id, 0) : null));
1500 1498
 					}
1501 1499
 					if (empty($account['acc_imap_username']) && $account['acc_imap_logintype'] &&
1502 1500
 						(!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['account_id']))
@@ -1515,7 +1513,7 @@  discard block
 block discarded – undo
1515 1513
 					$account['ident_email'] = $account['acc_imap_username'];
1516 1514
 				}
1517 1515
 			}
1518
-			catch(Exception $e) {
1516
+			catch (Exception $e) {
1519 1517
 				_egw_log_exception($e);
1520 1518
 			}
1521 1519
 
@@ -1532,7 +1530,7 @@  discard block
 block discarded – undo
1532 1530
 		{
1533 1531
 			$name .= ' <'.$account['ident_email'].'>';
1534 1532
 		}
1535
-		elseif(strpos($account['acc_imap_username'], '@') !== false)
1533
+		elseif (strpos($account['acc_imap_username'], '@') !== false)
1536 1534
 		{
1537 1535
 			$name .= ' <'.$account['acc_imap_username'].'>';
1538 1536
 		}
@@ -1555,8 +1553,7 @@  discard block
 block discarded – undo
1555 1553
 	 */
1556 1554
 	public static function is_multiple($account)
1557 1555
 	{
1558
-		$is_multiple = !is_array($account['account_id']) ? $account['account_id'] <= 0 :
1559
-			(count($account['account_id']) > 1 || $account['account_id'][0] <= 0);
1556
+		$is_multiple = !is_array($account['account_id']) ? $account['account_id'] <= 0 : (count($account['account_id']) > 1 || $account['account_id'][0] <= 0);
1560 1557
 		//error_log(__METHOD__."(account_id=".array2string($account['account_id']).") returning ".array2string($is_multiple));
1561 1558
 		return $is_multiple;
1562 1559
 	}
@@ -1577,13 +1574,13 @@  discard block
 block discarded – undo
1577 1574
 	 * @param type $user
1578 1575
 	 * @return array
1579 1576
 	 */
1580
-	protected static function memberships($user=null)
1577
+	protected static function memberships($user = null)
1581 1578
 	{
1582 1579
 		if (!$user) $user = $GLOBALS['egw_info']['user']['account_id'];
1583 1580
 
1584 1581
 		$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1585 1582
 		$memberships[] = $user;
1586
-		$memberships[] = 0;	// marks accounts valid for everyone
1583
+		$memberships[] = 0; // marks accounts valid for everyone
1587 1584
 
1588 1585
 		return $memberships;
1589 1586
 	}
Please login to merge, or discard this patch.
Braces   +103 added lines, -26 removed lines patch added patch discarded remove patch
@@ -331,8 +331,14 @@  discard block
 block discarded – undo
331 331
 		{
332 332
 			// make sure mbstring.func_overload=0
333 333
 			static $func_overload = null;
334
-			if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
335
-			if ($func_overload) throw new egw_exception_assertion_failed('Fatal Error: EGroupware requires mbstring.func_overload=0 set in your php.ini!');
334
+			if (is_null($func_overload))
335
+			{
336
+				$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
337
+			}
338
+			if ($func_overload)
339
+			{
340
+				throw new egw_exception_assertion_failed('Fatal Error: EGroupware requires mbstring.func_overload=0 set in your php.ini!');
341
+			}
336 342
 
337 343
 			$class = self::getIcClass($this->params['acc_imap_type']);
338 344
 			$this->imapServer = new $class($this->params, $_adminConnection, $_timeout);
@@ -444,7 +450,10 @@  discard block
 block discarded – undo
444 450
 	protected static function _smtp(array $params)
445 451
 	{
446 452
 		$class = $params['acc_smtp_type'];
447
-		if ($class=='defaultsmtp') $class='emailadmin_smtp';
453
+		if ($class=='defaultsmtp')
454
+		{
455
+			$class='emailadmin_smtp';
456
+		}
448 457
 		// not all smtp plugins are autoloadable eg. postifxldap (qmailUser)
449 458
 		if (!class_exists($class) && file_exists($file=EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$class.'.inc.php'))
450 459
 		{
@@ -525,8 +534,14 @@  discard block
 block discarded – undo
525 534
 	 */
526 535
 	public /*static*/ function identities($account=null, $replace_placeholders=true, $field='name', $user=null)
527 536
 	{
528
-		if (is_null($account)) $account = $this;
529
-		if (!isset($user)) $user = $GLOBALS['egw_info']['user']['account_id'];
537
+		if (is_null($account))
538
+		{
539
+			$account = $this;
540
+		}
541
+		if (!isset($user))
542
+		{
543
+			$user = $GLOBALS['egw_info']['user']['account_id'];
544
+		}
530 545
 		$acc_id = is_scalar($account) ? $account : $account['acc_id'];
531 546
 
532 547
 		$cols = array('ident_id', 'ident_name', 'ident_realname', 'ident_org', 'ident_email', 'ident_signature', 'acc_id', 'acc_imap_username', 'acc_imap_logintype', 'acc_domain');
@@ -564,8 +579,14 @@  discard block
 block discarded – undo
564 579
 				// fill an empty ident_realname or ident_email of current user with data from user account
565 580
 				if ($replace_placeholders && (!isset($user) || $user == $GLOBALS['egw_info']['user']['acount_id']))
566 581
 				{
567
-					if (empty($row['ident_realname'])) $row['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
568
-					if (empty($row['ident_email'])) $row['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
582
+					if (empty($row['ident_realname']))
583
+					{
584
+						$row['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
585
+					}
586
+					if (empty($row['ident_email']))
587
+					{
588
+						$row['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
589
+					}
569 590
 				}
570 591
 				if ($field != 'name')
571 592
 				{
@@ -574,7 +595,9 @@  discard block
 block discarded – undo
574 595
 				}
575 596
 				return emailadmin_account::identity_name($row, $replace_placeholders);
576 597
 			}, array(),
577
-			function($row) { return $row['ident_id'];});
598
+			function($row)
599
+			{
600
+return $row['ident_id'];});
578 601
 	}
579 602
 
580 603
 	/**
@@ -590,10 +613,13 @@  discard block
 block discarded – undo
590 613
 		{
591 614
 			$address .= ($address && $identity['ident_org'] ? ' ' : '').$identity['ident_org'];
592 615
 		}
593
-		if (strpos($address, ',') !== false)	// need to quote comma
616
+		if (strpos($address, ',') !== false)
617
+		{
618
+			// need to quote comma
594 619
 		{
595 620
 			$address = '"'.str_replace('"', '\\"', $address).'"';
596 621
 		}
622
+		}
597 623
 		if (!strpos($identity['ident_email'], '@'))
598 624
 		{
599 625
 			$address = null;
@@ -682,7 +708,10 @@  discard block
 block discarded – undo
682 708
 	{
683 709
 		static $fields = array('ident_name','ident_realname','ident_org','ident_email','ident_signature');
684 710
 
685
-		if (!$identity && isset($this)) $identity = $this;
711
+		if (!$identity && isset($this))
712
+		{
713
+			$identity = $this;
714
+		}
686 715
 		if (!is_array($identity) && !is_a($identity, 'emailadmin_account'))
687 716
 		{
688 717
 			throw new egw_exception_wrong_parameter(__METHOD__."() requires an identity or account as first parameter!");
@@ -698,8 +727,14 @@  discard block
 block discarded – undo
698 727
 		if ($to_replace)
699 728
 		{
700 729
 			static $merge=null;
701
-			if (!isset($merge)) $merge = new addressbook_merge();
702
-			if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
730
+			if (!isset($merge))
731
+			{
732
+				$merge = new addressbook_merge();
733
+			}
734
+			if (!isset($account_id))
735
+			{
736
+				$account_id = $GLOBALS['egw_info']['user']['account_id'];
737
+			}
703 738
 			foreach($to_replace as $name => &$value)
704 739
 			{
705 740
 				$err = null;
@@ -777,7 +812,10 @@  discard block
 block discarded – undo
777 812
 	 */
778 813
 	public /*static*/ function save_identity($identity=null)
779 814
 	{
780
-		if (!$identity && isset($this)) $identity = $this;
815
+		if (!$identity && isset($this))
816
+		{
817
+			$identity = $this;
818
+		}
781 819
 		if (!is_array($identity) && !is_a($identity, 'emailadmin_account'))
782 820
 		{
783 821
 			throw new egw_exception_wrong_parameter(__METHOD__."() requires an identity or account as first parameter!");
@@ -936,7 +974,10 @@  discard block
 block discarded – undo
936 974
 	 */
937 975
 	public /*static*/ function check_access($rights, $account=null)
938 976
 	{
939
-		if (!isset($account)) $account = $this;
977
+		if (!isset($account))
978
+		{
979
+			$account = $this;
980
+		}
940 981
 
941 982
 		if (!is_array($account) && !is_a($account, 'emailadmin_account'))
942 983
 		{
@@ -1216,7 +1257,10 @@  discard block
 block discarded – undo
1216 1257
 	 */
1217 1258
 	protected static function credentials_valid_for($account, $account_id=null)
1218 1259
 	{
1219
-		if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id'];
1260
+		if (!isset($account_id))
1261
+		{
1262
+			$account_id = $GLOBALS['egw_info']['user']['account_id'];
1263
+		}
1220 1264
 
1221 1265
 		// if account valid for multiple users
1222 1266
 		if (self::is_multiple($account))
@@ -1335,9 +1379,12 @@  discard block
 block discarded – undo
1335 1379
 				$cols[] = $valid_account_id_sql.' AS account_id';
1336 1380
 				$join .= ' '.self::ALL_VALID_JOIN;
1337 1381
 			}
1338
-			if ($just_name == 'params')	// join in acc_imap_admin_username
1382
+			if ($just_name == 'params')
1383
+			{
1384
+				// join in acc_imap_admin_username
1339 1385
 			{
1340 1386
 				$cols[] = self::ADMIN_COL;
1387
+			}
1341 1388
 				$join .= ' '.self::ADMIN_JOIN;
1342 1389
 			}
1343 1390
 			$rs = self::$db->select(self::TABLE, $cols,	$where, __LINE__, __FILE__,
@@ -1371,7 +1418,10 @@  discard block
 block discarded – undo
1371 1418
 				}
1372 1419
 			}
1373 1420
 		}
1374
-		if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key]=array();
1421
+		if (is_null(self::$search_cache[$cache_key]))
1422
+		{
1423
+			self::$search_cache[$cache_key]=array();
1424
+		}
1375 1425
 		return new egw_db_callback_iterator(new ArrayIterator(self::$search_cache[$cache_key]),
1376 1426
 			// process each row
1377 1427
 			function($row) use ($just_name, $replace_placeholders, $account_id)
@@ -1413,12 +1463,18 @@  discard block
 block discarded – undo
1413 1463
 			{
1414 1464
 				if ($smtp)
1415 1465
 				{
1416
-					if (!$params['acc_smtp_host'] || !$params['acc_smtp_port']) continue;
1466
+					if (!$params['acc_smtp_host'] || !$params['acc_smtp_port'])
1467
+					{
1468
+						continue;
1469
+					}
1417 1470
 					// check requirement of session, which is not available in async service!
1418 1471
 					if (isset($GLOBALS['egw_info']['flags']['async-service']) ||
1419
-						empty($GLOBALS['egw_info']['user']['account_id']))	// happens during login when notifying about blocked accounts
1472
+						empty($GLOBALS['egw_info']['user']['account_id']))
1473
+					{
1474
+						// happens during login when notifying about blocked accounts
1420 1475
 					{
1421 1476
 						if ($params['acc_smtp_auth_session']) continue;
1477
+					}
1422 1478
 						// may fail because of smtp only profile, or no session password, etc
1423 1479
 						try
1424 1480
 						{
@@ -1429,15 +1485,24 @@  discard block
 block discarded – undo
1429 1485
 							unset($x);
1430 1486
 							continue;
1431 1487
 						}
1432
-						if ($account->acc_smtp_pw_enc == emailadmin_credentials::USER) continue;
1488
+						if ($account->acc_smtp_pw_enc == emailadmin_credentials::USER)
1489
+						{
1490
+							continue;
1491
+						}
1433 1492
 					}
1434 1493
 				}
1435 1494
 				else
1436 1495
 				{
1437
-					if (!$params['acc_imap_host'] || !$params['acc_imap_port']) continue;
1496
+					if (!$params['acc_imap_host'] || !$params['acc_imap_port'])
1497
+					{
1498
+						continue;
1499
+					}
1438 1500
 					$account = new emailadmin_account($params);
1439 1501
 					// continue if we have either no imap username or password
1440
-					if (!$account->is_imap()) continue;
1502
+					if (!$account->is_imap())
1503
+					{
1504
+						continue;
1505
+					}
1441 1506
 				}
1442 1507
 				return $return_id ? $acc_id : (isset($account) && $account->acc_id == $acc_id ?
1443 1508
 					$account : new emailadmin_account($params));
@@ -1445,7 +1510,10 @@  discard block
 block discarded – undo
1445 1510
 		}
1446 1511
 		catch (Exception $e)
1447 1512
 		{
1448
-			if ($log_no_default) error_log(__METHOD__.__LINE__.' Error no Default available.'.$e->getMessage());
1513
+			if ($log_no_default)
1514
+			{
1515
+				error_log(__METHOD__.__LINE__.' Error no Default available.'.$e->getMessage());
1516
+			}
1449 1517
 		}
1450 1518
 		return null;
1451 1519
 	}
@@ -1507,8 +1575,14 @@  discard block
 block discarded – undo
1507 1575
 				// fill an empty ident_realname or ident_email of current user with data from user account
1508 1576
 				if ($replace_placeholders && (!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['acount_id']))
1509 1577
 				{
1510
-					if (empty($account['ident_realname'])) $account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
1511
-					if (empty($account['ident_email'])) $account['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
1578
+					if (empty($account['ident_realname']))
1579
+					{
1580
+						$account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
1581
+					}
1582
+					if (empty($account['ident_email']))
1583
+					{
1584
+						$account['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];
1585
+					}
1512 1586
 				}
1513 1587
 				if (empty($account['ident_email']) && !empty($account['acc_imap_username']) && strpos($account['acc_imap_username'], '@') !== false)
1514 1588
 				{
@@ -1579,7 +1653,10 @@  discard block
 block discarded – undo
1579 1653
 	 */
1580 1654
 	protected static function memberships($user=null)
1581 1655
 	{
1582
-		if (!$user) $user = $GLOBALS['egw_info']['user']['account_id'];
1656
+		if (!$user)
1657
+		{
1658
+			$user = $GLOBALS['egw_info']['user']['account_id'];
1659
+		}
1583 1660
 
1584 1661
 		$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1585 1662
 		$memberships[] = $user;
Please login to merge, or discard this patch.
emailadmin/inc/class.emailadmin_base.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	 *
47 47
 	 * Calls hook "imap_server_types" to allow applications to supply own server-types
48 48
 	 *
49
-	 * @param boolean $extended=true
49
+	 * @param boolean $extended
50 50
 	 * @return array classname => label pairs
51 51
 	 */
52 52
 	static public function getIMAPServerTypes($extended=true)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array classname => label pairs
22 22
 	 */
23
-	static public function getSMTPServerTypes($extended=true)
23
+	static public function getSMTPServerTypes($extended = true)
24 24
 	{
25 25
 		$retData = array();
26
-		foreach($GLOBALS['egw']->hooks->process(array(
26
+		foreach ($GLOBALS['egw']->hooks->process(array(
27 27
 			'location' => 'smtp_server_types',
28 28
 			'extended' => $extended,
29 29
 		), array('managementserver', 'emailadmin'), true) as $data)
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 	 * @param boolean $extended=true
50 50
 	 * @return array classname => label pairs
51 51
 	 */
52
-	static public function getIMAPServerTypes($extended=true)
52
+	static public function getIMAPServerTypes($extended = true)
53 53
 	{
54 54
 		$retData = array();
55
-		foreach($GLOBALS['egw']->hooks->process(array(
55
+		foreach ($GLOBALS['egw']->hooks->process(array(
56 56
 			'location' => 'imap_server_types',
57 57
 			'extended' => $extended,
58 58
 		), array('managementserver', 'emailadmin'), true) as $data)
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,13 @@  discard block
 block discarded – undo
28 28
 			'extended' => $extended,
29 29
 		), array('managementserver', 'emailadmin'), true) as $data)
30 30
 		{
31
-			if ($data) $retData += $data;
31
+			if ($data)
32
+			{
33
+				$retData += $data;
34
+			}
32 35
 		}
33
-		uksort($retData, function($a, $b) {
36
+		uksort($retData, function($a, $b)
37
+		{
34 38
 			static $prio = array(	// not explicitly mentioned get 0
35 39
 				'emailadmin_smtp' => 9,
36 40
 				'emailadmin_smtp_sql' => 8,
@@ -57,9 +61,13 @@  discard block
 block discarded – undo
57 61
 			'extended' => $extended,
58 62
 		), array('managementserver', 'emailadmin'), true) as $data)
59 63
 		{
60
-			if ($data) $retData += $data;
64
+			if ($data)
65
+			{
66
+				$retData += $data;
67
+			}
61 68
 		}
62
-		uksort($retData, function($a, $b) {
69
+		uksort($retData, function($a, $b)
70
+		{
63 71
 			static $prio = array(	// not explicitly mentioned get 0
64 72
 				'emailadmin_imap' => 9,
65 73
 				'emailadmin_oldimap' => 9,
Please login to merge, or discard this patch.
emailadmin/inc/class.emailadmin_credentials.inc.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -322,6 +322,7 @@
 block discarded – undo
322 322
 	 * @param int $account_id user-account password is for
323 323
 	 * @param int &$pw_enc on return encryption used
324 324
 	 * @param ressource $mcrypt =null mcrypt ressource for user, default calling self::init_crypt(true)
325
+	 * @param integer $pw_enc
325 326
 	 * @return string encrypted password
326 327
 	 */
327 328
 	protected static function encrypt($password, $account_id, &$pw_enc, $mcrypt=null)
Please login to merge, or discard this patch.
Spacing   +28 added lines, -31 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param int|array $account_id =null default use current user or all (in that order)
107 107
 	 * @return array with values for (imap|smtp|admin)_(username|password|cred_id)
108 108
 	 */
109
-	public static function read($acc_id, $type=null, $account_id=null)
109
+	public static function read($acc_id, $type = null, $account_id = null)
110 110
 	{
111 111
 		if (is_null($type)) $type = self::ALL;
112 112
 		if (is_null($account_id))
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			$rows = self::$db->select(self::TABLE, '*', array(
123 123
 				'acc_id' => $acc_id,
124 124
 				'account_id' => $account_id,
125
-				'(cred_type & '.(int)$type.') > 0',	// postgreSQL require > 0, or gives error as it expects boolean
125
+				'(cred_type & '.(int)$type.') > 0', // postgreSQL require > 0, or gives error as it expects boolean
126 126
 			), __LINE__, __FILE__, false,
127 127
 				// account_id DESC ensures 0=all allways overwrite (old user-specific credentials)
128 128
 				'ORDER BY account_id ASC', self::APP);
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 		else
132 132
 		{
133
-			ksort($rows);	// ORDER BY account_id ASC
133
+			ksort($rows); // ORDER BY account_id ASC
134 134
 
135 135
 			// flatten account_id => cred_type => row array again, to have format like from database
136 136
 			$rows = call_user_func_array('array_merge', $rows);
137 137
 			//error_log(__METHOD__."($acc_id, $type, ".array2string($account_id).") read from cache ".array2string($rows));
138 138
 		}
139 139
 		$results = array();
140
-		foreach($rows as $row)
140
+		foreach ($rows as $row)
141 141
 		{
142 142
 			// update cache (only if we have database-iterator and all credentials asked!)
143 143
 			if (!is_array($rows) && $type == self::ALL)
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			$password = self::decrypt($row);
149 149
 
150
-			foreach(self::$type2prefix as $pattern => $prefix)
150
+			foreach (self::$type2prefix as $pattern => $prefix)
151 151
 			{
152
-				if ($row['cred_type'] & $pattern)
152
+				if ($row['cred_type']&$pattern)
153 153
 				{
154 154
 					$results[$prefix.'username'] = $row['cred_username'];
155 155
 					$results[$prefix.'password'] = $password;
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 * @param boolean $set_identity =true true: also set identity values realname&email, if not yet set
170 170
 	 * @return array with values for keys 'acc_(imap|smtp)_(username|password|cred_id)'
171 171
 	 */
172
-	public static function from_session(array $data, $set_identity=true)
172
+	public static function from_session(array $data, $set_identity = true)
173 173
 	{
174
-		switch($data['acc_imap_logintype'])
174
+		switch ($data['acc_imap_logintype'])
175 175
 		{
176 176
 			case 'standard':
177 177
 				$username = $GLOBALS['egw_info']['user']['account_lid'];
@@ -197,23 +197,21 @@  discard block
 block discarded – undo
197 197
 				throw new egw_exception_wrong_parameter("Unknown data[acc_imap_logintype]=".array2string($data['acc_imap_logintype']).'!');
198 198
 		}
199 199
 		$password = base64_decode(egw_cache::getSession('phpgwapi', 'password'));
200
-		$realname = !$set_identity || $data['ident_realname'] ? $data['ident_realname'] :
201
-			$GLOBALS['egw_info']['user']['account_fullname'];
202
-		$email = !$set_identity || $data['ident_email'] ? $data['ident_email'] :
203
-			$GLOBALS['egw_info']['user']['account_email'];
200
+		$realname = !$set_identity || $data['ident_realname'] ? $data['ident_realname'] : $GLOBALS['egw_info']['user']['account_fullname'];
201
+		$email = !$set_identity || $data['ident_email'] ? $data['ident_email'] : $GLOBALS['egw_info']['user']['account_email'];
204 202
 
205 203
 		return array(
206 204
 			'ident_realname' => $realname,
207 205
 			'ident_email' => $email,
208 206
 			'acc_imap_username' => $username,
209 207
 			'acc_imap_password' => $password,
210
-			'acc_imap_cred_id'  => $data['acc_imap_logintype'],	// to NOT store it
208
+			'acc_imap_cred_id'  => $data['acc_imap_logintype'], // to NOT store it
211 209
 			'acc_imap_account_id' => 'c',
212 210
 		) + ($data['acc_smtp_auth_session'] ? array(
213 211
 			// only set smtp
214 212
 			'acc_smtp_username' => $username,
215 213
 			'acc_smtp_password' => $password,
216
-			'acc_smtp_cred_id'  => $data['acc_imap_logintype'],	// to NOT store it
214
+			'acc_smtp_cred_id'  => $data['acc_imap_logintype'], // to NOT store it
217 215
 			'acc_smtp_account_id' => 'c',
218 216
 		) : array());
219 217
 	}
@@ -230,27 +228,26 @@  discard block
 block discarded – undo
230 228
 	 * @param ressource $mcrypt =null mcrypt ressource for user, default calling self::init_crypt(true)
231 229
 	 * @return int cred_id
232 230
 	 */
233
-	public static function write($acc_id, $username, $password, $type, $account_id=0, $cred_id=null, $mcrypt=null)
231
+	public static function write($acc_id, $username, $password, $type, $account_id = 0, $cred_id = null, $mcrypt = null)
234 232
 	{
235 233
 		//error_log(__METHOD__."(acc_id=$acc_id, '$username', \$password, type=$type, account_id=$account_id, cred_id=$cred_id)");
236 234
 		if (!empty($cred_id) && !is_numeric($cred_id) || !is_numeric($account_id))
237 235
 		{
238 236
 			//error_log(__METHOD__."($acc_id, '$username', \$password, $type, $account_id, ".array2string($cred_id).") not storing session credentials!");
239
-			return;	// do NOT store credentials from session of current user!
237
+			return; // do NOT store credentials from session of current user!
240 238
 		}
241 239
 		// no need to write empty usernames, but delete existing row
242 240
 		if ((string)$username === '')
243 241
 		{
244 242
 			if ($cred_id) self::$db->delete(self::TABLE, array('cred_id' => $cred_id), __LINE__, __FILE__, self::APP);
245
-			return;	// nothing to save
243
+			return; // nothing to save
246 244
 		}
247 245
 		$pw_enc = self::CLEARTEXT;
248 246
 		$data = array(
249 247
 			'acc_id' => $acc_id,
250 248
 			'account_id' => $account_id,
251 249
 			'cred_username' => $username,
252
-			'cred_password' => (string)$password === '' ? '' :
253
-				self::encrypt($password, $account_id, $pw_enc, $mcrypt),
250
+			'cred_password' => (string)$password === '' ? '' : self::encrypt($password, $account_id, $pw_enc, $mcrypt),
254 251
 			'cred_type' => $type,
255 252
 			'cred_pw_enc' => $pw_enc,
256 253
 		);
@@ -290,7 +287,7 @@  discard block
 block discarded – undo
290 287
 	 * @param boolean $exact_type =false true: delete only cred_type=$type, false: delete cred_type&$type
291 288
 	 * @return int number of rows deleted
292 289
 	 */
293
-	public static function delete($acc_id, $account_id=null, $type=self::ALL, $exact_type=false)
290
+	public static function delete($acc_id, $account_id = null, $type = self::ALL, $exact_type = false)
294 291
 	{
295 292
 		if (!($acc_id > 0) && !isset($account_id))
296 293
 		{
@@ -305,12 +302,12 @@  discard block
 block discarded – undo
305 302
 		}
306 303
 		elseif ($type != self::ALL)
307 304
 		{
308
-			$where[] = '(cred_type & '.(int)$type.') > 0';	// postgreSQL require > 0, or gives error as it expects boolean
305
+			$where[] = '(cred_type & '.(int)$type.') > 0'; // postgreSQL require > 0, or gives error as it expects boolean
309 306
 		}
310 307
 		self::$db->delete(self::TABLE, $where, __LINE__, __FILE__, self::APP);
311 308
 
312 309
 		// invalidate cache: we allways unset everything about an account to simplify cache handling
313
-		foreach($acc_id > 0 ? (array)$acc_id : array_keys(self::$cache) as $acc_id)
310
+		foreach ($acc_id > 0 ? (array)$acc_id : array_keys(self::$cache) as $acc_id)
314 311
 		{
315 312
 			unset(self::$cache[$acc_id]);
316 313
 		}
@@ -328,7 +325,7 @@  discard block
 block discarded – undo
328 325
 	 * @param ressource $mcrypt =null mcrypt ressource for user, default calling self::init_crypt(true)
329 326
 	 * @return string encrypted password
330 327
 	 */
331
-	protected static function encrypt($password, $account_id, &$pw_enc, $mcrypt=null)
328
+	protected static function encrypt($password, $account_id, &$pw_enc, $mcrypt = null)
332 329
 	{
333 330
 		if ($account_id > 0 && $account_id == $GLOBALS['egw_info']['user']['account_id'] &&
334 331
 			($mcrypt || ($mcrypt = self::init_crypt(true))))
@@ -355,7 +352,7 @@  discard block
 block discarded – undo
355 352
 	 * @param array $row database row
356 353
 	 * @param ressource $mcrypt =null mcrypt ressource for user, default calling self::init_crypt(true)
357 354
 	 */
358
-	protected static function decrypt(array $row, $mcrypt=null)
355
+	protected static function decrypt(array $row, $mcrypt = null)
359 356
 	{
360 357
 		switch ($row['cred_pw_enc'])
361 358
 		{
@@ -394,9 +391,9 @@  discard block
 block discarded – undo
394 391
 		if (empty($data['old_passwd'])) return;
395 392
 
396 393
 		$old_mcrypt = null;
397
-		foreach(self::$db->select(self::TABLE, self::TABLE.'.*', array(
394
+		foreach (self::$db->select(self::TABLE, self::TABLE.'.*', array(
398 395
 			'account_id' => $data['account_id']
399
-		),__LINE__, __FILE__, false, '', 'emailadmin', 0, self::USER_EDITABLE_JOIN.self::$db->quote(true, 'bool')) as $row)
396
+		), __LINE__, __FILE__, false, '', 'emailadmin', 0, self::USER_EDITABLE_JOIN.self::$db->quote(true, 'bool')) as $row)
400 397
 		{
401 398
 			if (!isset($old_mcrypt))
402 399
 			{
@@ -420,7 +417,7 @@  discard block
 block discarded – undo
420 417
 	 * @param string $mode ='ecb'
421 418
 	 * @return ressource|boolean mcrypt ressource to use or false if not available
422 419
 	 */
423
-	static public function init_crypt($user=false, $algo='tripledes',$mode='ecb')
420
+	static public function init_crypt($user = false, $algo = 'tripledes', $mode = 'ecb')
424 421
 	{
425 422
 		if (is_string($user))
426 423
 		{
@@ -428,11 +425,11 @@  discard block
 block discarded – undo
428 425
 		}
429 426
 		elseif ($user)
430 427
 		{
431
-			$mcrypt =& self::$user_mcrypt;
428
+			$mcrypt = & self::$user_mcrypt;
432 429
 		}
433 430
 		else
434 431
 		{
435
-			$mcrypt =& self::$system_mcrypt;
432
+			$mcrypt = & self::$system_mcrypt;
436 433
 		}
437 434
 		if (!isset($mcrypt))
438 435
 		{
@@ -468,10 +465,10 @@  discard block
 block discarded – undo
468 465
 			{
469 466
 				$iv_size = mcrypt_enc_get_iv_size($mcrypt);
470 467
 				$iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ?
471
-					mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);
468
+					mcrypt_create_iv($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'], 0, $iv_size);
472 469
 
473 470
 				$key_size = mcrypt_enc_get_key_size($mcrypt);
474
-				if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1);
471
+				if (bytes($key) > $key_size) $key = cut_bytes($key, 0, $key_size - 1);
475 472
 
476 473
 				if (mcrypt_generic_init($mcrypt, $key, $iv) < 0)
477 474
 				{
Please login to merge, or discard this patch.
Braces   +28 added lines, -7 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public static function read($acc_id, $type=null, $account_id=null)
124 124
 	{
125
-		if (is_null($type)) $type = self::ALL;
125
+		if (is_null($type))
126
+		{
127
+			$type = self::ALL;
128
+		}
126 129
 		if (is_null($account_id))
127 130
 		{
128 131
 			$account_id = array(0, $GLOBALS['egw_info']['user']['account_id']);
@@ -255,7 +258,10 @@  discard block
 block discarded – undo
255 258
 		// no need to write empty usernames, but delete existing row
256 259
 		if ((string)$username === '')
257 260
 		{
258
-			if ($cred_id) self::$db->delete(self::TABLE, array('cred_id' => $cred_id), __LINE__, __FILE__, self::APP);
261
+			if ($cred_id)
262
+			{
263
+				self::$db->delete(self::TABLE, array('cred_id' => $cred_id), __LINE__, __FILE__, self::APP);
264
+			}
259 265
 			return;	// nothing to save
260 266
 		}
261 267
 		$pw_enc = self::CLEARTEXT;
@@ -311,8 +317,14 @@  discard block
 block discarded – undo
311 317
 			throw new Api\Exception\WrongParameter(__METHOD__."() no acc_id AND no account_id parameter!");
312 318
 		}
313 319
 		$where = array();
314
-		if ($acc_id > 0) $where['acc_id'] = $acc_id;
315
-		if (isset($account_id)) $where['account_id'] = $account_id;
320
+		if ($acc_id > 0)
321
+		{
322
+			$where['acc_id'] = $acc_id;
323
+		}
324
+		if (isset($account_id))
325
+		{
326
+			$where['account_id'] = $account_id;
327
+		}
316 328
 		if ($exact_type)
317 329
 		{
318 330
 			$where['cred_type'] = $type;
@@ -405,7 +417,10 @@  discard block
 block discarded – undo
405 417
 	 */
406 418
 	static public function changepassword(array $data)
407 419
 	{
408
-		if (empty($data['old_passwd'])) return;
420
+		if (empty($data['old_passwd']))
421
+		{
422
+			return;
423
+		}
409 424
 
410 425
 		$old_mcrypt = null;
411 426
 		foreach(self::$db->select(self::TABLE, self::TABLE.'.*', array(
@@ -416,7 +431,10 @@  discard block
 block discarded – undo
416 431
 			{
417 432
 				$old_mcrypt = self::init_crypt($data['old_passwd']);
418 433
 				$new_mcrypt = self::init_crypt($data['new_passwd']);
419
-				if (!$old_mcrypt && !$new_mcrypt) return;
434
+				if (!$old_mcrypt && !$new_mcrypt)
435
+				{
436
+					return;
437
+				}
420 438
 			}
421 439
 			$password = self::decrypt($row, $old_mcrypt);
422 440
 
@@ -485,7 +503,10 @@  discard block
 block discarded – undo
485 503
 					mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size);
486 504
 
487 505
 				$key_size = mcrypt_enc_get_key_size($mcrypt);
488
-				if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1);
506
+				if (bytes($key) > $key_size)
507
+				{
508
+					$key = cut_bytes($key,0,$key_size-1);
509
+				}
489 510
 
490 511
 				if (mcrypt_generic_init($mcrypt, $key, $iv) < 0)
491 512
 				{
Please login to merge, or discard this patch.
emailadmin/inc/class.emailadmin_hooks.inc.php 4 patches
Doc Comments   -9 removed lines patch added patch discarded remove patch
@@ -20,7 +20,6 @@  discard block
 block discarded – undo
20 20
      * Hook called to add action to user
21 21
      *
22 22
      * @param array $data
23
-     * @param int $data['account_id'] numerical id
24 23
      */
25 24
 	static function edit_user($data)
26 25
 	{
@@ -81,9 +80,6 @@  discard block
 block discarded – undo
81 80
      * Hook called before an account get deleted
82 81
      *
83 82
      * @param array $data
84
-     * @param int $data['account_id'] numerical id
85
-     * @param string $data['account_lid'] account-name
86
-     * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted
87 83
      */
88 84
 	static function deleteaccount(array $data)
89 85
 	{
@@ -97,8 +93,6 @@  discard block
 block discarded – undo
97 93
      * Hook called before a group get deleted
98 94
      *
99 95
      * @param array $data
100
-     * @param int $data['account_id'] numerical id
101
-     * @param string $data['account_name'] account-name
102 96
      */
103 97
 	static function deletegroup(array $data)
104 98
 	{
@@ -109,9 +103,6 @@  discard block
 block discarded – undo
109 103
      * Hook called when an account get added or edited
110 104
      *
111 105
      * @param array $data
112
-     * @param int $data['account_id'] numerical id
113
-     * @param string $data['account_lid'] account-name
114
-     * @param string $data['account_email'] email
115 106
 	 */
116 107
 	static function addaccount(array $data)
117 108
 	{
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class emailadmin_hooks
18 18
 {
19
-    /**
20
-     * Hook called to add action to user
21
-     *
22
-     * @param array $data
23
-     * @param int $data['account_id'] numerical id
24
-     */
19
+	/**
20
+	 * Hook called to add action to user
21
+	 *
22
+	 * @param array $data
23
+	 * @param int $data['account_id'] numerical id
24
+	 */
25 25
 	static function edit_user($data)
26 26
 	{
27 27
 		unset($data);	// not used
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		}
78 78
 	}
79 79
 
80
-    /**
81
-     * Hook called before an account get deleted
82
-     *
83
-     * @param array $data
84
-     * @param int $data['account_id'] numerical id
85
-     * @param string $data['account_lid'] account-name
86
-     * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted
87
-     */
80
+	/**
81
+	 * Hook called before an account get deleted
82
+	 *
83
+	 * @param array $data
84
+	 * @param int $data['account_id'] numerical id
85
+	 * @param string $data['account_lid'] account-name
86
+	 * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted
87
+	 */
88 88
 	static function deleteaccount(array $data)
89 89
 	{
90 90
 		self::run_plugin_hooks('deleteAccount', $data);
@@ -93,25 +93,25 @@  discard block
 block discarded – undo
93 93
 		emailadmin_account::delete(0, $data['account_id']);
94 94
 	}
95 95
 
96
-    /**
97
-     * Hook called before a group get deleted
98
-     *
99
-     * @param array $data
100
-     * @param int $data['account_id'] numerical id
101
-     * @param string $data['account_name'] account-name
102
-     */
96
+	/**
97
+	 * Hook called before a group get deleted
98
+	 *
99
+	 * @param array $data
100
+	 * @param int $data['account_id'] numerical id
101
+	 * @param string $data['account_name'] account-name
102
+	 */
103 103
 	static function deletegroup(array $data)
104 104
 	{
105 105
 		emailadmin_account::delete(0, $data['account_id']);
106 106
 	}
107 107
 
108 108
 	/**
109
-     * Hook called when an account get added or edited
110
-     *
111
-     * @param array $data
112
-     * @param int $data['account_id'] numerical id
113
-     * @param string $data['account_lid'] account-name
114
-     * @param string $data['account_email'] email
109
+	 * Hook called when an account get added or edited
110
+	 *
111
+	 * @param array $data
112
+	 * @param int $data['account_id'] numerical id
113
+	 * @param string $data['account_lid'] account-name
114
+	 * @param string $data['account_email'] email
115 115
 	 */
116 116
 	static function addaccount(array $data)
117 117
 	{
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
 	static function edit_user($data)
26 26
 	{
27
-		unset($data);	// not used
27
+		unset($data); // not used
28 28
 
29 29
 		$actions = array();
30 30
 
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
 			$emailadmin = emailadmin_account::get_default();
42 42
 			if ($emailadmin->acc_smtp_type && $emailadmin->acc_smtp_type !== 'emailadmin_smtp')
43 43
 			{
44
-				$actions[] = array (
44
+				$actions[] = array(
45 45
 					'id'       => 'mail_activeAccounts',
46 46
 					'caption'  => '(de)activate mail accounts',
47
-					'children' => array (
48
-						'active' => array (
47
+					'children' => array(
48
+						'active' => array(
49 49
 							'caption'		  => 'activate',
50 50
 							'onExecute'	  	  => 'javaScript:app.admin.emailadminActiveAccounts',
51 51
 							'icon'			  => 'emailadmin/navbar',
52 52
 							'allowOnMultiple' => true
53 53
 						),
54
-						'inactive' => array (
54
+						'inactive' => array(
55 55
 							'caption'		  => 'deactivate',
56 56
 							'onExecute'		  => 'javaScript:app.admin.emailadminActiveAccounts',
57 57
 							'icon'			  => 'emailadmin/navbar',
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected static function run_plugin_hooks($method, array $data)
129 129
 	{
130
-		foreach(emailadmin_account::search((int)$data['account_id'], 'params') as $params)
130
+		foreach (emailadmin_account::search((int)$data['account_id'], 'params') as $params)
131 131
 		{
132
-			if (!emailadmin_account::is_multiple($params)) continue;	// no need to waste time on personal accounts
132
+			if (!emailadmin_account::is_multiple($params)) continue; // no need to waste time on personal accounts
133 133
 
134 134
 			try {
135 135
 				$account = new emailadmin_account($params);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 					$imap->$method($data);
146 146
 				}
147 147
 			}
148
-			catch(Exception $e) {
148
+			catch (Exception $e) {
149 149
 				_egw_log_exception($e);
150 150
 				// ignore exception, without stalling other hooks
151 151
 			}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$extended = is_array($data) ? $data['extended'] : false;
165 165
 
166 166
 		$types = array();
167
-		foreach(scandir($dir=EGW_INCLUDE_ROOT.'/emailadmin/inc') as $file)
167
+		foreach (scandir($dir = EGW_INCLUDE_ROOT.'/emailadmin/inc') as $file)
168 168
 		{
169 169
 			$matches = null;
170 170
 			if (!preg_match('/^class\.([^.]*(smtp|imap|postfix|dovecot|dbmail)[^.*]*)\.inc\.php$/', $file, $matches)) continue;
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 			if ($is_smtp && $location == 'smtp_server_types' || $is_imap && $location == 'imap_server_types')
179 179
 			{
180 180
 				// only register new imap-class-names
181
-				if ($is_imap && $class_name == emailadmin_account::getIcClass ($class_name, true)) continue;
181
+				if ($is_imap && $class_name == emailadmin_account::getIcClass($class_name, true)) continue;
182 182
 
183 183
 				$type = array(
184 184
 					'classname' => $class_name,
185
-					'description' => is_callable($function=$class_name.'::description') ? call_user_func($function) : $class_name,
185
+					'description' => is_callable($function = $class_name.'::description') ? call_user_func($function) : $class_name,
186 186
 				);
187 187
 
188 188
 				if ($is_imap) $type['protocol'] = 'imap';
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		}
193 193
 		if (!$extended)
194 194
 		{
195
-			foreach($types as $class_name => &$type)
195
+			foreach ($types as $class_name => &$type)
196 196
 			{
197 197
 				$type = $type['description'];
198 198
 			}
Please login to merge, or discard this patch.
Braces   +21 added lines, -5 removed lines patch added patch discarded remove patch
@@ -129,7 +129,11 @@  discard block
 block discarded – undo
129 129
 	{
130 130
 		foreach(emailadmin_account::search((int)$data['account_id'], 'params') as $params)
131 131
 		{
132
-			if (!emailadmin_account::is_multiple($params)) continue;	// no need to waste time on personal accounts
132
+			if (!emailadmin_account::is_multiple($params))
133
+			{
134
+				continue;
135
+			}
136
+			// no need to waste time on personal accounts
133 137
 
134 138
 			try {
135 139
 				$account = new emailadmin_account($params);
@@ -167,10 +171,16 @@  discard block
 block discarded – undo
167 171
 		foreach(scandir($dir=EGW_INCLUDE_ROOT.'/emailadmin/inc') as $file)
168 172
 		{
169 173
 			$matches = null;
170
-			if (!preg_match('/^class\.([^.]*(smtp|imap|postfix|dovecot|dbmail)[^.*]*)\.inc\.php$/', $file, $matches)) continue;
174
+			if (!preg_match('/^class\.([^.]*(smtp|imap|postfix|dovecot|dbmail)[^.*]*)\.inc\.php$/', $file, $matches))
175
+			{
176
+				continue;
177
+			}
171 178
 			$class_name = $matches[1];
172 179
 			include_once($dir.'/'.$file);
173
-			if (!class_exists($class_name)) continue;
180
+			if (!class_exists($class_name))
181
+			{
182
+				continue;
183
+			}
174 184
 
175 185
 			$is_imap = $class_name == 'emailadmin_imap' || is_subclass_of($class_name, 'emailadmin_imap');
176 186
 			$is_smtp = $class_name == 'emailadmin_smtp' || is_subclass_of($class_name, 'emailadmin_smtp') && $class_name != 'defaultsmtp';
@@ -178,14 +188,20 @@  discard block
 block discarded – undo
178 188
 			if ($is_smtp && $location == 'smtp_server_types' || $is_imap && $location == 'imap_server_types')
179 189
 			{
180 190
 				// only register new imap-class-names
181
-				if ($is_imap && $class_name == emailadmin_account::getIcClass ($class_name, true)) continue;
191
+				if ($is_imap && $class_name == emailadmin_account::getIcClass ($class_name, true))
192
+				{
193
+					continue;
194
+				}
182 195
 
183 196
 				$type = array(
184 197
 					'classname' => $class_name,
185 198
 					'description' => is_callable($function=$class_name.'::description') ? call_user_func($function) : $class_name,
186 199
 				);
187 200
 
188
-				if ($is_imap) $type['protocol'] = 'imap';
201
+				if ($is_imap)
202
+				{
203
+					$type['protocol'] = 'imap';
204
+				}
189 205
 
190 206
 				$types[$class_name] = $type;
191 207
 			}
Please login to merge, or discard this patch.